diff --git a/go.mod b/go.mod index 61b69f0991a..5d3312439c4 100644 --- a/go.mod +++ b/go.mod @@ -9,8 +9,10 @@ require ( github.com/Azure/go-autorest/autorest v0.11.18 github.com/Azure/go-autorest/autorest/azure/auth v0.4.1 github.com/Azure/go-autorest/autorest/to v0.4.0 - github.com/IBM-Cloud/bluemix-go v0.0.0-20210611051827-cdc80c935c05 - github.com/IBM/go-sdk-core/v5 v5.4.3 + github.com/IBM-Cloud/bluemix-go v0.0.0-20211102075456-ffc4e11dfb16 + github.com/IBM-Cloud/power-go-client v1.1.4 + github.com/IBM/go-sdk-core/v4 v4.9.0 + github.com/IBM/go-sdk-core/v5 v5.9.1 github.com/IBM/networking-go-sdk v0.14.0 github.com/IBM/platform-services-go-sdk v0.18.16 github.com/IBM/vpc-go-sdk v1.0.1 @@ -38,7 +40,7 @@ require ( github.com/metal3-io/baremetal-operator/apis v0.0.0 github.com/metal3-io/baremetal-operator/pkg/hardwareutils v0.0.0 github.com/openshift/api v0.0.0-20220222102030-354aa98a475c - github.com/openshift/client-go v0.0.0-20211025111749-96ca2abfc56c + github.com/openshift/client-go v0.0.0-20211209144617-7385dd6338e3 github.com/openshift/cloud-credential-operator v0.0.0-20200316201045-d10080b52c9e github.com/openshift/cluster-api-provider-baremetal v0.0.0-20210924143856-c2d3ece4da38 github.com/openshift/cluster-api-provider-ibmcloud v0.0.0-20211008100740-4d7907adbd6b @@ -61,9 +63,9 @@ require ( github.com/vmware/govmomi v0.24.0 golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 - golang.org/x/net v0.0.0-20210825183410-e898025ed96a + golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f - golang.org/x/sys v0.0.0-20211029165221-6e7872819dc8 + golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e google.golang.org/api v0.44.0 google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2 google.golang.org/grpc v1.40.0 @@ -75,7 +77,7 @@ require ( k8s.io/client-go v12.0.0+incompatible k8s.io/klog v1.0.0 k8s.io/klog/v2 v2.30.0 - k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b + k8s.io/utils v0.0.0-20211208161948-7d6a63dca704 sigs.k8s.io/cluster-api-provider-aws v0.0.0 sigs.k8s.io/cluster-api-provider-openstack v0.0.0 sigs.k8s.io/controller-tools v0.7.0 @@ -90,8 +92,9 @@ require ( github.com/Azure/go-autorest/logger v0.2.1 // indirect github.com/Azure/go-autorest/tracing v0.6.0 // indirect github.com/BurntSushi/toml v0.3.1 // indirect - github.com/IBM/go-sdk-core/v4 v4.9.0 // indirect - github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef // indirect + github.com/PuerkitoBio/purell v1.1.1 // indirect + github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect + github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.1.1 // indirect @@ -101,45 +104,56 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/dimchansky/utfbom v1.1.0 // indirect github.com/evanphx/json-patch v4.12.0+incompatible // indirect - github.com/fatih/color v1.7.0 // indirect + github.com/fatih/color v1.12.0 // indirect github.com/form3tech-oss/jwt-go v3.2.3+incompatible // indirect github.com/fsnotify/fsnotify v1.5.1 // indirect - github.com/go-logr/logr v1.2.0 // indirect - github.com/go-openapi/errors v0.19.8 // indirect - github.com/go-openapi/strfmt v0.20.1 // indirect - github.com/go-playground/locales v0.13.0 // indirect - github.com/go-playground/universal-translator v0.17.0 // indirect - github.com/go-stack/stack v1.8.0 // indirect - github.com/gobuffalo/flect v0.2.2 // indirect + github.com/go-logr/logr v1.2.2 // indirect + github.com/go-openapi/analysis v0.21.2 // indirect + github.com/go-openapi/errors v0.20.2 // indirect + github.com/go-openapi/jsonpointer v0.19.5 // indirect + github.com/go-openapi/jsonreference v0.19.6 // indirect + github.com/go-openapi/loads v0.21.1 // indirect + github.com/go-openapi/runtime v0.23.0 // indirect + github.com/go-openapi/spec v0.20.4 // indirect + github.com/go-openapi/strfmt v0.21.2 // indirect + github.com/go-openapi/swag v0.21.1 // indirect + github.com/go-openapi/validate v0.20.3 // indirect + github.com/go-playground/locales v0.14.0 // indirect + github.com/go-playground/universal-translator v0.18.0 // indirect + github.com/go-stack/stack v1.8.1 // indirect + github.com/gobuffalo/flect v0.2.3 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/google/gofuzz v1.1.0 // indirect + github.com/google/gofuzz v1.2.0 // indirect github.com/google/renameio v1.0.0 // indirect github.com/googleapis/gax-go/v2 v2.0.5 // indirect github.com/googleapis/gnostic v0.5.5 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-retryablehttp v0.6.6 // indirect + github.com/hashicorp/go-retryablehttp v0.7.0 // indirect github.com/hashicorp/go-version v1.4.0 // indirect github.com/hashicorp/terraform-json v0.13.0 // indirect github.com/imdario/mergo v0.3.12 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect + github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect github.com/kr/fs v0.1.0 // indirect - github.com/leodido/go-urn v1.2.0 // indirect - github.com/mattn/go-colorable v0.1.2 // indirect + github.com/leodido/go-urn v1.2.1 // indirect + github.com/mailru/easyjson v0.7.7 // indirect + github.com/mattn/go-colorable v0.1.8 // indirect github.com/mattn/go-isatty v0.0.12 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect - github.com/mitchellh/mapstructure v1.4.1 // indirect + github.com/mitchellh/mapstructure v1.4.3 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/oklog/ulid v1.3.1 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.0.2-0.20190823105129-775207bd45b6 // indirect github.com/openshift/cluster-api v0.0.0-20190805113604-f8de78af80fc // indirect + github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/procfs v0.6.0 // indirect @@ -147,10 +161,10 @@ require ( github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/zclconf/go-cty v1.10.0 // indirect - go.mongodb.org/mongo-driver v1.5.1 // indirect + go.mongodb.org/mongo-driver v1.8.3 // indirect go.opencensus.io v0.23.0 // indirect golang.org/x/mod v0.4.2 // indirect - golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b // indirect + golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect golang.org/x/text v0.3.7 // indirect golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect golang.org/x/tools v0.1.6-0.20210820212750-d4cc65f0b2ff // indirect @@ -164,7 +178,7 @@ require ( k8s.io/component-base v0.23.0 // indirect k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 // indirect sigs.k8s.io/controller-runtime v0.11.0 // indirect - sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 // indirect + sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.2.0 // indirect sigs.k8s.io/yaml v1.3.0 // indirect ) diff --git a/go.sum b/go.sum index c112308b976..02c8aa95f0f 100644 --- a/go.sum +++ b/go.sum @@ -96,8 +96,10 @@ github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBp github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/IBM-Cloud/bluemix-go v0.0.0-20210611051827-cdc80c935c05 h1:b/epmuvf99xhUlf81l0r/ciONJSjoUs78t+BC7lCcvI= -github.com/IBM-Cloud/bluemix-go v0.0.0-20210611051827-cdc80c935c05/go.mod h1:kqTYO0mts71aa8PVwviaKlCKYud/NbEkFIqU8aHH3/g= +github.com/IBM-Cloud/bluemix-go v0.0.0-20211102075456-ffc4e11dfb16 h1:kSfKKawp3hYDcjV+d+qcadWfFsCNHDCgklOUnVMle+I= +github.com/IBM-Cloud/bluemix-go v0.0.0-20211102075456-ffc4e11dfb16/go.mod h1:q0fXFSbum/16D8Mgn1ROSfSyX4BmvBCm/hHdcXz0wCU= +github.com/IBM-Cloud/power-go-client v1.1.4 h1:E1sve+j7k3xHD9VKsQCrJ5Eth6Ndt7BC0tkeFhRFjOQ= +github.com/IBM-Cloud/power-go-client v1.1.4/go.mod h1:YcAHrWuTvckGQYPLLReJ9ijcO/tQuRxAp2kCZ7fnnVk= github.com/IBM/go-sdk-core v1.1.0 h1:pV73lZqr9r1xKb3h08c1uNG3AphwoV5KzUzhS+pfEqY= github.com/IBM/go-sdk-core v1.1.0/go.mod h1:2pcx9YWsIsZ3I7kH+1amiAkXvLTZtAq9kbxsfXilSoY= github.com/IBM/go-sdk-core/v4 v4.5.1/go.mod h1:lTUXbqIX6/aAbSCkP6q59+dyFsTwZAc0ewRS2vJWVbg= @@ -106,8 +108,8 @@ github.com/IBM/go-sdk-core/v4 v4.9.0/go.mod h1:DbQ+3pFoIjxGGTEiA9zQ2V0cemMNmFMkL github.com/IBM/go-sdk-core/v5 v5.2.0/go.mod h1:vyNdbFujJtdTj9HbihtvKwwS3k/GKSKpOx9ZIQ6MWDY= github.com/IBM/go-sdk-core/v5 v5.4.0/go.mod h1:+MNa5Jbqb9FO7KEevo982Pb/YXr4adkyEffJlPs2TGc= github.com/IBM/go-sdk-core/v5 v5.4.2/go.mod h1:Sn+z+qTDREQvCr+UFa22TqqfXNxx3o723y8GsfLV8e0= -github.com/IBM/go-sdk-core/v5 v5.4.3 h1:g3HUKD2wyptGTAGOjS4IkYWmLFgGsioFCnBUXz5NB4g= -github.com/IBM/go-sdk-core/v5 v5.4.3/go.mod h1:Sn+z+qTDREQvCr+UFa22TqqfXNxx3o723y8GsfLV8e0= +github.com/IBM/go-sdk-core/v5 v5.9.1 h1:06pXbD9Rgmqqe2HA5YAeQbB4eYRRFgIoOT+Kh3cp1zo= +github.com/IBM/go-sdk-core/v5 v5.9.1/go.mod h1:axE2JrRq79gIJTjKPBwV6gWHswvVptBjbcvvCPIxARM= github.com/IBM/networking-go-sdk v0.14.0 h1:CWQufnSxynqxYORGbkSqePPSZ33fUijiwmcuZsMRv/Q= github.com/IBM/networking-go-sdk v0.14.0/go.mod h1:8f3hEoWVUSYKbaIj7WZhdeJaseYGDSY85Iz+PqxLEbQ= github.com/IBM/platform-services-go-sdk v0.18.16 h1:blYycstPoNtPKtu1uZe240WvzcJENy/Lzx+HMUA8bOo= @@ -139,8 +141,10 @@ github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 h1:YoJbenK9C6 github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo= github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= @@ -184,8 +188,11 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkY github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= -github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef h1:46PFijGLmAjMPwCCCo7Jf0W6f9slllCkkv7vyc1yOSg= +github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496/go.mod h1:oGkLhpf+kjZl6xBf758TQhh5XrAeiJv/7FRz/2spLIg= +github.com/asaskevich/govalidator v0.0.0-20200428143746-21a406dcc535/go.mod h1:oGkLhpf+kjZl6xBf758TQhh5XrAeiJv/7FRz/2spLIg= github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= +github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d h1:Byv0BzEl3/e6D5CLfI0j/7hiIEtvGVFPCZ7Ei2oq8iQ= +github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/ashcrow/osrelease v0.0.0-20180626175927-9b292693c55c/go.mod h1:BRljTyotlu+6N+Qlu5MhjxpdmccCnp9lDvZjNNV8qr4= github.com/awalterschulze/gographviz v0.0.0-20190522210029-fa59802746ab h1:+cdNqtOJWjvepyhxy23G7z7vmpYCoC65AP0nqi1f53s= github.com/awalterschulze/gographviz v0.0.0-20190522210029-fa59802746ab/go.mod h1:GEV5wmg4YquNw7v1kkyoX9etIk8yVmXj+AkDHuuETHs= @@ -370,8 +377,9 @@ github.com/evanphx/json-patch v4.12.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQL github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d/go.mod h1:ZZMPRZwes7CROmyNKgQzC3XPs6L/G2EJLHddWejkmf4= github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc= github.com/fatih/color v1.6.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fatih/color v1.12.0 h1:mRhaKNwANqRgUBGKmnI5ZxEk7QXmjQeCcuYFMX2bfcc= +github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/form3tech-oss/jwt-go v3.2.1+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= @@ -426,8 +434,9 @@ github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTg github.com/go-logr/logr v0.2.1/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= github.com/go-logr/logr v0.3.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= github.com/go-logr/logr v0.4.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= -github.com/go-logr/logr v1.2.0 h1:QK40JKJyMdUDz+h+xvCsru/bJhvG0UxvePV0ufL/AcE= github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.2 h1:ahHml/yUpnlb96Rp8HCvtYVPY8ZYpxq3g7UYchIYwbs= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/zapr v0.1.0/go.mod h1:tabnROwaDl0UNxkVeFRbY8bwB37GwRv0P8lg6aAiEnk= github.com/go-logr/zapr v0.2.0/go.mod h1:qhKdvif7YF5GI9NWEpyxTSSBdGmzkNguibrdCNVPunU= github.com/go-logr/zapr v0.4.0/go.mod h1:tabnROwaDl0UNxkVeFRbY8bwB37GwRv0P8lg6aAiEnk= @@ -438,17 +447,31 @@ github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70t github.com/go-openapi/analysis v0.17.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= github.com/go-openapi/analysis v0.18.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= github.com/go-openapi/analysis v0.19.2/go.mod h1:3P1osvZa9jKjb8ed2TPng3f0i/UY9snX6gxi44djMjk= +github.com/go-openapi/analysis v0.19.4/go.mod h1:3P1osvZa9jKjb8ed2TPng3f0i/UY9snX6gxi44djMjk= github.com/go-openapi/analysis v0.19.5/go.mod h1:hkEAkxagaIvIP7VTn8ygJNkd4kAYON2rCu0v0ObL0AU= +github.com/go-openapi/analysis v0.19.10/go.mod h1:qmhS3VNFxBlquFJ0RGoDtylO9y4pgTAUNE9AEEMdlJQ= +github.com/go-openapi/analysis v0.19.16/go.mod h1:GLInF007N83Ad3m8a/CbQ5TPzdnGT7workfHwuVjNVk= +github.com/go-openapi/analysis v0.20.0/go.mod h1:BMchjvaHDykmRMsK40iPtvyOfFdMMxlOmQr9FBZk+Og= +github.com/go-openapi/analysis v0.20.1/go.mod h1:BMchjvaHDykmRMsK40iPtvyOfFdMMxlOmQr9FBZk+Og= +github.com/go-openapi/analysis v0.21.2 h1:hXFrOYFHUAMQdu6zwAiKKJHJQ8kqZs1ux/ru1P1wLJU= +github.com/go-openapi/analysis v0.21.2/go.mod h1:HZwRk4RRisyG8vx2Oe6aqeSQcoxRp47Xkp3+K6q+LdY= github.com/go-openapi/errors v0.17.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= github.com/go-openapi/errors v0.18.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= github.com/go-openapi/errors v0.19.2/go.mod h1:qX0BLWsyaKfvhluLejVpVNwNRdXZhEbTA4kxxpKBC94= -github.com/go-openapi/errors v0.19.8 h1:doM+tQdZbUm9gydV9yR+iQNmztbjj7I3sW4sIcAwIzc= +github.com/go-openapi/errors v0.19.3/go.mod h1:qX0BLWsyaKfvhluLejVpVNwNRdXZhEbTA4kxxpKBC94= +github.com/go-openapi/errors v0.19.6/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= +github.com/go-openapi/errors v0.19.7/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= github.com/go-openapi/errors v0.19.8/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= +github.com/go-openapi/errors v0.19.9/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= +github.com/go-openapi/errors v0.20.1/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= +github.com/go-openapi/errors v0.20.2 h1:dxy7PGTqEh94zj2E3h1cUmQQWiM1+aeCROfAr02EmK8= +github.com/go-openapi/errors v0.20.2/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0= github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= github.com/go-openapi/jsonpointer v0.18.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg= github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= @@ -456,53 +479,101 @@ github.com/go-openapi/jsonreference v0.18.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3Hfo github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc= github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8= github.com/go-openapi/jsonreference v0.19.5/go.mod h1:RdybgQwPxbL4UEjuAruzK1x3nE69AqPYEJeo/TWfEeg= +github.com/go-openapi/jsonreference v0.19.6 h1:UBIxjkht+AWIgYzCDSv2GN+E/togfwXUJFRTWhl2Jjs= +github.com/go-openapi/jsonreference v0.19.6/go.mod h1:diGHMEHg2IqXZGKxqyvWdfWU/aim5Dprw5bqpKkTvns= github.com/go-openapi/loads v0.17.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= github.com/go-openapi/loads v0.18.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= github.com/go-openapi/loads v0.19.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= github.com/go-openapi/loads v0.19.2/go.mod h1:QAskZPMX5V0C2gvfkGZzJlINuP7Hx/4+ix5jWFxsNPs= +github.com/go-openapi/loads v0.19.3/go.mod h1:YVfqhUCdahYwR3f3iiwQLhicVRvLlU/WO5WPaZvcvSI= github.com/go-openapi/loads v0.19.4/go.mod h1:zZVHonKd8DXyxyw4yfnVjPzBjIQcLt0CCsn0N0ZrQsk= +github.com/go-openapi/loads v0.19.5/go.mod h1:dswLCAdonkRufe/gSUC3gN8nTSaB9uaS2es0x5/IbjY= +github.com/go-openapi/loads v0.19.6/go.mod h1:brCsvE6j8mnbmGBh103PT/QLHfbyDxA4hsKvYBNEGVc= +github.com/go-openapi/loads v0.19.7/go.mod h1:brCsvE6j8mnbmGBh103PT/QLHfbyDxA4hsKvYBNEGVc= +github.com/go-openapi/loads v0.20.0/go.mod h1:2LhKquiE513rN5xC6Aan6lYOSddlL8Mp20AW9kpviM4= +github.com/go-openapi/loads v0.20.2/go.mod h1:hTVUotJ+UonAMMZsvakEgmWKgtulweO9vYP2bQYKA/o= +github.com/go-openapi/loads v0.21.0/go.mod h1:rHYve9nZrQ4CJhyeIIFJINGCg1tQpx2yJrrNo8sf1ws= +github.com/go-openapi/loads v0.21.1 h1:Wb3nVZpdEzDTcly8S4HMkey6fjARRzb7iEaySimlDW0= +github.com/go-openapi/loads v0.21.1/go.mod h1:/DtAMXXneXFjbQMGEtbamCZb+4x7eGwkvZCvBmwUG+g= github.com/go-openapi/runtime v0.0.0-20180920151709-4f900dc2ade9/go.mod h1:6v9a6LTXWQCdL8k1AO3cvqx5OtZY/Y9wKTgaoP6YRfA= github.com/go-openapi/runtime v0.19.0/go.mod h1:OwNfisksmmaZse4+gpV3Ne9AyMOlP1lt4sK4FXt0O64= github.com/go-openapi/runtime v0.19.4/go.mod h1:X277bwSUBxVlCYR3r7xgZZGKVvBd/29gLDlFGtJ8NL4= +github.com/go-openapi/runtime v0.19.15/go.mod h1:dhGWCTKRXlAfGnQG0ONViOZpjfg0m2gUt9nTQPQZuoo= +github.com/go-openapi/runtime v0.19.16/go.mod h1:5P9104EJgYcizotuXhEuUrzVc+j1RiSjahULvYmlv98= +github.com/go-openapi/runtime v0.19.24/go.mod h1:Lm9YGCeecBnUUkFTxPC4s1+lwrkJ0pthx8YvyjCfkgk= +github.com/go-openapi/runtime v0.23.0 h1:HX6ET2sHCIvaKeDDQoU01CtO1ekg5EkekHSkLTtWXH0= +github.com/go-openapi/runtime v0.23.0/go.mod h1:aQg+kaIQEn+A2CRSY1TxbM8+sT9g2V3aLc1FbIAnbbs= github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc= github.com/go-openapi/spec v0.17.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= github.com/go-openapi/spec v0.18.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= github.com/go-openapi/spec v0.19.2/go.mod h1:sCxk3jxKgioEJikev4fgkNmwS+3kuYdJtcsZsD5zxMY= github.com/go-openapi/spec v0.19.3/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo= github.com/go-openapi/spec v0.19.5/go.mod h1:Hm2Jr4jv8G1ciIAo+frC/Ft+rR2kQDh8JHKHb3gWUSk= +github.com/go-openapi/spec v0.19.6/go.mod h1:Hm2Jr4jv8G1ciIAo+frC/Ft+rR2kQDh8JHKHb3gWUSk= +github.com/go-openapi/spec v0.19.8/go.mod h1:Hm2Jr4jv8G1ciIAo+frC/Ft+rR2kQDh8JHKHb3gWUSk= +github.com/go-openapi/spec v0.19.15/go.mod h1:+81FIL1JwC5P3/Iuuozq3pPE9dXdIEGxFutcFKaVbmU= +github.com/go-openapi/spec v0.20.0/go.mod h1:+81FIL1JwC5P3/Iuuozq3pPE9dXdIEGxFutcFKaVbmU= +github.com/go-openapi/spec v0.20.1/go.mod h1:93x7oh+d+FQsmsieroS4cmR3u0p/ywH649a3qwC9OsQ= +github.com/go-openapi/spec v0.20.3/go.mod h1:gG4F8wdEDN+YPBMVnzE85Rbhf+Th2DTvA9nFPQ5AYEg= +github.com/go-openapi/spec v0.20.4 h1:O8hJrt0UMnhHcluhIdUgCLRWyM2x7QkBXRvOs7m+O1M= +github.com/go-openapi/spec v0.20.4/go.mod h1:faYFR1CvsJZ0mNsmsphTMSoRrNV3TEDoAM7FOEWeq8I= github.com/go-openapi/strfmt v0.17.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= github.com/go-openapi/strfmt v0.18.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= github.com/go-openapi/strfmt v0.19.0/go.mod h1:+uW+93UVvGGq2qGaZxdDeJqSAqBqBdl+ZPMF/cC8nDY= +github.com/go-openapi/strfmt v0.19.2/go.mod h1:0yX7dbo8mKIvc3XSKp7MNfxw4JytCfCD6+bY1AVL9LU= github.com/go-openapi/strfmt v0.19.3/go.mod h1:0yX7dbo8mKIvc3XSKp7MNfxw4JytCfCD6+bY1AVL9LU= +github.com/go-openapi/strfmt v0.19.4/go.mod h1:eftuHTlB/dI8Uq8JJOyRlieZf+WkkxUuk0dgdHXr2Qk= github.com/go-openapi/strfmt v0.19.5/go.mod h1:eftuHTlB/dI8Uq8JJOyRlieZf+WkkxUuk0dgdHXr2Qk= github.com/go-openapi/strfmt v0.19.10/go.mod h1:qBBipho+3EoIqn6YDI+4RnQEtj6jT/IdKm+PAlXxSUc= +github.com/go-openapi/strfmt v0.19.11/go.mod h1:UukAYgTaQfqJuAFlNxxMWNvMYiwiXtLsF2VwmoFtbtc= github.com/go-openapi/strfmt v0.20.0/go.mod h1:UukAYgTaQfqJuAFlNxxMWNvMYiwiXtLsF2VwmoFtbtc= -github.com/go-openapi/strfmt v0.20.1 h1:1VgxvehFne1mbChGeCmZ5pc0LxUf6yaACVSIYAR91Xc= github.com/go-openapi/strfmt v0.20.1/go.mod h1:43urheQI9dNtE5lTZQfuFJvjYJKPrxicATpEfZwHUNk= +github.com/go-openapi/strfmt v0.20.2/go.mod h1:43urheQI9dNtE5lTZQfuFJvjYJKPrxicATpEfZwHUNk= +github.com/go-openapi/strfmt v0.21.0/go.mod h1:ZRQ409bWMj+SOgXofQAGTIo2Ebu72Gs+WaRADcS5iNg= +github.com/go-openapi/strfmt v0.21.1/go.mod h1:I/XVKeLc5+MM5oPNN7P6urMOpuLXEcNrCX/rPGuWb0k= +github.com/go-openapi/strfmt v0.21.2 h1:5NDNgadiX1Vhemth/TH4gCGopWSTdDjxl60H3B7f+os= +github.com/go-openapi/strfmt v0.21.2/go.mod h1:I/XVKeLc5+MM5oPNN7P6urMOpuLXEcNrCX/rPGuWb0k= github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= github.com/go-openapi/swag v0.18.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.19.7/go.mod h1:ao+8BpOPyKdpQz3AOJfbeEVpLmWAvlT1IfTe5McPyhY= +github.com/go-openapi/swag v0.19.9/go.mod h1:ao+8BpOPyKdpQz3AOJfbeEVpLmWAvlT1IfTe5McPyhY= +github.com/go-openapi/swag v0.19.12/go.mod h1:eFdyEBkTdoAf/9RXBvj4cr1nH7GD8Kzo5HTt47gr72M= +github.com/go-openapi/swag v0.19.13/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= github.com/go-openapi/swag v0.19.14/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= +github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= +github.com/go-openapi/swag v0.21.1 h1:wm0rhTb5z7qpJRHBdPOMuY4QjVUMbF6/kwoYeRAOrKU= +github.com/go-openapi/swag v0.21.1/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4= github.com/go-openapi/validate v0.19.2/go.mod h1:1tRCw7m3jtI8eNWEEliiAqUIcBztB2KDnRCRMUi7GTA= +github.com/go-openapi/validate v0.19.3/go.mod h1:90Vh6jjkTn+OT1Eefm0ZixWNFjhtOH7vS9k0lo6zwJo= github.com/go-openapi/validate v0.19.5/go.mod h1:8DJv2CVJQ6kGNpFW6eV9N3JviE1C85nY1c2z52x1Gk4= github.com/go-openapi/validate v0.19.8/go.mod h1:8DJv2CVJQ6kGNpFW6eV9N3JviE1C85nY1c2z52x1Gk4= +github.com/go-openapi/validate v0.19.10/go.mod h1:RKEZTUWDkxKQxN2jDT7ZnZi2bhZlbNMAuKvKB+IaGx8= +github.com/go-openapi/validate v0.19.12/go.mod h1:Rzou8hA/CBw8donlS6WNEUQupNvUZ0waH08tGe6kAQ4= +github.com/go-openapi/validate v0.19.15/go.mod h1:tbn/fdOwYHgrhPBzidZfJC2MIVvs9GA7monOmWBbeCI= +github.com/go-openapi/validate v0.20.1/go.mod h1:b60iJT+xNNLfaQJUqLI7946tYiFEOuE9E4k54HpKcJ0= +github.com/go-openapi/validate v0.20.3 h1:GZPPhhKSZrE8HjB4eEkoYAZmoWA4+tCemSgINH1/vKw= +github.com/go-openapi/validate v0.20.3/go.mod h1:goDdqVGiigM3jChcrYJxD2joalke3ZXeftD16byIjA4= github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3ygWanZIBtBW0W2TM= -github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= +github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= +github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY= -github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= +github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= +github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY= github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= -github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= +github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/go-toolsmith/astcast v1.0.0/go.mod h1:mt2OdQTeAQcY4DQgPSArJjHCcOwlX+Wl/kwN+LbLGQ4= github.com/go-toolsmith/astcopy v1.0.0/go.mod h1:vrgyG+5Bxrnz4MZWPF+pI4R8h3qKRjjyvV/DSez4WVQ= @@ -526,8 +597,9 @@ github.com/gobuffalo/flect v0.1.0/go.mod h1:d2ehjJqGOH/Kjqcoz+F7jHTBbmDb38yXA598 github.com/gobuffalo/flect v0.1.1/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= github.com/gobuffalo/flect v0.1.3/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= github.com/gobuffalo/flect v0.2.0/go.mod h1:W3K3X9ksuZfir8f/LrfVtWmCDQFfayuylOJ7sz/Fj80= -github.com/gobuffalo/flect v0.2.2 h1:PAVD7sp0KOdfswjAw9BpLCU9hXo7wFSzgpQ+zNeks/A= github.com/gobuffalo/flect v0.2.2/go.mod h1:vmkQwuZYhN5Pc4ljYQZzP+1sq+NEkK+lh20jmEmX3jc= +github.com/gobuffalo/flect v0.2.3 h1:f/ZukRnSNA/DUpSNDadko7Qc0PhGvsew35p/2tu+CRY= +github.com/gobuffalo/flect v0.2.3/go.mod h1:vmkQwuZYhN5Pc4ljYQZzP+1sq+NEkK+lh20jmEmX3jc= github.com/gobuffalo/genny v0.0.0-20190329151137-27723ad26ef9/go.mod h1:rWs4Z12d1Zbf19rlsn0nurr75KqhYp52EAGGxTbBhNk= github.com/gobuffalo/genny v0.0.0-20190403191548-3ca520ef0d9e/go.mod h1:80lIj3kVJWwOrXWWMRzzdhW3DsrdjILVil/SFKBzF28= github.com/gobuffalo/genny v0.1.0/go.mod h1:XidbUqzak3lHdS//TPu2OgiFB+51Ur5f7CSnXZ/JDvo= @@ -654,8 +726,9 @@ github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g= github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -743,8 +816,9 @@ github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjh github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/go-retryablehttp v0.6.6 h1:HJunrbHTDDbBb/ay4kxa1n+dLmttUlnP3V9oNE4hmsM= github.com/hashicorp/go-retryablehttp v0.6.6/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= +github.com/hashicorp/go-retryablehttp v0.7.0 h1:eu1EI/mbirUgP5C8hVsTNaGZreBDlYiwC1FZWkvQPQ4= +github.com/hashicorp/go-retryablehttp v0.7.0/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= @@ -806,6 +880,7 @@ github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= @@ -840,6 +915,7 @@ github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0 github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.10.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.10.8/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= +github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/cpuid v0.0.0-20180405133222-e7e905edc00e/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/pgzip v1.2.4/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= @@ -864,8 +940,9 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kubernetes-sigs/kube-storage-version-migrator v0.0.0-20191127225502-51849bc15f17/go.mod h1:enH0BVV+4+DAgWdwSlMefG8bBzTfVMTr1lApzdLZ/cc= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= -github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= +github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= +github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/libvirt/libvirt-go v4.10.0+incompatible/go.mod h1:34zsnB4iGeOv7Byj6qotuW8Ya4v4Tr43ttjz/F0wjLE= github.com/libvirt/libvirt-go v5.10.0+incompatible h1:01fwkdUHH2hk4YyFNCr48OvSGqXYLzp9cofUpeyeLNc= @@ -887,14 +964,18 @@ github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= +github.com/mailru/easyjson v0.7.1/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE= github.com/markbates/pkger v0.17.1/go.mod h1:0JoVlrol20BSywW79rN3kdFFsE5xYM+rSCQDXbLhiuI= github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0= github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= +github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= @@ -926,9 +1007,12 @@ github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0Qu github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v0.0.0-20180220230111-00c29f56e238/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.3.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= +github.com/mitchellh/mapstructure v1.4.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs= +github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= github.com/moby/term v0.0.0-20200312100748-672ec06f55cd/go.mod h1:DdlQx2hp0Ss5/fLikoLlEeIYiATotOjgB//nb973jeo= @@ -1004,6 +1088,7 @@ github.com/onsi/gomega v1.10.5/go.mod h1:gza4q3jKQJijlu05nKWRCW/GavJumGt8aNRxWg7 github.com/onsi/gomega v1.13.0/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je41yGY= github.com/onsi/gomega v1.14.0/go.mod h1:cIuvLEne0aoVhAgh/O6ac0Op8WWw9H6eYCriF+tEHG0= github.com/onsi/gomega v1.15.0/go.mod h1:cIuvLEne0aoVhAgh/O6ac0Op8WWw9H6eYCriF+tEHG0= +github.com/onsi/gomega v1.16.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= github.com/onsi/gomega v1.17.0 h1:9Luw4uT5HTjHTN8+aNcSThgH1vdXnmdJ8xIfZ4wyTRE= github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= @@ -1036,6 +1121,7 @@ github.com/openshift/api v0.0.0-20210730095913-85e1d547cdee/go.mod h1:ntkQrC1Z6A github.com/openshift/api v0.0.0-20210816181336-8ff39b776da3/go.mod h1:x81TFA31x1OMT9SYWukQqJ/KbmeveRN6fo+XeGRK8g0= github.com/openshift/api v0.0.0-20211025104849-a11323ccb6ea/go.mod h1:RsQCVJu4qhUawxxDP7pGlwU3IA4F01wYm3qKEu29Su8= github.com/openshift/api v0.0.0-20211108165917-be1be0e89115/go.mod h1:RsQCVJu4qhUawxxDP7pGlwU3IA4F01wYm3qKEu29Su8= +github.com/openshift/api v0.0.0-20211209135129-c58d9f695577/go.mod h1:DoslCwtqUpr3d/gsbq4ZlkaMEdYqKxuypsDjorcHhME= github.com/openshift/api v0.0.0-20220222102030-354aa98a475c h1:teP/Es0/vieKbpRde+xwoM0F1cWO5ZFLS4ihJ2WG7BQ= github.com/openshift/api v0.0.0-20220222102030-354aa98a475c/go.mod h1:F/eU6jgr6Q2VhMu1mSpMmygxAELd7+BUxs3NHZ25jV4= github.com/openshift/baremetal-operator v0.0.0-20211201170610-92ffa60c683d h1:4KkYItiWENIs2bV6lKOcIMdWUnZJA+GWT9Us7z0P1UA= @@ -1057,8 +1143,9 @@ github.com/openshift/client-go v0.0.0-20201214125552-e615e336eb49/go.mod h1:9/jG github.com/openshift/client-go v0.0.0-20210331195552-cf6c2669e01f/go.mod h1:hHaRJ6vp2MRd/CpuZ1oJkqnMGy5eEnoAkQmKPZKcUPI= github.com/openshift/client-go v0.0.0-20210409155308-a8e62c60e930/go.mod h1:uBPbAyIbjMuhPQy4NgF8q1alNGX2qA8bXIkAycsSDc0= github.com/openshift/client-go v0.0.0-20210730113412-1811c1b3fc0e/go.mod h1:P1pjphFOgm/nYjmtouHGaSLGtdP25dQICJnYtcYhfEs= -github.com/openshift/client-go v0.0.0-20211025111749-96ca2abfc56c h1:2yUcA5LUiKqEnRnqW8MYaB3/7tEAFqCjLtVcbDFlIjg= github.com/openshift/client-go v0.0.0-20211025111749-96ca2abfc56c/go.mod h1:xigLF97kzy1PZuDsC0Lfu6GlzChRt62+2Ts/nG3sPHY= +github.com/openshift/client-go v0.0.0-20211209144617-7385dd6338e3 h1:SG1aqwleU6bGD0X4mhkTNupjVnByMYYuW4XbnCPavQU= +github.com/openshift/client-go v0.0.0-20211209144617-7385dd6338e3/go.mod h1:cwhyki5lqBmrT0m8Im+9I7PGFaraOzcYPtEz93RcsGY= github.com/openshift/cloud-credential-operator v0.0.0-20200316201045-d10080b52c9e h1:2gyl9UVyjHSWzdS56KUXxQwIhENbq2x2olqoMQSA/C8= github.com/openshift/cloud-credential-operator v0.0.0-20200316201045-d10080b52c9e/go.mod h1:iPn+uhIe7nkP5BMHe2QnbLtg5m/AIQ1xvz9s3cig5ss= github.com/openshift/cluster-api v0.0.0-20190805113604-f8de78af80fc h1:6Nf3TaiooyEZNk+3ZHonNOujT+HacuSj9cxyeGTc/zg= @@ -1109,6 +1196,8 @@ github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= +github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA= github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= @@ -1126,6 +1215,7 @@ github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.1.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pelletier/go-toml v1.4.0/go.mod h1:PN7xzY2wHTK0K9p34ErDQMlFxa51Fk0OUruD3k1mMwo= github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= @@ -1400,10 +1490,17 @@ go.etcd.io/etcd/server/v3 v3.5.0/go.mod h1:3Ah5ruV+M+7RZr0+Y/5mNLwC+eQlni+mQmOVd go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= go.mongodb.org/mongo-driver v1.1.1/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= go.mongodb.org/mongo-driver v1.1.2/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= +go.mongodb.org/mongo-driver v1.3.0/go.mod h1:MSWZXKOynuguX+JSvwP8i+58jYCXxbia8HS3gZBapIE= +go.mongodb.org/mongo-driver v1.3.4/go.mod h1:MSWZXKOynuguX+JSvwP8i+58jYCXxbia8HS3gZBapIE= go.mongodb.org/mongo-driver v1.4.2/go.mod h1:WcMNYLx/IlOxLe6JRJiv2uXuCz6zBLndR4SoGjYphSc= go.mongodb.org/mongo-driver v1.4.3/go.mod h1:WcMNYLx/IlOxLe6JRJiv2uXuCz6zBLndR4SoGjYphSc= -go.mongodb.org/mongo-driver v1.5.1 h1:9nOVLGDfOaZ9R0tBumx/BcuqkbFpyTCU2r/Po7A2azI= +go.mongodb.org/mongo-driver v1.4.4/go.mod h1:WcMNYLx/IlOxLe6JRJiv2uXuCz6zBLndR4SoGjYphSc= +go.mongodb.org/mongo-driver v1.4.6/go.mod h1:WcMNYLx/IlOxLe6JRJiv2uXuCz6zBLndR4SoGjYphSc= go.mongodb.org/mongo-driver v1.5.1/go.mod h1:gRXCHX4Jo7J0IJ1oDQyUxF7jfy19UfxniMS4xxMmUqw= +go.mongodb.org/mongo-driver v1.7.3/go.mod h1:NqaYOwnXWr5Pm7AOpO5QFxKJ503nbMse/R79oO62zWg= +go.mongodb.org/mongo-driver v1.7.5/go.mod h1:VXEWRZ6URJIkUq2SCAyapmhH0ZLRBP+FT4xhp5Zvxng= +go.mongodb.org/mongo-driver v1.8.3 h1:TDKlTkGDKm9kkJVUOAXDK5/fkqKHJVwYQSpoRfB43R4= +go.mongodb.org/mongo-driver v1.8.3/go.mod h1:0sQWfOeY63QTntERDJJ/0SuKK0T1uVSgKCuAROlKEPY= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= @@ -1486,6 +1583,7 @@ golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200423211502-4bdfaf469ed5/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= @@ -1591,18 +1689,22 @@ golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210224082022-3d97a244fca7/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20210520170846-37e1c6afe023/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210825183410-e898025ed96a h1:bRuuGXV8wwSdGTB+CtJf+FjgO1APK1CoO39T4BN/XBw= golang.org/x/net v0.0.0-20210825183410-e898025ed96a/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk= +golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -1722,6 +1824,7 @@ golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210426230700-d19ff857e887/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1733,12 +1836,14 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210817190340-bfb29a6856f2/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211029165221-6e7872819dc8 h1:M69LAlWZCshgp0QSzyDcSsSIejIEeuaCVpmwcKwyLMk= golang.org/x/sys v0.0.0-20211029165221-6e7872819dc8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b h1:9zKuko04nR4gjZ4+DNjHqRlAJqbJETHwiNKDqTfOjfE= golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.0.0-20170915090833-1cbadb444a80/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -2247,8 +2352,9 @@ k8s.io/utils v0.0.0-20210527160623-6fdb442a123b/go.mod h1:jPW/WVKK9YHAvNhRxK0md/ k8s.io/utils v0.0.0-20210707171843-4b05e18ac7d9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= k8s.io/utils v0.0.0-20210722164352-7f3ee0f31471/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= -k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b h1:wxEMGetGMur3J1xuGLQY7GEQYg9bZxKn3tKo5k/eYcs= k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= +k8s.io/utils v0.0.0-20211208161948-7d6a63dca704 h1:ZKMMxTvduyf5WUtREOqg5LiXaN1KO/+0oOQPRFrClpo= +k8s.io/utils v0.0.0-20211208161948-7d6a63dca704/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= @@ -2281,8 +2387,9 @@ sigs.k8s.io/controller-runtime v0.11.0 h1:DqO+c8mywcZLFJWILq4iktoECTyn30Bkj0Cwgq sigs.k8s.io/controller-runtime v0.11.0/go.mod h1:KKwLiTooNGu+JmLZGn9Sl3Gjmfj66eMbCQznLP5zcqA= sigs.k8s.io/controller-tools v0.3.1-0.20200617211605-651903477185 h1:wLsmaqTEgs3DIfNzr0u/AfPHSVJbWHj/eevcS4AFvFE= sigs.k8s.io/controller-tools v0.3.1-0.20200617211605-651903477185/go.mod h1:JuPG+FXjAeZL7eGmTuXUJduEMlI2/kGqb0rUGlVi+Yo= -sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 h1:fD1pz4yfdADVNfFmcP2aBEtudwUQ1AlLnRBALr33v3s= sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6/go.mod h1:p4QtZmO4uMYipTQNzagwnNoseA6OxSUutVw05NhYDRs= +sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 h1:kDi4JBNAsJWfz1aEXhO8Jg87JJaPNLh5tIzYHgStQ9Y= +sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2/go.mod h1:B+TnT182UBxE84DiCz4CVE26eOSDAeYCpfDnC2kdKMY= sigs.k8s.io/kube-storage-version-migrator v0.0.3/go.mod h1:mXfSLkx9xbJHQsgNDDUZK/iQTs2tMbx/hsJlWe6Fthw= sigs.k8s.io/kube-storage-version-migrator v0.0.4/go.mod h1:mXfSLkx9xbJHQsgNDDUZK/iQTs2tMbx/hsJlWe6Fthw= sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU= diff --git a/pkg/asset/installconfig/basedomain.go b/pkg/asset/installconfig/basedomain.go index 8bd07e3109c..a505cd1a9dd 100644 --- a/pkg/asset/installconfig/basedomain.go +++ b/pkg/asset/installconfig/basedomain.go @@ -16,6 +16,7 @@ import ( "github.com/openshift/installer/pkg/types/azure" "github.com/openshift/installer/pkg/types/gcp" "github.com/openshift/installer/pkg/types/ibmcloud" + "github.com/openshift/installer/pkg/types/powervs" "github.com/openshift/installer/pkg/validate" ) @@ -71,7 +72,7 @@ func (a *baseDomain) Generate(parents asset.Parents) error { if !(gcpconfig.IsForbidden(err) || gcpconfig.IsThrottled(err)) { return err } - case ibmcloud.Name: + case ibmcloud.Name, powervs.Name: zone, err := ibmcloudconfig.GetDNSZone() if err != nil { return err diff --git a/pkg/asset/installconfig/installconfig.go b/pkg/asset/installconfig/installconfig.go index 4253ec63364..d613d2f10de 100644 --- a/pkg/asset/installconfig/installconfig.go +++ b/pkg/asset/installconfig/installconfig.go @@ -18,6 +18,7 @@ import ( icibmcloud "github.com/openshift/installer/pkg/asset/installconfig/ibmcloud" icopenstack "github.com/openshift/installer/pkg/asset/installconfig/openstack" icovirt "github.com/openshift/installer/pkg/asset/installconfig/ovirt" + icpowervs "github.com/openshift/installer/pkg/asset/installconfig/powervs" icvsphere "github.com/openshift/installer/pkg/asset/installconfig/vsphere" "github.com/openshift/installer/pkg/types" "github.com/openshift/installer/pkg/types/conversion" @@ -37,6 +38,7 @@ type InstallConfig struct { Azure *icazure.Metadata `json:"azure,omitempty"` IBMCloud *icibmcloud.Metadata `json:"ibmcloud,omitempty"` AlibabaCloud *alibabacloud.Metadata `json:"alibabacloud,omitempty"` + PowerVS *icpowervs.Metadata `json:"powervs,omitempty"` } var _ asset.WritableAsset = (*InstallConfig)(nil) @@ -97,6 +99,7 @@ func (a *InstallConfig) Generate(parents asset.Parents) error { a.Config.IBMCloud = platform.IBMCloud a.Config.BareMetal = platform.BareMetal a.Config.Ovirt = platform.Ovirt + a.Config.PowerVS = platform.PowerVS return a.finish("") } @@ -161,6 +164,10 @@ func (a *InstallConfig) finish(filename string) error { if a.Config.IBMCloud != nil { a.IBMCloud = icibmcloud.NewMetadata(a.Config.BaseDomain) } + if a.Config.PowerVS != nil { + a.PowerVS = icpowervs.NewMetadata(a.Config.BaseDomain) + } + if err := validation.ValidateInstallConfig(a.Config).ToAggregate(); err != nil { if filename == "" { return errors.Wrap(err, "invalid install config") diff --git a/pkg/asset/installconfig/platform.go b/pkg/asset/installconfig/platform.go index 84faf7e7ab2..fd2f625046e 100644 --- a/pkg/asset/installconfig/platform.go +++ b/pkg/asset/installconfig/platform.go @@ -18,6 +18,7 @@ import ( libvirtconfig "github.com/openshift/installer/pkg/asset/installconfig/libvirt" openstackconfig "github.com/openshift/installer/pkg/asset/installconfig/openstack" ovirtconfig "github.com/openshift/installer/pkg/asset/installconfig/ovirt" + powervsconfig "github.com/openshift/installer/pkg/asset/installconfig/powervs" vsphereconfig "github.com/openshift/installer/pkg/asset/installconfig/vsphere" "github.com/openshift/installer/pkg/types" "github.com/openshift/installer/pkg/types/alibabacloud" @@ -30,6 +31,7 @@ import ( "github.com/openshift/installer/pkg/types/none" "github.com/openshift/installer/pkg/types/openstack" "github.com/openshift/installer/pkg/types/ovirt" + "github.com/openshift/installer/pkg/types/powervs" "github.com/openshift/installer/pkg/types/vsphere" ) @@ -106,6 +108,11 @@ func (a *platform) Generate(asset.Parents) error { if err != nil { return err } + case powervs.Name: + a.PowerVS, err = powervsconfig.Platform() + if err != nil { + return err + } default: return fmt.Errorf("unknown platform type %q", platform) } diff --git a/pkg/asset/installconfig/platformcredscheck.go b/pkg/asset/installconfig/platformcredscheck.go index a77cf68478a..d689959fb34 100644 --- a/pkg/asset/installconfig/platformcredscheck.go +++ b/pkg/asset/installconfig/platformcredscheck.go @@ -11,6 +11,7 @@ import ( ibmcloudconfig "github.com/openshift/installer/pkg/asset/installconfig/ibmcloud" openstackconfig "github.com/openshift/installer/pkg/asset/installconfig/openstack" ovirtconfig "github.com/openshift/installer/pkg/asset/installconfig/ovirt" + powervsconfig "github.com/openshift/installer/pkg/asset/installconfig/powervs" "github.com/openshift/installer/pkg/types/alibabacloud" "github.com/openshift/installer/pkg/types/aws" "github.com/openshift/installer/pkg/types/azure" @@ -21,6 +22,7 @@ import ( "github.com/openshift/installer/pkg/types/none" "github.com/openshift/installer/pkg/types/openstack" "github.com/openshift/installer/pkg/types/ovirt" + "github.com/openshift/installer/pkg/types/powervs" "github.com/openshift/installer/pkg/types/vsphere" ) @@ -52,6 +54,7 @@ func (a *PlatformCredsCheck) Generate(dependencies asset.Parents) error { if err != nil { return errors.Wrap(err, "creating AlibabaCloud Cloud session") } + case aws.Name: _, err := ic.AWS.Session(ctx) if err != nil { @@ -88,6 +91,11 @@ func (a *PlatformCredsCheck) Generate(dependencies asset.Parents) error { if err != nil { return errors.Wrap(err, "testing Engine connection") } + case powervs.Name: + _, err = powervsconfig.GetSession() + if err != nil { + return errors.Wrap(err, "creating IBM Cloud session") + } default: err = fmt.Errorf("unknown platform type %q", platform) } diff --git a/pkg/asset/installconfig/platformpermscheck.go b/pkg/asset/installconfig/platformpermscheck.go index e745959d568..6cae20c3912 100644 --- a/pkg/asset/installconfig/platformpermscheck.go +++ b/pkg/asset/installconfig/platformpermscheck.go @@ -9,6 +9,7 @@ import ( "github.com/openshift/installer/pkg/asset" awsconfig "github.com/openshift/installer/pkg/asset/installconfig/aws" gcpconfig "github.com/openshift/installer/pkg/asset/installconfig/gcp" + "github.com/openshift/installer/pkg/types/alibabacloud" "github.com/openshift/installer/pkg/types/aws" "github.com/openshift/installer/pkg/types/azure" @@ -19,6 +20,7 @@ import ( "github.com/openshift/installer/pkg/types/none" "github.com/openshift/installer/pkg/types/openstack" "github.com/openshift/installer/pkg/types/ovirt" + "github.com/openshift/installer/pkg/types/powervs" "github.com/openshift/installer/pkg/types/vsphere" ) @@ -87,6 +89,8 @@ func (a *PlatformPermsCheck) Generate(dependencies asset.Parents) error { } case ibmcloud.Name: // TODO: IBM[#90]: platformpermscheck + case powervs.Name: + //@TODO add check that the account plan is anything but "lite" case azure.Name, baremetal.Name, libvirt.Name, none.Name, openstack.Name, ovirt.Name, vsphere.Name, alibabacloud.Name: // no permissions to check default: diff --git a/pkg/asset/installconfig/platformprovisioncheck.go b/pkg/asset/installconfig/platformprovisioncheck.go index 5a50458a64a..802f52ec488 100644 --- a/pkg/asset/installconfig/platformprovisioncheck.go +++ b/pkg/asset/installconfig/platformprovisioncheck.go @@ -13,6 +13,7 @@ import ( ibmcloudconfig "github.com/openshift/installer/pkg/asset/installconfig/ibmcloud" osconfig "github.com/openshift/installer/pkg/asset/installconfig/openstack" ovirtconfig "github.com/openshift/installer/pkg/asset/installconfig/ovirt" + powervsconfig "github.com/openshift/installer/pkg/asset/installconfig/powervs" vsconfig "github.com/openshift/installer/pkg/asset/installconfig/vsphere" "github.com/openshift/installer/pkg/types/alibabacloud" "github.com/openshift/installer/pkg/types/aws" @@ -24,6 +25,7 @@ import ( "github.com/openshift/installer/pkg/types/none" "github.com/openshift/installer/pkg/types/openstack" "github.com/openshift/installer/pkg/types/ovirt" + "github.com/openshift/installer/pkg/types/powervs" "github.com/openshift/installer/pkg/types/vsphere" ) @@ -112,6 +114,8 @@ func (a *PlatformProvisionCheck) Generate(dependencies asset.Parents) error { return err } err = alibabacloudconfig.ValidateForProvisioning(client, ic.Config, ic.AlibabaCloud) + case powervs.Name: + err = powervsconfig.ValidateForProvisioning() if err != nil { return err } diff --git a/pkg/asset/installconfig/powervs/client.go b/pkg/asset/installconfig/powervs/client.go new file mode 100644 index 00000000000..ec4094d4bcf --- /dev/null +++ b/pkg/asset/installconfig/powervs/client.go @@ -0,0 +1,219 @@ +package powervs + +import ( + "context" + "fmt" + "os" + "time" + + "github.com/IBM/go-sdk-core/v5/core" + "github.com/IBM/networking-go-sdk/zonesv1" + "github.com/IBM/platform-services-go-sdk/iamidentityv1" + "github.com/IBM/platform-services-go-sdk/resourcecontrollerv2" + "github.com/IBM/platform-services-go-sdk/resourcemanagerv2" + "github.com/IBM/vpc-go-sdk/vpcv1" + "github.com/pkg/errors" +) + +// API represents the calls made to the API. +type API interface { + GetDNSZoneIDByName(ctx context.Context, name string) (string, error) + GetDNSZones(ctx context.Context) ([]DNSZoneResponse, error) + GetAuthenticatorAPIKeyDetails(ctx context.Context) (*iamidentityv1.APIKey, error) +} + +// Client makes calls to the PowerVS API. +type Client struct { + APIKey string + managementAPI *resourcemanagerv2.ResourceManagerV2 + controllerAPI *resourcecontrollerv2.ResourceControllerV2 + vpcAPI *vpcv1.VpcV1 +} + +// cisServiceID is the Cloud Internet Services' catalog service ID. +const cisServiceID = "75874a60-cb12-11e7-948e-37ac098eb1b9" + +// DNSZoneResponse represents a DNS zone response. +type DNSZoneResponse struct { + // Name is the domain name of the zone. + Name string + + // ID is the zone's ID. + ID string + + // CISInstanceCRN is the IBM Cloud Resource Name for the CIS instance where + // the DNS zone is managed. + CISInstanceCRN string + + // CISInstanceName is the display name of the CIS instance where the DNS zone + // is managed. + CISInstanceName string + + // ResourceGroupID is the resource group ID of the CIS instance. + ResourceGroupID string +} + +// NewClient initializes a client with a session. +func NewClient() (*Client, error) { + apiKey := os.Getenv("IC_API_KEY") + client := &Client{ + APIKey: apiKey, + } + + if err := client.loadSDKServices(); err != nil { + return nil, errors.Wrap(err, "failed to load IBM SDK services") + } + + return client, nil +} + +func (c *Client) loadSDKServices() error { + servicesToLoad := []func() error{ + c.loadResourceManagementAPI, + c.loadResourceControllerAPI, + c.loadVPCV1API, + } + + // Call all the load functions. + for _, fn := range servicesToLoad { + if err := fn(); err != nil { + return err + } + } + + return nil +} + +// GetDNSZoneIDByName gets the CIS zone ID from its domain name. +func (c *Client) GetDNSZoneIDByName(ctx context.Context, name string) (string, error) { + + zones, err := c.GetDNSZones(ctx) + if err != nil { + return "", err + } + + for _, z := range zones { + if z.Name == name { + return z.ID, nil + } + } + + return "", fmt.Errorf("DNS zone %q not found", name) +} + +// GetDNSZones returns all of the active DNS zones managed by CIS. +func (c *Client) GetDNSZones(ctx context.Context) ([]DNSZoneResponse, error) { + _, cancel := context.WithTimeout(ctx, 1*time.Minute) + defer cancel() + + options := c.controllerAPI.NewListResourceInstancesOptions() + options.SetResourceID(cisServiceID) + + listResourceInstancesResponse, _, err := c.controllerAPI.ListResourceInstances(options) + if err != nil { + return nil, errors.Wrap(err, "failed to get cis instance") + } + + var allZones []DNSZoneResponse + for _, instance := range listResourceInstancesResponse.Resources { + crnstr := instance.CRN + authenticator := &core.IamAuthenticator{ + ApiKey: c.APIKey, + } + zonesService, err := zonesv1.NewZonesV1(&zonesv1.ZonesV1Options{ + Authenticator: authenticator, + Crn: crnstr, + }) + if err != nil { + return nil, errors.Wrap(err, "failed to list DNS zones") + } + + options := zonesService.NewListZonesOptions() + listZonesResponse, _, err := zonesService.ListZones(options) + + if listZonesResponse == nil { + return nil, err + } + + for _, zone := range listZonesResponse.Result { + if *zone.Status == "active" { + zoneStruct := DNSZoneResponse{ + Name: *zone.Name, + ID: *zone.ID, + CISInstanceCRN: *instance.CRN, + CISInstanceName: *instance.Name, + ResourceGroupID: *instance.ResourceGroupID, + } + allZones = append(allZones, zoneStruct) + } + } + } + + return allZones, nil +} + +func (c *Client) loadResourceManagementAPI() error { + authenticator := &core.IamAuthenticator{ + ApiKey: c.APIKey, + } + options := &resourcemanagerv2.ResourceManagerV2Options{ + Authenticator: authenticator, + } + resourceManagerV2Service, err := resourcemanagerv2.NewResourceManagerV2(options) + if err != nil { + return err + } + c.managementAPI = resourceManagerV2Service + return nil +} + +func (c *Client) loadResourceControllerAPI() error { + authenticator := &core.IamAuthenticator{ + ApiKey: c.APIKey, + } + options := &resourcecontrollerv2.ResourceControllerV2Options{ + Authenticator: authenticator, + } + resourceControllerV2Service, err := resourcecontrollerv2.NewResourceControllerV2(options) + if err != nil { + return err + } + c.controllerAPI = resourceControllerV2Service + return nil +} + +func (c *Client) loadVPCV1API() error { + authenticator := &core.IamAuthenticator{ + ApiKey: c.APIKey, + } + vpcService, err := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + Authenticator: authenticator, + }) + if err != nil { + return err + } + c.vpcAPI = vpcService + return nil +} + +// GetAuthenticatorAPIKeyDetails gets detailed information on the API key used +// for authentication to the IBM Cloud APIs. +func (c *Client) GetAuthenticatorAPIKeyDetails(ctx context.Context) (*iamidentityv1.APIKey, error) { + authenticator := &core.IamAuthenticator{ + ApiKey: c.APIKey, + } + iamIdentityService, err := iamidentityv1.NewIamIdentityV1(&iamidentityv1.IamIdentityV1Options{ + Authenticator: authenticator, + }) + if err != nil { + return nil, err + } + + options := iamIdentityService.NewGetAPIKeysDetailsOptions() + options.SetIamAPIKey(c.APIKey) + details, _, err := iamIdentityService.GetAPIKeysDetailsWithContext(ctx, options) + if err != nil { + return nil, err + } + return details, nil +} diff --git a/pkg/asset/installconfig/powervs/metadata.go b/pkg/asset/installconfig/powervs/metadata.go new file mode 100644 index 00000000000..443b360ec98 --- /dev/null +++ b/pkg/asset/installconfig/powervs/metadata.go @@ -0,0 +1,92 @@ +package powervs + +import ( + "context" + "fmt" + "sync" +) + +// Metadata holds additional metadata for InstallConfig resources that +// do not need to be user-supplied (e.g. because it can be retrieved +// from external APIs). +type Metadata struct { + BaseDomain string + + accountID string + cisInstanceCRN string + client *Client + + mutex sync.Mutex +} + +// NewMetadata initializes a new Metadata object. +func NewMetadata(baseDomain string) *Metadata { + return &Metadata{BaseDomain: baseDomain} +} + +// AccountID returns the IBM Cloud account ID associated with the authentication +// credentials. +func (m *Metadata) AccountID(ctx context.Context) (string, error) { + m.mutex.Lock() + defer m.mutex.Unlock() + + if m.accountID == "" { + client, err := m.Client() + if err != nil { + return "", err + } + + apiKeyDetails, err := client.GetAuthenticatorAPIKeyDetails(ctx) + if err != nil { + return "", err + } + + m.accountID = *apiKeyDetails.AccountID + } + return m.accountID, nil +} + +// CISInstanceCRN returns the Cloud Internet Services instance CRN that is +// managing the DNS zone for the base domain. +func (m *Metadata) CISInstanceCRN(ctx context.Context) (string, error) { + m.mutex.Lock() + defer m.mutex.Unlock() + + if m.cisInstanceCRN == "" { + client, err := m.Client() + if err != nil { + return "", err + } + + zones, err := client.GetDNSZones(ctx) + if err != nil { + return "", err + } + + for _, z := range zones { + if z.Name == m.BaseDomain { + m.SetCISInstanceCRN(z.CISInstanceCRN) + return m.cisInstanceCRN, nil + } + } + return "", fmt.Errorf("cisInstanceCRN unknown due to DNS zone %q not found", m.BaseDomain) + } + return m.cisInstanceCRN, nil +} + +// SetCISInstanceCRN sets Cloud Internet Services instance CRN to a string value. +func (m *Metadata) SetCISInstanceCRN(crn string) { + m.cisInstanceCRN = crn +} + +// Client returns a client used for making API calls to IBM Cloud services. +func (m *Metadata) Client() (*Client, error) { + if m.client == nil { + client, err := NewClient() + if err != nil { + return nil, err + } + m.client = client + } + return m.client, nil +} diff --git a/pkg/asset/installconfig/powervs/platform.go b/pkg/asset/installconfig/powervs/platform.go new file mode 100644 index 00000000000..3be2293ea63 --- /dev/null +++ b/pkg/asset/installconfig/powervs/platform.go @@ -0,0 +1,31 @@ +package powervs + +import ( + "os" + + "github.com/openshift/installer/pkg/types/powervs" +) + +// Platform collects powervs-specific configuration. +func Platform() (*powervs.Platform, error) { + + ssn, err := GetSession() + if err != nil { + return nil, err + } + + var p powervs.Platform + + // @TODO: The way we're using this (a precreated boot image in a Power VS Service instance) doesn't + // align with the installer's definition of this. We need a new var here and in the install config. + // This should be done before code cutoff in a followon PR. + if osOverride := os.Getenv("OPENSHIFT_INSTALL_OS_IMAGE_OVERRIDE"); len(osOverride) != 0 { + p.ClusterOSImage = osOverride + } + + p.Region = ssn.Session.Options.Region + p.Zone = ssn.Session.Options.Zone + p.UserID = ssn.Session.Options.UserAccount + + return &p, nil +} diff --git a/pkg/asset/installconfig/powervs/regions.go b/pkg/asset/installconfig/powervs/regions.go new file mode 100644 index 00000000000..6dee14409f2 --- /dev/null +++ b/pkg/asset/installconfig/powervs/regions.go @@ -0,0 +1,139 @@ +package powervs + +import ( + "fmt" + "sort" + "strings" + + survey "github.com/AlecAivazis/survey/v2" + "github.com/AlecAivazis/survey/v2/core" + "github.com/openshift/installer/pkg/types/powervs" + "github.com/pkg/errors" +) + +func knownRegions() map[string]string { + + regions := make(map[string]string) + + for name, region := range powervs.Regions { + regions[name] = region.Description + } + return regions +} + +// IsKnownRegion return true is a specified region is Known to the installer. +func IsKnownRegion(region string) bool { + if _, ok := knownRegions()[region]; ok { + return true + } + return false +} + +func knownZones(region string) []string { + return powervs.Regions[region].Zones +} + +// IsKnownZone return true is a specified zone is Known to the installer. +func IsKnownZone(region string, zone string) bool { + if _, ok := knownRegions()[region]; ok { + zones := knownZones(region) + for _, z := range zones { + if z == zone { + return true + } + } + return false + } + return false +} + +// GetRegion prompts the user to select a region and returns that region. +func GetRegion() (string, error) { + regions := knownRegions() + + longRegions := make([]string, 0, len(regions)) + shortRegions := make([]string, 0, len(regions)) + for id, location := range regions { + longRegions = append(longRegions, fmt.Sprintf("%s (%s)", id, location)) + shortRegions = append(shortRegions, id) + } + sort.Strings(longRegions) + sort.Strings(shortRegions) + + var regionTransform survey.Transformer = func(ans interface{}) interface{} { + switch v := ans.(type) { + case core.OptionAnswer: + return core.OptionAnswer{Value: strings.SplitN(v.Value, " ", 2)[0], Index: v.Index} + case string: + return strings.SplitN(v, " ", 2)[0] + } + return "" + } + + var region string + + err := survey.Ask([]*survey.Question{ + { + Prompt: &survey.Select{ + Message: "Region", + Help: "The Power VS region to be used for installation.", + Options: longRegions, + }, + Validate: survey.ComposeValidators(survey.Required, func(ans interface{}) error { + choice := regionTransform(ans).(core.OptionAnswer).Value + i := sort.SearchStrings(shortRegions, choice) + if i == len(shortRegions) || shortRegions[i] != choice { + return errors.Errorf("Invalid region %q", choice) + } + return nil + }), + Transform: regionTransform, + }, + }, ®ion) + if err != nil { + return "", err + } + + return region, nil +} + +// GetZone prompts the user for a zone given a zone. +func GetZone(region string) (string, error) { + zones := knownZones(region) + defaultZone := zones[0] + + var zoneTransform survey.Transformer = func(ans interface{}) interface{} { + switch v := ans.(type) { + case core.OptionAnswer: + return core.OptionAnswer{Value: strings.SplitN(v.Value, " ", 2)[0], Index: v.Index} + case string: + return strings.SplitN(v, " ", 2)[0] + } + return "" + } + + var zone string + err := survey.Ask([]*survey.Question{ + { + Prompt: &survey.Select{ + Message: "Zone", + Help: "The Power VS zone within the region to be used for installation.", + Default: fmt.Sprintf("%s", defaultZone), + Options: zones, + }, + Validate: survey.ComposeValidators(survey.Required, func(ans interface{}) error { + choice := zoneTransform(ans).(core.OptionAnswer).Value + i := sort.SearchStrings(zones, choice) + if i == len(zones) || zones[i] != choice { + return errors.Errorf("Invalid zone %q", choice) + } + return nil + }), + Transform: zoneTransform, + }, + }, &zone) + if err != nil { + return "", err + } + return zone, err +} diff --git a/pkg/asset/installconfig/powervs/session.go b/pkg/asset/installconfig/powervs/session.go new file mode 100644 index 00000000000..885f8e46db5 --- /dev/null +++ b/pkg/asset/installconfig/powervs/session.go @@ -0,0 +1,235 @@ +package powervs + +import ( + "encoding/json" + "io/ioutil" + "os" + "path/filepath" + "time" + + "github.com/IBM/go-sdk-core/v4/core" + "github.com/pkg/errors" + + survey "github.com/AlecAivazis/survey/v2" + "github.com/IBM-Cloud/power-go-client/ibmpisession" +) + +var ( + defSessionTimeout time.Duration = 9000000000000000000.0 + defRegion = "us_south" +) + +// Session is an object representing a session for the IBM Power VS API. +type Session struct { + Session *ibmpisession.IBMPISession + APIKey string +} + +// PISessionVars is an object that holds the variables required to create an ibmpisession object. +type PISessionVars struct { + ID string `json:"id,omitempty"` + APIKey string `json:"apikey,omitempty"` + Region string `json:"region,omitempty"` + Zone string `json:"zone,omitempty"` +} + +// GetSession returns an ibmpisession object. +func GetSession() (*Session, error) { + s, apiKey, err := getPISession() + if err != nil { + return nil, errors.Wrap(err, "failed to load credentials") + } + return &Session{Session: s, APIKey: apiKey}, nil +} + +var ( + defaultAuthFilePath = filepath.Join(os.Getenv("HOME"), ".powervs", "config.json") +) + +func getPISession() (*ibmpisession.IBMPISession, string, error) { + + var err error + var pisv PISessionVars + + // Grab variables from the installer written authFilePath. + err = getPISessionVarsFromAuthFile(&pisv) + if err != nil { + return nil, "", err + } + + // Grab variables from the users environment. + err = getPISessionVarsFromEnv(&pisv) + if err != nil { + return nil, "", err + } + + // Prompt the user for the remaining variables. + err = getPISessionVarsFromUser(&pisv) + if err != nil { + return nil, "", err + } + + // Save variables to disk. + err = savePISessionVars(&pisv) + if err != nil { + return nil, "", err + } + + // This is needed by ibmcloud code to gather DNS information later. + os.Setenv("IC_API_KEY", pisv.APIKey) + + piOpts := ibmpisession.IBMPIOptions{ + Authenticator: &core.IamAuthenticator{ + ApiKey: pisv.APIKey, + }, + Region: pisv.Region, + UserAccount: pisv.ID, + Zone: pisv.Zone, + } + s, err := ibmpisession.NewIBMPISession(&piOpts) + if err != nil { + return nil, "", err + } + + return s, pisv.APIKey, err +} + +func getPISessionVarsFromAuthFile(pisv *PISessionVars) error { + + if pisv == nil { + return errors.New("nil var: PISessionVars") + } + + authFilePath := defaultAuthFilePath + if f := os.Getenv("POWERVS_AUTH_FILEPATH"); len(f) > 0 { + authFilePath = f + } + + if _, err := os.Stat(authFilePath); os.IsNotExist(err) { + return nil + } + + content, err := ioutil.ReadFile(authFilePath) + if err != nil { + return err + } + + err = json.Unmarshal(content, pisv) + if err != nil { + return err + } + + return nil +} + +func getPISessionVarsFromEnv(pisv *PISessionVars) error { + + if pisv == nil { + return errors.New("nil var: PiSessionVars") + } + + if len(pisv.ID) == 0 { + pisv.ID = os.Getenv("IBMID") + } + + if len(pisv.APIKey) == 0 { + // APIKeyEnvVars is a list of environment variable names containing an IBM Cloud API key. + var APIKeyEnvVars = []string{"IC_API_KEY", "IBMCLOUD_API_KEY", "BM_API_KEY", "BLUEMIX_API_KEY"} + pisv.APIKey = getEnv(APIKeyEnvVars) + } + + if len(pisv.Region) == 0 { + var regionEnvVars = []string{"IBMCLOUD_REGION", "IC_REGION"} + pisv.Region = getEnv(regionEnvVars) + } + + if len(pisv.Zone) == 0 { + var zoneEnvVars = []string{"IBMCLOUD_ZONE"} + pisv.Zone = getEnv(zoneEnvVars) + } + + return nil +} + +func getPISessionVarsFromUser(pisv *PISessionVars) error { + var err error + + if pisv == nil { + return errors.New("nil var: PiSessionVars") + } + + if len(pisv.ID) == 0 { + err = survey.Ask([]*survey.Question{ + { + Prompt: &survey.Input{ + Message: "IBM Cloud User ID", + Help: "The login for \nhttps://cloud.ibm.com/", + }, + }, + }, &pisv.ID) + if err != nil { + return errors.New("error saving the IBM Cloud User ID") + } + + } + + if len(pisv.APIKey) == 0 { + err = survey.Ask([]*survey.Question{ + { + Prompt: &survey.Password{ + Message: "IBM Cloud API Key", + Help: "The API key installation.\nhttps://cloud.ibm.com/iam/apikeys", + }, + }, + }, &pisv.APIKey) + if err != nil { + return errors.New("error saving the API Key") + } + + } + + if len(pisv.Region) == 0 { + pisv.Region, err = GetRegion() + if err != nil { + return err + } + + } + + if len(pisv.Zone) == 0 { + pisv.Zone, err = GetZone(pisv.Region) + if err != nil { + return err + } + } + + return nil +} + +func savePISessionVars(pisv *PISessionVars) error { + + authFilePath := defaultAuthFilePath + if f := os.Getenv("POWERVS_AUTH_FILEPATH"); len(f) > 0 { + authFilePath = f + } + + jsonVars, err := json.Marshal(*pisv) + if err != nil { + return err + } + + err = os.MkdirAll(filepath.Dir(authFilePath), 0700) + if err != nil { + return err + } + return ioutil.WriteFile(authFilePath, jsonVars, 0600) +} + +func getEnv(envs []string) string { + for _, k := range envs { + if v := os.Getenv(k); v != "" { + return v + } + } + return "" +} diff --git a/pkg/asset/installconfig/powervs/validation.go b/pkg/asset/installconfig/powervs/validation.go new file mode 100644 index 00000000000..954b2e3b2e5 --- /dev/null +++ b/pkg/asset/installconfig/powervs/validation.go @@ -0,0 +1,8 @@ +package powervs + +// ValidateForProvisioning only validates credentials +// @TODO: Expand this to use the install config creds +func ValidateForProvisioning() error { + _, err := GetSession() + return err +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/LICENSE b/vendor/github.com/IBM-Cloud/power-go-client/LICENSE new file mode 100644 index 00000000000..261eeb9e9f8 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/IBM-Cloud/power-go-client/helpers/constants.go b/vendor/github.com/IBM-Cloud/power-go-client/helpers/constants.go new file mode 100644 index 00000000000..8daa7f1befe --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/helpers/constants.go @@ -0,0 +1,251 @@ +package helpers + +import "time" + +const ( + // IBM PI Instance + + PIInstanceName = "pi_instance_name" + PIInstanceDate = "pi_creation_date" + PIInstanceSSHKeyName = "pi_key_pair_name" + PIInstanceImageId = "pi_image_id" + PIInstanceProcessors = "pi_processors" + PIInstanceProcType = "pi_proc_type" + PIInstanceMemory = "pi_memory" + PIInstanceSystemType = "pi_sys_type" + PIInstanceId = "pi_instance_id" + PIInstanceDiskSize = "pi_disk_size" + PIInstanceStatus = "pi_instance_status" + PIInstanceMinProc = "pi_minproc" + PIInstanceVolumeIds = "pi_volume_ids" + PIInstanceNetworkIds = "pi_network_ids" + PIInstancePublicNetwork = "pi_public_network" + PIInstanceMigratable = "pi_migratable" + PICloudInstanceId = "pi_cloud_instance_id" + PICloudInstanceSubnetName = "pi_cloud_instance_subnet_name" + PIInstanceMimMem = "pi_minmem" + PIInstanceMaxProc = "pi_maxproc" + PIInstanceMaxMem = "pi_maxmem" + PIInstanceReboot = "pi_reboot" + PITenantId = "pi_tenant_id" + PIVirtualCoresAssigned = "pi_virtual_cores_assigned" + PIVirtualCoresMax = "pi_virtual_cores_max" + PIVirtualCoresMin = "pi_virtual_cores_min" + PIInstancePVMNetwork = "pi_instance_pvm_network" + PIInstanceStorageType = "pi_storage_type" + PIInstanceStorageConnection = "pi_storage_connection" + PIInstanceStoragePool = "pi_instance_storage_pool" + PIInstanceStorageAffinityPool = "pi_instance_storage_affinity_pool" + PIInstanceLicenseRepositoryCapacity = "pi_license_repository_capacity" + + PIInstanceHealthStatus = "pi_health_status" + PIInstanceReplicants = "pi_replicants" + PIInstanceReplicationPolicy = "pi_replication_policy" + PIInstanceReplicationScheme = "pi_replication_scheme" + PIInstanceProgress = "pi_progress" + PIInstanceUserData = "pi_user_data" + PIInstancePinPolicy = "pi_pin_policy" + + // IBM PI Volume + PIVolumeName = "pi_volume_name" + PIVolumeSize = "pi_volume_size" + PIVolumeType = "pi_volume_type" + PIVolumeShareable = "pi_volume_shareable" + PIVolumeId = "pi_volume_id" + PIVolumeStatus = "pi_volume_status" + PIVolumeWWN = "pi_volume_wwn" + PIVolumeDeleteOnTerminate = "pi_volume_delete_on_terminate" + PIVolumeCreateDate = "pi_volume_create_date" + PIVolumeLastUpdate = "pi_last_updated_date" + PIVolumePool = "pi_volume_pool" + PIAffinityPolicy = "pi_volume_affinity_policy" + PIAffinityVolume = "pi_volume_affinity" + PIAffinityInstance = "pi_volume_affinity_instance" + PIAffinityDiskCount = "pi_volume_disk_count" + PIStoragePoolValue = "pi_storage_pool_type" + PIStoragePoolName = "pi_storage_pool_name" + + // IBM PI Snapshots + + PISnapshot = "pi_snap_shot_id" + PISnapshotName = "pi_snap_shot_name" + PISnapshotStatus = "pi_snap_shot_status" + PISnapshotAction = "pi_snap_shot_action" + PISnapshotComplete = "pi_snap_shot_complete" + + // IBM PI SAP Profile + + PISAPProfileID = "pi_sap_profile_id" + PISAPProfile = "pi_sap_profile" + PISAPProfileMemory = "pi_sap_profile_memory" + PISAPProfileCertified = "pi_sap_profile_certified" + PISAPProfileType = "pi_sap_profile_type" + PISAPProfileCores = "pi_sap_profile_cores" + + // IBM PI Clone Volume + PIVolumeCloneStatus = "pi_volume_clone_status" + PIVolumeClonePercent = "pi_volume_clone_percent" + PIVolumeCloneFailure = "pi_volume_clone_failure" + + // IBM PI Image + + PIImageName = "pi_image_name" + PIImageId = "pi_image_id" + PIImageAccessKey = "pi_image_access_key" + PIImageSecretKey = "pi_image_secret_key" + PIImageSource = "pi_image_source" + PIImageBucketName = "pi_image_bucket_name" + PIImageBucketAccess = "pi_image_bucket_access" + PIImageBucketFileName = "pi_image_bucket_file_name" + PIImageBucketRegion = "pi_image_bucket_region" + PIImageStorageAffinity = "pi_image_storage_affinity" + PIImageStoragePool = "pi_image_storage_pool" + PIImageStorageType = "pi_image_storage_type" + PIImageCopyID = "pi_image_copy_id" + PIImagePath = "pi_image_path" + PIImageOsType = "pi_image_os_type" + + // IBM PI Key + + PIKeyName = "pi_key_name" + PIKey = "pi_ssh_key" + PIKeyDate = "pi_creation_date" + PIKeyId = "pi_key_id" + + // IBM PI Network + + PINetworkReady = "ready" + PINetworkID = "pi_networkid" + PINetworkName = "pi_network_name" + PINetworkCidr = "pi_cidr" + PINetworkDNS = "pi_dns" + PINetworkType = "pi_network_type" + PINetworkGateway = "pi_gateway" + PINetworkIPAddressRange = "pi_ipaddress_range" + PINetworkVlanId = "pi_vlan_id" + PINetworkProvisioning = "build" + PINetworkJumbo = "pi_network_jumbo" + PINetworkPortDescription = "pi_network_port_description" + PINetworkPortIPAddress = "pi_network_port_ipaddress" + PINetworkPortMacAddress = "pi_network_port_macaddress" + PINetworkPortStatus = "pi_network_port_status" + PINetworkPortPortID = "pi_network_port_portid" + + // IBM PI Operations + PIInstanceOperationType = "pi_operation" + PIInstanceOperationProgress = "pi_progress" + PIInstanceOperationStatus = "pi_status" + PIInstanceOperationServerName = "pi_instance_name" + + // IBM PI Volume Attach + PIVolumeAttachName = "pi_volume_attach_name" + PIVolumeAllowableAttachStatus = "in-use" + PIVolumeAttachStatus = "status" + PowerVolumeAttachDeleting = "deleting" + PowerVolumeAttachProvisioning = "creating" + PowerVolumeAttachProvisioningDone = "available" + + // IBM PI Instance Capture + PIInstanceCaptureName = "pi_capture_name" + PIInstanceCaptureDestination = "pi_capture_destination" + PIInstanceCaptureVolumeIds = "pi_capture_volume_ids" + PIInstanceCaptureCloudStorageImagePath = "pi_capture_storage_image_path" + PIInstanceCaptureCloudStorageRegion = "pi_capture_cloud_storage_region" + PIInstanceCaptureCloudStorageAccessKey = "pi_capture_cloud_storage_access_key" + PIInstanceCaptureCloudStorageSecretKey = "pi_capture_cloud_storage_secret_key" + + // IBM PI Cloud Connections + + PICloudConnectionName = "pi_cloud_connection_name" + PICloudConnectionStatus = "pi_cloud_connection_status" + PICloudConnectionMetered = "pi_cloud_connection_metered" + PICloudConnectionUserIPAddress = "pi_cloud_connection_user_ip_address" + PICloudConnectionIBMIPAddress = "pi_cloud_connection_ibm_ip_address" + PICloudConnectionSpeed = "pi_cloud_connection_speed" + PICloudConnectionPort = "pi_cloud_connection_port" + PICloudConnectionGlobalRouting = "pi_cloud_connection_global_routing" + PICloudConnectionId = "pi_cloud_connection_id" + //PICloudConnectionClassic = "pi_cloud_connection_classic" + PICloudConnectionClassicEnabled = "pi_cloud_connection_classic_enabled" + PICloudConnectionClassicGreCidr = "pi_cloud_connection_gre_cidr" + PICloudConnectionClassicGreDest = "pi_cloud_connection_gre_destination_address" + PICloudConnectionClassicGreSource = "pi_cloud_connection_gre_source_address" + PICloudConnectionNetworks = "pi_cloud_connection_networks" + //PICloudConnectionVPC = "pi_cloud_connection_vpc" + PICloudConnectionVPCEnabled = "pi_cloud_connection_vpc_enabled" + PICloudConnectionVPCCRNs = "pi_cloud_connection_vpc_crns" + PICloudConnectionVPCName = "pi_cloud_connection_vpc_name" + + // IBM PI VPN Connections + + PIVPNConnectionName = "pi_vpn_connection_name" + PIVPNConnectionId = "pi_vpn_connection_id" + PIVPNIKEPolicyId = "pi_ike_policy_id" + PIVPNIPSecPolicyId = "pi_ipsec_policy_id" + PIVPNConnectionLocalGatewayAddress = "pi_local_gateway_address" + PIVPNConnectionMode = "pi_vpn_connection_mode" + PIVPNConnectionNetworks = "pi_networks" + PIVPNConnectionPeerGatewayAddress = "pi_peer_gateway_address" + PIVPNConnectionPeerSubnets = "pi_peer_subnets" + PIVPNConnectionStatus = "pi_vpn_connection_status" + PIVPNConnectionVpnGatewayAddress = "pi_gateway_address" + PIVPNConnectionDeadPeerDetection = "pi_dead_peer_detections" + PIVPNConnectionDeadPeerDetectionAction = "pi_dead_peer_detections_action" + PIVPNConnectionDeadPeerDetectionInterval = "pi_dead_peer_detections_interval" + PIVPNConnectionDeadPeerDetectionThreshold = "pi_dead_peer_detections_threshold" + + // IBM PI VPN Policy + PIVPNPolicyId = "pi_policy_id" + PIVPNPolicyName = "pi_policy_name" + PIVPNPolicyDhGroup = "pi_policy_dh_group" + PIVPNPolicyEncryption = "pi_policy_encryption" + PIVPNPolicyKeyLifetime = "pi_policy_key_lifetime" + PIVPNPolicyPresharedKey = "pi_policy_preshared_key" + PIVPNPolicyVersion = "pi_policy_version" + PIVPNPolicyAuthentication = "pi_policy_authentication" + PIVPNPolicyPFS = "pi_policy_pfs" + + JobStatusQueued = "queued" + JobStatusReadyForProcessing = "readyForProcessing" + JobStatusInProgress = "inProgress" + JobStatusCompleted = "completed" + JobStatusFailed = "failed" + JobStatusRunning = "running" + JobStatusWaiting = "waiting" + + // IBM PI DHCP + PIDhcpId = "pi_dhcp_id" + PIDhcpStatus = "pi_dhcp_status" + PIDhcpNetwork = "pi_dhcp_network" + PIDhcpLeases = "pi_dhcp_leases" + PIDhcpInstanceIp = "pi_dhcp_instance_ip" + PIDhcpInstanceMac = "pi_dhcp_instance_mac" + + // IBM PI Placement Groups + + PIPlacementGroupName = "pi_placement_group_name" + PIPlacementGroupPolicy = "pi_placement_group_policy" + PIPlacementGroupID = "pi_placement_group_id" + + // Status For all the resources + + PIVolumeDeleting = "deleting" + PIVolumeDeleted = "done" + PIVolumeProvisioning = "creating" + PIVolumeProvisioningDone = "available" + PIInstanceAvailable = "ACTIVE" + PIInstanceHealthOk = "OK" + PIInstanceHealthWarning = "WARNING" + PIInstanceBuilding = "BUILD" + PIInstanceDeleting = "DELETING" + PIInstanceNotFound = "Not Found" + PIImageQueStatus = "queued" + PIImageActiveStatus = "active" + + //Timeout values for Power VS - + + PICreateTimeOut = 5 * time.Minute + PIUpdateTimeOut = 5 * time.Minute + PIDeleteTimeOut = 3 * time.Minute + PIGetTimeOut = 2 * time.Minute +) diff --git a/vendor/github.com/IBM-Cloud/power-go-client/helpers/env.go b/vendor/github.com/IBM-Cloud/power-go-client/helpers/env.go new file mode 100644 index 00000000000..ede87cc0c7f --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/helpers/env.go @@ -0,0 +1,18 @@ +package helpers + +import "os" + +//EnvFallBack ... +func EnvFallBack(envs []string, defaultValue string) string { + for _, k := range envs { + if v := os.Getenv(k); v != "" { + return v + } + } + return defaultValue +} + +// GetPowerEndPoint +func GetPowerEndPoint() string { + return EnvFallBack([]string{"IBMCLOUD_POWER_API_ENDPOINT"}, "") +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/ibmpisession/logger.go b/vendor/github.com/IBM-Cloud/power-go-client/ibmpisession/logger.go new file mode 100644 index 00000000000..454d456a31d --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/ibmpisession/logger.go @@ -0,0 +1,81 @@ +package ibmpisession + +import ( + "fmt" + "os" + "reflect" + "regexp" + + "github.com/go-openapi/runtime/logger" +) + +var _ logger.Logger = &IBMPILogger{} + +type IBMPILogger struct{} + +func (IBMPILogger) Printf(format string, args ...interface{}) { + if len(format) == 0 || format[len(format)-1] != '\n' { + format += "\n" + } + fmt.Fprintf(os.Stderr, format, args...) +} + +func (IBMPILogger) Debugf(format string, args ...interface{}) { + if len(format) == 0 || format[len(format)-1] != '\n' { + format += "\n" + } + fmt.Fprintf(os.Stderr, format, sanatizeArgs(args)...) +} + +func sanatizeArgs(args []interface{}) (out []interface{}) { + for _, arg := range args { + if reflect.TypeOf(arg).String() == "string" { + arg = sanitize(fmt.Sprintf("%s", arg)) + } + out = append(out, arg) + } + return +} + +func sanitize(input string) string { + re := regexp.MustCompile(`(?m)^Authorization: .*`) + sanitized := re.ReplaceAllString(input, "Authorization: "+privateDataPlaceholder()) + + re = regexp.MustCompile(`(?m)^X-Auth-Token: .*`) + sanitized = re.ReplaceAllString(sanitized, "X-Auth-Token: "+privateDataPlaceholder()) + + re = regexp.MustCompile(`(?m)^X-Auth-Refresh-Token: .*`) + sanitized = re.ReplaceAllString(sanitized, "X-Auth-Refresh-Token: "+privateDataPlaceholder()) + + re = regexp.MustCompile(`(?m)^X-Auth-Uaa-Token: .*`) + sanitized = re.ReplaceAllString(sanitized, "X-Auth-Uaa-Token: "+privateDataPlaceholder()) + + re = regexp.MustCompile(`(?m)^X-Auth-User-Token: .*`) + sanitized = re.ReplaceAllString(sanitized, "X-Auth-User-Token: "+privateDataPlaceholder()) + + re = regexp.MustCompile(`password=[^&]*&`) + sanitized = re.ReplaceAllString(sanitized, "password="+privateDataPlaceholder()+"&") + + re = regexp.MustCompile(`refresh_token=[^&]*&`) + sanitized = re.ReplaceAllString(sanitized, "refresh_token="+privateDataPlaceholder()+"&") + + re = regexp.MustCompile(`apikey=[^&]*&`) + sanitized = re.ReplaceAllString(sanitized, "apikey="+privateDataPlaceholder()+"&") + + sanitized = sanitizeJSON("token", sanitized) + sanitized = sanitizeJSON("password", sanitized) + sanitized = sanitizeJSON("apikey", sanitized) + sanitized = sanitizeJSON("passcode", sanitized) + + return sanitized +} + +func sanitizeJSON(propertySubstring string, json string) string { + regex := regexp.MustCompile(fmt.Sprintf(`(?i)"([^"]*%s[^"]*)":\s*"[^\,]*"`, propertySubstring)) + return regex.ReplaceAllString(json, fmt.Sprintf(`"$1":"%s"`, privateDataPlaceholder())) +} + +// privateDataPlaceholder returns the text to replace the sentive data. +func privateDataPlaceholder() string { + return "[PRIVATE DATA HIDDEN]" +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/ibmpisession/session.go b/vendor/github.com/IBM-Cloud/power-go-client/ibmpisession/session.go new file mode 100644 index 00000000000..c7e40201191 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/ibmpisession/session.go @@ -0,0 +1,121 @@ +package ibmpisession + +import ( + "fmt" + "strings" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/helpers" + "github.com/IBM-Cloud/power-go-client/power/client" + "github.com/IBM/go-sdk-core/v5/core" +) + +// IBMPISession ... +type IBMPISession struct { + CRNFormat string + Power *client.PowerIaasAPI + Options *IBMPIOptions +} + +// PIOptions +type IBMPIOptions struct { + // The authenticator implementation to be used by the + // service instance to authenticate outbound requests + // Required + Authenticator core.Authenticator + + // Enable/Disable http transport debugging log + Debug bool + + // Region of the Power Cloud Service Instance + // For generating the default endpoint + // Required when URL or env `IBMCLOUD_POWER_API_ENDPOINT` is not set + Region string + + // Power Virtual Server host or URL endpoint + // This will be used instead of generating the default host + // eg: dal.power-iaas.cloud.ibm.com + // Required when Region is not provided + URL string + + // Account id of the Power Cloud Service Instance + // It will be part of the CRN string + // Required + UserAccount string + + // Zone of the Power Cloud Service Instance + // It will be part of the CRN string + // Required + Zone string +} + +// Create a IBMPISession +func NewIBMPISession(o *IBMPIOptions) (*IBMPISession, error) { + if core.IsNil(o) { + return nil, fmt.Errorf("options is required") + } + + if core.IsNil(o.Authenticator) { + return nil, fmt.Errorf("option Authenticator is required") + } + + if o.UserAccount == "" { + return nil, fmt.Errorf("option UserAccount is required") + } + + if o.Zone == "" { + return nil, fmt.Errorf("option Zone is required") + } + + var serviceURL string + if o.URL != "" { + serviceURL = o.URL + } else { + // If URL is not set check in env + serviceURL = helpers.GetPowerEndPoint() + if serviceURL == "" { + // Generate default endpoint with Region + if o.Region != "" { + serviceURL = o.Region + ".power-iaas.cloud.ibm.com" + } else { + return nil, fmt.Errorf("atleast one of Region or URL is required") + } + } + } + + // We need just the server host from the URL + var host, scheme string + if strings.HasPrefix(serviceURL, "https://") { + scheme = SCHEME_HTTPS + host = strings.TrimPrefix(serviceURL, "https://") + } else if strings.HasPrefix(serviceURL, "http://") { + scheme = SCHEME_HTTP + host = strings.TrimPrefix(serviceURL, "http://") + } else { + // by default we use "https" + scheme = SCHEME_HTTPS + host = serviceURL + } + + return &IBMPISession{ + CRNFormat: crnBuilder(o.UserAccount, o.Zone, host), + Options: o, + Power: getPIClient(o.Debug, host, scheme), + }, nil +} + +// authInfo ... +func (s *IBMPISession) AuthInfo(cloudInstanceID string) runtime.ClientAuthInfoWriter { + return runtime.ClientAuthInfoWriterFunc(func(r runtime.ClientRequest, _ strfmt.Registry) error { + auth, err := fetchAuthorizationData(s.Options.Authenticator) + if err != nil { + return err + } + if err := r.SetHeaderParam("Authorization", auth); err != nil { + return err + } + return r.SetHeaderParam("CRN", fmt.Sprintf(s.CRNFormat, cloudInstanceID)) + }) +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/ibmpisession/utils.go b/vendor/github.com/IBM-Cloud/power-go-client/ibmpisession/utils.go new file mode 100644 index 00000000000..7e9bcb2df1c --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/ibmpisession/utils.go @@ -0,0 +1,74 @@ +package ibmpisession + +import ( + "bytes" + "crypto/tls" + "encoding/json" + "fmt" + "io" + "net/http" + "strings" + + "github.com/IBM-Cloud/power-go-client/power/client" + "github.com/IBM/go-sdk-core/v5/core" + "github.com/go-openapi/runtime" + httptransport "github.com/go-openapi/runtime/client" +) + +const ( + SCHEME_HTTPS = "https" + SCHEME_HTTP = "http" +) + +// fetchAuthorizationData Fetch Authorization token using the Authenticator +func fetchAuthorizationData(a core.Authenticator) (string, error) { + req := &http.Request{ + Header: make(http.Header), + } + if err := a.Authenticate(req); err != nil { + return "", err + } + return req.Header.Get("Authorization"), nil +} + +// crnBuilder Return string format to create CRN using the cloud instance id +// The result string will have crn data with a string placeholder to set the cloud instance id +// Usage: +// `crn := fmt.Sprintf(crnBuilder(useraccount, regionZone, host), )` +func crnBuilder(useraccount, zone, host string) string { + var service string + if strings.Contains(host, ".power-iaas.cloud.ibm.com") { + service = "bluemix" + } else { + service = "staging" + } + crn := fmt.Sprintf("crn:v1:%s:public:power-iaas:%s:a/%s:", service, zone, useraccount) + return crn + "%s::" +} + +func powerJSONConsumer() runtime.Consumer { + return runtime.ConsumerFunc(func(reader io.Reader, data interface{}) error { + buf := new(bytes.Buffer) + _, err := buf.ReadFrom(reader) + if err != nil { + return err + } + b := buf.Bytes() + dec := json.NewDecoder(bytes.NewReader(b)) + dec.UseNumber() // preserve number formats + return dec.Decode(data) + }) +} + +// getPIClient generates a PowerIaas client +func getPIClient(debug bool, host string, scheme string) *client.PowerIaasAPI { + http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: false} + if scheme == "" { + scheme = SCHEME_HTTPS + } + transport := httptransport.New(host, "/", []string{scheme}) + transport.Debug = debug + transport.SetLogger(IBMPILogger{}) + transport.Consumers[runtime.JSONMime] = powerJSONConsumer() + return client.New(transport, nil) +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/authentication_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/authentication_client.go new file mode 100644 index 00000000000..2e9c3f96bf2 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/authentication_client.go @@ -0,0 +1,442 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package authentication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new authentication API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for authentication API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + ServiceBrokerAuthCallback(params *ServiceBrokerAuthCallbackParams, opts ...ClientOption) (*ServiceBrokerAuthCallbackOK, error) + + ServiceBrokerAuthDeviceCodePost(params *ServiceBrokerAuthDeviceCodePostParams, opts ...ClientOption) (*ServiceBrokerAuthDeviceCodePostOK, error) + + ServiceBrokerAuthDeviceTokenPost(params *ServiceBrokerAuthDeviceTokenPostParams, opts ...ClientOption) (*ServiceBrokerAuthDeviceTokenPostOK, error) + + ServiceBrokerAuthInfoToken(params *ServiceBrokerAuthInfoTokenParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceBrokerAuthInfoTokenOK, error) + + ServiceBrokerAuthInfoUser(params *ServiceBrokerAuthInfoUserParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceBrokerAuthInfoUserOK, error) + + ServiceBrokerAuthLogin(params *ServiceBrokerAuthLoginParams, opts ...ClientOption) (*ServiceBrokerAuthLoginOK, error) + + ServiceBrokerAuthLogout(params *ServiceBrokerAuthLogoutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceBrokerAuthLogoutOK, error) + + ServiceBrokerAuthRegistration(params *ServiceBrokerAuthRegistrationParams, opts ...ClientOption) (*ServiceBrokerAuthRegistrationOK, error) + + ServiceBrokerAuthRegistrationCallback(params *ServiceBrokerAuthRegistrationCallbackParams, opts ...ClientOption) (*ServiceBrokerAuthRegistrationCallbackOK, error) + + ServiceBrokerAuthTokenPost(params *ServiceBrokerAuthTokenPostParams, opts ...ClientOption) (*ServiceBrokerAuthTokenPostOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + ServiceBrokerAuthCallback returns an access token and set cookie +*/ +func (a *Client) ServiceBrokerAuthCallback(params *ServiceBrokerAuthCallbackParams, opts ...ClientOption) (*ServiceBrokerAuthCallbackOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewServiceBrokerAuthCallbackParams() + } + op := &runtime.ClientOperation{ + ID: "serviceBroker.auth.callback", + Method: "GET", + PathPattern: "/auth/v1/callback", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ServiceBrokerAuthCallbackReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ServiceBrokerAuthCallbackOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for serviceBroker.auth.callback: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + ServiceBrokerAuthDeviceCodePost requests a authorization device code +*/ +func (a *Client) ServiceBrokerAuthDeviceCodePost(params *ServiceBrokerAuthDeviceCodePostParams, opts ...ClientOption) (*ServiceBrokerAuthDeviceCodePostOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewServiceBrokerAuthDeviceCodePostParams() + } + op := &runtime.ClientOperation{ + ID: "serviceBroker.auth.device.code.post", + Method: "POST", + PathPattern: "/auth/v1/device/code", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ServiceBrokerAuthDeviceCodePostReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ServiceBrokerAuthDeviceCodePostOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for serviceBroker.auth.device.code.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + ServiceBrokerAuthDeviceTokenPost polls for authorization device token +*/ +func (a *Client) ServiceBrokerAuthDeviceTokenPost(params *ServiceBrokerAuthDeviceTokenPostParams, opts ...ClientOption) (*ServiceBrokerAuthDeviceTokenPostOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewServiceBrokerAuthDeviceTokenPostParams() + } + op := &runtime.ClientOperation{ + ID: "serviceBroker.auth.device.token.post", + Method: "POST", + PathPattern: "/auth/v1/device/token", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ServiceBrokerAuthDeviceTokenPostReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ServiceBrokerAuthDeviceTokenPostOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for serviceBroker.auth.device.token.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + ServiceBrokerAuthInfoToken information about current access token +*/ +func (a *Client) ServiceBrokerAuthInfoToken(params *ServiceBrokerAuthInfoTokenParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceBrokerAuthInfoTokenOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewServiceBrokerAuthInfoTokenParams() + } + op := &runtime.ClientOperation{ + ID: "serviceBroker.auth.info.token", + Method: "GET", + PathPattern: "/auth/v1/info/token", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ServiceBrokerAuthInfoTokenReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ServiceBrokerAuthInfoTokenOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for serviceBroker.auth.info.token: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + ServiceBrokerAuthInfoUser information about current user +*/ +func (a *Client) ServiceBrokerAuthInfoUser(params *ServiceBrokerAuthInfoUserParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceBrokerAuthInfoUserOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewServiceBrokerAuthInfoUserParams() + } + op := &runtime.ClientOperation{ + ID: "serviceBroker.auth.info.user", + Method: "GET", + PathPattern: "/auth/v1/info/user", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ServiceBrokerAuthInfoUserReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ServiceBrokerAuthInfoUserOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for serviceBroker.auth.info.user: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + ServiceBrokerAuthLogin logins +*/ +func (a *Client) ServiceBrokerAuthLogin(params *ServiceBrokerAuthLoginParams, opts ...ClientOption) (*ServiceBrokerAuthLoginOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewServiceBrokerAuthLoginParams() + } + op := &runtime.ClientOperation{ + ID: "serviceBroker.auth.login", + Method: "GET", + PathPattern: "/auth/v1/login", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ServiceBrokerAuthLoginReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ServiceBrokerAuthLoginOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for serviceBroker.auth.login: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + ServiceBrokerAuthLogout logouts +*/ +func (a *Client) ServiceBrokerAuthLogout(params *ServiceBrokerAuthLogoutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceBrokerAuthLogoutOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewServiceBrokerAuthLogoutParams() + } + op := &runtime.ClientOperation{ + ID: "serviceBroker.auth.logout", + Method: "GET", + PathPattern: "/auth/v1/logout", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ServiceBrokerAuthLogoutReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ServiceBrokerAuthLogoutOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for serviceBroker.auth.logout: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + ServiceBrokerAuthRegistration registrations of a new tenant and login +*/ +func (a *Client) ServiceBrokerAuthRegistration(params *ServiceBrokerAuthRegistrationParams, opts ...ClientOption) (*ServiceBrokerAuthRegistrationOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewServiceBrokerAuthRegistrationParams() + } + op := &runtime.ClientOperation{ + ID: "serviceBroker.auth.registration", + Method: "GET", + PathPattern: "/auth/v1/registration", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ServiceBrokerAuthRegistrationReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ServiceBrokerAuthRegistrationOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for serviceBroker.auth.registration: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + ServiceBrokerAuthRegistrationCallback associates the user with a tenant and returns an access token +*/ +func (a *Client) ServiceBrokerAuthRegistrationCallback(params *ServiceBrokerAuthRegistrationCallbackParams, opts ...ClientOption) (*ServiceBrokerAuthRegistrationCallbackOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewServiceBrokerAuthRegistrationCallbackParams() + } + op := &runtime.ClientOperation{ + ID: "serviceBroker.auth.registration.callback", + Method: "GET", + PathPattern: "/auth/v1/callback-registration", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ServiceBrokerAuthRegistrationCallbackReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ServiceBrokerAuthRegistrationCallbackOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for serviceBroker.auth.registration.callback: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + ServiceBrokerAuthTokenPost requests a new token from a refresh token +*/ +func (a *Client) ServiceBrokerAuthTokenPost(params *ServiceBrokerAuthTokenPostParams, opts ...ClientOption) (*ServiceBrokerAuthTokenPostOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewServiceBrokerAuthTokenPostParams() + } + op := &runtime.ClientOperation{ + ID: "serviceBroker.auth.token.post", + Method: "POST", + PathPattern: "/auth/v1/token", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ServiceBrokerAuthTokenPostReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ServiceBrokerAuthTokenPostOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for serviceBroker.auth.token.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_callback_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_callback_parameters.go new file mode 100644 index 00000000000..7c2aaa3c94a --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_callback_parameters.go @@ -0,0 +1,126 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package authentication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewServiceBrokerAuthCallbackParams creates a new ServiceBrokerAuthCallbackParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewServiceBrokerAuthCallbackParams() *ServiceBrokerAuthCallbackParams { + return &ServiceBrokerAuthCallbackParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewServiceBrokerAuthCallbackParamsWithTimeout creates a new ServiceBrokerAuthCallbackParams object +// with the ability to set a timeout on a request. +func NewServiceBrokerAuthCallbackParamsWithTimeout(timeout time.Duration) *ServiceBrokerAuthCallbackParams { + return &ServiceBrokerAuthCallbackParams{ + timeout: timeout, + } +} + +// NewServiceBrokerAuthCallbackParamsWithContext creates a new ServiceBrokerAuthCallbackParams object +// with the ability to set a context for a request. +func NewServiceBrokerAuthCallbackParamsWithContext(ctx context.Context) *ServiceBrokerAuthCallbackParams { + return &ServiceBrokerAuthCallbackParams{ + Context: ctx, + } +} + +// NewServiceBrokerAuthCallbackParamsWithHTTPClient creates a new ServiceBrokerAuthCallbackParams object +// with the ability to set a custom HTTPClient for a request. +func NewServiceBrokerAuthCallbackParamsWithHTTPClient(client *http.Client) *ServiceBrokerAuthCallbackParams { + return &ServiceBrokerAuthCallbackParams{ + HTTPClient: client, + } +} + +/* ServiceBrokerAuthCallbackParams contains all the parameters to send to the API endpoint + for the service broker auth callback operation. + + Typically these are written to a http.Request. +*/ +type ServiceBrokerAuthCallbackParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the service broker auth callback params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerAuthCallbackParams) WithDefaults() *ServiceBrokerAuthCallbackParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the service broker auth callback params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerAuthCallbackParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the service broker auth callback params +func (o *ServiceBrokerAuthCallbackParams) WithTimeout(timeout time.Duration) *ServiceBrokerAuthCallbackParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the service broker auth callback params +func (o *ServiceBrokerAuthCallbackParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the service broker auth callback params +func (o *ServiceBrokerAuthCallbackParams) WithContext(ctx context.Context) *ServiceBrokerAuthCallbackParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the service broker auth callback params +func (o *ServiceBrokerAuthCallbackParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the service broker auth callback params +func (o *ServiceBrokerAuthCallbackParams) WithHTTPClient(client *http.Client) *ServiceBrokerAuthCallbackParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the service broker auth callback params +func (o *ServiceBrokerAuthCallbackParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *ServiceBrokerAuthCallbackParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_callback_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_callback_responses.go new file mode 100644 index 00000000000..b48acc24a3e --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_callback_responses.go @@ -0,0 +1,143 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package authentication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// ServiceBrokerAuthCallbackReader is a Reader for the ServiceBrokerAuthCallback structure. +type ServiceBrokerAuthCallbackReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ServiceBrokerAuthCallbackReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewServiceBrokerAuthCallbackOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewServiceBrokerAuthCallbackUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewServiceBrokerAuthCallbackInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewServiceBrokerAuthCallbackOK creates a ServiceBrokerAuthCallbackOK with default headers values +func NewServiceBrokerAuthCallbackOK() *ServiceBrokerAuthCallbackOK { + return &ServiceBrokerAuthCallbackOK{} +} + +/* ServiceBrokerAuthCallbackOK describes a response with status code 200, with default header values. + +OK +*/ +type ServiceBrokerAuthCallbackOK struct { + Payload *models.AccessToken +} + +func (o *ServiceBrokerAuthCallbackOK) Error() string { + return fmt.Sprintf("[GET /auth/v1/callback][%d] serviceBrokerAuthCallbackOK %+v", 200, o.Payload) +} +func (o *ServiceBrokerAuthCallbackOK) GetPayload() *models.AccessToken { + return o.Payload +} + +func (o *ServiceBrokerAuthCallbackOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AccessToken) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerAuthCallbackUnauthorized creates a ServiceBrokerAuthCallbackUnauthorized with default headers values +func NewServiceBrokerAuthCallbackUnauthorized() *ServiceBrokerAuthCallbackUnauthorized { + return &ServiceBrokerAuthCallbackUnauthorized{} +} + +/* ServiceBrokerAuthCallbackUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type ServiceBrokerAuthCallbackUnauthorized struct { + Payload *models.Error +} + +func (o *ServiceBrokerAuthCallbackUnauthorized) Error() string { + return fmt.Sprintf("[GET /auth/v1/callback][%d] serviceBrokerAuthCallbackUnauthorized %+v", 401, o.Payload) +} +func (o *ServiceBrokerAuthCallbackUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerAuthCallbackUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerAuthCallbackInternalServerError creates a ServiceBrokerAuthCallbackInternalServerError with default headers values +func NewServiceBrokerAuthCallbackInternalServerError() *ServiceBrokerAuthCallbackInternalServerError { + return &ServiceBrokerAuthCallbackInternalServerError{} +} + +/* ServiceBrokerAuthCallbackInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type ServiceBrokerAuthCallbackInternalServerError struct { + Payload *models.Error +} + +func (o *ServiceBrokerAuthCallbackInternalServerError) Error() string { + return fmt.Sprintf("[GET /auth/v1/callback][%d] serviceBrokerAuthCallbackInternalServerError %+v", 500, o.Payload) +} +func (o *ServiceBrokerAuthCallbackInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerAuthCallbackInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_device_code_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_device_code_post_parameters.go new file mode 100644 index 00000000000..ad621b60a2e --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_device_code_post_parameters.go @@ -0,0 +1,126 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package authentication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewServiceBrokerAuthDeviceCodePostParams creates a new ServiceBrokerAuthDeviceCodePostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewServiceBrokerAuthDeviceCodePostParams() *ServiceBrokerAuthDeviceCodePostParams { + return &ServiceBrokerAuthDeviceCodePostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewServiceBrokerAuthDeviceCodePostParamsWithTimeout creates a new ServiceBrokerAuthDeviceCodePostParams object +// with the ability to set a timeout on a request. +func NewServiceBrokerAuthDeviceCodePostParamsWithTimeout(timeout time.Duration) *ServiceBrokerAuthDeviceCodePostParams { + return &ServiceBrokerAuthDeviceCodePostParams{ + timeout: timeout, + } +} + +// NewServiceBrokerAuthDeviceCodePostParamsWithContext creates a new ServiceBrokerAuthDeviceCodePostParams object +// with the ability to set a context for a request. +func NewServiceBrokerAuthDeviceCodePostParamsWithContext(ctx context.Context) *ServiceBrokerAuthDeviceCodePostParams { + return &ServiceBrokerAuthDeviceCodePostParams{ + Context: ctx, + } +} + +// NewServiceBrokerAuthDeviceCodePostParamsWithHTTPClient creates a new ServiceBrokerAuthDeviceCodePostParams object +// with the ability to set a custom HTTPClient for a request. +func NewServiceBrokerAuthDeviceCodePostParamsWithHTTPClient(client *http.Client) *ServiceBrokerAuthDeviceCodePostParams { + return &ServiceBrokerAuthDeviceCodePostParams{ + HTTPClient: client, + } +} + +/* ServiceBrokerAuthDeviceCodePostParams contains all the parameters to send to the API endpoint + for the service broker auth device code post operation. + + Typically these are written to a http.Request. +*/ +type ServiceBrokerAuthDeviceCodePostParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the service broker auth device code post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerAuthDeviceCodePostParams) WithDefaults() *ServiceBrokerAuthDeviceCodePostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the service broker auth device code post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerAuthDeviceCodePostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the service broker auth device code post params +func (o *ServiceBrokerAuthDeviceCodePostParams) WithTimeout(timeout time.Duration) *ServiceBrokerAuthDeviceCodePostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the service broker auth device code post params +func (o *ServiceBrokerAuthDeviceCodePostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the service broker auth device code post params +func (o *ServiceBrokerAuthDeviceCodePostParams) WithContext(ctx context.Context) *ServiceBrokerAuthDeviceCodePostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the service broker auth device code post params +func (o *ServiceBrokerAuthDeviceCodePostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the service broker auth device code post params +func (o *ServiceBrokerAuthDeviceCodePostParams) WithHTTPClient(client *http.Client) *ServiceBrokerAuthDeviceCodePostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the service broker auth device code post params +func (o *ServiceBrokerAuthDeviceCodePostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *ServiceBrokerAuthDeviceCodePostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_device_code_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_device_code_post_responses.go new file mode 100644 index 00000000000..b0d31f0b39c --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_device_code_post_responses.go @@ -0,0 +1,143 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package authentication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// ServiceBrokerAuthDeviceCodePostReader is a Reader for the ServiceBrokerAuthDeviceCodePost structure. +type ServiceBrokerAuthDeviceCodePostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ServiceBrokerAuthDeviceCodePostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewServiceBrokerAuthDeviceCodePostOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 403: + result := NewServiceBrokerAuthDeviceCodePostForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewServiceBrokerAuthDeviceCodePostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewServiceBrokerAuthDeviceCodePostOK creates a ServiceBrokerAuthDeviceCodePostOK with default headers values +func NewServiceBrokerAuthDeviceCodePostOK() *ServiceBrokerAuthDeviceCodePostOK { + return &ServiceBrokerAuthDeviceCodePostOK{} +} + +/* ServiceBrokerAuthDeviceCodePostOK describes a response with status code 200, with default header values. + +OK +*/ +type ServiceBrokerAuthDeviceCodePostOK struct { + Payload *models.DeviceCode +} + +func (o *ServiceBrokerAuthDeviceCodePostOK) Error() string { + return fmt.Sprintf("[POST /auth/v1/device/code][%d] serviceBrokerAuthDeviceCodePostOK %+v", 200, o.Payload) +} +func (o *ServiceBrokerAuthDeviceCodePostOK) GetPayload() *models.DeviceCode { + return o.Payload +} + +func (o *ServiceBrokerAuthDeviceCodePostOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.DeviceCode) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerAuthDeviceCodePostForbidden creates a ServiceBrokerAuthDeviceCodePostForbidden with default headers values +func NewServiceBrokerAuthDeviceCodePostForbidden() *ServiceBrokerAuthDeviceCodePostForbidden { + return &ServiceBrokerAuthDeviceCodePostForbidden{} +} + +/* ServiceBrokerAuthDeviceCodePostForbidden describes a response with status code 403, with default header values. + +Quota exceeded +*/ +type ServiceBrokerAuthDeviceCodePostForbidden struct { + Payload *models.Error +} + +func (o *ServiceBrokerAuthDeviceCodePostForbidden) Error() string { + return fmt.Sprintf("[POST /auth/v1/device/code][%d] serviceBrokerAuthDeviceCodePostForbidden %+v", 403, o.Payload) +} +func (o *ServiceBrokerAuthDeviceCodePostForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerAuthDeviceCodePostForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerAuthDeviceCodePostInternalServerError creates a ServiceBrokerAuthDeviceCodePostInternalServerError with default headers values +func NewServiceBrokerAuthDeviceCodePostInternalServerError() *ServiceBrokerAuthDeviceCodePostInternalServerError { + return &ServiceBrokerAuthDeviceCodePostInternalServerError{} +} + +/* ServiceBrokerAuthDeviceCodePostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type ServiceBrokerAuthDeviceCodePostInternalServerError struct { + Payload *models.Error +} + +func (o *ServiceBrokerAuthDeviceCodePostInternalServerError) Error() string { + return fmt.Sprintf("[POST /auth/v1/device/code][%d] serviceBrokerAuthDeviceCodePostInternalServerError %+v", 500, o.Payload) +} +func (o *ServiceBrokerAuthDeviceCodePostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerAuthDeviceCodePostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_device_token_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_device_token_post_parameters.go new file mode 100644 index 00000000000..ab928c9a224 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_device_token_post_parameters.go @@ -0,0 +1,147 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package authentication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewServiceBrokerAuthDeviceTokenPostParams creates a new ServiceBrokerAuthDeviceTokenPostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewServiceBrokerAuthDeviceTokenPostParams() *ServiceBrokerAuthDeviceTokenPostParams { + return &ServiceBrokerAuthDeviceTokenPostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewServiceBrokerAuthDeviceTokenPostParamsWithTimeout creates a new ServiceBrokerAuthDeviceTokenPostParams object +// with the ability to set a timeout on a request. +func NewServiceBrokerAuthDeviceTokenPostParamsWithTimeout(timeout time.Duration) *ServiceBrokerAuthDeviceTokenPostParams { + return &ServiceBrokerAuthDeviceTokenPostParams{ + timeout: timeout, + } +} + +// NewServiceBrokerAuthDeviceTokenPostParamsWithContext creates a new ServiceBrokerAuthDeviceTokenPostParams object +// with the ability to set a context for a request. +func NewServiceBrokerAuthDeviceTokenPostParamsWithContext(ctx context.Context) *ServiceBrokerAuthDeviceTokenPostParams { + return &ServiceBrokerAuthDeviceTokenPostParams{ + Context: ctx, + } +} + +// NewServiceBrokerAuthDeviceTokenPostParamsWithHTTPClient creates a new ServiceBrokerAuthDeviceTokenPostParams object +// with the ability to set a custom HTTPClient for a request. +func NewServiceBrokerAuthDeviceTokenPostParamsWithHTTPClient(client *http.Client) *ServiceBrokerAuthDeviceTokenPostParams { + return &ServiceBrokerAuthDeviceTokenPostParams{ + HTTPClient: client, + } +} + +/* ServiceBrokerAuthDeviceTokenPostParams contains all the parameters to send to the API endpoint + for the service broker auth device token post operation. + + Typically these are written to a http.Request. +*/ +type ServiceBrokerAuthDeviceTokenPostParams struct { + + /* Body. + + Parameters for polling authorization device code + */ + Body ServiceBrokerAuthDeviceTokenPostBody + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the service broker auth device token post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerAuthDeviceTokenPostParams) WithDefaults() *ServiceBrokerAuthDeviceTokenPostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the service broker auth device token post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerAuthDeviceTokenPostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the service broker auth device token post params +func (o *ServiceBrokerAuthDeviceTokenPostParams) WithTimeout(timeout time.Duration) *ServiceBrokerAuthDeviceTokenPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the service broker auth device token post params +func (o *ServiceBrokerAuthDeviceTokenPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the service broker auth device token post params +func (o *ServiceBrokerAuthDeviceTokenPostParams) WithContext(ctx context.Context) *ServiceBrokerAuthDeviceTokenPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the service broker auth device token post params +func (o *ServiceBrokerAuthDeviceTokenPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the service broker auth device token post params +func (o *ServiceBrokerAuthDeviceTokenPostParams) WithHTTPClient(client *http.Client) *ServiceBrokerAuthDeviceTokenPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the service broker auth device token post params +func (o *ServiceBrokerAuthDeviceTokenPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the service broker auth device token post params +func (o *ServiceBrokerAuthDeviceTokenPostParams) WithBody(body ServiceBrokerAuthDeviceTokenPostBody) *ServiceBrokerAuthDeviceTokenPostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the service broker auth device token post params +func (o *ServiceBrokerAuthDeviceTokenPostParams) SetBody(body ServiceBrokerAuthDeviceTokenPostBody) { + o.Body = body +} + +// WriteToRequest writes these params to a swagger request +func (o *ServiceBrokerAuthDeviceTokenPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_device_token_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_device_token_post_responses.go new file mode 100644 index 00000000000..f9579f5c6c4 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_device_token_post_responses.go @@ -0,0 +1,258 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package authentication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// ServiceBrokerAuthDeviceTokenPostReader is a Reader for the ServiceBrokerAuthDeviceTokenPost structure. +type ServiceBrokerAuthDeviceTokenPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ServiceBrokerAuthDeviceTokenPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewServiceBrokerAuthDeviceTokenPostOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewServiceBrokerAuthDeviceTokenPostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewServiceBrokerAuthDeviceTokenPostForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 429: + result := NewServiceBrokerAuthDeviceTokenPostTooManyRequests() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewServiceBrokerAuthDeviceTokenPostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewServiceBrokerAuthDeviceTokenPostOK creates a ServiceBrokerAuthDeviceTokenPostOK with default headers values +func NewServiceBrokerAuthDeviceTokenPostOK() *ServiceBrokerAuthDeviceTokenPostOK { + return &ServiceBrokerAuthDeviceTokenPostOK{} +} + +/* ServiceBrokerAuthDeviceTokenPostOK describes a response with status code 200, with default header values. + +OK +*/ +type ServiceBrokerAuthDeviceTokenPostOK struct { + Payload *models.Token +} + +func (o *ServiceBrokerAuthDeviceTokenPostOK) Error() string { + return fmt.Sprintf("[POST /auth/v1/device/token][%d] serviceBrokerAuthDeviceTokenPostOK %+v", 200, o.Payload) +} +func (o *ServiceBrokerAuthDeviceTokenPostOK) GetPayload() *models.Token { + return o.Payload +} + +func (o *ServiceBrokerAuthDeviceTokenPostOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Token) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerAuthDeviceTokenPostBadRequest creates a ServiceBrokerAuthDeviceTokenPostBadRequest with default headers values +func NewServiceBrokerAuthDeviceTokenPostBadRequest() *ServiceBrokerAuthDeviceTokenPostBadRequest { + return &ServiceBrokerAuthDeviceTokenPostBadRequest{} +} + +/* ServiceBrokerAuthDeviceTokenPostBadRequest describes a response with status code 400, with default header values. + +Authorization pending +*/ +type ServiceBrokerAuthDeviceTokenPostBadRequest struct { + Payload *models.Error +} + +func (o *ServiceBrokerAuthDeviceTokenPostBadRequest) Error() string { + return fmt.Sprintf("[POST /auth/v1/device/token][%d] serviceBrokerAuthDeviceTokenPostBadRequest %+v", 400, o.Payload) +} +func (o *ServiceBrokerAuthDeviceTokenPostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerAuthDeviceTokenPostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerAuthDeviceTokenPostForbidden creates a ServiceBrokerAuthDeviceTokenPostForbidden with default headers values +func NewServiceBrokerAuthDeviceTokenPostForbidden() *ServiceBrokerAuthDeviceTokenPostForbidden { + return &ServiceBrokerAuthDeviceTokenPostForbidden{} +} + +/* ServiceBrokerAuthDeviceTokenPostForbidden describes a response with status code 403, with default header values. + +User refused grant +*/ +type ServiceBrokerAuthDeviceTokenPostForbidden struct { + Payload *models.Error +} + +func (o *ServiceBrokerAuthDeviceTokenPostForbidden) Error() string { + return fmt.Sprintf("[POST /auth/v1/device/token][%d] serviceBrokerAuthDeviceTokenPostForbidden %+v", 403, o.Payload) +} +func (o *ServiceBrokerAuthDeviceTokenPostForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerAuthDeviceTokenPostForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerAuthDeviceTokenPostTooManyRequests creates a ServiceBrokerAuthDeviceTokenPostTooManyRequests with default headers values +func NewServiceBrokerAuthDeviceTokenPostTooManyRequests() *ServiceBrokerAuthDeviceTokenPostTooManyRequests { + return &ServiceBrokerAuthDeviceTokenPostTooManyRequests{} +} + +/* ServiceBrokerAuthDeviceTokenPostTooManyRequests describes a response with status code 429, with default header values. + +Polling too frequently +*/ +type ServiceBrokerAuthDeviceTokenPostTooManyRequests struct { + Payload *models.Error +} + +func (o *ServiceBrokerAuthDeviceTokenPostTooManyRequests) Error() string { + return fmt.Sprintf("[POST /auth/v1/device/token][%d] serviceBrokerAuthDeviceTokenPostTooManyRequests %+v", 429, o.Payload) +} +func (o *ServiceBrokerAuthDeviceTokenPostTooManyRequests) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerAuthDeviceTokenPostTooManyRequests) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerAuthDeviceTokenPostInternalServerError creates a ServiceBrokerAuthDeviceTokenPostInternalServerError with default headers values +func NewServiceBrokerAuthDeviceTokenPostInternalServerError() *ServiceBrokerAuthDeviceTokenPostInternalServerError { + return &ServiceBrokerAuthDeviceTokenPostInternalServerError{} +} + +/* ServiceBrokerAuthDeviceTokenPostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type ServiceBrokerAuthDeviceTokenPostInternalServerError struct { + Payload *models.Error +} + +func (o *ServiceBrokerAuthDeviceTokenPostInternalServerError) Error() string { + return fmt.Sprintf("[POST /auth/v1/device/token][%d] serviceBrokerAuthDeviceTokenPostInternalServerError %+v", 500, o.Payload) +} +func (o *ServiceBrokerAuthDeviceTokenPostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerAuthDeviceTokenPostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +/*ServiceBrokerAuthDeviceTokenPostBody service broker auth device token post body +swagger:model ServiceBrokerAuthDeviceTokenPostBody +*/ +type ServiceBrokerAuthDeviceTokenPostBody struct { + + // The deviceCode that the authorization server returned + DeviceCode string `json:"deviceCode,omitempty"` +} + +// Validate validates this service broker auth device token post body +func (o *ServiceBrokerAuthDeviceTokenPostBody) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this service broker auth device token post body based on context it is used +func (o *ServiceBrokerAuthDeviceTokenPostBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *ServiceBrokerAuthDeviceTokenPostBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *ServiceBrokerAuthDeviceTokenPostBody) UnmarshalBinary(b []byte) error { + var res ServiceBrokerAuthDeviceTokenPostBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_info_token_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_info_token_parameters.go new file mode 100644 index 00000000000..8bd091b80af --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_info_token_parameters.go @@ -0,0 +1,126 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package authentication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewServiceBrokerAuthInfoTokenParams creates a new ServiceBrokerAuthInfoTokenParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewServiceBrokerAuthInfoTokenParams() *ServiceBrokerAuthInfoTokenParams { + return &ServiceBrokerAuthInfoTokenParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewServiceBrokerAuthInfoTokenParamsWithTimeout creates a new ServiceBrokerAuthInfoTokenParams object +// with the ability to set a timeout on a request. +func NewServiceBrokerAuthInfoTokenParamsWithTimeout(timeout time.Duration) *ServiceBrokerAuthInfoTokenParams { + return &ServiceBrokerAuthInfoTokenParams{ + timeout: timeout, + } +} + +// NewServiceBrokerAuthInfoTokenParamsWithContext creates a new ServiceBrokerAuthInfoTokenParams object +// with the ability to set a context for a request. +func NewServiceBrokerAuthInfoTokenParamsWithContext(ctx context.Context) *ServiceBrokerAuthInfoTokenParams { + return &ServiceBrokerAuthInfoTokenParams{ + Context: ctx, + } +} + +// NewServiceBrokerAuthInfoTokenParamsWithHTTPClient creates a new ServiceBrokerAuthInfoTokenParams object +// with the ability to set a custom HTTPClient for a request. +func NewServiceBrokerAuthInfoTokenParamsWithHTTPClient(client *http.Client) *ServiceBrokerAuthInfoTokenParams { + return &ServiceBrokerAuthInfoTokenParams{ + HTTPClient: client, + } +} + +/* ServiceBrokerAuthInfoTokenParams contains all the parameters to send to the API endpoint + for the service broker auth info token operation. + + Typically these are written to a http.Request. +*/ +type ServiceBrokerAuthInfoTokenParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the service broker auth info token params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerAuthInfoTokenParams) WithDefaults() *ServiceBrokerAuthInfoTokenParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the service broker auth info token params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerAuthInfoTokenParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the service broker auth info token params +func (o *ServiceBrokerAuthInfoTokenParams) WithTimeout(timeout time.Duration) *ServiceBrokerAuthInfoTokenParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the service broker auth info token params +func (o *ServiceBrokerAuthInfoTokenParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the service broker auth info token params +func (o *ServiceBrokerAuthInfoTokenParams) WithContext(ctx context.Context) *ServiceBrokerAuthInfoTokenParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the service broker auth info token params +func (o *ServiceBrokerAuthInfoTokenParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the service broker auth info token params +func (o *ServiceBrokerAuthInfoTokenParams) WithHTTPClient(client *http.Client) *ServiceBrokerAuthInfoTokenParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the service broker auth info token params +func (o *ServiceBrokerAuthInfoTokenParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *ServiceBrokerAuthInfoTokenParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_info_token_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_info_token_responses.go new file mode 100644 index 00000000000..5c38010ddb9 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_info_token_responses.go @@ -0,0 +1,105 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package authentication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// ServiceBrokerAuthInfoTokenReader is a Reader for the ServiceBrokerAuthInfoToken structure. +type ServiceBrokerAuthInfoTokenReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ServiceBrokerAuthInfoTokenReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewServiceBrokerAuthInfoTokenOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 500: + result := NewServiceBrokerAuthInfoTokenInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewServiceBrokerAuthInfoTokenOK creates a ServiceBrokerAuthInfoTokenOK with default headers values +func NewServiceBrokerAuthInfoTokenOK() *ServiceBrokerAuthInfoTokenOK { + return &ServiceBrokerAuthInfoTokenOK{} +} + +/* ServiceBrokerAuthInfoTokenOK describes a response with status code 200, with default header values. + +OK +*/ +type ServiceBrokerAuthInfoTokenOK struct { + Payload *models.TokenExtra +} + +func (o *ServiceBrokerAuthInfoTokenOK) Error() string { + return fmt.Sprintf("[GET /auth/v1/info/token][%d] serviceBrokerAuthInfoTokenOK %+v", 200, o.Payload) +} +func (o *ServiceBrokerAuthInfoTokenOK) GetPayload() *models.TokenExtra { + return o.Payload +} + +func (o *ServiceBrokerAuthInfoTokenOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.TokenExtra) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerAuthInfoTokenInternalServerError creates a ServiceBrokerAuthInfoTokenInternalServerError with default headers values +func NewServiceBrokerAuthInfoTokenInternalServerError() *ServiceBrokerAuthInfoTokenInternalServerError { + return &ServiceBrokerAuthInfoTokenInternalServerError{} +} + +/* ServiceBrokerAuthInfoTokenInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type ServiceBrokerAuthInfoTokenInternalServerError struct { + Payload *models.Error +} + +func (o *ServiceBrokerAuthInfoTokenInternalServerError) Error() string { + return fmt.Sprintf("[GET /auth/v1/info/token][%d] serviceBrokerAuthInfoTokenInternalServerError %+v", 500, o.Payload) +} +func (o *ServiceBrokerAuthInfoTokenInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerAuthInfoTokenInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_info_user_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_info_user_parameters.go new file mode 100644 index 00000000000..400cfced998 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_info_user_parameters.go @@ -0,0 +1,126 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package authentication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewServiceBrokerAuthInfoUserParams creates a new ServiceBrokerAuthInfoUserParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewServiceBrokerAuthInfoUserParams() *ServiceBrokerAuthInfoUserParams { + return &ServiceBrokerAuthInfoUserParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewServiceBrokerAuthInfoUserParamsWithTimeout creates a new ServiceBrokerAuthInfoUserParams object +// with the ability to set a timeout on a request. +func NewServiceBrokerAuthInfoUserParamsWithTimeout(timeout time.Duration) *ServiceBrokerAuthInfoUserParams { + return &ServiceBrokerAuthInfoUserParams{ + timeout: timeout, + } +} + +// NewServiceBrokerAuthInfoUserParamsWithContext creates a new ServiceBrokerAuthInfoUserParams object +// with the ability to set a context for a request. +func NewServiceBrokerAuthInfoUserParamsWithContext(ctx context.Context) *ServiceBrokerAuthInfoUserParams { + return &ServiceBrokerAuthInfoUserParams{ + Context: ctx, + } +} + +// NewServiceBrokerAuthInfoUserParamsWithHTTPClient creates a new ServiceBrokerAuthInfoUserParams object +// with the ability to set a custom HTTPClient for a request. +func NewServiceBrokerAuthInfoUserParamsWithHTTPClient(client *http.Client) *ServiceBrokerAuthInfoUserParams { + return &ServiceBrokerAuthInfoUserParams{ + HTTPClient: client, + } +} + +/* ServiceBrokerAuthInfoUserParams contains all the parameters to send to the API endpoint + for the service broker auth info user operation. + + Typically these are written to a http.Request. +*/ +type ServiceBrokerAuthInfoUserParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the service broker auth info user params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerAuthInfoUserParams) WithDefaults() *ServiceBrokerAuthInfoUserParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the service broker auth info user params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerAuthInfoUserParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the service broker auth info user params +func (o *ServiceBrokerAuthInfoUserParams) WithTimeout(timeout time.Duration) *ServiceBrokerAuthInfoUserParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the service broker auth info user params +func (o *ServiceBrokerAuthInfoUserParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the service broker auth info user params +func (o *ServiceBrokerAuthInfoUserParams) WithContext(ctx context.Context) *ServiceBrokerAuthInfoUserParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the service broker auth info user params +func (o *ServiceBrokerAuthInfoUserParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the service broker auth info user params +func (o *ServiceBrokerAuthInfoUserParams) WithHTTPClient(client *http.Client) *ServiceBrokerAuthInfoUserParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the service broker auth info user params +func (o *ServiceBrokerAuthInfoUserParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *ServiceBrokerAuthInfoUserParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_info_user_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_info_user_responses.go new file mode 100644 index 00000000000..c8a412dff77 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_info_user_responses.go @@ -0,0 +1,105 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package authentication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// ServiceBrokerAuthInfoUserReader is a Reader for the ServiceBrokerAuthInfoUser structure. +type ServiceBrokerAuthInfoUserReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ServiceBrokerAuthInfoUserReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewServiceBrokerAuthInfoUserOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 500: + result := NewServiceBrokerAuthInfoUserInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewServiceBrokerAuthInfoUserOK creates a ServiceBrokerAuthInfoUserOK with default headers values +func NewServiceBrokerAuthInfoUserOK() *ServiceBrokerAuthInfoUserOK { + return &ServiceBrokerAuthInfoUserOK{} +} + +/* ServiceBrokerAuthInfoUserOK describes a response with status code 200, with default header values. + +OK +*/ +type ServiceBrokerAuthInfoUserOK struct { + Payload *models.UserInfo +} + +func (o *ServiceBrokerAuthInfoUserOK) Error() string { + return fmt.Sprintf("[GET /auth/v1/info/user][%d] serviceBrokerAuthInfoUserOK %+v", 200, o.Payload) +} +func (o *ServiceBrokerAuthInfoUserOK) GetPayload() *models.UserInfo { + return o.Payload +} + +func (o *ServiceBrokerAuthInfoUserOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.UserInfo) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerAuthInfoUserInternalServerError creates a ServiceBrokerAuthInfoUserInternalServerError with default headers values +func NewServiceBrokerAuthInfoUserInternalServerError() *ServiceBrokerAuthInfoUserInternalServerError { + return &ServiceBrokerAuthInfoUserInternalServerError{} +} + +/* ServiceBrokerAuthInfoUserInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type ServiceBrokerAuthInfoUserInternalServerError struct { + Payload *models.Error +} + +func (o *ServiceBrokerAuthInfoUserInternalServerError) Error() string { + return fmt.Sprintf("[GET /auth/v1/info/user][%d] serviceBrokerAuthInfoUserInternalServerError %+v", 500, o.Payload) +} +func (o *ServiceBrokerAuthInfoUserInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerAuthInfoUserInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_login_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_login_parameters.go new file mode 100644 index 00000000000..821c5a04197 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_login_parameters.go @@ -0,0 +1,242 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package authentication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewServiceBrokerAuthLoginParams creates a new ServiceBrokerAuthLoginParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewServiceBrokerAuthLoginParams() *ServiceBrokerAuthLoginParams { + return &ServiceBrokerAuthLoginParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewServiceBrokerAuthLoginParamsWithTimeout creates a new ServiceBrokerAuthLoginParams object +// with the ability to set a timeout on a request. +func NewServiceBrokerAuthLoginParamsWithTimeout(timeout time.Duration) *ServiceBrokerAuthLoginParams { + return &ServiceBrokerAuthLoginParams{ + timeout: timeout, + } +} + +// NewServiceBrokerAuthLoginParamsWithContext creates a new ServiceBrokerAuthLoginParams object +// with the ability to set a context for a request. +func NewServiceBrokerAuthLoginParamsWithContext(ctx context.Context) *ServiceBrokerAuthLoginParams { + return &ServiceBrokerAuthLoginParams{ + Context: ctx, + } +} + +// NewServiceBrokerAuthLoginParamsWithHTTPClient creates a new ServiceBrokerAuthLoginParams object +// with the ability to set a custom HTTPClient for a request. +func NewServiceBrokerAuthLoginParamsWithHTTPClient(client *http.Client) *ServiceBrokerAuthLoginParams { + return &ServiceBrokerAuthLoginParams{ + HTTPClient: client, + } +} + +/* ServiceBrokerAuthLoginParams contains all the parameters to send to the API endpoint + for the service broker auth login operation. + + Typically these are written to a http.Request. +*/ +type ServiceBrokerAuthLoginParams struct { + + /* AccessType. + + Determines if a refresh token is returned + + Default: "online" + */ + AccessType *string + + /* RedirectURL. + + The URL to redirect to after login/registration + */ + RedirectURL *string + + /* UserID. + + The user id of the user + */ + UserID *string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the service broker auth login params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerAuthLoginParams) WithDefaults() *ServiceBrokerAuthLoginParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the service broker auth login params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerAuthLoginParams) SetDefaults() { + var ( + accessTypeDefault = string("online") + ) + + val := ServiceBrokerAuthLoginParams{ + AccessType: &accessTypeDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + +// WithTimeout adds the timeout to the service broker auth login params +func (o *ServiceBrokerAuthLoginParams) WithTimeout(timeout time.Duration) *ServiceBrokerAuthLoginParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the service broker auth login params +func (o *ServiceBrokerAuthLoginParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the service broker auth login params +func (o *ServiceBrokerAuthLoginParams) WithContext(ctx context.Context) *ServiceBrokerAuthLoginParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the service broker auth login params +func (o *ServiceBrokerAuthLoginParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the service broker auth login params +func (o *ServiceBrokerAuthLoginParams) WithHTTPClient(client *http.Client) *ServiceBrokerAuthLoginParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the service broker auth login params +func (o *ServiceBrokerAuthLoginParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithAccessType adds the accessType to the service broker auth login params +func (o *ServiceBrokerAuthLoginParams) WithAccessType(accessType *string) *ServiceBrokerAuthLoginParams { + o.SetAccessType(accessType) + return o +} + +// SetAccessType adds the accessType to the service broker auth login params +func (o *ServiceBrokerAuthLoginParams) SetAccessType(accessType *string) { + o.AccessType = accessType +} + +// WithRedirectURL adds the redirectURL to the service broker auth login params +func (o *ServiceBrokerAuthLoginParams) WithRedirectURL(redirectURL *string) *ServiceBrokerAuthLoginParams { + o.SetRedirectURL(redirectURL) + return o +} + +// SetRedirectURL adds the redirectUrl to the service broker auth login params +func (o *ServiceBrokerAuthLoginParams) SetRedirectURL(redirectURL *string) { + o.RedirectURL = redirectURL +} + +// WithUserID adds the userID to the service broker auth login params +func (o *ServiceBrokerAuthLoginParams) WithUserID(userID *string) *ServiceBrokerAuthLoginParams { + o.SetUserID(userID) + return o +} + +// SetUserID adds the userId to the service broker auth login params +func (o *ServiceBrokerAuthLoginParams) SetUserID(userID *string) { + o.UserID = userID +} + +// WriteToRequest writes these params to a swagger request +func (o *ServiceBrokerAuthLoginParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.AccessType != nil { + + // query param access_type + var qrAccessType string + + if o.AccessType != nil { + qrAccessType = *o.AccessType + } + qAccessType := qrAccessType + if qAccessType != "" { + + if err := r.SetQueryParam("access_type", qAccessType); err != nil { + return err + } + } + } + + if o.RedirectURL != nil { + + // query param redirect_url + var qrRedirectURL string + + if o.RedirectURL != nil { + qrRedirectURL = *o.RedirectURL + } + qRedirectURL := qrRedirectURL + if qRedirectURL != "" { + + if err := r.SetQueryParam("redirect_url", qRedirectURL); err != nil { + return err + } + } + } + + if o.UserID != nil { + + // query param user_id + var qrUserID string + + if o.UserID != nil { + qrUserID = *o.UserID + } + qUserID := qrUserID + if qUserID != "" { + + if err := r.SetQueryParam("user_id", qUserID); err != nil { + return err + } + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_login_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_login_responses.go new file mode 100644 index 00000000000..0372c622fbb --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_login_responses.go @@ -0,0 +1,143 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package authentication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// ServiceBrokerAuthLoginReader is a Reader for the ServiceBrokerAuthLogin structure. +type ServiceBrokerAuthLoginReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ServiceBrokerAuthLoginReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewServiceBrokerAuthLoginOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewServiceBrokerAuthLoginUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewServiceBrokerAuthLoginInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewServiceBrokerAuthLoginOK creates a ServiceBrokerAuthLoginOK with default headers values +func NewServiceBrokerAuthLoginOK() *ServiceBrokerAuthLoginOK { + return &ServiceBrokerAuthLoginOK{} +} + +/* ServiceBrokerAuthLoginOK describes a response with status code 200, with default header values. + +OK +*/ +type ServiceBrokerAuthLoginOK struct { + Payload *models.AccessToken +} + +func (o *ServiceBrokerAuthLoginOK) Error() string { + return fmt.Sprintf("[GET /auth/v1/login][%d] serviceBrokerAuthLoginOK %+v", 200, o.Payload) +} +func (o *ServiceBrokerAuthLoginOK) GetPayload() *models.AccessToken { + return o.Payload +} + +func (o *ServiceBrokerAuthLoginOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AccessToken) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerAuthLoginUnauthorized creates a ServiceBrokerAuthLoginUnauthorized with default headers values +func NewServiceBrokerAuthLoginUnauthorized() *ServiceBrokerAuthLoginUnauthorized { + return &ServiceBrokerAuthLoginUnauthorized{} +} + +/* ServiceBrokerAuthLoginUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type ServiceBrokerAuthLoginUnauthorized struct { + Payload *models.Error +} + +func (o *ServiceBrokerAuthLoginUnauthorized) Error() string { + return fmt.Sprintf("[GET /auth/v1/login][%d] serviceBrokerAuthLoginUnauthorized %+v", 401, o.Payload) +} +func (o *ServiceBrokerAuthLoginUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerAuthLoginUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerAuthLoginInternalServerError creates a ServiceBrokerAuthLoginInternalServerError with default headers values +func NewServiceBrokerAuthLoginInternalServerError() *ServiceBrokerAuthLoginInternalServerError { + return &ServiceBrokerAuthLoginInternalServerError{} +} + +/* ServiceBrokerAuthLoginInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type ServiceBrokerAuthLoginInternalServerError struct { + Payload *models.Error +} + +func (o *ServiceBrokerAuthLoginInternalServerError) Error() string { + return fmt.Sprintf("[GET /auth/v1/login][%d] serviceBrokerAuthLoginInternalServerError %+v", 500, o.Payload) +} +func (o *ServiceBrokerAuthLoginInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerAuthLoginInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_logout_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_logout_parameters.go new file mode 100644 index 00000000000..dd227cda394 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_logout_parameters.go @@ -0,0 +1,126 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package authentication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewServiceBrokerAuthLogoutParams creates a new ServiceBrokerAuthLogoutParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewServiceBrokerAuthLogoutParams() *ServiceBrokerAuthLogoutParams { + return &ServiceBrokerAuthLogoutParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewServiceBrokerAuthLogoutParamsWithTimeout creates a new ServiceBrokerAuthLogoutParams object +// with the ability to set a timeout on a request. +func NewServiceBrokerAuthLogoutParamsWithTimeout(timeout time.Duration) *ServiceBrokerAuthLogoutParams { + return &ServiceBrokerAuthLogoutParams{ + timeout: timeout, + } +} + +// NewServiceBrokerAuthLogoutParamsWithContext creates a new ServiceBrokerAuthLogoutParams object +// with the ability to set a context for a request. +func NewServiceBrokerAuthLogoutParamsWithContext(ctx context.Context) *ServiceBrokerAuthLogoutParams { + return &ServiceBrokerAuthLogoutParams{ + Context: ctx, + } +} + +// NewServiceBrokerAuthLogoutParamsWithHTTPClient creates a new ServiceBrokerAuthLogoutParams object +// with the ability to set a custom HTTPClient for a request. +func NewServiceBrokerAuthLogoutParamsWithHTTPClient(client *http.Client) *ServiceBrokerAuthLogoutParams { + return &ServiceBrokerAuthLogoutParams{ + HTTPClient: client, + } +} + +/* ServiceBrokerAuthLogoutParams contains all the parameters to send to the API endpoint + for the service broker auth logout operation. + + Typically these are written to a http.Request. +*/ +type ServiceBrokerAuthLogoutParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the service broker auth logout params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerAuthLogoutParams) WithDefaults() *ServiceBrokerAuthLogoutParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the service broker auth logout params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerAuthLogoutParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the service broker auth logout params +func (o *ServiceBrokerAuthLogoutParams) WithTimeout(timeout time.Duration) *ServiceBrokerAuthLogoutParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the service broker auth logout params +func (o *ServiceBrokerAuthLogoutParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the service broker auth logout params +func (o *ServiceBrokerAuthLogoutParams) WithContext(ctx context.Context) *ServiceBrokerAuthLogoutParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the service broker auth logout params +func (o *ServiceBrokerAuthLogoutParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the service broker auth logout params +func (o *ServiceBrokerAuthLogoutParams) WithHTTPClient(client *http.Client) *ServiceBrokerAuthLogoutParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the service broker auth logout params +func (o *ServiceBrokerAuthLogoutParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *ServiceBrokerAuthLogoutParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_logout_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_logout_responses.go new file mode 100644 index 00000000000..6907da0111c --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_logout_responses.go @@ -0,0 +1,103 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package authentication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// ServiceBrokerAuthLogoutReader is a Reader for the ServiceBrokerAuthLogout structure. +type ServiceBrokerAuthLogoutReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ServiceBrokerAuthLogoutReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewServiceBrokerAuthLogoutOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 500: + result := NewServiceBrokerAuthLogoutInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewServiceBrokerAuthLogoutOK creates a ServiceBrokerAuthLogoutOK with default headers values +func NewServiceBrokerAuthLogoutOK() *ServiceBrokerAuthLogoutOK { + return &ServiceBrokerAuthLogoutOK{} +} + +/* ServiceBrokerAuthLogoutOK describes a response with status code 200, with default header values. + +OK +*/ +type ServiceBrokerAuthLogoutOK struct { + Payload models.Object +} + +func (o *ServiceBrokerAuthLogoutOK) Error() string { + return fmt.Sprintf("[GET /auth/v1/logout][%d] serviceBrokerAuthLogoutOK %+v", 200, o.Payload) +} +func (o *ServiceBrokerAuthLogoutOK) GetPayload() models.Object { + return o.Payload +} + +func (o *ServiceBrokerAuthLogoutOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerAuthLogoutInternalServerError creates a ServiceBrokerAuthLogoutInternalServerError with default headers values +func NewServiceBrokerAuthLogoutInternalServerError() *ServiceBrokerAuthLogoutInternalServerError { + return &ServiceBrokerAuthLogoutInternalServerError{} +} + +/* ServiceBrokerAuthLogoutInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type ServiceBrokerAuthLogoutInternalServerError struct { + Payload *models.Error +} + +func (o *ServiceBrokerAuthLogoutInternalServerError) Error() string { + return fmt.Sprintf("[GET /auth/v1/logout][%d] serviceBrokerAuthLogoutInternalServerError %+v", 500, o.Payload) +} +func (o *ServiceBrokerAuthLogoutInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerAuthLogoutInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_registration_callback_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_registration_callback_parameters.go new file mode 100644 index 00000000000..0aceb5313bc --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_registration_callback_parameters.go @@ -0,0 +1,126 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package authentication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewServiceBrokerAuthRegistrationCallbackParams creates a new ServiceBrokerAuthRegistrationCallbackParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewServiceBrokerAuthRegistrationCallbackParams() *ServiceBrokerAuthRegistrationCallbackParams { + return &ServiceBrokerAuthRegistrationCallbackParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewServiceBrokerAuthRegistrationCallbackParamsWithTimeout creates a new ServiceBrokerAuthRegistrationCallbackParams object +// with the ability to set a timeout on a request. +func NewServiceBrokerAuthRegistrationCallbackParamsWithTimeout(timeout time.Duration) *ServiceBrokerAuthRegistrationCallbackParams { + return &ServiceBrokerAuthRegistrationCallbackParams{ + timeout: timeout, + } +} + +// NewServiceBrokerAuthRegistrationCallbackParamsWithContext creates a new ServiceBrokerAuthRegistrationCallbackParams object +// with the ability to set a context for a request. +func NewServiceBrokerAuthRegistrationCallbackParamsWithContext(ctx context.Context) *ServiceBrokerAuthRegistrationCallbackParams { + return &ServiceBrokerAuthRegistrationCallbackParams{ + Context: ctx, + } +} + +// NewServiceBrokerAuthRegistrationCallbackParamsWithHTTPClient creates a new ServiceBrokerAuthRegistrationCallbackParams object +// with the ability to set a custom HTTPClient for a request. +func NewServiceBrokerAuthRegistrationCallbackParamsWithHTTPClient(client *http.Client) *ServiceBrokerAuthRegistrationCallbackParams { + return &ServiceBrokerAuthRegistrationCallbackParams{ + HTTPClient: client, + } +} + +/* ServiceBrokerAuthRegistrationCallbackParams contains all the parameters to send to the API endpoint + for the service broker auth registration callback operation. + + Typically these are written to a http.Request. +*/ +type ServiceBrokerAuthRegistrationCallbackParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the service broker auth registration callback params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerAuthRegistrationCallbackParams) WithDefaults() *ServiceBrokerAuthRegistrationCallbackParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the service broker auth registration callback params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerAuthRegistrationCallbackParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the service broker auth registration callback params +func (o *ServiceBrokerAuthRegistrationCallbackParams) WithTimeout(timeout time.Duration) *ServiceBrokerAuthRegistrationCallbackParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the service broker auth registration callback params +func (o *ServiceBrokerAuthRegistrationCallbackParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the service broker auth registration callback params +func (o *ServiceBrokerAuthRegistrationCallbackParams) WithContext(ctx context.Context) *ServiceBrokerAuthRegistrationCallbackParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the service broker auth registration callback params +func (o *ServiceBrokerAuthRegistrationCallbackParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the service broker auth registration callback params +func (o *ServiceBrokerAuthRegistrationCallbackParams) WithHTTPClient(client *http.Client) *ServiceBrokerAuthRegistrationCallbackParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the service broker auth registration callback params +func (o *ServiceBrokerAuthRegistrationCallbackParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *ServiceBrokerAuthRegistrationCallbackParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_registration_callback_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_registration_callback_responses.go new file mode 100644 index 00000000000..bc09a80543e --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_registration_callback_responses.go @@ -0,0 +1,143 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package authentication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// ServiceBrokerAuthRegistrationCallbackReader is a Reader for the ServiceBrokerAuthRegistrationCallback structure. +type ServiceBrokerAuthRegistrationCallbackReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ServiceBrokerAuthRegistrationCallbackReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewServiceBrokerAuthRegistrationCallbackOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewServiceBrokerAuthRegistrationCallbackUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewServiceBrokerAuthRegistrationCallbackInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewServiceBrokerAuthRegistrationCallbackOK creates a ServiceBrokerAuthRegistrationCallbackOK with default headers values +func NewServiceBrokerAuthRegistrationCallbackOK() *ServiceBrokerAuthRegistrationCallbackOK { + return &ServiceBrokerAuthRegistrationCallbackOK{} +} + +/* ServiceBrokerAuthRegistrationCallbackOK describes a response with status code 200, with default header values. + +OK +*/ +type ServiceBrokerAuthRegistrationCallbackOK struct { + Payload *models.AccessToken +} + +func (o *ServiceBrokerAuthRegistrationCallbackOK) Error() string { + return fmt.Sprintf("[GET /auth/v1/callback-registration][%d] serviceBrokerAuthRegistrationCallbackOK %+v", 200, o.Payload) +} +func (o *ServiceBrokerAuthRegistrationCallbackOK) GetPayload() *models.AccessToken { + return o.Payload +} + +func (o *ServiceBrokerAuthRegistrationCallbackOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AccessToken) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerAuthRegistrationCallbackUnauthorized creates a ServiceBrokerAuthRegistrationCallbackUnauthorized with default headers values +func NewServiceBrokerAuthRegistrationCallbackUnauthorized() *ServiceBrokerAuthRegistrationCallbackUnauthorized { + return &ServiceBrokerAuthRegistrationCallbackUnauthorized{} +} + +/* ServiceBrokerAuthRegistrationCallbackUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type ServiceBrokerAuthRegistrationCallbackUnauthorized struct { + Payload *models.Error +} + +func (o *ServiceBrokerAuthRegistrationCallbackUnauthorized) Error() string { + return fmt.Sprintf("[GET /auth/v1/callback-registration][%d] serviceBrokerAuthRegistrationCallbackUnauthorized %+v", 401, o.Payload) +} +func (o *ServiceBrokerAuthRegistrationCallbackUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerAuthRegistrationCallbackUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerAuthRegistrationCallbackInternalServerError creates a ServiceBrokerAuthRegistrationCallbackInternalServerError with default headers values +func NewServiceBrokerAuthRegistrationCallbackInternalServerError() *ServiceBrokerAuthRegistrationCallbackInternalServerError { + return &ServiceBrokerAuthRegistrationCallbackInternalServerError{} +} + +/* ServiceBrokerAuthRegistrationCallbackInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type ServiceBrokerAuthRegistrationCallbackInternalServerError struct { + Payload *models.Error +} + +func (o *ServiceBrokerAuthRegistrationCallbackInternalServerError) Error() string { + return fmt.Sprintf("[GET /auth/v1/callback-registration][%d] serviceBrokerAuthRegistrationCallbackInternalServerError %+v", 500, o.Payload) +} +func (o *ServiceBrokerAuthRegistrationCallbackInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerAuthRegistrationCallbackInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_registration_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_registration_parameters.go new file mode 100644 index 00000000000..3a49c00a2e0 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_registration_parameters.go @@ -0,0 +1,315 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package authentication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewServiceBrokerAuthRegistrationParams creates a new ServiceBrokerAuthRegistrationParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewServiceBrokerAuthRegistrationParams() *ServiceBrokerAuthRegistrationParams { + return &ServiceBrokerAuthRegistrationParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewServiceBrokerAuthRegistrationParamsWithTimeout creates a new ServiceBrokerAuthRegistrationParams object +// with the ability to set a timeout on a request. +func NewServiceBrokerAuthRegistrationParamsWithTimeout(timeout time.Duration) *ServiceBrokerAuthRegistrationParams { + return &ServiceBrokerAuthRegistrationParams{ + timeout: timeout, + } +} + +// NewServiceBrokerAuthRegistrationParamsWithContext creates a new ServiceBrokerAuthRegistrationParams object +// with the ability to set a context for a request. +func NewServiceBrokerAuthRegistrationParamsWithContext(ctx context.Context) *ServiceBrokerAuthRegistrationParams { + return &ServiceBrokerAuthRegistrationParams{ + Context: ctx, + } +} + +// NewServiceBrokerAuthRegistrationParamsWithHTTPClient creates a new ServiceBrokerAuthRegistrationParams object +// with the ability to set a custom HTTPClient for a request. +func NewServiceBrokerAuthRegistrationParamsWithHTTPClient(client *http.Client) *ServiceBrokerAuthRegistrationParams { + return &ServiceBrokerAuthRegistrationParams{ + HTTPClient: client, + } +} + +/* ServiceBrokerAuthRegistrationParams contains all the parameters to send to the API endpoint + for the service broker auth registration operation. + + Typically these are written to a http.Request. +*/ +type ServiceBrokerAuthRegistrationParams struct { + + /* EntitlementID. + + Entitlement ID of for this tenant + */ + EntitlementID string + + /* Icn. + + IBM Customer Number (ICN) for this tenant + */ + Icn string + + /* Plan. + + Plan for this tenant and entitlement + */ + Plan string + + /* RedirectURL. + + The URL to redirect to after login/registration + */ + RedirectURL *string + + /* Regions. + + An array of regions matching the number of cloud-instances in the plan + */ + Regions []string + + /* TenantID. + + Tenant ID of a pcloud tenant + */ + TenantID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the service broker auth registration params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerAuthRegistrationParams) WithDefaults() *ServiceBrokerAuthRegistrationParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the service broker auth registration params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerAuthRegistrationParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the service broker auth registration params +func (o *ServiceBrokerAuthRegistrationParams) WithTimeout(timeout time.Duration) *ServiceBrokerAuthRegistrationParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the service broker auth registration params +func (o *ServiceBrokerAuthRegistrationParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the service broker auth registration params +func (o *ServiceBrokerAuthRegistrationParams) WithContext(ctx context.Context) *ServiceBrokerAuthRegistrationParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the service broker auth registration params +func (o *ServiceBrokerAuthRegistrationParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the service broker auth registration params +func (o *ServiceBrokerAuthRegistrationParams) WithHTTPClient(client *http.Client) *ServiceBrokerAuthRegistrationParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the service broker auth registration params +func (o *ServiceBrokerAuthRegistrationParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithEntitlementID adds the entitlementID to the service broker auth registration params +func (o *ServiceBrokerAuthRegistrationParams) WithEntitlementID(entitlementID string) *ServiceBrokerAuthRegistrationParams { + o.SetEntitlementID(entitlementID) + return o +} + +// SetEntitlementID adds the entitlementId to the service broker auth registration params +func (o *ServiceBrokerAuthRegistrationParams) SetEntitlementID(entitlementID string) { + o.EntitlementID = entitlementID +} + +// WithIcn adds the icn to the service broker auth registration params +func (o *ServiceBrokerAuthRegistrationParams) WithIcn(icn string) *ServiceBrokerAuthRegistrationParams { + o.SetIcn(icn) + return o +} + +// SetIcn adds the icn to the service broker auth registration params +func (o *ServiceBrokerAuthRegistrationParams) SetIcn(icn string) { + o.Icn = icn +} + +// WithPlan adds the plan to the service broker auth registration params +func (o *ServiceBrokerAuthRegistrationParams) WithPlan(plan string) *ServiceBrokerAuthRegistrationParams { + o.SetPlan(plan) + return o +} + +// SetPlan adds the plan to the service broker auth registration params +func (o *ServiceBrokerAuthRegistrationParams) SetPlan(plan string) { + o.Plan = plan +} + +// WithRedirectURL adds the redirectURL to the service broker auth registration params +func (o *ServiceBrokerAuthRegistrationParams) WithRedirectURL(redirectURL *string) *ServiceBrokerAuthRegistrationParams { + o.SetRedirectURL(redirectURL) + return o +} + +// SetRedirectURL adds the redirectUrl to the service broker auth registration params +func (o *ServiceBrokerAuthRegistrationParams) SetRedirectURL(redirectURL *string) { + o.RedirectURL = redirectURL +} + +// WithRegions adds the regions to the service broker auth registration params +func (o *ServiceBrokerAuthRegistrationParams) WithRegions(regions []string) *ServiceBrokerAuthRegistrationParams { + o.SetRegions(regions) + return o +} + +// SetRegions adds the regions to the service broker auth registration params +func (o *ServiceBrokerAuthRegistrationParams) SetRegions(regions []string) { + o.Regions = regions +} + +// WithTenantID adds the tenantID to the service broker auth registration params +func (o *ServiceBrokerAuthRegistrationParams) WithTenantID(tenantID string) *ServiceBrokerAuthRegistrationParams { + o.SetTenantID(tenantID) + return o +} + +// SetTenantID adds the tenantId to the service broker auth registration params +func (o *ServiceBrokerAuthRegistrationParams) SetTenantID(tenantID string) { + o.TenantID = tenantID +} + +// WriteToRequest writes these params to a swagger request +func (o *ServiceBrokerAuthRegistrationParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // query param entitlement_id + qrEntitlementID := o.EntitlementID + qEntitlementID := qrEntitlementID + if qEntitlementID != "" { + + if err := r.SetQueryParam("entitlement_id", qEntitlementID); err != nil { + return err + } + } + + // query param icn + qrIcn := o.Icn + qIcn := qrIcn + if qIcn != "" { + + if err := r.SetQueryParam("icn", qIcn); err != nil { + return err + } + } + + // query param plan + qrPlan := o.Plan + qPlan := qrPlan + if qPlan != "" { + + if err := r.SetQueryParam("plan", qPlan); err != nil { + return err + } + } + + if o.RedirectURL != nil { + + // query param redirect_url + var qrRedirectURL string + + if o.RedirectURL != nil { + qrRedirectURL = *o.RedirectURL + } + qRedirectURL := qrRedirectURL + if qRedirectURL != "" { + + if err := r.SetQueryParam("redirect_url", qRedirectURL); err != nil { + return err + } + } + } + + if o.Regions != nil { + + // binding items for regions + joinedRegions := o.bindParamRegions(reg) + + // query array param regions + if err := r.SetQueryParam("regions", joinedRegions...); err != nil { + return err + } + } + + // query param tenant_id + qrTenantID := o.TenantID + qTenantID := qrTenantID + if qTenantID != "" { + + if err := r.SetQueryParam("tenant_id", qTenantID); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParamServiceBrokerAuthRegistration binds the parameter regions +func (o *ServiceBrokerAuthRegistrationParams) bindParamRegions(formats strfmt.Registry) []string { + regionsIR := o.Regions + + var regionsIC []string + for _, regionsIIR := range regionsIR { // explode []string + + regionsIIV := regionsIIR // string as string + regionsIC = append(regionsIC, regionsIIV) + } + + // items.CollectionFormat: "" + regionsIS := swag.JoinByFormat(regionsIC, "") + + return regionsIS +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_registration_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_registration_responses.go new file mode 100644 index 00000000000..7ccbe10af14 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_registration_responses.go @@ -0,0 +1,143 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package authentication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// ServiceBrokerAuthRegistrationReader is a Reader for the ServiceBrokerAuthRegistration structure. +type ServiceBrokerAuthRegistrationReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ServiceBrokerAuthRegistrationReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewServiceBrokerAuthRegistrationOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewServiceBrokerAuthRegistrationUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewServiceBrokerAuthRegistrationInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewServiceBrokerAuthRegistrationOK creates a ServiceBrokerAuthRegistrationOK with default headers values +func NewServiceBrokerAuthRegistrationOK() *ServiceBrokerAuthRegistrationOK { + return &ServiceBrokerAuthRegistrationOK{} +} + +/* ServiceBrokerAuthRegistrationOK describes a response with status code 200, with default header values. + +OK +*/ +type ServiceBrokerAuthRegistrationOK struct { + Payload *models.AccessToken +} + +func (o *ServiceBrokerAuthRegistrationOK) Error() string { + return fmt.Sprintf("[GET /auth/v1/registration][%d] serviceBrokerAuthRegistrationOK %+v", 200, o.Payload) +} +func (o *ServiceBrokerAuthRegistrationOK) GetPayload() *models.AccessToken { + return o.Payload +} + +func (o *ServiceBrokerAuthRegistrationOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AccessToken) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerAuthRegistrationUnauthorized creates a ServiceBrokerAuthRegistrationUnauthorized with default headers values +func NewServiceBrokerAuthRegistrationUnauthorized() *ServiceBrokerAuthRegistrationUnauthorized { + return &ServiceBrokerAuthRegistrationUnauthorized{} +} + +/* ServiceBrokerAuthRegistrationUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type ServiceBrokerAuthRegistrationUnauthorized struct { + Payload *models.Error +} + +func (o *ServiceBrokerAuthRegistrationUnauthorized) Error() string { + return fmt.Sprintf("[GET /auth/v1/registration][%d] serviceBrokerAuthRegistrationUnauthorized %+v", 401, o.Payload) +} +func (o *ServiceBrokerAuthRegistrationUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerAuthRegistrationUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerAuthRegistrationInternalServerError creates a ServiceBrokerAuthRegistrationInternalServerError with default headers values +func NewServiceBrokerAuthRegistrationInternalServerError() *ServiceBrokerAuthRegistrationInternalServerError { + return &ServiceBrokerAuthRegistrationInternalServerError{} +} + +/* ServiceBrokerAuthRegistrationInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type ServiceBrokerAuthRegistrationInternalServerError struct { + Payload *models.Error +} + +func (o *ServiceBrokerAuthRegistrationInternalServerError) Error() string { + return fmt.Sprintf("[GET /auth/v1/registration][%d] serviceBrokerAuthRegistrationInternalServerError %+v", 500, o.Payload) +} +func (o *ServiceBrokerAuthRegistrationInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerAuthRegistrationInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_token_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_token_post_parameters.go new file mode 100644 index 00000000000..7c77f5ac72a --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_token_post_parameters.go @@ -0,0 +1,151 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package authentication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewServiceBrokerAuthTokenPostParams creates a new ServiceBrokerAuthTokenPostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewServiceBrokerAuthTokenPostParams() *ServiceBrokerAuthTokenPostParams { + return &ServiceBrokerAuthTokenPostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewServiceBrokerAuthTokenPostParamsWithTimeout creates a new ServiceBrokerAuthTokenPostParams object +// with the ability to set a timeout on a request. +func NewServiceBrokerAuthTokenPostParamsWithTimeout(timeout time.Duration) *ServiceBrokerAuthTokenPostParams { + return &ServiceBrokerAuthTokenPostParams{ + timeout: timeout, + } +} + +// NewServiceBrokerAuthTokenPostParamsWithContext creates a new ServiceBrokerAuthTokenPostParams object +// with the ability to set a context for a request. +func NewServiceBrokerAuthTokenPostParamsWithContext(ctx context.Context) *ServiceBrokerAuthTokenPostParams { + return &ServiceBrokerAuthTokenPostParams{ + Context: ctx, + } +} + +// NewServiceBrokerAuthTokenPostParamsWithHTTPClient creates a new ServiceBrokerAuthTokenPostParams object +// with the ability to set a custom HTTPClient for a request. +func NewServiceBrokerAuthTokenPostParamsWithHTTPClient(client *http.Client) *ServiceBrokerAuthTokenPostParams { + return &ServiceBrokerAuthTokenPostParams{ + HTTPClient: client, + } +} + +/* ServiceBrokerAuthTokenPostParams contains all the parameters to send to the API endpoint + for the service broker auth token post operation. + + Typically these are written to a http.Request. +*/ +type ServiceBrokerAuthTokenPostParams struct { + + /* Body. + + Parameters for requesting a new Token from a Refresh Token + */ + Body *models.TokenRequest + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the service broker auth token post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerAuthTokenPostParams) WithDefaults() *ServiceBrokerAuthTokenPostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the service broker auth token post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerAuthTokenPostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the service broker auth token post params +func (o *ServiceBrokerAuthTokenPostParams) WithTimeout(timeout time.Duration) *ServiceBrokerAuthTokenPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the service broker auth token post params +func (o *ServiceBrokerAuthTokenPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the service broker auth token post params +func (o *ServiceBrokerAuthTokenPostParams) WithContext(ctx context.Context) *ServiceBrokerAuthTokenPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the service broker auth token post params +func (o *ServiceBrokerAuthTokenPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the service broker auth token post params +func (o *ServiceBrokerAuthTokenPostParams) WithHTTPClient(client *http.Client) *ServiceBrokerAuthTokenPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the service broker auth token post params +func (o *ServiceBrokerAuthTokenPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the service broker auth token post params +func (o *ServiceBrokerAuthTokenPostParams) WithBody(body *models.TokenRequest) *ServiceBrokerAuthTokenPostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the service broker auth token post params +func (o *ServiceBrokerAuthTokenPostParams) SetBody(body *models.TokenRequest) { + o.Body = body +} + +// WriteToRequest writes these params to a swagger request +func (o *ServiceBrokerAuthTokenPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_token_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_token_post_responses.go new file mode 100644 index 00000000000..72087200a26 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/authentication/service_broker_auth_token_post_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package authentication + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// ServiceBrokerAuthTokenPostReader is a Reader for the ServiceBrokerAuthTokenPost structure. +type ServiceBrokerAuthTokenPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ServiceBrokerAuthTokenPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewServiceBrokerAuthTokenPostOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewServiceBrokerAuthTokenPostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewServiceBrokerAuthTokenPostForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 429: + result := NewServiceBrokerAuthTokenPostTooManyRequests() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewServiceBrokerAuthTokenPostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewServiceBrokerAuthTokenPostOK creates a ServiceBrokerAuthTokenPostOK with default headers values +func NewServiceBrokerAuthTokenPostOK() *ServiceBrokerAuthTokenPostOK { + return &ServiceBrokerAuthTokenPostOK{} +} + +/* ServiceBrokerAuthTokenPostOK describes a response with status code 200, with default header values. + +OK +*/ +type ServiceBrokerAuthTokenPostOK struct { + Payload *models.Token +} + +func (o *ServiceBrokerAuthTokenPostOK) Error() string { + return fmt.Sprintf("[POST /auth/v1/token][%d] serviceBrokerAuthTokenPostOK %+v", 200, o.Payload) +} +func (o *ServiceBrokerAuthTokenPostOK) GetPayload() *models.Token { + return o.Payload +} + +func (o *ServiceBrokerAuthTokenPostOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Token) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerAuthTokenPostBadRequest creates a ServiceBrokerAuthTokenPostBadRequest with default headers values +func NewServiceBrokerAuthTokenPostBadRequest() *ServiceBrokerAuthTokenPostBadRequest { + return &ServiceBrokerAuthTokenPostBadRequest{} +} + +/* ServiceBrokerAuthTokenPostBadRequest describes a response with status code 400, with default header values. + +Authorization pending +*/ +type ServiceBrokerAuthTokenPostBadRequest struct { + Payload *models.Error +} + +func (o *ServiceBrokerAuthTokenPostBadRequest) Error() string { + return fmt.Sprintf("[POST /auth/v1/token][%d] serviceBrokerAuthTokenPostBadRequest %+v", 400, o.Payload) +} +func (o *ServiceBrokerAuthTokenPostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerAuthTokenPostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerAuthTokenPostForbidden creates a ServiceBrokerAuthTokenPostForbidden with default headers values +func NewServiceBrokerAuthTokenPostForbidden() *ServiceBrokerAuthTokenPostForbidden { + return &ServiceBrokerAuthTokenPostForbidden{} +} + +/* ServiceBrokerAuthTokenPostForbidden describes a response with status code 403, with default header values. + +User refused grant +*/ +type ServiceBrokerAuthTokenPostForbidden struct { + Payload *models.Error +} + +func (o *ServiceBrokerAuthTokenPostForbidden) Error() string { + return fmt.Sprintf("[POST /auth/v1/token][%d] serviceBrokerAuthTokenPostForbidden %+v", 403, o.Payload) +} +func (o *ServiceBrokerAuthTokenPostForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerAuthTokenPostForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerAuthTokenPostTooManyRequests creates a ServiceBrokerAuthTokenPostTooManyRequests with default headers values +func NewServiceBrokerAuthTokenPostTooManyRequests() *ServiceBrokerAuthTokenPostTooManyRequests { + return &ServiceBrokerAuthTokenPostTooManyRequests{} +} + +/* ServiceBrokerAuthTokenPostTooManyRequests describes a response with status code 429, with default header values. + +Polling too frequently +*/ +type ServiceBrokerAuthTokenPostTooManyRequests struct { + Payload *models.Error +} + +func (o *ServiceBrokerAuthTokenPostTooManyRequests) Error() string { + return fmt.Sprintf("[POST /auth/v1/token][%d] serviceBrokerAuthTokenPostTooManyRequests %+v", 429, o.Payload) +} +func (o *ServiceBrokerAuthTokenPostTooManyRequests) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerAuthTokenPostTooManyRequests) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerAuthTokenPostInternalServerError creates a ServiceBrokerAuthTokenPostInternalServerError with default headers values +func NewServiceBrokerAuthTokenPostInternalServerError() *ServiceBrokerAuthTokenPostInternalServerError { + return &ServiceBrokerAuthTokenPostInternalServerError{} +} + +/* ServiceBrokerAuthTokenPostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type ServiceBrokerAuthTokenPostInternalServerError struct { + Payload *models.Error +} + +func (o *ServiceBrokerAuthTokenPostInternalServerError) Error() string { + return fmt.Sprintf("[POST /auth/v1/token][%d] serviceBrokerAuthTokenPostInternalServerError %+v", 500, o.Payload) +} +func (o *ServiceBrokerAuthTokenPostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerAuthTokenPostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/bluemix_service_instances/bluemix_service_instance_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/bluemix_service_instances/bluemix_service_instance_get_parameters.go new file mode 100644 index 00000000000..185400b277b --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/bluemix_service_instances/bluemix_service_instance_get_parameters.go @@ -0,0 +1,149 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package bluemix_service_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewBluemixServiceInstanceGetParams creates a new BluemixServiceInstanceGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewBluemixServiceInstanceGetParams() *BluemixServiceInstanceGetParams { + return &BluemixServiceInstanceGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewBluemixServiceInstanceGetParamsWithTimeout creates a new BluemixServiceInstanceGetParams object +// with the ability to set a timeout on a request. +func NewBluemixServiceInstanceGetParamsWithTimeout(timeout time.Duration) *BluemixServiceInstanceGetParams { + return &BluemixServiceInstanceGetParams{ + timeout: timeout, + } +} + +// NewBluemixServiceInstanceGetParamsWithContext creates a new BluemixServiceInstanceGetParams object +// with the ability to set a context for a request. +func NewBluemixServiceInstanceGetParamsWithContext(ctx context.Context) *BluemixServiceInstanceGetParams { + return &BluemixServiceInstanceGetParams{ + Context: ctx, + } +} + +// NewBluemixServiceInstanceGetParamsWithHTTPClient creates a new BluemixServiceInstanceGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewBluemixServiceInstanceGetParamsWithHTTPClient(client *http.Client) *BluemixServiceInstanceGetParams { + return &BluemixServiceInstanceGetParams{ + HTTPClient: client, + } +} + +/* BluemixServiceInstanceGetParams contains all the parameters to send to the API endpoint + for the bluemix service instance get operation. + + Typically these are written to a http.Request. +*/ +type BluemixServiceInstanceGetParams struct { + + /* InstanceID. + + instance id of instance to provision + */ + InstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the bluemix service instance get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *BluemixServiceInstanceGetParams) WithDefaults() *BluemixServiceInstanceGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the bluemix service instance get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *BluemixServiceInstanceGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the bluemix service instance get params +func (o *BluemixServiceInstanceGetParams) WithTimeout(timeout time.Duration) *BluemixServiceInstanceGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the bluemix service instance get params +func (o *BluemixServiceInstanceGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the bluemix service instance get params +func (o *BluemixServiceInstanceGetParams) WithContext(ctx context.Context) *BluemixServiceInstanceGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the bluemix service instance get params +func (o *BluemixServiceInstanceGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the bluemix service instance get params +func (o *BluemixServiceInstanceGetParams) WithHTTPClient(client *http.Client) *BluemixServiceInstanceGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the bluemix service instance get params +func (o *BluemixServiceInstanceGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithInstanceID adds the instanceID to the bluemix service instance get params +func (o *BluemixServiceInstanceGetParams) WithInstanceID(instanceID string) *BluemixServiceInstanceGetParams { + o.SetInstanceID(instanceID) + return o +} + +// SetInstanceID adds the instanceId to the bluemix service instance get params +func (o *BluemixServiceInstanceGetParams) SetInstanceID(instanceID string) { + o.InstanceID = instanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *BluemixServiceInstanceGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param instance_id + if err := r.SetPathParam("instance_id", o.InstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/bluemix_service_instances/bluemix_service_instance_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/bluemix_service_instances/bluemix_service_instance_get_responses.go new file mode 100644 index 00000000000..0fe5b096e30 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/bluemix_service_instances/bluemix_service_instance_get_responses.go @@ -0,0 +1,105 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package bluemix_service_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// BluemixServiceInstanceGetReader is a Reader for the BluemixServiceInstanceGet structure. +type BluemixServiceInstanceGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *BluemixServiceInstanceGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewBluemixServiceInstanceGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewBluemixServiceInstanceGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewBluemixServiceInstanceGetOK creates a BluemixServiceInstanceGetOK with default headers values +func NewBluemixServiceInstanceGetOK() *BluemixServiceInstanceGetOK { + return &BluemixServiceInstanceGetOK{} +} + +/* BluemixServiceInstanceGetOK describes a response with status code 200, with default header values. + +OK +*/ +type BluemixServiceInstanceGetOK struct { + Payload *models.ServiceInstance +} + +func (o *BluemixServiceInstanceGetOK) Error() string { + return fmt.Sprintf("[GET /bluemix_v1/service_instances/{instance_id}][%d] bluemixServiceInstanceGetOK %+v", 200, o.Payload) +} +func (o *BluemixServiceInstanceGetOK) GetPayload() *models.ServiceInstance { + return o.Payload +} + +func (o *BluemixServiceInstanceGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ServiceInstance) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewBluemixServiceInstanceGetBadRequest creates a BluemixServiceInstanceGetBadRequest with default headers values +func NewBluemixServiceInstanceGetBadRequest() *BluemixServiceInstanceGetBadRequest { + return &BluemixServiceInstanceGetBadRequest{} +} + +/* BluemixServiceInstanceGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type BluemixServiceInstanceGetBadRequest struct { + Payload *models.Error +} + +func (o *BluemixServiceInstanceGetBadRequest) Error() string { + return fmt.Sprintf("[GET /bluemix_v1/service_instances/{instance_id}][%d] bluemixServiceInstanceGetBadRequest %+v", 400, o.Payload) +} +func (o *BluemixServiceInstanceGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *BluemixServiceInstanceGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/bluemix_service_instances/bluemix_service_instance_put_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/bluemix_service_instances/bluemix_service_instance_put_parameters.go new file mode 100644 index 00000000000..7bc989beb97 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/bluemix_service_instances/bluemix_service_instance_put_parameters.go @@ -0,0 +1,173 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package bluemix_service_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewBluemixServiceInstancePutParams creates a new BluemixServiceInstancePutParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewBluemixServiceInstancePutParams() *BluemixServiceInstancePutParams { + return &BluemixServiceInstancePutParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewBluemixServiceInstancePutParamsWithTimeout creates a new BluemixServiceInstancePutParams object +// with the ability to set a timeout on a request. +func NewBluemixServiceInstancePutParamsWithTimeout(timeout time.Duration) *BluemixServiceInstancePutParams { + return &BluemixServiceInstancePutParams{ + timeout: timeout, + } +} + +// NewBluemixServiceInstancePutParamsWithContext creates a new BluemixServiceInstancePutParams object +// with the ability to set a context for a request. +func NewBluemixServiceInstancePutParamsWithContext(ctx context.Context) *BluemixServiceInstancePutParams { + return &BluemixServiceInstancePutParams{ + Context: ctx, + } +} + +// NewBluemixServiceInstancePutParamsWithHTTPClient creates a new BluemixServiceInstancePutParams object +// with the ability to set a custom HTTPClient for a request. +func NewBluemixServiceInstancePutParamsWithHTTPClient(client *http.Client) *BluemixServiceInstancePutParams { + return &BluemixServiceInstancePutParams{ + HTTPClient: client, + } +} + +/* BluemixServiceInstancePutParams contains all the parameters to send to the API endpoint + for the bluemix service instance put operation. + + Typically these are written to a http.Request. +*/ +type BluemixServiceInstancePutParams struct { + + /* Body. + + parameters for the requested state of a provisioned service + */ + Body *models.ServiceInstanceRequest + + /* InstanceID. + + instance id of instance to provision + */ + InstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the bluemix service instance put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *BluemixServiceInstancePutParams) WithDefaults() *BluemixServiceInstancePutParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the bluemix service instance put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *BluemixServiceInstancePutParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the bluemix service instance put params +func (o *BluemixServiceInstancePutParams) WithTimeout(timeout time.Duration) *BluemixServiceInstancePutParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the bluemix service instance put params +func (o *BluemixServiceInstancePutParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the bluemix service instance put params +func (o *BluemixServiceInstancePutParams) WithContext(ctx context.Context) *BluemixServiceInstancePutParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the bluemix service instance put params +func (o *BluemixServiceInstancePutParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the bluemix service instance put params +func (o *BluemixServiceInstancePutParams) WithHTTPClient(client *http.Client) *BluemixServiceInstancePutParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the bluemix service instance put params +func (o *BluemixServiceInstancePutParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the bluemix service instance put params +func (o *BluemixServiceInstancePutParams) WithBody(body *models.ServiceInstanceRequest) *BluemixServiceInstancePutParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the bluemix service instance put params +func (o *BluemixServiceInstancePutParams) SetBody(body *models.ServiceInstanceRequest) { + o.Body = body +} + +// WithInstanceID adds the instanceID to the bluemix service instance put params +func (o *BluemixServiceInstancePutParams) WithInstanceID(instanceID string) *BluemixServiceInstancePutParams { + o.SetInstanceID(instanceID) + return o +} + +// SetInstanceID adds the instanceId to the bluemix service instance put params +func (o *BluemixServiceInstancePutParams) SetInstanceID(instanceID string) { + o.InstanceID = instanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *BluemixServiceInstancePutParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param instance_id + if err := r.SetPathParam("instance_id", o.InstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/bluemix_service_instances/bluemix_service_instance_put_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/bluemix_service_instances/bluemix_service_instance_put_responses.go new file mode 100644 index 00000000000..d35787f1805 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/bluemix_service_instances/bluemix_service_instance_put_responses.go @@ -0,0 +1,105 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package bluemix_service_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// BluemixServiceInstancePutReader is a Reader for the BluemixServiceInstancePut structure. +type BluemixServiceInstancePutReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *BluemixServiceInstancePutReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewBluemixServiceInstancePutOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewBluemixServiceInstancePutBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewBluemixServiceInstancePutOK creates a BluemixServiceInstancePutOK with default headers values +func NewBluemixServiceInstancePutOK() *BluemixServiceInstancePutOK { + return &BluemixServiceInstancePutOK{} +} + +/* BluemixServiceInstancePutOK describes a response with status code 200, with default header values. + +OK +*/ +type BluemixServiceInstancePutOK struct { + Payload *models.ServiceInstance +} + +func (o *BluemixServiceInstancePutOK) Error() string { + return fmt.Sprintf("[PUT /bluemix_v1/service_instances/{instance_id}][%d] bluemixServiceInstancePutOK %+v", 200, o.Payload) +} +func (o *BluemixServiceInstancePutOK) GetPayload() *models.ServiceInstance { + return o.Payload +} + +func (o *BluemixServiceInstancePutOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ServiceInstance) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewBluemixServiceInstancePutBadRequest creates a BluemixServiceInstancePutBadRequest with default headers values +func NewBluemixServiceInstancePutBadRequest() *BluemixServiceInstancePutBadRequest { + return &BluemixServiceInstancePutBadRequest{} +} + +/* BluemixServiceInstancePutBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type BluemixServiceInstancePutBadRequest struct { + Payload *models.Error +} + +func (o *BluemixServiceInstancePutBadRequest) Error() string { + return fmt.Sprintf("[PUT /bluemix_v1/service_instances/{instance_id}][%d] bluemixServiceInstancePutBadRequest %+v", 400, o.Payload) +} +func (o *BluemixServiceInstancePutBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *BluemixServiceInstancePutBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/bluemix_service_instances/bluemix_service_instances_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/bluemix_service_instances/bluemix_service_instances_client.go new file mode 100644 index 00000000000..d0cb0758c4a --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/bluemix_service_instances/bluemix_service_instances_client.go @@ -0,0 +1,121 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package bluemix_service_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new bluemix service instances API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for bluemix service instances API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + BluemixServiceInstanceGet(params *BluemixServiceInstanceGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*BluemixServiceInstanceGetOK, error) + + BluemixServiceInstancePut(params *BluemixServiceInstancePutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*BluemixServiceInstancePutOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + BluemixServiceInstanceGet gets the current state information associated with the service instance +*/ +func (a *Client) BluemixServiceInstanceGet(params *BluemixServiceInstanceGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*BluemixServiceInstanceGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewBluemixServiceInstanceGetParams() + } + op := &runtime.ClientOperation{ + ID: "bluemix.serviceInstance.get", + Method: "GET", + PathPattern: "/bluemix_v1/service_instances/{instance_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &BluemixServiceInstanceGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*BluemixServiceInstanceGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for bluemix.serviceInstance.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + BluemixServiceInstancePut updates disable or enable the state of a provisioned service instance +*/ +func (a *Client) BluemixServiceInstancePut(params *BluemixServiceInstancePutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*BluemixServiceInstancePutOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewBluemixServiceInstancePutParams() + } + op := &runtime.ClientOperation{ + ID: "bluemix.serviceInstance.put", + Method: "PUT", + PathPattern: "/bluemix_v1/service_instances/{instance_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &BluemixServiceInstancePutReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*BluemixServiceInstancePutOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for bluemix.serviceInstance.put: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/catalog/catalog_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/catalog/catalog_client.go new file mode 100644 index 00000000000..265b7dfec29 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/catalog/catalog_client.go @@ -0,0 +1,80 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package catalog + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new catalog API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for catalog API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + CatalogGet(params *CatalogGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CatalogGetOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + CatalogGet gets the catalog of services that the service broker offers +*/ +func (a *Client) CatalogGet(params *CatalogGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CatalogGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewCatalogGetParams() + } + op := &runtime.ClientOperation{ + ID: "catalog.get", + Method: "GET", + PathPattern: "/v2/catalog", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &CatalogGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*CatalogGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for catalog.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/catalog/catalog_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/catalog/catalog_get_parameters.go new file mode 100644 index 00000000000..5f11d0a1ac5 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/catalog/catalog_get_parameters.go @@ -0,0 +1,149 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package catalog + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewCatalogGetParams creates a new CatalogGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewCatalogGetParams() *CatalogGetParams { + return &CatalogGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewCatalogGetParamsWithTimeout creates a new CatalogGetParams object +// with the ability to set a timeout on a request. +func NewCatalogGetParamsWithTimeout(timeout time.Duration) *CatalogGetParams { + return &CatalogGetParams{ + timeout: timeout, + } +} + +// NewCatalogGetParamsWithContext creates a new CatalogGetParams object +// with the ability to set a context for a request. +func NewCatalogGetParamsWithContext(ctx context.Context) *CatalogGetParams { + return &CatalogGetParams{ + Context: ctx, + } +} + +// NewCatalogGetParamsWithHTTPClient creates a new CatalogGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewCatalogGetParamsWithHTTPClient(client *http.Client) *CatalogGetParams { + return &CatalogGetParams{ + HTTPClient: client, + } +} + +/* CatalogGetParams contains all the parameters to send to the API endpoint + for the catalog get operation. + + Typically these are written to a http.Request. +*/ +type CatalogGetParams struct { + + /* XBrokerAPIVersion. + + version number of the Service Broker API that the Platform will use + */ + XBrokerAPIVersion string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the catalog get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CatalogGetParams) WithDefaults() *CatalogGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the catalog get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CatalogGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the catalog get params +func (o *CatalogGetParams) WithTimeout(timeout time.Duration) *CatalogGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the catalog get params +func (o *CatalogGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the catalog get params +func (o *CatalogGetParams) WithContext(ctx context.Context) *CatalogGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the catalog get params +func (o *CatalogGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the catalog get params +func (o *CatalogGetParams) WithHTTPClient(client *http.Client) *CatalogGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the catalog get params +func (o *CatalogGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXBrokerAPIVersion adds the xBrokerAPIVersion to the catalog get params +func (o *CatalogGetParams) WithXBrokerAPIVersion(xBrokerAPIVersion string) *CatalogGetParams { + o.SetXBrokerAPIVersion(xBrokerAPIVersion) + return o +} + +// SetXBrokerAPIVersion adds the xBrokerApiVersion to the catalog get params +func (o *CatalogGetParams) SetXBrokerAPIVersion(xBrokerAPIVersion string) { + o.XBrokerAPIVersion = xBrokerAPIVersion +} + +// WriteToRequest writes these params to a swagger request +func (o *CatalogGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // header param X-Broker-API-Version + if err := r.SetHeaderParam("X-Broker-API-Version", o.XBrokerAPIVersion); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/catalog/catalog_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/catalog/catalog_get_responses.go new file mode 100644 index 00000000000..448d665f886 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/catalog/catalog_get_responses.go @@ -0,0 +1,67 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package catalog + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// CatalogGetReader is a Reader for the CatalogGet structure. +type CatalogGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *CatalogGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewCatalogGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewCatalogGetOK creates a CatalogGetOK with default headers values +func NewCatalogGetOK() *CatalogGetOK { + return &CatalogGetOK{} +} + +/* CatalogGetOK describes a response with status code 200, with default header values. + +catalog response +*/ +type CatalogGetOK struct { + Payload *models.Catalog +} + +func (o *CatalogGetOK) Error() string { + return fmt.Sprintf("[GET /v2/catalog][%d] catalogGetOK %+v", 200, o.Payload) +} +func (o *CatalogGetOK) GetPayload() *models.Catalog { + return o.Payload +} + +func (o *CatalogGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Catalog) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/hardware_platforms/hardware_platforms_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/hardware_platforms/hardware_platforms_client.go new file mode 100644 index 00000000000..0cb215ec15d --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/hardware_platforms/hardware_platforms_client.go @@ -0,0 +1,79 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package hardware_platforms + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new hardware platforms API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for hardware platforms API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + ServiceBrokerHardwareplatformsGet(params *ServiceBrokerHardwareplatformsGetParams, opts ...ClientOption) (*ServiceBrokerHardwareplatformsGetOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + ServiceBrokerHardwareplatformsGet availables hardware statistics and limits +*/ +func (a *Client) ServiceBrokerHardwareplatformsGet(params *ServiceBrokerHardwareplatformsGetParams, opts ...ClientOption) (*ServiceBrokerHardwareplatformsGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewServiceBrokerHardwareplatformsGetParams() + } + op := &runtime.ClientOperation{ + ID: "serviceBroker.hardwareplatforms.get", + Method: "GET", + PathPattern: "/broker/v1/hardware-platforms", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ServiceBrokerHardwareplatformsGetReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ServiceBrokerHardwareplatformsGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for serviceBroker.hardwareplatforms.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/hardware_platforms/service_broker_hardwareplatforms_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/hardware_platforms/service_broker_hardwareplatforms_get_parameters.go new file mode 100644 index 00000000000..53c6aee7321 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/hardware_platforms/service_broker_hardwareplatforms_get_parameters.go @@ -0,0 +1,161 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package hardware_platforms + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewServiceBrokerHardwareplatformsGetParams creates a new ServiceBrokerHardwareplatformsGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewServiceBrokerHardwareplatformsGetParams() *ServiceBrokerHardwareplatformsGetParams { + return &ServiceBrokerHardwareplatformsGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewServiceBrokerHardwareplatformsGetParamsWithTimeout creates a new ServiceBrokerHardwareplatformsGetParams object +// with the ability to set a timeout on a request. +func NewServiceBrokerHardwareplatformsGetParamsWithTimeout(timeout time.Duration) *ServiceBrokerHardwareplatformsGetParams { + return &ServiceBrokerHardwareplatformsGetParams{ + timeout: timeout, + } +} + +// NewServiceBrokerHardwareplatformsGetParamsWithContext creates a new ServiceBrokerHardwareplatformsGetParams object +// with the ability to set a context for a request. +func NewServiceBrokerHardwareplatformsGetParamsWithContext(ctx context.Context) *ServiceBrokerHardwareplatformsGetParams { + return &ServiceBrokerHardwareplatformsGetParams{ + Context: ctx, + } +} + +// NewServiceBrokerHardwareplatformsGetParamsWithHTTPClient creates a new ServiceBrokerHardwareplatformsGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewServiceBrokerHardwareplatformsGetParamsWithHTTPClient(client *http.Client) *ServiceBrokerHardwareplatformsGetParams { + return &ServiceBrokerHardwareplatformsGetParams{ + HTTPClient: client, + } +} + +/* ServiceBrokerHardwareplatformsGetParams contains all the parameters to send to the API endpoint + for the service broker hardwareplatforms get operation. + + Typically these are written to a http.Request. +*/ +type ServiceBrokerHardwareplatformsGetParams struct { + + /* RegionZone. + + The region zone of the cloud instance + */ + RegionZone *string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the service broker hardwareplatforms get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerHardwareplatformsGetParams) WithDefaults() *ServiceBrokerHardwareplatformsGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the service broker hardwareplatforms get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerHardwareplatformsGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the service broker hardwareplatforms get params +func (o *ServiceBrokerHardwareplatformsGetParams) WithTimeout(timeout time.Duration) *ServiceBrokerHardwareplatformsGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the service broker hardwareplatforms get params +func (o *ServiceBrokerHardwareplatformsGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the service broker hardwareplatforms get params +func (o *ServiceBrokerHardwareplatformsGetParams) WithContext(ctx context.Context) *ServiceBrokerHardwareplatformsGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the service broker hardwareplatforms get params +func (o *ServiceBrokerHardwareplatformsGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the service broker hardwareplatforms get params +func (o *ServiceBrokerHardwareplatformsGetParams) WithHTTPClient(client *http.Client) *ServiceBrokerHardwareplatformsGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the service broker hardwareplatforms get params +func (o *ServiceBrokerHardwareplatformsGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithRegionZone adds the regionZone to the service broker hardwareplatforms get params +func (o *ServiceBrokerHardwareplatformsGetParams) WithRegionZone(regionZone *string) *ServiceBrokerHardwareplatformsGetParams { + o.SetRegionZone(regionZone) + return o +} + +// SetRegionZone adds the regionZone to the service broker hardwareplatforms get params +func (o *ServiceBrokerHardwareplatformsGetParams) SetRegionZone(regionZone *string) { + o.RegionZone = regionZone +} + +// WriteToRequest writes these params to a swagger request +func (o *ServiceBrokerHardwareplatformsGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.RegionZone != nil { + + // query param regionZone + var qrRegionZone string + + if o.RegionZone != nil { + qrRegionZone = *o.RegionZone + } + qRegionZone := qrRegionZone + if qRegionZone != "" { + + if err := r.SetQueryParam("regionZone", qRegionZone); err != nil { + return err + } + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/hardware_platforms/service_broker_hardwareplatforms_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/hardware_platforms/service_broker_hardwareplatforms_get_responses.go new file mode 100644 index 00000000000..41e79c37ccc --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/hardware_platforms/service_broker_hardwareplatforms_get_responses.go @@ -0,0 +1,103 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package hardware_platforms + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// ServiceBrokerHardwareplatformsGetReader is a Reader for the ServiceBrokerHardwareplatformsGet structure. +type ServiceBrokerHardwareplatformsGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ServiceBrokerHardwareplatformsGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewServiceBrokerHardwareplatformsGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 500: + result := NewServiceBrokerHardwareplatformsGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewServiceBrokerHardwareplatformsGetOK creates a ServiceBrokerHardwareplatformsGetOK with default headers values +func NewServiceBrokerHardwareplatformsGetOK() *ServiceBrokerHardwareplatformsGetOK { + return &ServiceBrokerHardwareplatformsGetOK{} +} + +/* ServiceBrokerHardwareplatformsGetOK describes a response with status code 200, with default header values. + +OK +*/ +type ServiceBrokerHardwareplatformsGetOK struct { + Payload models.HardwarePlatforms +} + +func (o *ServiceBrokerHardwareplatformsGetOK) Error() string { + return fmt.Sprintf("[GET /broker/v1/hardware-platforms][%d] serviceBrokerHardwareplatformsGetOK %+v", 200, o.Payload) +} +func (o *ServiceBrokerHardwareplatformsGetOK) GetPayload() models.HardwarePlatforms { + return o.Payload +} + +func (o *ServiceBrokerHardwareplatformsGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerHardwareplatformsGetInternalServerError creates a ServiceBrokerHardwareplatformsGetInternalServerError with default headers values +func NewServiceBrokerHardwareplatformsGetInternalServerError() *ServiceBrokerHardwareplatformsGetInternalServerError { + return &ServiceBrokerHardwareplatformsGetInternalServerError{} +} + +/* ServiceBrokerHardwareplatformsGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type ServiceBrokerHardwareplatformsGetInternalServerError struct { + Payload *models.Error +} + +func (o *ServiceBrokerHardwareplatformsGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /broker/v1/hardware-platforms][%d] serviceBrokerHardwareplatformsGetInternalServerError %+v", 500, o.Payload) +} +func (o *ServiceBrokerHardwareplatformsGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerHardwareplatformsGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/iaas_service_broker/iaas_service_broker_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/iaas_service_broker/iaas_service_broker_client.go new file mode 100644 index 00000000000..fee72986f6b --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/iaas_service_broker/iaas_service_broker_client.go @@ -0,0 +1,200 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package iaas_service_broker + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new iaas service broker API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for iaas service broker API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + ServiceBrokerHealth(params *ServiceBrokerHealthParams, opts ...ClientOption) (*ServiceBrokerHealthOK, error) + + ServiceBrokerHealthHead(params *ServiceBrokerHealthHeadParams, opts ...ClientOption) (*ServiceBrokerHealthHeadOK, error) + + ServiceBrokerTestTimeout(params *ServiceBrokerTestTimeoutParams, opts ...ClientOption) (*ServiceBrokerTestTimeoutOK, error) + + ServiceBrokerVersion(params *ServiceBrokerVersionParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceBrokerVersionOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + ServiceBrokerHealth gets current server health +*/ +func (a *Client) ServiceBrokerHealth(params *ServiceBrokerHealthParams, opts ...ClientOption) (*ServiceBrokerHealthOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewServiceBrokerHealthParams() + } + op := &runtime.ClientOperation{ + ID: "serviceBroker.health", + Method: "GET", + PathPattern: "/broker/v1/health", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ServiceBrokerHealthReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ServiceBrokerHealthOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for serviceBroker.health: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + ServiceBrokerHealthHead gets current server health +*/ +func (a *Client) ServiceBrokerHealthHead(params *ServiceBrokerHealthHeadParams, opts ...ClientOption) (*ServiceBrokerHealthHeadOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewServiceBrokerHealthHeadParams() + } + op := &runtime.ClientOperation{ + ID: "serviceBroker.health.head", + Method: "HEAD", + PathPattern: "/broker/v1/health", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ServiceBrokerHealthHeadReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ServiceBrokerHealthHeadOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for serviceBroker.health.head: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + ServiceBrokerTestTimeout gets current server version +*/ +func (a *Client) ServiceBrokerTestTimeout(params *ServiceBrokerTestTimeoutParams, opts ...ClientOption) (*ServiceBrokerTestTimeoutOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewServiceBrokerTestTimeoutParams() + } + op := &runtime.ClientOperation{ + ID: "serviceBroker.test.timeout", + Method: "GET", + PathPattern: "/broker/v1/test/timeout", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ServiceBrokerTestTimeoutReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ServiceBrokerTestTimeoutOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for serviceBroker.test.timeout: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + ServiceBrokerVersion gets current server version +*/ +func (a *Client) ServiceBrokerVersion(params *ServiceBrokerVersionParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceBrokerVersionOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewServiceBrokerVersionParams() + } + op := &runtime.ClientOperation{ + ID: "serviceBroker.version", + Method: "GET", + PathPattern: "/broker/v1/version", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ServiceBrokerVersionReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ServiceBrokerVersionOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for serviceBroker.version: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/iaas_service_broker/service_broker_health_head_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/iaas_service_broker/service_broker_health_head_parameters.go new file mode 100644 index 00000000000..04086695929 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/iaas_service_broker/service_broker_health_head_parameters.go @@ -0,0 +1,126 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package iaas_service_broker + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewServiceBrokerHealthHeadParams creates a new ServiceBrokerHealthHeadParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewServiceBrokerHealthHeadParams() *ServiceBrokerHealthHeadParams { + return &ServiceBrokerHealthHeadParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewServiceBrokerHealthHeadParamsWithTimeout creates a new ServiceBrokerHealthHeadParams object +// with the ability to set a timeout on a request. +func NewServiceBrokerHealthHeadParamsWithTimeout(timeout time.Duration) *ServiceBrokerHealthHeadParams { + return &ServiceBrokerHealthHeadParams{ + timeout: timeout, + } +} + +// NewServiceBrokerHealthHeadParamsWithContext creates a new ServiceBrokerHealthHeadParams object +// with the ability to set a context for a request. +func NewServiceBrokerHealthHeadParamsWithContext(ctx context.Context) *ServiceBrokerHealthHeadParams { + return &ServiceBrokerHealthHeadParams{ + Context: ctx, + } +} + +// NewServiceBrokerHealthHeadParamsWithHTTPClient creates a new ServiceBrokerHealthHeadParams object +// with the ability to set a custom HTTPClient for a request. +func NewServiceBrokerHealthHeadParamsWithHTTPClient(client *http.Client) *ServiceBrokerHealthHeadParams { + return &ServiceBrokerHealthHeadParams{ + HTTPClient: client, + } +} + +/* ServiceBrokerHealthHeadParams contains all the parameters to send to the API endpoint + for the service broker health head operation. + + Typically these are written to a http.Request. +*/ +type ServiceBrokerHealthHeadParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the service broker health head params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerHealthHeadParams) WithDefaults() *ServiceBrokerHealthHeadParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the service broker health head params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerHealthHeadParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the service broker health head params +func (o *ServiceBrokerHealthHeadParams) WithTimeout(timeout time.Duration) *ServiceBrokerHealthHeadParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the service broker health head params +func (o *ServiceBrokerHealthHeadParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the service broker health head params +func (o *ServiceBrokerHealthHeadParams) WithContext(ctx context.Context) *ServiceBrokerHealthHeadParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the service broker health head params +func (o *ServiceBrokerHealthHeadParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the service broker health head params +func (o *ServiceBrokerHealthHeadParams) WithHTTPClient(client *http.Client) *ServiceBrokerHealthHeadParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the service broker health head params +func (o *ServiceBrokerHealthHeadParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *ServiceBrokerHealthHeadParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/iaas_service_broker/service_broker_health_head_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/iaas_service_broker/service_broker_health_head_responses.go new file mode 100644 index 00000000000..3af3bd54575 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/iaas_service_broker/service_broker_health_head_responses.go @@ -0,0 +1,105 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package iaas_service_broker + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// ServiceBrokerHealthHeadReader is a Reader for the ServiceBrokerHealthHead structure. +type ServiceBrokerHealthHeadReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ServiceBrokerHealthHeadReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewServiceBrokerHealthHeadOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewServiceBrokerHealthHeadBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewServiceBrokerHealthHeadOK creates a ServiceBrokerHealthHeadOK with default headers values +func NewServiceBrokerHealthHeadOK() *ServiceBrokerHealthHeadOK { + return &ServiceBrokerHealthHeadOK{} +} + +/* ServiceBrokerHealthHeadOK describes a response with status code 200, with default header values. + +OK +*/ +type ServiceBrokerHealthHeadOK struct { + Payload *models.Health +} + +func (o *ServiceBrokerHealthHeadOK) Error() string { + return fmt.Sprintf("[HEAD /broker/v1/health][%d] serviceBrokerHealthHeadOK %+v", 200, o.Payload) +} +func (o *ServiceBrokerHealthHeadOK) GetPayload() *models.Health { + return o.Payload +} + +func (o *ServiceBrokerHealthHeadOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Health) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerHealthHeadBadRequest creates a ServiceBrokerHealthHeadBadRequest with default headers values +func NewServiceBrokerHealthHeadBadRequest() *ServiceBrokerHealthHeadBadRequest { + return &ServiceBrokerHealthHeadBadRequest{} +} + +/* ServiceBrokerHealthHeadBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type ServiceBrokerHealthHeadBadRequest struct { + Payload *models.Error +} + +func (o *ServiceBrokerHealthHeadBadRequest) Error() string { + return fmt.Sprintf("[HEAD /broker/v1/health][%d] serviceBrokerHealthHeadBadRequest %+v", 400, o.Payload) +} +func (o *ServiceBrokerHealthHeadBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerHealthHeadBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/iaas_service_broker/service_broker_health_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/iaas_service_broker/service_broker_health_parameters.go new file mode 100644 index 00000000000..bed2ea2fcab --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/iaas_service_broker/service_broker_health_parameters.go @@ -0,0 +1,126 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package iaas_service_broker + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewServiceBrokerHealthParams creates a new ServiceBrokerHealthParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewServiceBrokerHealthParams() *ServiceBrokerHealthParams { + return &ServiceBrokerHealthParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewServiceBrokerHealthParamsWithTimeout creates a new ServiceBrokerHealthParams object +// with the ability to set a timeout on a request. +func NewServiceBrokerHealthParamsWithTimeout(timeout time.Duration) *ServiceBrokerHealthParams { + return &ServiceBrokerHealthParams{ + timeout: timeout, + } +} + +// NewServiceBrokerHealthParamsWithContext creates a new ServiceBrokerHealthParams object +// with the ability to set a context for a request. +func NewServiceBrokerHealthParamsWithContext(ctx context.Context) *ServiceBrokerHealthParams { + return &ServiceBrokerHealthParams{ + Context: ctx, + } +} + +// NewServiceBrokerHealthParamsWithHTTPClient creates a new ServiceBrokerHealthParams object +// with the ability to set a custom HTTPClient for a request. +func NewServiceBrokerHealthParamsWithHTTPClient(client *http.Client) *ServiceBrokerHealthParams { + return &ServiceBrokerHealthParams{ + HTTPClient: client, + } +} + +/* ServiceBrokerHealthParams contains all the parameters to send to the API endpoint + for the service broker health operation. + + Typically these are written to a http.Request. +*/ +type ServiceBrokerHealthParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the service broker health params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerHealthParams) WithDefaults() *ServiceBrokerHealthParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the service broker health params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerHealthParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the service broker health params +func (o *ServiceBrokerHealthParams) WithTimeout(timeout time.Duration) *ServiceBrokerHealthParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the service broker health params +func (o *ServiceBrokerHealthParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the service broker health params +func (o *ServiceBrokerHealthParams) WithContext(ctx context.Context) *ServiceBrokerHealthParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the service broker health params +func (o *ServiceBrokerHealthParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the service broker health params +func (o *ServiceBrokerHealthParams) WithHTTPClient(client *http.Client) *ServiceBrokerHealthParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the service broker health params +func (o *ServiceBrokerHealthParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *ServiceBrokerHealthParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/iaas_service_broker/service_broker_health_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/iaas_service_broker/service_broker_health_responses.go new file mode 100644 index 00000000000..9ad3dd6b5d9 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/iaas_service_broker/service_broker_health_responses.go @@ -0,0 +1,105 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package iaas_service_broker + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// ServiceBrokerHealthReader is a Reader for the ServiceBrokerHealth structure. +type ServiceBrokerHealthReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ServiceBrokerHealthReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewServiceBrokerHealthOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewServiceBrokerHealthBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewServiceBrokerHealthOK creates a ServiceBrokerHealthOK with default headers values +func NewServiceBrokerHealthOK() *ServiceBrokerHealthOK { + return &ServiceBrokerHealthOK{} +} + +/* ServiceBrokerHealthOK describes a response with status code 200, with default header values. + +OK +*/ +type ServiceBrokerHealthOK struct { + Payload *models.Health +} + +func (o *ServiceBrokerHealthOK) Error() string { + return fmt.Sprintf("[GET /broker/v1/health][%d] serviceBrokerHealthOK %+v", 200, o.Payload) +} +func (o *ServiceBrokerHealthOK) GetPayload() *models.Health { + return o.Payload +} + +func (o *ServiceBrokerHealthOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Health) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerHealthBadRequest creates a ServiceBrokerHealthBadRequest with default headers values +func NewServiceBrokerHealthBadRequest() *ServiceBrokerHealthBadRequest { + return &ServiceBrokerHealthBadRequest{} +} + +/* ServiceBrokerHealthBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type ServiceBrokerHealthBadRequest struct { + Payload *models.Error +} + +func (o *ServiceBrokerHealthBadRequest) Error() string { + return fmt.Sprintf("[GET /broker/v1/health][%d] serviceBrokerHealthBadRequest %+v", 400, o.Payload) +} +func (o *ServiceBrokerHealthBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerHealthBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/iaas_service_broker/service_broker_test_timeout_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/iaas_service_broker/service_broker_test_timeout_parameters.go new file mode 100644 index 00000000000..aec4dc2a330 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/iaas_service_broker/service_broker_test_timeout_parameters.go @@ -0,0 +1,155 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package iaas_service_broker + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewServiceBrokerTestTimeoutParams creates a new ServiceBrokerTestTimeoutParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewServiceBrokerTestTimeoutParams() *ServiceBrokerTestTimeoutParams { + return &ServiceBrokerTestTimeoutParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewServiceBrokerTestTimeoutParamsWithTimeout creates a new ServiceBrokerTestTimeoutParams object +// with the ability to set a timeout on a request. +func NewServiceBrokerTestTimeoutParamsWithTimeout(timeout time.Duration) *ServiceBrokerTestTimeoutParams { + return &ServiceBrokerTestTimeoutParams{ + timeout: timeout, + } +} + +// NewServiceBrokerTestTimeoutParamsWithContext creates a new ServiceBrokerTestTimeoutParams object +// with the ability to set a context for a request. +func NewServiceBrokerTestTimeoutParamsWithContext(ctx context.Context) *ServiceBrokerTestTimeoutParams { + return &ServiceBrokerTestTimeoutParams{ + Context: ctx, + } +} + +// NewServiceBrokerTestTimeoutParamsWithHTTPClient creates a new ServiceBrokerTestTimeoutParams object +// with the ability to set a custom HTTPClient for a request. +func NewServiceBrokerTestTimeoutParamsWithHTTPClient(client *http.Client) *ServiceBrokerTestTimeoutParams { + return &ServiceBrokerTestTimeoutParams{ + HTTPClient: client, + } +} + +/* ServiceBrokerTestTimeoutParams contains all the parameters to send to the API endpoint + for the service broker test timeout operation. + + Typically these are written to a http.Request. +*/ +type ServiceBrokerTestTimeoutParams struct { + + /* T. + + seconds + */ + T int64 + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the service broker test timeout params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerTestTimeoutParams) WithDefaults() *ServiceBrokerTestTimeoutParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the service broker test timeout params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerTestTimeoutParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the service broker test timeout params +func (o *ServiceBrokerTestTimeoutParams) WithTimeout(timeout time.Duration) *ServiceBrokerTestTimeoutParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the service broker test timeout params +func (o *ServiceBrokerTestTimeoutParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the service broker test timeout params +func (o *ServiceBrokerTestTimeoutParams) WithContext(ctx context.Context) *ServiceBrokerTestTimeoutParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the service broker test timeout params +func (o *ServiceBrokerTestTimeoutParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the service broker test timeout params +func (o *ServiceBrokerTestTimeoutParams) WithHTTPClient(client *http.Client) *ServiceBrokerTestTimeoutParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the service broker test timeout params +func (o *ServiceBrokerTestTimeoutParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithT adds the t to the service broker test timeout params +func (o *ServiceBrokerTestTimeoutParams) WithT(t int64) *ServiceBrokerTestTimeoutParams { + o.SetT(t) + return o +} + +// SetT adds the t to the service broker test timeout params +func (o *ServiceBrokerTestTimeoutParams) SetT(t int64) { + o.T = t +} + +// WriteToRequest writes these params to a swagger request +func (o *ServiceBrokerTestTimeoutParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // query param t + qrT := o.T + qT := swag.FormatInt64(qrT) + if qT != "" { + + if err := r.SetQueryParam("t", qT); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/iaas_service_broker/service_broker_test_timeout_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/iaas_service_broker/service_broker_test_timeout_responses.go new file mode 100644 index 00000000000..4aee22ea56b --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/iaas_service_broker/service_broker_test_timeout_responses.go @@ -0,0 +1,65 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package iaas_service_broker + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// ServiceBrokerTestTimeoutReader is a Reader for the ServiceBrokerTestTimeout structure. +type ServiceBrokerTestTimeoutReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ServiceBrokerTestTimeoutReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewServiceBrokerTestTimeoutOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewServiceBrokerTestTimeoutOK creates a ServiceBrokerTestTimeoutOK with default headers values +func NewServiceBrokerTestTimeoutOK() *ServiceBrokerTestTimeoutOK { + return &ServiceBrokerTestTimeoutOK{} +} + +/* ServiceBrokerTestTimeoutOK describes a response with status code 200, with default header values. + +OK +*/ +type ServiceBrokerTestTimeoutOK struct { + Payload models.Object +} + +func (o *ServiceBrokerTestTimeoutOK) Error() string { + return fmt.Sprintf("[GET /broker/v1/test/timeout][%d] serviceBrokerTestTimeoutOK %+v", 200, o.Payload) +} +func (o *ServiceBrokerTestTimeoutOK) GetPayload() models.Object { + return o.Payload +} + +func (o *ServiceBrokerTestTimeoutOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/iaas_service_broker/service_broker_version_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/iaas_service_broker/service_broker_version_parameters.go new file mode 100644 index 00000000000..6afbe895cfe --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/iaas_service_broker/service_broker_version_parameters.go @@ -0,0 +1,126 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package iaas_service_broker + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewServiceBrokerVersionParams creates a new ServiceBrokerVersionParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewServiceBrokerVersionParams() *ServiceBrokerVersionParams { + return &ServiceBrokerVersionParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewServiceBrokerVersionParamsWithTimeout creates a new ServiceBrokerVersionParams object +// with the ability to set a timeout on a request. +func NewServiceBrokerVersionParamsWithTimeout(timeout time.Duration) *ServiceBrokerVersionParams { + return &ServiceBrokerVersionParams{ + timeout: timeout, + } +} + +// NewServiceBrokerVersionParamsWithContext creates a new ServiceBrokerVersionParams object +// with the ability to set a context for a request. +func NewServiceBrokerVersionParamsWithContext(ctx context.Context) *ServiceBrokerVersionParams { + return &ServiceBrokerVersionParams{ + Context: ctx, + } +} + +// NewServiceBrokerVersionParamsWithHTTPClient creates a new ServiceBrokerVersionParams object +// with the ability to set a custom HTTPClient for a request. +func NewServiceBrokerVersionParamsWithHTTPClient(client *http.Client) *ServiceBrokerVersionParams { + return &ServiceBrokerVersionParams{ + HTTPClient: client, + } +} + +/* ServiceBrokerVersionParams contains all the parameters to send to the API endpoint + for the service broker version operation. + + Typically these are written to a http.Request. +*/ +type ServiceBrokerVersionParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the service broker version params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerVersionParams) WithDefaults() *ServiceBrokerVersionParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the service broker version params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerVersionParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the service broker version params +func (o *ServiceBrokerVersionParams) WithTimeout(timeout time.Duration) *ServiceBrokerVersionParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the service broker version params +func (o *ServiceBrokerVersionParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the service broker version params +func (o *ServiceBrokerVersionParams) WithContext(ctx context.Context) *ServiceBrokerVersionParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the service broker version params +func (o *ServiceBrokerVersionParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the service broker version params +func (o *ServiceBrokerVersionParams) WithHTTPClient(client *http.Client) *ServiceBrokerVersionParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the service broker version params +func (o *ServiceBrokerVersionParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *ServiceBrokerVersionParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/iaas_service_broker/service_broker_version_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/iaas_service_broker/service_broker_version_responses.go new file mode 100644 index 00000000000..85c8fc176c3 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/iaas_service_broker/service_broker_version_responses.go @@ -0,0 +1,105 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package iaas_service_broker + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// ServiceBrokerVersionReader is a Reader for the ServiceBrokerVersion structure. +type ServiceBrokerVersionReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ServiceBrokerVersionReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewServiceBrokerVersionOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewServiceBrokerVersionBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewServiceBrokerVersionOK creates a ServiceBrokerVersionOK with default headers values +func NewServiceBrokerVersionOK() *ServiceBrokerVersionOK { + return &ServiceBrokerVersionOK{} +} + +/* ServiceBrokerVersionOK describes a response with status code 200, with default header values. + +OK +*/ +type ServiceBrokerVersionOK struct { + Payload *models.Version +} + +func (o *ServiceBrokerVersionOK) Error() string { + return fmt.Sprintf("[GET /broker/v1/version][%d] serviceBrokerVersionOK %+v", 200, o.Payload) +} +func (o *ServiceBrokerVersionOK) GetPayload() *models.Version { + return o.Payload +} + +func (o *ServiceBrokerVersionOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Version) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerVersionBadRequest creates a ServiceBrokerVersionBadRequest with default headers values +func NewServiceBrokerVersionBadRequest() *ServiceBrokerVersionBadRequest { + return &ServiceBrokerVersionBadRequest{} +} + +/* ServiceBrokerVersionBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type ServiceBrokerVersionBadRequest struct { + Payload *models.Error +} + +func (o *ServiceBrokerVersionBadRequest) Error() string { + return fmt.Sprintf("[GET /broker/v1/version][%d] serviceBrokerVersionBadRequest %+v", 400, o.Payload) +} +func (o *ServiceBrokerVersionBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerVersionBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_storage_regions_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_storage_regions_client.go new file mode 100644 index 00000000000..eb44b6d75aa --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_storage_regions_client.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package internal_storage_regions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new internal storage regions API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for internal storage regions API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + InternalV1StorageRegionsStoragePoolsGet(params *InternalV1StorageRegionsStoragePoolsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*InternalV1StorageRegionsStoragePoolsGetOK, error) + + InternalV1StorageRegionsStoragePoolsGetall(params *InternalV1StorageRegionsStoragePoolsGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*InternalV1StorageRegionsStoragePoolsGetallOK, error) + + InternalV1StorageRegionsStoragePoolsPut(params *InternalV1StorageRegionsStoragePoolsPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*InternalV1StorageRegionsStoragePoolsPutOK, error) + + InternalV1StorageRegionsThresholdsGet(params *InternalV1StorageRegionsThresholdsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*InternalV1StorageRegionsThresholdsGetOK, error) + + InternalV1StorageRegionsThresholdsPut(params *InternalV1StorageRegionsThresholdsPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*InternalV1StorageRegionsThresholdsPutAccepted, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + InternalV1StorageRegionsStoragePoolsGet gets the settings for given pool name +*/ +func (a *Client) InternalV1StorageRegionsStoragePoolsGet(params *InternalV1StorageRegionsStoragePoolsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*InternalV1StorageRegionsStoragePoolsGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewInternalV1StorageRegionsStoragePoolsGetParams() + } + op := &runtime.ClientOperation{ + ID: "internal.v1.storage.regions.storage-pools.get", + Method: "GET", + PathPattern: "/internal/v1/storage/regions/{region_zone_id}/storage-pools/{storage_pool_name}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &InternalV1StorageRegionsStoragePoolsGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*InternalV1StorageRegionsStoragePoolsGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for internal.v1.storage.regions.storage-pools.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + InternalV1StorageRegionsStoragePoolsGetall gets the current storage pools settings for a region zone +*/ +func (a *Client) InternalV1StorageRegionsStoragePoolsGetall(params *InternalV1StorageRegionsStoragePoolsGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*InternalV1StorageRegionsStoragePoolsGetallOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewInternalV1StorageRegionsStoragePoolsGetallParams() + } + op := &runtime.ClientOperation{ + ID: "internal.v1.storage.regions.storage-pools.getall", + Method: "GET", + PathPattern: "/internal/v1/storage/regions/{region_zone_id}/storage-pools", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &InternalV1StorageRegionsStoragePoolsGetallReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*InternalV1StorageRegionsStoragePoolsGetallOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for internal.v1.storage.regions.storage-pools.getall: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + InternalV1StorageRegionsStoragePoolsPut updates the settings for given pool name +*/ +func (a *Client) InternalV1StorageRegionsStoragePoolsPut(params *InternalV1StorageRegionsStoragePoolsPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*InternalV1StorageRegionsStoragePoolsPutOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewInternalV1StorageRegionsStoragePoolsPutParams() + } + op := &runtime.ClientOperation{ + ID: "internal.v1.storage.regions.storage-pools.put", + Method: "PUT", + PathPattern: "/internal/v1/storage/regions/{region_zone_id}/storage-pools/{storage_pool_name}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &InternalV1StorageRegionsStoragePoolsPutReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*InternalV1StorageRegionsStoragePoolsPutOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for internal.v1.storage.regions.storage-pools.put: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + InternalV1StorageRegionsThresholdsGet gets the current default threshold settings for a region zone +*/ +func (a *Client) InternalV1StorageRegionsThresholdsGet(params *InternalV1StorageRegionsThresholdsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*InternalV1StorageRegionsThresholdsGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewInternalV1StorageRegionsThresholdsGetParams() + } + op := &runtime.ClientOperation{ + ID: "internal.v1.storage.regions.thresholds.get", + Method: "GET", + PathPattern: "/internal/v1/storage/regions/{region_zone_id}/thresholds", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &InternalV1StorageRegionsThresholdsGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*InternalV1StorageRegionsThresholdsGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for internal.v1.storage.regions.thresholds.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + InternalV1StorageRegionsThresholdsPut updates a default threshold setting for a region zone +*/ +func (a *Client) InternalV1StorageRegionsThresholdsPut(params *InternalV1StorageRegionsThresholdsPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*InternalV1StorageRegionsThresholdsPutAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewInternalV1StorageRegionsThresholdsPutParams() + } + op := &runtime.ClientOperation{ + ID: "internal.v1.storage.regions.thresholds.put", + Method: "PUT", + PathPattern: "/internal/v1/storage/regions/{region_zone_id}/thresholds", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &InternalV1StorageRegionsThresholdsPutReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*InternalV1StorageRegionsThresholdsPutAccepted) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for internal.v1.storage.regions.thresholds.put: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_v1_storage_regions_storage_pools_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_v1_storage_regions_storage_pools_get_parameters.go new file mode 100644 index 00000000000..7f5c37e4b22 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_v1_storage_regions_storage_pools_get_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package internal_storage_regions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewInternalV1StorageRegionsStoragePoolsGetParams creates a new InternalV1StorageRegionsStoragePoolsGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewInternalV1StorageRegionsStoragePoolsGetParams() *InternalV1StorageRegionsStoragePoolsGetParams { + return &InternalV1StorageRegionsStoragePoolsGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewInternalV1StorageRegionsStoragePoolsGetParamsWithTimeout creates a new InternalV1StorageRegionsStoragePoolsGetParams object +// with the ability to set a timeout on a request. +func NewInternalV1StorageRegionsStoragePoolsGetParamsWithTimeout(timeout time.Duration) *InternalV1StorageRegionsStoragePoolsGetParams { + return &InternalV1StorageRegionsStoragePoolsGetParams{ + timeout: timeout, + } +} + +// NewInternalV1StorageRegionsStoragePoolsGetParamsWithContext creates a new InternalV1StorageRegionsStoragePoolsGetParams object +// with the ability to set a context for a request. +func NewInternalV1StorageRegionsStoragePoolsGetParamsWithContext(ctx context.Context) *InternalV1StorageRegionsStoragePoolsGetParams { + return &InternalV1StorageRegionsStoragePoolsGetParams{ + Context: ctx, + } +} + +// NewInternalV1StorageRegionsStoragePoolsGetParamsWithHTTPClient creates a new InternalV1StorageRegionsStoragePoolsGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewInternalV1StorageRegionsStoragePoolsGetParamsWithHTTPClient(client *http.Client) *InternalV1StorageRegionsStoragePoolsGetParams { + return &InternalV1StorageRegionsStoragePoolsGetParams{ + HTTPClient: client, + } +} + +/* InternalV1StorageRegionsStoragePoolsGetParams contains all the parameters to send to the API endpoint + for the internal v1 storage regions storage pools get operation. + + Typically these are written to a http.Request. +*/ +type InternalV1StorageRegionsStoragePoolsGetParams struct { + + /* RegionZoneID. + + ID of a Power Cloud Region Zone + */ + RegionZoneID string + + /* StoragePoolName. + + Storage pool name + */ + StoragePoolName string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the internal v1 storage regions storage pools get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *InternalV1StorageRegionsStoragePoolsGetParams) WithDefaults() *InternalV1StorageRegionsStoragePoolsGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the internal v1 storage regions storage pools get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *InternalV1StorageRegionsStoragePoolsGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the internal v1 storage regions storage pools get params +func (o *InternalV1StorageRegionsStoragePoolsGetParams) WithTimeout(timeout time.Duration) *InternalV1StorageRegionsStoragePoolsGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the internal v1 storage regions storage pools get params +func (o *InternalV1StorageRegionsStoragePoolsGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the internal v1 storage regions storage pools get params +func (o *InternalV1StorageRegionsStoragePoolsGetParams) WithContext(ctx context.Context) *InternalV1StorageRegionsStoragePoolsGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the internal v1 storage regions storage pools get params +func (o *InternalV1StorageRegionsStoragePoolsGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the internal v1 storage regions storage pools get params +func (o *InternalV1StorageRegionsStoragePoolsGetParams) WithHTTPClient(client *http.Client) *InternalV1StorageRegionsStoragePoolsGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the internal v1 storage regions storage pools get params +func (o *InternalV1StorageRegionsStoragePoolsGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithRegionZoneID adds the regionZoneID to the internal v1 storage regions storage pools get params +func (o *InternalV1StorageRegionsStoragePoolsGetParams) WithRegionZoneID(regionZoneID string) *InternalV1StorageRegionsStoragePoolsGetParams { + o.SetRegionZoneID(regionZoneID) + return o +} + +// SetRegionZoneID adds the regionZoneId to the internal v1 storage regions storage pools get params +func (o *InternalV1StorageRegionsStoragePoolsGetParams) SetRegionZoneID(regionZoneID string) { + o.RegionZoneID = regionZoneID +} + +// WithStoragePoolName adds the storagePoolName to the internal v1 storage regions storage pools get params +func (o *InternalV1StorageRegionsStoragePoolsGetParams) WithStoragePoolName(storagePoolName string) *InternalV1StorageRegionsStoragePoolsGetParams { + o.SetStoragePoolName(storagePoolName) + return o +} + +// SetStoragePoolName adds the storagePoolName to the internal v1 storage regions storage pools get params +func (o *InternalV1StorageRegionsStoragePoolsGetParams) SetStoragePoolName(storagePoolName string) { + o.StoragePoolName = storagePoolName +} + +// WriteToRequest writes these params to a swagger request +func (o *InternalV1StorageRegionsStoragePoolsGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param region_zone_id + if err := r.SetPathParam("region_zone_id", o.RegionZoneID); err != nil { + return err + } + + // path param storage_pool_name + if err := r.SetPathParam("storage_pool_name", o.StoragePoolName); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_v1_storage_regions_storage_pools_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_v1_storage_regions_storage_pools_get_responses.go new file mode 100644 index 00000000000..4cb42f88364 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_v1_storage_regions_storage_pools_get_responses.go @@ -0,0 +1,179 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package internal_storage_regions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// InternalV1StorageRegionsStoragePoolsGetReader is a Reader for the InternalV1StorageRegionsStoragePoolsGet structure. +type InternalV1StorageRegionsStoragePoolsGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *InternalV1StorageRegionsStoragePoolsGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewInternalV1StorageRegionsStoragePoolsGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewInternalV1StorageRegionsStoragePoolsGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewInternalV1StorageRegionsStoragePoolsGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewInternalV1StorageRegionsStoragePoolsGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewInternalV1StorageRegionsStoragePoolsGetOK creates a InternalV1StorageRegionsStoragePoolsGetOK with default headers values +func NewInternalV1StorageRegionsStoragePoolsGetOK() *InternalV1StorageRegionsStoragePoolsGetOK { + return &InternalV1StorageRegionsStoragePoolsGetOK{} +} + +/* InternalV1StorageRegionsStoragePoolsGetOK describes a response with status code 200, with default header values. + +OK +*/ +type InternalV1StorageRegionsStoragePoolsGetOK struct { + Payload models.StoragePools +} + +func (o *InternalV1StorageRegionsStoragePoolsGetOK) Error() string { + return fmt.Sprintf("[GET /internal/v1/storage/regions/{region_zone_id}/storage-pools/{storage_pool_name}][%d] internalV1StorageRegionsStoragePoolsGetOK %+v", 200, o.Payload) +} +func (o *InternalV1StorageRegionsStoragePoolsGetOK) GetPayload() models.StoragePools { + return o.Payload +} + +func (o *InternalV1StorageRegionsStoragePoolsGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewInternalV1StorageRegionsStoragePoolsGetUnauthorized creates a InternalV1StorageRegionsStoragePoolsGetUnauthorized with default headers values +func NewInternalV1StorageRegionsStoragePoolsGetUnauthorized() *InternalV1StorageRegionsStoragePoolsGetUnauthorized { + return &InternalV1StorageRegionsStoragePoolsGetUnauthorized{} +} + +/* InternalV1StorageRegionsStoragePoolsGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type InternalV1StorageRegionsStoragePoolsGetUnauthorized struct { + Payload *models.Error +} + +func (o *InternalV1StorageRegionsStoragePoolsGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /internal/v1/storage/regions/{region_zone_id}/storage-pools/{storage_pool_name}][%d] internalV1StorageRegionsStoragePoolsGetUnauthorized %+v", 401, o.Payload) +} +func (o *InternalV1StorageRegionsStoragePoolsGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *InternalV1StorageRegionsStoragePoolsGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewInternalV1StorageRegionsStoragePoolsGetNotFound creates a InternalV1StorageRegionsStoragePoolsGetNotFound with default headers values +func NewInternalV1StorageRegionsStoragePoolsGetNotFound() *InternalV1StorageRegionsStoragePoolsGetNotFound { + return &InternalV1StorageRegionsStoragePoolsGetNotFound{} +} + +/* InternalV1StorageRegionsStoragePoolsGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type InternalV1StorageRegionsStoragePoolsGetNotFound struct { + Payload *models.Error +} + +func (o *InternalV1StorageRegionsStoragePoolsGetNotFound) Error() string { + return fmt.Sprintf("[GET /internal/v1/storage/regions/{region_zone_id}/storage-pools/{storage_pool_name}][%d] internalV1StorageRegionsStoragePoolsGetNotFound %+v", 404, o.Payload) +} +func (o *InternalV1StorageRegionsStoragePoolsGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *InternalV1StorageRegionsStoragePoolsGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewInternalV1StorageRegionsStoragePoolsGetInternalServerError creates a InternalV1StorageRegionsStoragePoolsGetInternalServerError with default headers values +func NewInternalV1StorageRegionsStoragePoolsGetInternalServerError() *InternalV1StorageRegionsStoragePoolsGetInternalServerError { + return &InternalV1StorageRegionsStoragePoolsGetInternalServerError{} +} + +/* InternalV1StorageRegionsStoragePoolsGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type InternalV1StorageRegionsStoragePoolsGetInternalServerError struct { + Payload *models.Error +} + +func (o *InternalV1StorageRegionsStoragePoolsGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /internal/v1/storage/regions/{region_zone_id}/storage-pools/{storage_pool_name}][%d] internalV1StorageRegionsStoragePoolsGetInternalServerError %+v", 500, o.Payload) +} +func (o *InternalV1StorageRegionsStoragePoolsGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *InternalV1StorageRegionsStoragePoolsGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_v1_storage_regions_storage_pools_getall_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_v1_storage_regions_storage_pools_getall_parameters.go new file mode 100644 index 00000000000..cda5153c50b --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_v1_storage_regions_storage_pools_getall_parameters.go @@ -0,0 +1,149 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package internal_storage_regions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewInternalV1StorageRegionsStoragePoolsGetallParams creates a new InternalV1StorageRegionsStoragePoolsGetallParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewInternalV1StorageRegionsStoragePoolsGetallParams() *InternalV1StorageRegionsStoragePoolsGetallParams { + return &InternalV1StorageRegionsStoragePoolsGetallParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewInternalV1StorageRegionsStoragePoolsGetallParamsWithTimeout creates a new InternalV1StorageRegionsStoragePoolsGetallParams object +// with the ability to set a timeout on a request. +func NewInternalV1StorageRegionsStoragePoolsGetallParamsWithTimeout(timeout time.Duration) *InternalV1StorageRegionsStoragePoolsGetallParams { + return &InternalV1StorageRegionsStoragePoolsGetallParams{ + timeout: timeout, + } +} + +// NewInternalV1StorageRegionsStoragePoolsGetallParamsWithContext creates a new InternalV1StorageRegionsStoragePoolsGetallParams object +// with the ability to set a context for a request. +func NewInternalV1StorageRegionsStoragePoolsGetallParamsWithContext(ctx context.Context) *InternalV1StorageRegionsStoragePoolsGetallParams { + return &InternalV1StorageRegionsStoragePoolsGetallParams{ + Context: ctx, + } +} + +// NewInternalV1StorageRegionsStoragePoolsGetallParamsWithHTTPClient creates a new InternalV1StorageRegionsStoragePoolsGetallParams object +// with the ability to set a custom HTTPClient for a request. +func NewInternalV1StorageRegionsStoragePoolsGetallParamsWithHTTPClient(client *http.Client) *InternalV1StorageRegionsStoragePoolsGetallParams { + return &InternalV1StorageRegionsStoragePoolsGetallParams{ + HTTPClient: client, + } +} + +/* InternalV1StorageRegionsStoragePoolsGetallParams contains all the parameters to send to the API endpoint + for the internal v1 storage regions storage pools getall operation. + + Typically these are written to a http.Request. +*/ +type InternalV1StorageRegionsStoragePoolsGetallParams struct { + + /* RegionZoneID. + + ID of a Power Cloud Region Zone + */ + RegionZoneID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the internal v1 storage regions storage pools getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *InternalV1StorageRegionsStoragePoolsGetallParams) WithDefaults() *InternalV1StorageRegionsStoragePoolsGetallParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the internal v1 storage regions storage pools getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *InternalV1StorageRegionsStoragePoolsGetallParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the internal v1 storage regions storage pools getall params +func (o *InternalV1StorageRegionsStoragePoolsGetallParams) WithTimeout(timeout time.Duration) *InternalV1StorageRegionsStoragePoolsGetallParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the internal v1 storage regions storage pools getall params +func (o *InternalV1StorageRegionsStoragePoolsGetallParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the internal v1 storage regions storage pools getall params +func (o *InternalV1StorageRegionsStoragePoolsGetallParams) WithContext(ctx context.Context) *InternalV1StorageRegionsStoragePoolsGetallParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the internal v1 storage regions storage pools getall params +func (o *InternalV1StorageRegionsStoragePoolsGetallParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the internal v1 storage regions storage pools getall params +func (o *InternalV1StorageRegionsStoragePoolsGetallParams) WithHTTPClient(client *http.Client) *InternalV1StorageRegionsStoragePoolsGetallParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the internal v1 storage regions storage pools getall params +func (o *InternalV1StorageRegionsStoragePoolsGetallParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithRegionZoneID adds the regionZoneID to the internal v1 storage regions storage pools getall params +func (o *InternalV1StorageRegionsStoragePoolsGetallParams) WithRegionZoneID(regionZoneID string) *InternalV1StorageRegionsStoragePoolsGetallParams { + o.SetRegionZoneID(regionZoneID) + return o +} + +// SetRegionZoneID adds the regionZoneId to the internal v1 storage regions storage pools getall params +func (o *InternalV1StorageRegionsStoragePoolsGetallParams) SetRegionZoneID(regionZoneID string) { + o.RegionZoneID = regionZoneID +} + +// WriteToRequest writes these params to a swagger request +func (o *InternalV1StorageRegionsStoragePoolsGetallParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param region_zone_id + if err := r.SetPathParam("region_zone_id", o.RegionZoneID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_v1_storage_regions_storage_pools_getall_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_v1_storage_regions_storage_pools_getall_responses.go new file mode 100644 index 00000000000..1c654e2d53a --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_v1_storage_regions_storage_pools_getall_responses.go @@ -0,0 +1,179 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package internal_storage_regions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// InternalV1StorageRegionsStoragePoolsGetallReader is a Reader for the InternalV1StorageRegionsStoragePoolsGetall structure. +type InternalV1StorageRegionsStoragePoolsGetallReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *InternalV1StorageRegionsStoragePoolsGetallReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewInternalV1StorageRegionsStoragePoolsGetallOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewInternalV1StorageRegionsStoragePoolsGetallUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewInternalV1StorageRegionsStoragePoolsGetallNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewInternalV1StorageRegionsStoragePoolsGetallInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewInternalV1StorageRegionsStoragePoolsGetallOK creates a InternalV1StorageRegionsStoragePoolsGetallOK with default headers values +func NewInternalV1StorageRegionsStoragePoolsGetallOK() *InternalV1StorageRegionsStoragePoolsGetallOK { + return &InternalV1StorageRegionsStoragePoolsGetallOK{} +} + +/* InternalV1StorageRegionsStoragePoolsGetallOK describes a response with status code 200, with default header values. + +OK +*/ +type InternalV1StorageRegionsStoragePoolsGetallOK struct { + Payload models.StoragePools +} + +func (o *InternalV1StorageRegionsStoragePoolsGetallOK) Error() string { + return fmt.Sprintf("[GET /internal/v1/storage/regions/{region_zone_id}/storage-pools][%d] internalV1StorageRegionsStoragePoolsGetallOK %+v", 200, o.Payload) +} +func (o *InternalV1StorageRegionsStoragePoolsGetallOK) GetPayload() models.StoragePools { + return o.Payload +} + +func (o *InternalV1StorageRegionsStoragePoolsGetallOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewInternalV1StorageRegionsStoragePoolsGetallUnauthorized creates a InternalV1StorageRegionsStoragePoolsGetallUnauthorized with default headers values +func NewInternalV1StorageRegionsStoragePoolsGetallUnauthorized() *InternalV1StorageRegionsStoragePoolsGetallUnauthorized { + return &InternalV1StorageRegionsStoragePoolsGetallUnauthorized{} +} + +/* InternalV1StorageRegionsStoragePoolsGetallUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type InternalV1StorageRegionsStoragePoolsGetallUnauthorized struct { + Payload *models.Error +} + +func (o *InternalV1StorageRegionsStoragePoolsGetallUnauthorized) Error() string { + return fmt.Sprintf("[GET /internal/v1/storage/regions/{region_zone_id}/storage-pools][%d] internalV1StorageRegionsStoragePoolsGetallUnauthorized %+v", 401, o.Payload) +} +func (o *InternalV1StorageRegionsStoragePoolsGetallUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *InternalV1StorageRegionsStoragePoolsGetallUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewInternalV1StorageRegionsStoragePoolsGetallNotFound creates a InternalV1StorageRegionsStoragePoolsGetallNotFound with default headers values +func NewInternalV1StorageRegionsStoragePoolsGetallNotFound() *InternalV1StorageRegionsStoragePoolsGetallNotFound { + return &InternalV1StorageRegionsStoragePoolsGetallNotFound{} +} + +/* InternalV1StorageRegionsStoragePoolsGetallNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type InternalV1StorageRegionsStoragePoolsGetallNotFound struct { + Payload *models.Error +} + +func (o *InternalV1StorageRegionsStoragePoolsGetallNotFound) Error() string { + return fmt.Sprintf("[GET /internal/v1/storage/regions/{region_zone_id}/storage-pools][%d] internalV1StorageRegionsStoragePoolsGetallNotFound %+v", 404, o.Payload) +} +func (o *InternalV1StorageRegionsStoragePoolsGetallNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *InternalV1StorageRegionsStoragePoolsGetallNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewInternalV1StorageRegionsStoragePoolsGetallInternalServerError creates a InternalV1StorageRegionsStoragePoolsGetallInternalServerError with default headers values +func NewInternalV1StorageRegionsStoragePoolsGetallInternalServerError() *InternalV1StorageRegionsStoragePoolsGetallInternalServerError { + return &InternalV1StorageRegionsStoragePoolsGetallInternalServerError{} +} + +/* InternalV1StorageRegionsStoragePoolsGetallInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type InternalV1StorageRegionsStoragePoolsGetallInternalServerError struct { + Payload *models.Error +} + +func (o *InternalV1StorageRegionsStoragePoolsGetallInternalServerError) Error() string { + return fmt.Sprintf("[GET /internal/v1/storage/regions/{region_zone_id}/storage-pools][%d] internalV1StorageRegionsStoragePoolsGetallInternalServerError %+v", 500, o.Payload) +} +func (o *InternalV1StorageRegionsStoragePoolsGetallInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *InternalV1StorageRegionsStoragePoolsGetallInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_v1_storage_regions_storage_pools_put_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_v1_storage_regions_storage_pools_put_parameters.go new file mode 100644 index 00000000000..624f961b4c7 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_v1_storage_regions_storage_pools_put_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package internal_storage_regions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewInternalV1StorageRegionsStoragePoolsPutParams creates a new InternalV1StorageRegionsStoragePoolsPutParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewInternalV1StorageRegionsStoragePoolsPutParams() *InternalV1StorageRegionsStoragePoolsPutParams { + return &InternalV1StorageRegionsStoragePoolsPutParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewInternalV1StorageRegionsStoragePoolsPutParamsWithTimeout creates a new InternalV1StorageRegionsStoragePoolsPutParams object +// with the ability to set a timeout on a request. +func NewInternalV1StorageRegionsStoragePoolsPutParamsWithTimeout(timeout time.Duration) *InternalV1StorageRegionsStoragePoolsPutParams { + return &InternalV1StorageRegionsStoragePoolsPutParams{ + timeout: timeout, + } +} + +// NewInternalV1StorageRegionsStoragePoolsPutParamsWithContext creates a new InternalV1StorageRegionsStoragePoolsPutParams object +// with the ability to set a context for a request. +func NewInternalV1StorageRegionsStoragePoolsPutParamsWithContext(ctx context.Context) *InternalV1StorageRegionsStoragePoolsPutParams { + return &InternalV1StorageRegionsStoragePoolsPutParams{ + Context: ctx, + } +} + +// NewInternalV1StorageRegionsStoragePoolsPutParamsWithHTTPClient creates a new InternalV1StorageRegionsStoragePoolsPutParams object +// with the ability to set a custom HTTPClient for a request. +func NewInternalV1StorageRegionsStoragePoolsPutParamsWithHTTPClient(client *http.Client) *InternalV1StorageRegionsStoragePoolsPutParams { + return &InternalV1StorageRegionsStoragePoolsPutParams{ + HTTPClient: client, + } +} + +/* InternalV1StorageRegionsStoragePoolsPutParams contains all the parameters to send to the API endpoint + for the internal v1 storage regions storage pools put operation. + + Typically these are written to a http.Request. +*/ +type InternalV1StorageRegionsStoragePoolsPutParams struct { + + /* Body. + + Parameters for updating a storage pool + */ + Body *models.UpdateStoragePool + + /* RegionZoneID. + + ID of a Power Cloud Region Zone + */ + RegionZoneID string + + /* StoragePoolName. + + Storage pool name + */ + StoragePoolName string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the internal v1 storage regions storage pools put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *InternalV1StorageRegionsStoragePoolsPutParams) WithDefaults() *InternalV1StorageRegionsStoragePoolsPutParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the internal v1 storage regions storage pools put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *InternalV1StorageRegionsStoragePoolsPutParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the internal v1 storage regions storage pools put params +func (o *InternalV1StorageRegionsStoragePoolsPutParams) WithTimeout(timeout time.Duration) *InternalV1StorageRegionsStoragePoolsPutParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the internal v1 storage regions storage pools put params +func (o *InternalV1StorageRegionsStoragePoolsPutParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the internal v1 storage regions storage pools put params +func (o *InternalV1StorageRegionsStoragePoolsPutParams) WithContext(ctx context.Context) *InternalV1StorageRegionsStoragePoolsPutParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the internal v1 storage regions storage pools put params +func (o *InternalV1StorageRegionsStoragePoolsPutParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the internal v1 storage regions storage pools put params +func (o *InternalV1StorageRegionsStoragePoolsPutParams) WithHTTPClient(client *http.Client) *InternalV1StorageRegionsStoragePoolsPutParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the internal v1 storage regions storage pools put params +func (o *InternalV1StorageRegionsStoragePoolsPutParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the internal v1 storage regions storage pools put params +func (o *InternalV1StorageRegionsStoragePoolsPutParams) WithBody(body *models.UpdateStoragePool) *InternalV1StorageRegionsStoragePoolsPutParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the internal v1 storage regions storage pools put params +func (o *InternalV1StorageRegionsStoragePoolsPutParams) SetBody(body *models.UpdateStoragePool) { + o.Body = body +} + +// WithRegionZoneID adds the regionZoneID to the internal v1 storage regions storage pools put params +func (o *InternalV1StorageRegionsStoragePoolsPutParams) WithRegionZoneID(regionZoneID string) *InternalV1StorageRegionsStoragePoolsPutParams { + o.SetRegionZoneID(regionZoneID) + return o +} + +// SetRegionZoneID adds the regionZoneId to the internal v1 storage regions storage pools put params +func (o *InternalV1StorageRegionsStoragePoolsPutParams) SetRegionZoneID(regionZoneID string) { + o.RegionZoneID = regionZoneID +} + +// WithStoragePoolName adds the storagePoolName to the internal v1 storage regions storage pools put params +func (o *InternalV1StorageRegionsStoragePoolsPutParams) WithStoragePoolName(storagePoolName string) *InternalV1StorageRegionsStoragePoolsPutParams { + o.SetStoragePoolName(storagePoolName) + return o +} + +// SetStoragePoolName adds the storagePoolName to the internal v1 storage regions storage pools put params +func (o *InternalV1StorageRegionsStoragePoolsPutParams) SetStoragePoolName(storagePoolName string) { + o.StoragePoolName = storagePoolName +} + +// WriteToRequest writes these params to a swagger request +func (o *InternalV1StorageRegionsStoragePoolsPutParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param region_zone_id + if err := r.SetPathParam("region_zone_id", o.RegionZoneID); err != nil { + return err + } + + // path param storage_pool_name + if err := r.SetPathParam("storage_pool_name", o.StoragePoolName); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_v1_storage_regions_storage_pools_put_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_v1_storage_regions_storage_pools_put_responses.go new file mode 100644 index 00000000000..f36b6457212 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_v1_storage_regions_storage_pools_put_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package internal_storage_regions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// InternalV1StorageRegionsStoragePoolsPutReader is a Reader for the InternalV1StorageRegionsStoragePoolsPut structure. +type InternalV1StorageRegionsStoragePoolsPutReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *InternalV1StorageRegionsStoragePoolsPutReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewInternalV1StorageRegionsStoragePoolsPutOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewInternalV1StorageRegionsStoragePoolsPutBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewInternalV1StorageRegionsStoragePoolsPutUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewInternalV1StorageRegionsStoragePoolsPutNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewInternalV1StorageRegionsStoragePoolsPutInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewInternalV1StorageRegionsStoragePoolsPutOK creates a InternalV1StorageRegionsStoragePoolsPutOK with default headers values +func NewInternalV1StorageRegionsStoragePoolsPutOK() *InternalV1StorageRegionsStoragePoolsPutOK { + return &InternalV1StorageRegionsStoragePoolsPutOK{} +} + +/* InternalV1StorageRegionsStoragePoolsPutOK describes a response with status code 200, with default header values. + +OK +*/ +type InternalV1StorageRegionsStoragePoolsPutOK struct { + Payload *models.StoragePool +} + +func (o *InternalV1StorageRegionsStoragePoolsPutOK) Error() string { + return fmt.Sprintf("[PUT /internal/v1/storage/regions/{region_zone_id}/storage-pools/{storage_pool_name}][%d] internalV1StorageRegionsStoragePoolsPutOK %+v", 200, o.Payload) +} +func (o *InternalV1StorageRegionsStoragePoolsPutOK) GetPayload() *models.StoragePool { + return o.Payload +} + +func (o *InternalV1StorageRegionsStoragePoolsPutOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.StoragePool) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewInternalV1StorageRegionsStoragePoolsPutBadRequest creates a InternalV1StorageRegionsStoragePoolsPutBadRequest with default headers values +func NewInternalV1StorageRegionsStoragePoolsPutBadRequest() *InternalV1StorageRegionsStoragePoolsPutBadRequest { + return &InternalV1StorageRegionsStoragePoolsPutBadRequest{} +} + +/* InternalV1StorageRegionsStoragePoolsPutBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type InternalV1StorageRegionsStoragePoolsPutBadRequest struct { + Payload *models.Error +} + +func (o *InternalV1StorageRegionsStoragePoolsPutBadRequest) Error() string { + return fmt.Sprintf("[PUT /internal/v1/storage/regions/{region_zone_id}/storage-pools/{storage_pool_name}][%d] internalV1StorageRegionsStoragePoolsPutBadRequest %+v", 400, o.Payload) +} +func (o *InternalV1StorageRegionsStoragePoolsPutBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *InternalV1StorageRegionsStoragePoolsPutBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewInternalV1StorageRegionsStoragePoolsPutUnauthorized creates a InternalV1StorageRegionsStoragePoolsPutUnauthorized with default headers values +func NewInternalV1StorageRegionsStoragePoolsPutUnauthorized() *InternalV1StorageRegionsStoragePoolsPutUnauthorized { + return &InternalV1StorageRegionsStoragePoolsPutUnauthorized{} +} + +/* InternalV1StorageRegionsStoragePoolsPutUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type InternalV1StorageRegionsStoragePoolsPutUnauthorized struct { + Payload *models.Error +} + +func (o *InternalV1StorageRegionsStoragePoolsPutUnauthorized) Error() string { + return fmt.Sprintf("[PUT /internal/v1/storage/regions/{region_zone_id}/storage-pools/{storage_pool_name}][%d] internalV1StorageRegionsStoragePoolsPutUnauthorized %+v", 401, o.Payload) +} +func (o *InternalV1StorageRegionsStoragePoolsPutUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *InternalV1StorageRegionsStoragePoolsPutUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewInternalV1StorageRegionsStoragePoolsPutNotFound creates a InternalV1StorageRegionsStoragePoolsPutNotFound with default headers values +func NewInternalV1StorageRegionsStoragePoolsPutNotFound() *InternalV1StorageRegionsStoragePoolsPutNotFound { + return &InternalV1StorageRegionsStoragePoolsPutNotFound{} +} + +/* InternalV1StorageRegionsStoragePoolsPutNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type InternalV1StorageRegionsStoragePoolsPutNotFound struct { + Payload *models.Error +} + +func (o *InternalV1StorageRegionsStoragePoolsPutNotFound) Error() string { + return fmt.Sprintf("[PUT /internal/v1/storage/regions/{region_zone_id}/storage-pools/{storage_pool_name}][%d] internalV1StorageRegionsStoragePoolsPutNotFound %+v", 404, o.Payload) +} +func (o *InternalV1StorageRegionsStoragePoolsPutNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *InternalV1StorageRegionsStoragePoolsPutNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewInternalV1StorageRegionsStoragePoolsPutInternalServerError creates a InternalV1StorageRegionsStoragePoolsPutInternalServerError with default headers values +func NewInternalV1StorageRegionsStoragePoolsPutInternalServerError() *InternalV1StorageRegionsStoragePoolsPutInternalServerError { + return &InternalV1StorageRegionsStoragePoolsPutInternalServerError{} +} + +/* InternalV1StorageRegionsStoragePoolsPutInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type InternalV1StorageRegionsStoragePoolsPutInternalServerError struct { + Payload *models.Error +} + +func (o *InternalV1StorageRegionsStoragePoolsPutInternalServerError) Error() string { + return fmt.Sprintf("[PUT /internal/v1/storage/regions/{region_zone_id}/storage-pools/{storage_pool_name}][%d] internalV1StorageRegionsStoragePoolsPutInternalServerError %+v", 500, o.Payload) +} +func (o *InternalV1StorageRegionsStoragePoolsPutInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *InternalV1StorageRegionsStoragePoolsPutInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_v1_storage_regions_thresholds_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_v1_storage_regions_thresholds_get_parameters.go new file mode 100644 index 00000000000..c60d4fea48a --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_v1_storage_regions_thresholds_get_parameters.go @@ -0,0 +1,149 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package internal_storage_regions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewInternalV1StorageRegionsThresholdsGetParams creates a new InternalV1StorageRegionsThresholdsGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewInternalV1StorageRegionsThresholdsGetParams() *InternalV1StorageRegionsThresholdsGetParams { + return &InternalV1StorageRegionsThresholdsGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewInternalV1StorageRegionsThresholdsGetParamsWithTimeout creates a new InternalV1StorageRegionsThresholdsGetParams object +// with the ability to set a timeout on a request. +func NewInternalV1StorageRegionsThresholdsGetParamsWithTimeout(timeout time.Duration) *InternalV1StorageRegionsThresholdsGetParams { + return &InternalV1StorageRegionsThresholdsGetParams{ + timeout: timeout, + } +} + +// NewInternalV1StorageRegionsThresholdsGetParamsWithContext creates a new InternalV1StorageRegionsThresholdsGetParams object +// with the ability to set a context for a request. +func NewInternalV1StorageRegionsThresholdsGetParamsWithContext(ctx context.Context) *InternalV1StorageRegionsThresholdsGetParams { + return &InternalV1StorageRegionsThresholdsGetParams{ + Context: ctx, + } +} + +// NewInternalV1StorageRegionsThresholdsGetParamsWithHTTPClient creates a new InternalV1StorageRegionsThresholdsGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewInternalV1StorageRegionsThresholdsGetParamsWithHTTPClient(client *http.Client) *InternalV1StorageRegionsThresholdsGetParams { + return &InternalV1StorageRegionsThresholdsGetParams{ + HTTPClient: client, + } +} + +/* InternalV1StorageRegionsThresholdsGetParams contains all the parameters to send to the API endpoint + for the internal v1 storage regions thresholds get operation. + + Typically these are written to a http.Request. +*/ +type InternalV1StorageRegionsThresholdsGetParams struct { + + /* RegionZoneID. + + ID of a Power Cloud Region Zone + */ + RegionZoneID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the internal v1 storage regions thresholds get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *InternalV1StorageRegionsThresholdsGetParams) WithDefaults() *InternalV1StorageRegionsThresholdsGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the internal v1 storage regions thresholds get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *InternalV1StorageRegionsThresholdsGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the internal v1 storage regions thresholds get params +func (o *InternalV1StorageRegionsThresholdsGetParams) WithTimeout(timeout time.Duration) *InternalV1StorageRegionsThresholdsGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the internal v1 storage regions thresholds get params +func (o *InternalV1StorageRegionsThresholdsGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the internal v1 storage regions thresholds get params +func (o *InternalV1StorageRegionsThresholdsGetParams) WithContext(ctx context.Context) *InternalV1StorageRegionsThresholdsGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the internal v1 storage regions thresholds get params +func (o *InternalV1StorageRegionsThresholdsGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the internal v1 storage regions thresholds get params +func (o *InternalV1StorageRegionsThresholdsGetParams) WithHTTPClient(client *http.Client) *InternalV1StorageRegionsThresholdsGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the internal v1 storage regions thresholds get params +func (o *InternalV1StorageRegionsThresholdsGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithRegionZoneID adds the regionZoneID to the internal v1 storage regions thresholds get params +func (o *InternalV1StorageRegionsThresholdsGetParams) WithRegionZoneID(regionZoneID string) *InternalV1StorageRegionsThresholdsGetParams { + o.SetRegionZoneID(regionZoneID) + return o +} + +// SetRegionZoneID adds the regionZoneId to the internal v1 storage regions thresholds get params +func (o *InternalV1StorageRegionsThresholdsGetParams) SetRegionZoneID(regionZoneID string) { + o.RegionZoneID = regionZoneID +} + +// WriteToRequest writes these params to a swagger request +func (o *InternalV1StorageRegionsThresholdsGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param region_zone_id + if err := r.SetPathParam("region_zone_id", o.RegionZoneID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_v1_storage_regions_thresholds_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_v1_storage_regions_thresholds_get_responses.go new file mode 100644 index 00000000000..87dbb71ea4d --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_v1_storage_regions_thresholds_get_responses.go @@ -0,0 +1,181 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package internal_storage_regions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// InternalV1StorageRegionsThresholdsGetReader is a Reader for the InternalV1StorageRegionsThresholdsGet structure. +type InternalV1StorageRegionsThresholdsGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *InternalV1StorageRegionsThresholdsGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewInternalV1StorageRegionsThresholdsGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewInternalV1StorageRegionsThresholdsGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewInternalV1StorageRegionsThresholdsGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewInternalV1StorageRegionsThresholdsGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewInternalV1StorageRegionsThresholdsGetOK creates a InternalV1StorageRegionsThresholdsGetOK with default headers values +func NewInternalV1StorageRegionsThresholdsGetOK() *InternalV1StorageRegionsThresholdsGetOK { + return &InternalV1StorageRegionsThresholdsGetOK{} +} + +/* InternalV1StorageRegionsThresholdsGetOK describes a response with status code 200, with default header values. + +OK +*/ +type InternalV1StorageRegionsThresholdsGetOK struct { + Payload *models.Thresholds +} + +func (o *InternalV1StorageRegionsThresholdsGetOK) Error() string { + return fmt.Sprintf("[GET /internal/v1/storage/regions/{region_zone_id}/thresholds][%d] internalV1StorageRegionsThresholdsGetOK %+v", 200, o.Payload) +} +func (o *InternalV1StorageRegionsThresholdsGetOK) GetPayload() *models.Thresholds { + return o.Payload +} + +func (o *InternalV1StorageRegionsThresholdsGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Thresholds) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewInternalV1StorageRegionsThresholdsGetUnauthorized creates a InternalV1StorageRegionsThresholdsGetUnauthorized with default headers values +func NewInternalV1StorageRegionsThresholdsGetUnauthorized() *InternalV1StorageRegionsThresholdsGetUnauthorized { + return &InternalV1StorageRegionsThresholdsGetUnauthorized{} +} + +/* InternalV1StorageRegionsThresholdsGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type InternalV1StorageRegionsThresholdsGetUnauthorized struct { + Payload *models.Error +} + +func (o *InternalV1StorageRegionsThresholdsGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /internal/v1/storage/regions/{region_zone_id}/thresholds][%d] internalV1StorageRegionsThresholdsGetUnauthorized %+v", 401, o.Payload) +} +func (o *InternalV1StorageRegionsThresholdsGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *InternalV1StorageRegionsThresholdsGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewInternalV1StorageRegionsThresholdsGetNotFound creates a InternalV1StorageRegionsThresholdsGetNotFound with default headers values +func NewInternalV1StorageRegionsThresholdsGetNotFound() *InternalV1StorageRegionsThresholdsGetNotFound { + return &InternalV1StorageRegionsThresholdsGetNotFound{} +} + +/* InternalV1StorageRegionsThresholdsGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type InternalV1StorageRegionsThresholdsGetNotFound struct { + Payload *models.Error +} + +func (o *InternalV1StorageRegionsThresholdsGetNotFound) Error() string { + return fmt.Sprintf("[GET /internal/v1/storage/regions/{region_zone_id}/thresholds][%d] internalV1StorageRegionsThresholdsGetNotFound %+v", 404, o.Payload) +} +func (o *InternalV1StorageRegionsThresholdsGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *InternalV1StorageRegionsThresholdsGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewInternalV1StorageRegionsThresholdsGetInternalServerError creates a InternalV1StorageRegionsThresholdsGetInternalServerError with default headers values +func NewInternalV1StorageRegionsThresholdsGetInternalServerError() *InternalV1StorageRegionsThresholdsGetInternalServerError { + return &InternalV1StorageRegionsThresholdsGetInternalServerError{} +} + +/* InternalV1StorageRegionsThresholdsGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type InternalV1StorageRegionsThresholdsGetInternalServerError struct { + Payload *models.Error +} + +func (o *InternalV1StorageRegionsThresholdsGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /internal/v1/storage/regions/{region_zone_id}/thresholds][%d] internalV1StorageRegionsThresholdsGetInternalServerError %+v", 500, o.Payload) +} +func (o *InternalV1StorageRegionsThresholdsGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *InternalV1StorageRegionsThresholdsGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_v1_storage_regions_thresholds_put_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_v1_storage_regions_thresholds_put_parameters.go new file mode 100644 index 00000000000..37d8366532b --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_v1_storage_regions_thresholds_put_parameters.go @@ -0,0 +1,173 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package internal_storage_regions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewInternalV1StorageRegionsThresholdsPutParams creates a new InternalV1StorageRegionsThresholdsPutParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewInternalV1StorageRegionsThresholdsPutParams() *InternalV1StorageRegionsThresholdsPutParams { + return &InternalV1StorageRegionsThresholdsPutParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewInternalV1StorageRegionsThresholdsPutParamsWithTimeout creates a new InternalV1StorageRegionsThresholdsPutParams object +// with the ability to set a timeout on a request. +func NewInternalV1StorageRegionsThresholdsPutParamsWithTimeout(timeout time.Duration) *InternalV1StorageRegionsThresholdsPutParams { + return &InternalV1StorageRegionsThresholdsPutParams{ + timeout: timeout, + } +} + +// NewInternalV1StorageRegionsThresholdsPutParamsWithContext creates a new InternalV1StorageRegionsThresholdsPutParams object +// with the ability to set a context for a request. +func NewInternalV1StorageRegionsThresholdsPutParamsWithContext(ctx context.Context) *InternalV1StorageRegionsThresholdsPutParams { + return &InternalV1StorageRegionsThresholdsPutParams{ + Context: ctx, + } +} + +// NewInternalV1StorageRegionsThresholdsPutParamsWithHTTPClient creates a new InternalV1StorageRegionsThresholdsPutParams object +// with the ability to set a custom HTTPClient for a request. +func NewInternalV1StorageRegionsThresholdsPutParamsWithHTTPClient(client *http.Client) *InternalV1StorageRegionsThresholdsPutParams { + return &InternalV1StorageRegionsThresholdsPutParams{ + HTTPClient: client, + } +} + +/* InternalV1StorageRegionsThresholdsPutParams contains all the parameters to send to the API endpoint + for the internal v1 storage regions thresholds put operation. + + Typically these are written to a http.Request. +*/ +type InternalV1StorageRegionsThresholdsPutParams struct { + + /* Body. + + Parameters for updating default threshold settings for a region-zone + */ + Body *models.Thresholds + + /* RegionZoneID. + + ID of a Power Cloud Region Zone + */ + RegionZoneID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the internal v1 storage regions thresholds put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *InternalV1StorageRegionsThresholdsPutParams) WithDefaults() *InternalV1StorageRegionsThresholdsPutParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the internal v1 storage regions thresholds put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *InternalV1StorageRegionsThresholdsPutParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the internal v1 storage regions thresholds put params +func (o *InternalV1StorageRegionsThresholdsPutParams) WithTimeout(timeout time.Duration) *InternalV1StorageRegionsThresholdsPutParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the internal v1 storage regions thresholds put params +func (o *InternalV1StorageRegionsThresholdsPutParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the internal v1 storage regions thresholds put params +func (o *InternalV1StorageRegionsThresholdsPutParams) WithContext(ctx context.Context) *InternalV1StorageRegionsThresholdsPutParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the internal v1 storage regions thresholds put params +func (o *InternalV1StorageRegionsThresholdsPutParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the internal v1 storage regions thresholds put params +func (o *InternalV1StorageRegionsThresholdsPutParams) WithHTTPClient(client *http.Client) *InternalV1StorageRegionsThresholdsPutParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the internal v1 storage regions thresholds put params +func (o *InternalV1StorageRegionsThresholdsPutParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the internal v1 storage regions thresholds put params +func (o *InternalV1StorageRegionsThresholdsPutParams) WithBody(body *models.Thresholds) *InternalV1StorageRegionsThresholdsPutParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the internal v1 storage regions thresholds put params +func (o *InternalV1StorageRegionsThresholdsPutParams) SetBody(body *models.Thresholds) { + o.Body = body +} + +// WithRegionZoneID adds the regionZoneID to the internal v1 storage regions thresholds put params +func (o *InternalV1StorageRegionsThresholdsPutParams) WithRegionZoneID(regionZoneID string) *InternalV1StorageRegionsThresholdsPutParams { + o.SetRegionZoneID(regionZoneID) + return o +} + +// SetRegionZoneID adds the regionZoneId to the internal v1 storage regions thresholds put params +func (o *InternalV1StorageRegionsThresholdsPutParams) SetRegionZoneID(regionZoneID string) { + o.RegionZoneID = regionZoneID +} + +// WriteToRequest writes these params to a swagger request +func (o *InternalV1StorageRegionsThresholdsPutParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param region_zone_id + if err := r.SetPathParam("region_zone_id", o.RegionZoneID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_v1_storage_regions_thresholds_put_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_v1_storage_regions_thresholds_put_responses.go new file mode 100644 index 00000000000..fab946caab8 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions/internal_v1_storage_regions_thresholds_put_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package internal_storage_regions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// InternalV1StorageRegionsThresholdsPutReader is a Reader for the InternalV1StorageRegionsThresholdsPut structure. +type InternalV1StorageRegionsThresholdsPutReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *InternalV1StorageRegionsThresholdsPutReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 202: + result := NewInternalV1StorageRegionsThresholdsPutAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewInternalV1StorageRegionsThresholdsPutBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewInternalV1StorageRegionsThresholdsPutUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewInternalV1StorageRegionsThresholdsPutForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewInternalV1StorageRegionsThresholdsPutConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewInternalV1StorageRegionsThresholdsPutUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewInternalV1StorageRegionsThresholdsPutInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewInternalV1StorageRegionsThresholdsPutAccepted creates a InternalV1StorageRegionsThresholdsPutAccepted with default headers values +func NewInternalV1StorageRegionsThresholdsPutAccepted() *InternalV1StorageRegionsThresholdsPutAccepted { + return &InternalV1StorageRegionsThresholdsPutAccepted{} +} + +/* InternalV1StorageRegionsThresholdsPutAccepted describes a response with status code 202, with default header values. + +OK, region-zone default threshold settings update +*/ +type InternalV1StorageRegionsThresholdsPutAccepted struct { + Payload *models.Thresholds +} + +func (o *InternalV1StorageRegionsThresholdsPutAccepted) Error() string { + return fmt.Sprintf("[PUT /internal/v1/storage/regions/{region_zone_id}/thresholds][%d] internalV1StorageRegionsThresholdsPutAccepted %+v", 202, o.Payload) +} +func (o *InternalV1StorageRegionsThresholdsPutAccepted) GetPayload() *models.Thresholds { + return o.Payload +} + +func (o *InternalV1StorageRegionsThresholdsPutAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Thresholds) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewInternalV1StorageRegionsThresholdsPutBadRequest creates a InternalV1StorageRegionsThresholdsPutBadRequest with default headers values +func NewInternalV1StorageRegionsThresholdsPutBadRequest() *InternalV1StorageRegionsThresholdsPutBadRequest { + return &InternalV1StorageRegionsThresholdsPutBadRequest{} +} + +/* InternalV1StorageRegionsThresholdsPutBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type InternalV1StorageRegionsThresholdsPutBadRequest struct { + Payload *models.Error +} + +func (o *InternalV1StorageRegionsThresholdsPutBadRequest) Error() string { + return fmt.Sprintf("[PUT /internal/v1/storage/regions/{region_zone_id}/thresholds][%d] internalV1StorageRegionsThresholdsPutBadRequest %+v", 400, o.Payload) +} +func (o *InternalV1StorageRegionsThresholdsPutBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *InternalV1StorageRegionsThresholdsPutBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewInternalV1StorageRegionsThresholdsPutUnauthorized creates a InternalV1StorageRegionsThresholdsPutUnauthorized with default headers values +func NewInternalV1StorageRegionsThresholdsPutUnauthorized() *InternalV1StorageRegionsThresholdsPutUnauthorized { + return &InternalV1StorageRegionsThresholdsPutUnauthorized{} +} + +/* InternalV1StorageRegionsThresholdsPutUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type InternalV1StorageRegionsThresholdsPutUnauthorized struct { + Payload *models.Error +} + +func (o *InternalV1StorageRegionsThresholdsPutUnauthorized) Error() string { + return fmt.Sprintf("[PUT /internal/v1/storage/regions/{region_zone_id}/thresholds][%d] internalV1StorageRegionsThresholdsPutUnauthorized %+v", 401, o.Payload) +} +func (o *InternalV1StorageRegionsThresholdsPutUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *InternalV1StorageRegionsThresholdsPutUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewInternalV1StorageRegionsThresholdsPutForbidden creates a InternalV1StorageRegionsThresholdsPutForbidden with default headers values +func NewInternalV1StorageRegionsThresholdsPutForbidden() *InternalV1StorageRegionsThresholdsPutForbidden { + return &InternalV1StorageRegionsThresholdsPutForbidden{} +} + +/* InternalV1StorageRegionsThresholdsPutForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type InternalV1StorageRegionsThresholdsPutForbidden struct { + Payload *models.Error +} + +func (o *InternalV1StorageRegionsThresholdsPutForbidden) Error() string { + return fmt.Sprintf("[PUT /internal/v1/storage/regions/{region_zone_id}/thresholds][%d] internalV1StorageRegionsThresholdsPutForbidden %+v", 403, o.Payload) +} +func (o *InternalV1StorageRegionsThresholdsPutForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *InternalV1StorageRegionsThresholdsPutForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewInternalV1StorageRegionsThresholdsPutConflict creates a InternalV1StorageRegionsThresholdsPutConflict with default headers values +func NewInternalV1StorageRegionsThresholdsPutConflict() *InternalV1StorageRegionsThresholdsPutConflict { + return &InternalV1StorageRegionsThresholdsPutConflict{} +} + +/* InternalV1StorageRegionsThresholdsPutConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type InternalV1StorageRegionsThresholdsPutConflict struct { + Payload *models.Error +} + +func (o *InternalV1StorageRegionsThresholdsPutConflict) Error() string { + return fmt.Sprintf("[PUT /internal/v1/storage/regions/{region_zone_id}/thresholds][%d] internalV1StorageRegionsThresholdsPutConflict %+v", 409, o.Payload) +} +func (o *InternalV1StorageRegionsThresholdsPutConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *InternalV1StorageRegionsThresholdsPutConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewInternalV1StorageRegionsThresholdsPutUnprocessableEntity creates a InternalV1StorageRegionsThresholdsPutUnprocessableEntity with default headers values +func NewInternalV1StorageRegionsThresholdsPutUnprocessableEntity() *InternalV1StorageRegionsThresholdsPutUnprocessableEntity { + return &InternalV1StorageRegionsThresholdsPutUnprocessableEntity{} +} + +/* InternalV1StorageRegionsThresholdsPutUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type InternalV1StorageRegionsThresholdsPutUnprocessableEntity struct { + Payload *models.Error +} + +func (o *InternalV1StorageRegionsThresholdsPutUnprocessableEntity) Error() string { + return fmt.Sprintf("[PUT /internal/v1/storage/regions/{region_zone_id}/thresholds][%d] internalV1StorageRegionsThresholdsPutUnprocessableEntity %+v", 422, o.Payload) +} +func (o *InternalV1StorageRegionsThresholdsPutUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *InternalV1StorageRegionsThresholdsPutUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewInternalV1StorageRegionsThresholdsPutInternalServerError creates a InternalV1StorageRegionsThresholdsPutInternalServerError with default headers values +func NewInternalV1StorageRegionsThresholdsPutInternalServerError() *InternalV1StorageRegionsThresholdsPutInternalServerError { + return &InternalV1StorageRegionsThresholdsPutInternalServerError{} +} + +/* InternalV1StorageRegionsThresholdsPutInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type InternalV1StorageRegionsThresholdsPutInternalServerError struct { + Payload *models.Error +} + +func (o *InternalV1StorageRegionsThresholdsPutInternalServerError) Error() string { + return fmt.Sprintf("[PUT /internal/v1/storage/regions/{region_zone_id}/thresholds][%d] internalV1StorageRegionsThresholdsPutInternalServerError %+v", 500, o.Payload) +} +func (o *InternalV1StorageRegionsThresholdsPutInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *InternalV1StorageRegionsThresholdsPutInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/open_stacks_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/open_stacks_client.go new file mode 100644 index 00000000000..693bef3bab1 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/open_stacks_client.go @@ -0,0 +1,245 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package open_stacks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new open stacks API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for open stacks API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + ServiceBrokerOpenstacksGet(params *ServiceBrokerOpenstacksGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceBrokerOpenstacksGetOK, error) + + ServiceBrokerOpenstacksHostsGet(params *ServiceBrokerOpenstacksHostsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceBrokerOpenstacksHostsGetOK, error) + + ServiceBrokerOpenstacksOpenstackGet(params *ServiceBrokerOpenstacksOpenstackGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceBrokerOpenstacksOpenstackGetOK, error) + + ServiceBrokerOpenstacksPost(params *ServiceBrokerOpenstacksPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceBrokerOpenstacksPostOK, *ServiceBrokerOpenstacksPostCreated, error) + + ServiceBrokerOpenstacksServersGet(params *ServiceBrokerOpenstacksServersGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceBrokerOpenstacksServersGetOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + ServiceBrokerOpenstacksGet lists all open stack instances being managed +*/ +func (a *Client) ServiceBrokerOpenstacksGet(params *ServiceBrokerOpenstacksGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceBrokerOpenstacksGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewServiceBrokerOpenstacksGetParams() + } + op := &runtime.ClientOperation{ + ID: "serviceBroker.openstacks.get", + Method: "GET", + PathPattern: "/broker/v1/openstacks", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ServiceBrokerOpenstacksGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ServiceBrokerOpenstacksGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for serviceBroker.openstacks.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + ServiceBrokerOpenstacksHostsGet lists account information for all pvm instances on hostname +*/ +func (a *Client) ServiceBrokerOpenstacksHostsGet(params *ServiceBrokerOpenstacksHostsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceBrokerOpenstacksHostsGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewServiceBrokerOpenstacksHostsGetParams() + } + op := &runtime.ClientOperation{ + ID: "serviceBroker.openstacks.hosts.get", + Method: "GET", + PathPattern: "/broker/v1/openstacks/{openstack_id}/hosts/{hostname}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ServiceBrokerOpenstacksHostsGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ServiceBrokerOpenstacksHostsGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for serviceBroker.openstacks.hosts.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + ServiceBrokerOpenstacksOpenstackGet lists account information for all pvm instances on hostname +*/ +func (a *Client) ServiceBrokerOpenstacksOpenstackGet(params *ServiceBrokerOpenstacksOpenstackGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceBrokerOpenstacksOpenstackGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewServiceBrokerOpenstacksOpenstackGetParams() + } + op := &runtime.ClientOperation{ + ID: "serviceBroker.openstacks.openstack.get", + Method: "GET", + PathPattern: "/broker/v1/openstacks/{openstack_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ServiceBrokerOpenstacksOpenstackGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ServiceBrokerOpenstacksOpenstackGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for serviceBroker.openstacks.openstack.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + ServiceBrokerOpenstacksPost creates a new open stack instance to be managed +*/ +func (a *Client) ServiceBrokerOpenstacksPost(params *ServiceBrokerOpenstacksPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceBrokerOpenstacksPostOK, *ServiceBrokerOpenstacksPostCreated, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewServiceBrokerOpenstacksPostParams() + } + op := &runtime.ClientOperation{ + ID: "serviceBroker.openstacks.post", + Method: "POST", + PathPattern: "/broker/v1/openstacks", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ServiceBrokerOpenstacksPostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, nil, err + } + switch value := result.(type) { + case *ServiceBrokerOpenstacksPostOK: + return value, nil, nil + case *ServiceBrokerOpenstacksPostCreated: + return nil, value, nil + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for open_stacks: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + ServiceBrokerOpenstacksServersGet lists account information for a pvm instance +*/ +func (a *Client) ServiceBrokerOpenstacksServersGet(params *ServiceBrokerOpenstacksServersGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceBrokerOpenstacksServersGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewServiceBrokerOpenstacksServersGetParams() + } + op := &runtime.ClientOperation{ + ID: "serviceBroker.openstacks.servers.get", + Method: "GET", + PathPattern: "/broker/v1/openstacks/{openstack_id}/servers/{pvm_instance_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ServiceBrokerOpenstacksServersGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ServiceBrokerOpenstacksServersGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for serviceBroker.openstacks.servers.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/service_broker_openstacks_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/service_broker_openstacks_get_parameters.go new file mode 100644 index 00000000000..a5fc89bfd6c --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/service_broker_openstacks_get_parameters.go @@ -0,0 +1,126 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package open_stacks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewServiceBrokerOpenstacksGetParams creates a new ServiceBrokerOpenstacksGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewServiceBrokerOpenstacksGetParams() *ServiceBrokerOpenstacksGetParams { + return &ServiceBrokerOpenstacksGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewServiceBrokerOpenstacksGetParamsWithTimeout creates a new ServiceBrokerOpenstacksGetParams object +// with the ability to set a timeout on a request. +func NewServiceBrokerOpenstacksGetParamsWithTimeout(timeout time.Duration) *ServiceBrokerOpenstacksGetParams { + return &ServiceBrokerOpenstacksGetParams{ + timeout: timeout, + } +} + +// NewServiceBrokerOpenstacksGetParamsWithContext creates a new ServiceBrokerOpenstacksGetParams object +// with the ability to set a context for a request. +func NewServiceBrokerOpenstacksGetParamsWithContext(ctx context.Context) *ServiceBrokerOpenstacksGetParams { + return &ServiceBrokerOpenstacksGetParams{ + Context: ctx, + } +} + +// NewServiceBrokerOpenstacksGetParamsWithHTTPClient creates a new ServiceBrokerOpenstacksGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewServiceBrokerOpenstacksGetParamsWithHTTPClient(client *http.Client) *ServiceBrokerOpenstacksGetParams { + return &ServiceBrokerOpenstacksGetParams{ + HTTPClient: client, + } +} + +/* ServiceBrokerOpenstacksGetParams contains all the parameters to send to the API endpoint + for the service broker openstacks get operation. + + Typically these are written to a http.Request. +*/ +type ServiceBrokerOpenstacksGetParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the service broker openstacks get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerOpenstacksGetParams) WithDefaults() *ServiceBrokerOpenstacksGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the service broker openstacks get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerOpenstacksGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the service broker openstacks get params +func (o *ServiceBrokerOpenstacksGetParams) WithTimeout(timeout time.Duration) *ServiceBrokerOpenstacksGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the service broker openstacks get params +func (o *ServiceBrokerOpenstacksGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the service broker openstacks get params +func (o *ServiceBrokerOpenstacksGetParams) WithContext(ctx context.Context) *ServiceBrokerOpenstacksGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the service broker openstacks get params +func (o *ServiceBrokerOpenstacksGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the service broker openstacks get params +func (o *ServiceBrokerOpenstacksGetParams) WithHTTPClient(client *http.Client) *ServiceBrokerOpenstacksGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the service broker openstacks get params +func (o *ServiceBrokerOpenstacksGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *ServiceBrokerOpenstacksGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/service_broker_openstacks_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/service_broker_openstacks_get_responses.go new file mode 100644 index 00000000000..c1903411789 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/service_broker_openstacks_get_responses.go @@ -0,0 +1,181 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package open_stacks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// ServiceBrokerOpenstacksGetReader is a Reader for the ServiceBrokerOpenstacksGet structure. +type ServiceBrokerOpenstacksGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ServiceBrokerOpenstacksGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewServiceBrokerOpenstacksGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewServiceBrokerOpenstacksGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewServiceBrokerOpenstacksGetForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewServiceBrokerOpenstacksGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewServiceBrokerOpenstacksGetOK creates a ServiceBrokerOpenstacksGetOK with default headers values +func NewServiceBrokerOpenstacksGetOK() *ServiceBrokerOpenstacksGetOK { + return &ServiceBrokerOpenstacksGetOK{} +} + +/* ServiceBrokerOpenstacksGetOK describes a response with status code 200, with default header values. + +OK +*/ +type ServiceBrokerOpenstacksGetOK struct { + Payload *models.OpenStacks +} + +func (o *ServiceBrokerOpenstacksGetOK) Error() string { + return fmt.Sprintf("[GET /broker/v1/openstacks][%d] serviceBrokerOpenstacksGetOK %+v", 200, o.Payload) +} +func (o *ServiceBrokerOpenstacksGetOK) GetPayload() *models.OpenStacks { + return o.Payload +} + +func (o *ServiceBrokerOpenstacksGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.OpenStacks) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerOpenstacksGetBadRequest creates a ServiceBrokerOpenstacksGetBadRequest with default headers values +func NewServiceBrokerOpenstacksGetBadRequest() *ServiceBrokerOpenstacksGetBadRequest { + return &ServiceBrokerOpenstacksGetBadRequest{} +} + +/* ServiceBrokerOpenstacksGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type ServiceBrokerOpenstacksGetBadRequest struct { + Payload *models.Error +} + +func (o *ServiceBrokerOpenstacksGetBadRequest) Error() string { + return fmt.Sprintf("[GET /broker/v1/openstacks][%d] serviceBrokerOpenstacksGetBadRequest %+v", 400, o.Payload) +} +func (o *ServiceBrokerOpenstacksGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerOpenstacksGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerOpenstacksGetForbidden creates a ServiceBrokerOpenstacksGetForbidden with default headers values +func NewServiceBrokerOpenstacksGetForbidden() *ServiceBrokerOpenstacksGetForbidden { + return &ServiceBrokerOpenstacksGetForbidden{} +} + +/* ServiceBrokerOpenstacksGetForbidden describes a response with status code 403, with default header values. + +Unauthorized +*/ +type ServiceBrokerOpenstacksGetForbidden struct { + Payload *models.Error +} + +func (o *ServiceBrokerOpenstacksGetForbidden) Error() string { + return fmt.Sprintf("[GET /broker/v1/openstacks][%d] serviceBrokerOpenstacksGetForbidden %+v", 403, o.Payload) +} +func (o *ServiceBrokerOpenstacksGetForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerOpenstacksGetForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerOpenstacksGetInternalServerError creates a ServiceBrokerOpenstacksGetInternalServerError with default headers values +func NewServiceBrokerOpenstacksGetInternalServerError() *ServiceBrokerOpenstacksGetInternalServerError { + return &ServiceBrokerOpenstacksGetInternalServerError{} +} + +/* ServiceBrokerOpenstacksGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type ServiceBrokerOpenstacksGetInternalServerError struct { + Payload *models.Error +} + +func (o *ServiceBrokerOpenstacksGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /broker/v1/openstacks][%d] serviceBrokerOpenstacksGetInternalServerError %+v", 500, o.Payload) +} +func (o *ServiceBrokerOpenstacksGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerOpenstacksGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/service_broker_openstacks_hosts_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/service_broker_openstacks_hosts_get_parameters.go new file mode 100644 index 00000000000..0f29aa65ee4 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/service_broker_openstacks_hosts_get_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package open_stacks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewServiceBrokerOpenstacksHostsGetParams creates a new ServiceBrokerOpenstacksHostsGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewServiceBrokerOpenstacksHostsGetParams() *ServiceBrokerOpenstacksHostsGetParams { + return &ServiceBrokerOpenstacksHostsGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewServiceBrokerOpenstacksHostsGetParamsWithTimeout creates a new ServiceBrokerOpenstacksHostsGetParams object +// with the ability to set a timeout on a request. +func NewServiceBrokerOpenstacksHostsGetParamsWithTimeout(timeout time.Duration) *ServiceBrokerOpenstacksHostsGetParams { + return &ServiceBrokerOpenstacksHostsGetParams{ + timeout: timeout, + } +} + +// NewServiceBrokerOpenstacksHostsGetParamsWithContext creates a new ServiceBrokerOpenstacksHostsGetParams object +// with the ability to set a context for a request. +func NewServiceBrokerOpenstacksHostsGetParamsWithContext(ctx context.Context) *ServiceBrokerOpenstacksHostsGetParams { + return &ServiceBrokerOpenstacksHostsGetParams{ + Context: ctx, + } +} + +// NewServiceBrokerOpenstacksHostsGetParamsWithHTTPClient creates a new ServiceBrokerOpenstacksHostsGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewServiceBrokerOpenstacksHostsGetParamsWithHTTPClient(client *http.Client) *ServiceBrokerOpenstacksHostsGetParams { + return &ServiceBrokerOpenstacksHostsGetParams{ + HTTPClient: client, + } +} + +/* ServiceBrokerOpenstacksHostsGetParams contains all the parameters to send to the API endpoint + for the service broker openstacks hosts get operation. + + Typically these are written to a http.Request. +*/ +type ServiceBrokerOpenstacksHostsGetParams struct { + + /* Hostname. + + Hostname + */ + Hostname string + + /* OpenstackID. + + Openstack ID + */ + OpenstackID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the service broker openstacks hosts get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerOpenstacksHostsGetParams) WithDefaults() *ServiceBrokerOpenstacksHostsGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the service broker openstacks hosts get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerOpenstacksHostsGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the service broker openstacks hosts get params +func (o *ServiceBrokerOpenstacksHostsGetParams) WithTimeout(timeout time.Duration) *ServiceBrokerOpenstacksHostsGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the service broker openstacks hosts get params +func (o *ServiceBrokerOpenstacksHostsGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the service broker openstacks hosts get params +func (o *ServiceBrokerOpenstacksHostsGetParams) WithContext(ctx context.Context) *ServiceBrokerOpenstacksHostsGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the service broker openstacks hosts get params +func (o *ServiceBrokerOpenstacksHostsGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the service broker openstacks hosts get params +func (o *ServiceBrokerOpenstacksHostsGetParams) WithHTTPClient(client *http.Client) *ServiceBrokerOpenstacksHostsGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the service broker openstacks hosts get params +func (o *ServiceBrokerOpenstacksHostsGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithHostname adds the hostname to the service broker openstacks hosts get params +func (o *ServiceBrokerOpenstacksHostsGetParams) WithHostname(hostname string) *ServiceBrokerOpenstacksHostsGetParams { + o.SetHostname(hostname) + return o +} + +// SetHostname adds the hostname to the service broker openstacks hosts get params +func (o *ServiceBrokerOpenstacksHostsGetParams) SetHostname(hostname string) { + o.Hostname = hostname +} + +// WithOpenstackID adds the openstackID to the service broker openstacks hosts get params +func (o *ServiceBrokerOpenstacksHostsGetParams) WithOpenstackID(openstackID string) *ServiceBrokerOpenstacksHostsGetParams { + o.SetOpenstackID(openstackID) + return o +} + +// SetOpenstackID adds the openstackId to the service broker openstacks hosts get params +func (o *ServiceBrokerOpenstacksHostsGetParams) SetOpenstackID(openstackID string) { + o.OpenstackID = openstackID +} + +// WriteToRequest writes these params to a swagger request +func (o *ServiceBrokerOpenstacksHostsGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param hostname + if err := r.SetPathParam("hostname", o.Hostname); err != nil { + return err + } + + // path param openstack_id + if err := r.SetPathParam("openstack_id", o.OpenstackID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/service_broker_openstacks_hosts_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/service_broker_openstacks_hosts_get_responses.go new file mode 100644 index 00000000000..83eff4cf2e6 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/service_broker_openstacks_hosts_get_responses.go @@ -0,0 +1,181 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package open_stacks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// ServiceBrokerOpenstacksHostsGetReader is a Reader for the ServiceBrokerOpenstacksHostsGet structure. +type ServiceBrokerOpenstacksHostsGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ServiceBrokerOpenstacksHostsGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewServiceBrokerOpenstacksHostsGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewServiceBrokerOpenstacksHostsGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewServiceBrokerOpenstacksHostsGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewServiceBrokerOpenstacksHostsGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewServiceBrokerOpenstacksHostsGetOK creates a ServiceBrokerOpenstacksHostsGetOK with default headers values +func NewServiceBrokerOpenstacksHostsGetOK() *ServiceBrokerOpenstacksHostsGetOK { + return &ServiceBrokerOpenstacksHostsGetOK{} +} + +/* ServiceBrokerOpenstacksHostsGetOK describes a response with status code 200, with default header values. + +OK +*/ +type ServiceBrokerOpenstacksHostsGetOK struct { + Payload *models.HostInfo +} + +func (o *ServiceBrokerOpenstacksHostsGetOK) Error() string { + return fmt.Sprintf("[GET /broker/v1/openstacks/{openstack_id}/hosts/{hostname}][%d] serviceBrokerOpenstacksHostsGetOK %+v", 200, o.Payload) +} +func (o *ServiceBrokerOpenstacksHostsGetOK) GetPayload() *models.HostInfo { + return o.Payload +} + +func (o *ServiceBrokerOpenstacksHostsGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.HostInfo) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerOpenstacksHostsGetBadRequest creates a ServiceBrokerOpenstacksHostsGetBadRequest with default headers values +func NewServiceBrokerOpenstacksHostsGetBadRequest() *ServiceBrokerOpenstacksHostsGetBadRequest { + return &ServiceBrokerOpenstacksHostsGetBadRequest{} +} + +/* ServiceBrokerOpenstacksHostsGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type ServiceBrokerOpenstacksHostsGetBadRequest struct { + Payload *models.Error +} + +func (o *ServiceBrokerOpenstacksHostsGetBadRequest) Error() string { + return fmt.Sprintf("[GET /broker/v1/openstacks/{openstack_id}/hosts/{hostname}][%d] serviceBrokerOpenstacksHostsGetBadRequest %+v", 400, o.Payload) +} +func (o *ServiceBrokerOpenstacksHostsGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerOpenstacksHostsGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerOpenstacksHostsGetNotFound creates a ServiceBrokerOpenstacksHostsGetNotFound with default headers values +func NewServiceBrokerOpenstacksHostsGetNotFound() *ServiceBrokerOpenstacksHostsGetNotFound { + return &ServiceBrokerOpenstacksHostsGetNotFound{} +} + +/* ServiceBrokerOpenstacksHostsGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type ServiceBrokerOpenstacksHostsGetNotFound struct { + Payload *models.Error +} + +func (o *ServiceBrokerOpenstacksHostsGetNotFound) Error() string { + return fmt.Sprintf("[GET /broker/v1/openstacks/{openstack_id}/hosts/{hostname}][%d] serviceBrokerOpenstacksHostsGetNotFound %+v", 404, o.Payload) +} +func (o *ServiceBrokerOpenstacksHostsGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerOpenstacksHostsGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerOpenstacksHostsGetInternalServerError creates a ServiceBrokerOpenstacksHostsGetInternalServerError with default headers values +func NewServiceBrokerOpenstacksHostsGetInternalServerError() *ServiceBrokerOpenstacksHostsGetInternalServerError { + return &ServiceBrokerOpenstacksHostsGetInternalServerError{} +} + +/* ServiceBrokerOpenstacksHostsGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type ServiceBrokerOpenstacksHostsGetInternalServerError struct { + Payload *models.Error +} + +func (o *ServiceBrokerOpenstacksHostsGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /broker/v1/openstacks/{openstack_id}/hosts/{hostname}][%d] serviceBrokerOpenstacksHostsGetInternalServerError %+v", 500, o.Payload) +} +func (o *ServiceBrokerOpenstacksHostsGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerOpenstacksHostsGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/service_broker_openstacks_openstack_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/service_broker_openstacks_openstack_get_parameters.go new file mode 100644 index 00000000000..11249b70fb7 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/service_broker_openstacks_openstack_get_parameters.go @@ -0,0 +1,149 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package open_stacks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewServiceBrokerOpenstacksOpenstackGetParams creates a new ServiceBrokerOpenstacksOpenstackGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewServiceBrokerOpenstacksOpenstackGetParams() *ServiceBrokerOpenstacksOpenstackGetParams { + return &ServiceBrokerOpenstacksOpenstackGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewServiceBrokerOpenstacksOpenstackGetParamsWithTimeout creates a new ServiceBrokerOpenstacksOpenstackGetParams object +// with the ability to set a timeout on a request. +func NewServiceBrokerOpenstacksOpenstackGetParamsWithTimeout(timeout time.Duration) *ServiceBrokerOpenstacksOpenstackGetParams { + return &ServiceBrokerOpenstacksOpenstackGetParams{ + timeout: timeout, + } +} + +// NewServiceBrokerOpenstacksOpenstackGetParamsWithContext creates a new ServiceBrokerOpenstacksOpenstackGetParams object +// with the ability to set a context for a request. +func NewServiceBrokerOpenstacksOpenstackGetParamsWithContext(ctx context.Context) *ServiceBrokerOpenstacksOpenstackGetParams { + return &ServiceBrokerOpenstacksOpenstackGetParams{ + Context: ctx, + } +} + +// NewServiceBrokerOpenstacksOpenstackGetParamsWithHTTPClient creates a new ServiceBrokerOpenstacksOpenstackGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewServiceBrokerOpenstacksOpenstackGetParamsWithHTTPClient(client *http.Client) *ServiceBrokerOpenstacksOpenstackGetParams { + return &ServiceBrokerOpenstacksOpenstackGetParams{ + HTTPClient: client, + } +} + +/* ServiceBrokerOpenstacksOpenstackGetParams contains all the parameters to send to the API endpoint + for the service broker openstacks openstack get operation. + + Typically these are written to a http.Request. +*/ +type ServiceBrokerOpenstacksOpenstackGetParams struct { + + /* OpenstackID. + + Openstack ID + */ + OpenstackID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the service broker openstacks openstack get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerOpenstacksOpenstackGetParams) WithDefaults() *ServiceBrokerOpenstacksOpenstackGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the service broker openstacks openstack get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerOpenstacksOpenstackGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the service broker openstacks openstack get params +func (o *ServiceBrokerOpenstacksOpenstackGetParams) WithTimeout(timeout time.Duration) *ServiceBrokerOpenstacksOpenstackGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the service broker openstacks openstack get params +func (o *ServiceBrokerOpenstacksOpenstackGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the service broker openstacks openstack get params +func (o *ServiceBrokerOpenstacksOpenstackGetParams) WithContext(ctx context.Context) *ServiceBrokerOpenstacksOpenstackGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the service broker openstacks openstack get params +func (o *ServiceBrokerOpenstacksOpenstackGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the service broker openstacks openstack get params +func (o *ServiceBrokerOpenstacksOpenstackGetParams) WithHTTPClient(client *http.Client) *ServiceBrokerOpenstacksOpenstackGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the service broker openstacks openstack get params +func (o *ServiceBrokerOpenstacksOpenstackGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithOpenstackID adds the openstackID to the service broker openstacks openstack get params +func (o *ServiceBrokerOpenstacksOpenstackGetParams) WithOpenstackID(openstackID string) *ServiceBrokerOpenstacksOpenstackGetParams { + o.SetOpenstackID(openstackID) + return o +} + +// SetOpenstackID adds the openstackId to the service broker openstacks openstack get params +func (o *ServiceBrokerOpenstacksOpenstackGetParams) SetOpenstackID(openstackID string) { + o.OpenstackID = openstackID +} + +// WriteToRequest writes these params to a swagger request +func (o *ServiceBrokerOpenstacksOpenstackGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param openstack_id + if err := r.SetPathParam("openstack_id", o.OpenstackID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/service_broker_openstacks_openstack_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/service_broker_openstacks_openstack_get_responses.go new file mode 100644 index 00000000000..dece779e2ef --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/service_broker_openstacks_openstack_get_responses.go @@ -0,0 +1,181 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package open_stacks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// ServiceBrokerOpenstacksOpenstackGetReader is a Reader for the ServiceBrokerOpenstacksOpenstackGet structure. +type ServiceBrokerOpenstacksOpenstackGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ServiceBrokerOpenstacksOpenstackGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewServiceBrokerOpenstacksOpenstackGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewServiceBrokerOpenstacksOpenstackGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewServiceBrokerOpenstacksOpenstackGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewServiceBrokerOpenstacksOpenstackGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewServiceBrokerOpenstacksOpenstackGetOK creates a ServiceBrokerOpenstacksOpenstackGetOK with default headers values +func NewServiceBrokerOpenstacksOpenstackGetOK() *ServiceBrokerOpenstacksOpenstackGetOK { + return &ServiceBrokerOpenstacksOpenstackGetOK{} +} + +/* ServiceBrokerOpenstacksOpenstackGetOK describes a response with status code 200, with default header values. + +OK +*/ +type ServiceBrokerOpenstacksOpenstackGetOK struct { + Payload *models.OpenStackInfo +} + +func (o *ServiceBrokerOpenstacksOpenstackGetOK) Error() string { + return fmt.Sprintf("[GET /broker/v1/openstacks/{openstack_id}][%d] serviceBrokerOpenstacksOpenstackGetOK %+v", 200, o.Payload) +} +func (o *ServiceBrokerOpenstacksOpenstackGetOK) GetPayload() *models.OpenStackInfo { + return o.Payload +} + +func (o *ServiceBrokerOpenstacksOpenstackGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.OpenStackInfo) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerOpenstacksOpenstackGetBadRequest creates a ServiceBrokerOpenstacksOpenstackGetBadRequest with default headers values +func NewServiceBrokerOpenstacksOpenstackGetBadRequest() *ServiceBrokerOpenstacksOpenstackGetBadRequest { + return &ServiceBrokerOpenstacksOpenstackGetBadRequest{} +} + +/* ServiceBrokerOpenstacksOpenstackGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type ServiceBrokerOpenstacksOpenstackGetBadRequest struct { + Payload *models.Error +} + +func (o *ServiceBrokerOpenstacksOpenstackGetBadRequest) Error() string { + return fmt.Sprintf("[GET /broker/v1/openstacks/{openstack_id}][%d] serviceBrokerOpenstacksOpenstackGetBadRequest %+v", 400, o.Payload) +} +func (o *ServiceBrokerOpenstacksOpenstackGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerOpenstacksOpenstackGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerOpenstacksOpenstackGetNotFound creates a ServiceBrokerOpenstacksOpenstackGetNotFound with default headers values +func NewServiceBrokerOpenstacksOpenstackGetNotFound() *ServiceBrokerOpenstacksOpenstackGetNotFound { + return &ServiceBrokerOpenstacksOpenstackGetNotFound{} +} + +/* ServiceBrokerOpenstacksOpenstackGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type ServiceBrokerOpenstacksOpenstackGetNotFound struct { + Payload *models.Error +} + +func (o *ServiceBrokerOpenstacksOpenstackGetNotFound) Error() string { + return fmt.Sprintf("[GET /broker/v1/openstacks/{openstack_id}][%d] serviceBrokerOpenstacksOpenstackGetNotFound %+v", 404, o.Payload) +} +func (o *ServiceBrokerOpenstacksOpenstackGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerOpenstacksOpenstackGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerOpenstacksOpenstackGetInternalServerError creates a ServiceBrokerOpenstacksOpenstackGetInternalServerError with default headers values +func NewServiceBrokerOpenstacksOpenstackGetInternalServerError() *ServiceBrokerOpenstacksOpenstackGetInternalServerError { + return &ServiceBrokerOpenstacksOpenstackGetInternalServerError{} +} + +/* ServiceBrokerOpenstacksOpenstackGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type ServiceBrokerOpenstacksOpenstackGetInternalServerError struct { + Payload *models.Error +} + +func (o *ServiceBrokerOpenstacksOpenstackGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /broker/v1/openstacks/{openstack_id}][%d] serviceBrokerOpenstacksOpenstackGetInternalServerError %+v", 500, o.Payload) +} +func (o *ServiceBrokerOpenstacksOpenstackGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerOpenstacksOpenstackGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/service_broker_openstacks_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/service_broker_openstacks_post_parameters.go new file mode 100644 index 00000000000..32935216b2d --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/service_broker_openstacks_post_parameters.go @@ -0,0 +1,151 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package open_stacks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewServiceBrokerOpenstacksPostParams creates a new ServiceBrokerOpenstacksPostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewServiceBrokerOpenstacksPostParams() *ServiceBrokerOpenstacksPostParams { + return &ServiceBrokerOpenstacksPostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewServiceBrokerOpenstacksPostParamsWithTimeout creates a new ServiceBrokerOpenstacksPostParams object +// with the ability to set a timeout on a request. +func NewServiceBrokerOpenstacksPostParamsWithTimeout(timeout time.Duration) *ServiceBrokerOpenstacksPostParams { + return &ServiceBrokerOpenstacksPostParams{ + timeout: timeout, + } +} + +// NewServiceBrokerOpenstacksPostParamsWithContext creates a new ServiceBrokerOpenstacksPostParams object +// with the ability to set a context for a request. +func NewServiceBrokerOpenstacksPostParamsWithContext(ctx context.Context) *ServiceBrokerOpenstacksPostParams { + return &ServiceBrokerOpenstacksPostParams{ + Context: ctx, + } +} + +// NewServiceBrokerOpenstacksPostParamsWithHTTPClient creates a new ServiceBrokerOpenstacksPostParams object +// with the ability to set a custom HTTPClient for a request. +func NewServiceBrokerOpenstacksPostParamsWithHTTPClient(client *http.Client) *ServiceBrokerOpenstacksPostParams { + return &ServiceBrokerOpenstacksPostParams{ + HTTPClient: client, + } +} + +/* ServiceBrokerOpenstacksPostParams contains all the parameters to send to the API endpoint + for the service broker openstacks post operation. + + Typically these are written to a http.Request. +*/ +type ServiceBrokerOpenstacksPostParams struct { + + /* Body. + + Parameters for the creation of a new Open Stack Instance + */ + Body *models.OpenStackCreate + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the service broker openstacks post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerOpenstacksPostParams) WithDefaults() *ServiceBrokerOpenstacksPostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the service broker openstacks post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerOpenstacksPostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the service broker openstacks post params +func (o *ServiceBrokerOpenstacksPostParams) WithTimeout(timeout time.Duration) *ServiceBrokerOpenstacksPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the service broker openstacks post params +func (o *ServiceBrokerOpenstacksPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the service broker openstacks post params +func (o *ServiceBrokerOpenstacksPostParams) WithContext(ctx context.Context) *ServiceBrokerOpenstacksPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the service broker openstacks post params +func (o *ServiceBrokerOpenstacksPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the service broker openstacks post params +func (o *ServiceBrokerOpenstacksPostParams) WithHTTPClient(client *http.Client) *ServiceBrokerOpenstacksPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the service broker openstacks post params +func (o *ServiceBrokerOpenstacksPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the service broker openstacks post params +func (o *ServiceBrokerOpenstacksPostParams) WithBody(body *models.OpenStackCreate) *ServiceBrokerOpenstacksPostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the service broker openstacks post params +func (o *ServiceBrokerOpenstacksPostParams) SetBody(body *models.OpenStackCreate) { + o.Body = body +} + +// WriteToRequest writes these params to a swagger request +func (o *ServiceBrokerOpenstacksPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/service_broker_openstacks_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/service_broker_openstacks_post_responses.go new file mode 100644 index 00000000000..b83e9e39719 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/service_broker_openstacks_post_responses.go @@ -0,0 +1,257 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package open_stacks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// ServiceBrokerOpenstacksPostReader is a Reader for the ServiceBrokerOpenstacksPost structure. +type ServiceBrokerOpenstacksPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ServiceBrokerOpenstacksPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewServiceBrokerOpenstacksPostOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 201: + result := NewServiceBrokerOpenstacksPostCreated() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewServiceBrokerOpenstacksPostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewServiceBrokerOpenstacksPostConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewServiceBrokerOpenstacksPostUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewServiceBrokerOpenstacksPostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewServiceBrokerOpenstacksPostOK creates a ServiceBrokerOpenstacksPostOK with default headers values +func NewServiceBrokerOpenstacksPostOK() *ServiceBrokerOpenstacksPostOK { + return &ServiceBrokerOpenstacksPostOK{} +} + +/* ServiceBrokerOpenstacksPostOK describes a response with status code 200, with default header values. + +OK +*/ +type ServiceBrokerOpenstacksPostOK struct { + Payload *models.OpenStack +} + +func (o *ServiceBrokerOpenstacksPostOK) Error() string { + return fmt.Sprintf("[POST /broker/v1/openstacks][%d] serviceBrokerOpenstacksPostOK %+v", 200, o.Payload) +} +func (o *ServiceBrokerOpenstacksPostOK) GetPayload() *models.OpenStack { + return o.Payload +} + +func (o *ServiceBrokerOpenstacksPostOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.OpenStack) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerOpenstacksPostCreated creates a ServiceBrokerOpenstacksPostCreated with default headers values +func NewServiceBrokerOpenstacksPostCreated() *ServiceBrokerOpenstacksPostCreated { + return &ServiceBrokerOpenstacksPostCreated{} +} + +/* ServiceBrokerOpenstacksPostCreated describes a response with status code 201, with default header values. + +Created +*/ +type ServiceBrokerOpenstacksPostCreated struct { + Payload *models.OpenStack +} + +func (o *ServiceBrokerOpenstacksPostCreated) Error() string { + return fmt.Sprintf("[POST /broker/v1/openstacks][%d] serviceBrokerOpenstacksPostCreated %+v", 201, o.Payload) +} +func (o *ServiceBrokerOpenstacksPostCreated) GetPayload() *models.OpenStack { + return o.Payload +} + +func (o *ServiceBrokerOpenstacksPostCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.OpenStack) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerOpenstacksPostBadRequest creates a ServiceBrokerOpenstacksPostBadRequest with default headers values +func NewServiceBrokerOpenstacksPostBadRequest() *ServiceBrokerOpenstacksPostBadRequest { + return &ServiceBrokerOpenstacksPostBadRequest{} +} + +/* ServiceBrokerOpenstacksPostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type ServiceBrokerOpenstacksPostBadRequest struct { + Payload *models.Error +} + +func (o *ServiceBrokerOpenstacksPostBadRequest) Error() string { + return fmt.Sprintf("[POST /broker/v1/openstacks][%d] serviceBrokerOpenstacksPostBadRequest %+v", 400, o.Payload) +} +func (o *ServiceBrokerOpenstacksPostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerOpenstacksPostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerOpenstacksPostConflict creates a ServiceBrokerOpenstacksPostConflict with default headers values +func NewServiceBrokerOpenstacksPostConflict() *ServiceBrokerOpenstacksPostConflict { + return &ServiceBrokerOpenstacksPostConflict{} +} + +/* ServiceBrokerOpenstacksPostConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type ServiceBrokerOpenstacksPostConflict struct { + Payload *models.Error +} + +func (o *ServiceBrokerOpenstacksPostConflict) Error() string { + return fmt.Sprintf("[POST /broker/v1/openstacks][%d] serviceBrokerOpenstacksPostConflict %+v", 409, o.Payload) +} +func (o *ServiceBrokerOpenstacksPostConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerOpenstacksPostConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerOpenstacksPostUnprocessableEntity creates a ServiceBrokerOpenstacksPostUnprocessableEntity with default headers values +func NewServiceBrokerOpenstacksPostUnprocessableEntity() *ServiceBrokerOpenstacksPostUnprocessableEntity { + return &ServiceBrokerOpenstacksPostUnprocessableEntity{} +} + +/* ServiceBrokerOpenstacksPostUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type ServiceBrokerOpenstacksPostUnprocessableEntity struct { + Payload *models.Error +} + +func (o *ServiceBrokerOpenstacksPostUnprocessableEntity) Error() string { + return fmt.Sprintf("[POST /broker/v1/openstacks][%d] serviceBrokerOpenstacksPostUnprocessableEntity %+v", 422, o.Payload) +} +func (o *ServiceBrokerOpenstacksPostUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerOpenstacksPostUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerOpenstacksPostInternalServerError creates a ServiceBrokerOpenstacksPostInternalServerError with default headers values +func NewServiceBrokerOpenstacksPostInternalServerError() *ServiceBrokerOpenstacksPostInternalServerError { + return &ServiceBrokerOpenstacksPostInternalServerError{} +} + +/* ServiceBrokerOpenstacksPostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type ServiceBrokerOpenstacksPostInternalServerError struct { + Payload *models.Error +} + +func (o *ServiceBrokerOpenstacksPostInternalServerError) Error() string { + return fmt.Sprintf("[POST /broker/v1/openstacks][%d] serviceBrokerOpenstacksPostInternalServerError %+v", 500, o.Payload) +} +func (o *ServiceBrokerOpenstacksPostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerOpenstacksPostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/service_broker_openstacks_servers_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/service_broker_openstacks_servers_get_parameters.go new file mode 100644 index 00000000000..dbe1a1a52fc --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/service_broker_openstacks_servers_get_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package open_stacks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewServiceBrokerOpenstacksServersGetParams creates a new ServiceBrokerOpenstacksServersGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewServiceBrokerOpenstacksServersGetParams() *ServiceBrokerOpenstacksServersGetParams { + return &ServiceBrokerOpenstacksServersGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewServiceBrokerOpenstacksServersGetParamsWithTimeout creates a new ServiceBrokerOpenstacksServersGetParams object +// with the ability to set a timeout on a request. +func NewServiceBrokerOpenstacksServersGetParamsWithTimeout(timeout time.Duration) *ServiceBrokerOpenstacksServersGetParams { + return &ServiceBrokerOpenstacksServersGetParams{ + timeout: timeout, + } +} + +// NewServiceBrokerOpenstacksServersGetParamsWithContext creates a new ServiceBrokerOpenstacksServersGetParams object +// with the ability to set a context for a request. +func NewServiceBrokerOpenstacksServersGetParamsWithContext(ctx context.Context) *ServiceBrokerOpenstacksServersGetParams { + return &ServiceBrokerOpenstacksServersGetParams{ + Context: ctx, + } +} + +// NewServiceBrokerOpenstacksServersGetParamsWithHTTPClient creates a new ServiceBrokerOpenstacksServersGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewServiceBrokerOpenstacksServersGetParamsWithHTTPClient(client *http.Client) *ServiceBrokerOpenstacksServersGetParams { + return &ServiceBrokerOpenstacksServersGetParams{ + HTTPClient: client, + } +} + +/* ServiceBrokerOpenstacksServersGetParams contains all the parameters to send to the API endpoint + for the service broker openstacks servers get operation. + + Typically these are written to a http.Request. +*/ +type ServiceBrokerOpenstacksServersGetParams struct { + + /* OpenstackID. + + Openstack ID + */ + OpenstackID string + + /* PvmInstanceID. + + PCloud PVM Instance ID + */ + PvmInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the service broker openstacks servers get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerOpenstacksServersGetParams) WithDefaults() *ServiceBrokerOpenstacksServersGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the service broker openstacks servers get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerOpenstacksServersGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the service broker openstacks servers get params +func (o *ServiceBrokerOpenstacksServersGetParams) WithTimeout(timeout time.Duration) *ServiceBrokerOpenstacksServersGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the service broker openstacks servers get params +func (o *ServiceBrokerOpenstacksServersGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the service broker openstacks servers get params +func (o *ServiceBrokerOpenstacksServersGetParams) WithContext(ctx context.Context) *ServiceBrokerOpenstacksServersGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the service broker openstacks servers get params +func (o *ServiceBrokerOpenstacksServersGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the service broker openstacks servers get params +func (o *ServiceBrokerOpenstacksServersGetParams) WithHTTPClient(client *http.Client) *ServiceBrokerOpenstacksServersGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the service broker openstacks servers get params +func (o *ServiceBrokerOpenstacksServersGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithOpenstackID adds the openstackID to the service broker openstacks servers get params +func (o *ServiceBrokerOpenstacksServersGetParams) WithOpenstackID(openstackID string) *ServiceBrokerOpenstacksServersGetParams { + o.SetOpenstackID(openstackID) + return o +} + +// SetOpenstackID adds the openstackId to the service broker openstacks servers get params +func (o *ServiceBrokerOpenstacksServersGetParams) SetOpenstackID(openstackID string) { + o.OpenstackID = openstackID +} + +// WithPvmInstanceID adds the pvmInstanceID to the service broker openstacks servers get params +func (o *ServiceBrokerOpenstacksServersGetParams) WithPvmInstanceID(pvmInstanceID string) *ServiceBrokerOpenstacksServersGetParams { + o.SetPvmInstanceID(pvmInstanceID) + return o +} + +// SetPvmInstanceID adds the pvmInstanceId to the service broker openstacks servers get params +func (o *ServiceBrokerOpenstacksServersGetParams) SetPvmInstanceID(pvmInstanceID string) { + o.PvmInstanceID = pvmInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *ServiceBrokerOpenstacksServersGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param openstack_id + if err := r.SetPathParam("openstack_id", o.OpenstackID); err != nil { + return err + } + + // path param pvm_instance_id + if err := r.SetPathParam("pvm_instance_id", o.PvmInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/service_broker_openstacks_servers_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/service_broker_openstacks_servers_get_responses.go new file mode 100644 index 00000000000..d52ebc75f71 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/open_stacks/service_broker_openstacks_servers_get_responses.go @@ -0,0 +1,181 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package open_stacks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// ServiceBrokerOpenstacksServersGetReader is a Reader for the ServiceBrokerOpenstacksServersGet structure. +type ServiceBrokerOpenstacksServersGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ServiceBrokerOpenstacksServersGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewServiceBrokerOpenstacksServersGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewServiceBrokerOpenstacksServersGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewServiceBrokerOpenstacksServersGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewServiceBrokerOpenstacksServersGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewServiceBrokerOpenstacksServersGetOK creates a ServiceBrokerOpenstacksServersGetOK with default headers values +func NewServiceBrokerOpenstacksServersGetOK() *ServiceBrokerOpenstacksServersGetOK { + return &ServiceBrokerOpenstacksServersGetOK{} +} + +/* ServiceBrokerOpenstacksServersGetOK describes a response with status code 200, with default header values. + +OK +*/ +type ServiceBrokerOpenstacksServersGetOK struct { + Payload *models.HostPVMInstance +} + +func (o *ServiceBrokerOpenstacksServersGetOK) Error() string { + return fmt.Sprintf("[GET /broker/v1/openstacks/{openstack_id}/servers/{pvm_instance_id}][%d] serviceBrokerOpenstacksServersGetOK %+v", 200, o.Payload) +} +func (o *ServiceBrokerOpenstacksServersGetOK) GetPayload() *models.HostPVMInstance { + return o.Payload +} + +func (o *ServiceBrokerOpenstacksServersGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.HostPVMInstance) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerOpenstacksServersGetBadRequest creates a ServiceBrokerOpenstacksServersGetBadRequest with default headers values +func NewServiceBrokerOpenstacksServersGetBadRequest() *ServiceBrokerOpenstacksServersGetBadRequest { + return &ServiceBrokerOpenstacksServersGetBadRequest{} +} + +/* ServiceBrokerOpenstacksServersGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type ServiceBrokerOpenstacksServersGetBadRequest struct { + Payload *models.Error +} + +func (o *ServiceBrokerOpenstacksServersGetBadRequest) Error() string { + return fmt.Sprintf("[GET /broker/v1/openstacks/{openstack_id}/servers/{pvm_instance_id}][%d] serviceBrokerOpenstacksServersGetBadRequest %+v", 400, o.Payload) +} +func (o *ServiceBrokerOpenstacksServersGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerOpenstacksServersGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerOpenstacksServersGetNotFound creates a ServiceBrokerOpenstacksServersGetNotFound with default headers values +func NewServiceBrokerOpenstacksServersGetNotFound() *ServiceBrokerOpenstacksServersGetNotFound { + return &ServiceBrokerOpenstacksServersGetNotFound{} +} + +/* ServiceBrokerOpenstacksServersGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type ServiceBrokerOpenstacksServersGetNotFound struct { + Payload *models.Error +} + +func (o *ServiceBrokerOpenstacksServersGetNotFound) Error() string { + return fmt.Sprintf("[GET /broker/v1/openstacks/{openstack_id}/servers/{pvm_instance_id}][%d] serviceBrokerOpenstacksServersGetNotFound %+v", 404, o.Payload) +} +func (o *ServiceBrokerOpenstacksServersGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerOpenstacksServersGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerOpenstacksServersGetInternalServerError creates a ServiceBrokerOpenstacksServersGetInternalServerError with default headers values +func NewServiceBrokerOpenstacksServersGetInternalServerError() *ServiceBrokerOpenstacksServersGetInternalServerError { + return &ServiceBrokerOpenstacksServersGetInternalServerError{} +} + +/* ServiceBrokerOpenstacksServersGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type ServiceBrokerOpenstacksServersGetInternalServerError struct { + Payload *models.Error +} + +func (o *ServiceBrokerOpenstacksServersGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /broker/v1/openstacks/{openstack_id}/servers/{pvm_instance_id}][%d] serviceBrokerOpenstacksServersGetInternalServerError %+v", 500, o.Payload) +} +func (o *ServiceBrokerOpenstacksServersGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerOpenstacksServersGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/p_cloud_cloud_connections_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/p_cloud_cloud_connections_client.go new file mode 100644 index 00000000000..6b3a5437c37 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/p_cloud_cloud_connections_client.go @@ -0,0 +1,374 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_cloud_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new p cloud cloud connections API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for p cloud cloud connections API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + PcloudCloudconnectionsDelete(params *PcloudCloudconnectionsDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudconnectionsDeleteOK, *PcloudCloudconnectionsDeleteAccepted, error) + + PcloudCloudconnectionsGet(params *PcloudCloudconnectionsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudconnectionsGetOK, error) + + PcloudCloudconnectionsGetall(params *PcloudCloudconnectionsGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudconnectionsGetallOK, error) + + PcloudCloudconnectionsNetworksDelete(params *PcloudCloudconnectionsNetworksDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudconnectionsNetworksDeleteOK, *PcloudCloudconnectionsNetworksDeleteAccepted, error) + + PcloudCloudconnectionsNetworksPut(params *PcloudCloudconnectionsNetworksPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudconnectionsNetworksPutOK, *PcloudCloudconnectionsNetworksPutAccepted, error) + + PcloudCloudconnectionsPost(params *PcloudCloudconnectionsPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudconnectionsPostOK, *PcloudCloudconnectionsPostCreated, *PcloudCloudconnectionsPostAccepted, error) + + PcloudCloudconnectionsPut(params *PcloudCloudconnectionsPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudconnectionsPutOK, *PcloudCloudconnectionsPutAccepted, error) + + PcloudCloudconnectionsVirtualprivatecloudsGetall(params *PcloudCloudconnectionsVirtualprivatecloudsGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudconnectionsVirtualprivatecloudsGetallOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + PcloudCloudconnectionsDelete deletes a cloud connection +*/ +func (a *Client) PcloudCloudconnectionsDelete(params *PcloudCloudconnectionsDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudconnectionsDeleteOK, *PcloudCloudconnectionsDeleteAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudconnectionsDeleteParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.cloudconnections.delete", + Method: "DELETE", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudconnectionsDeleteReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, nil, err + } + switch value := result.(type) { + case *PcloudCloudconnectionsDeleteOK: + return value, nil, nil + case *PcloudCloudconnectionsDeleteAccepted: + return nil, value, nil + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for p_cloud_cloud_connections: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudCloudconnectionsGet gets a cloud connection s state information +*/ +func (a *Client) PcloudCloudconnectionsGet(params *PcloudCloudconnectionsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudconnectionsGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudconnectionsGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.cloudconnections.get", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudconnectionsGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudCloudconnectionsGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.cloudconnections.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudCloudconnectionsGetall gets all cloud connections in this cloud instance +*/ +func (a *Client) PcloudCloudconnectionsGetall(params *PcloudCloudconnectionsGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudconnectionsGetallOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudconnectionsGetallParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.cloudconnections.getall", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudconnectionsGetallReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudCloudconnectionsGetallOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.cloudconnections.getall: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudCloudconnectionsNetworksDelete deletes a network from a cloud connection +*/ +func (a *Client) PcloudCloudconnectionsNetworksDelete(params *PcloudCloudconnectionsNetworksDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudconnectionsNetworksDeleteOK, *PcloudCloudconnectionsNetworksDeleteAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudconnectionsNetworksDeleteParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.cloudconnections.networks.delete", + Method: "DELETE", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}/networks/{network_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudconnectionsNetworksDeleteReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, nil, err + } + switch value := result.(type) { + case *PcloudCloudconnectionsNetworksDeleteOK: + return value, nil, nil + case *PcloudCloudconnectionsNetworksDeleteAccepted: + return nil, value, nil + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for p_cloud_cloud_connections: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudCloudconnectionsNetworksPut adds a network to the cloud connection +*/ +func (a *Client) PcloudCloudconnectionsNetworksPut(params *PcloudCloudconnectionsNetworksPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudconnectionsNetworksPutOK, *PcloudCloudconnectionsNetworksPutAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudconnectionsNetworksPutParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.cloudconnections.networks.put", + Method: "PUT", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}/networks/{network_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudconnectionsNetworksPutReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, nil, err + } + switch value := result.(type) { + case *PcloudCloudconnectionsNetworksPutOK: + return value, nil, nil + case *PcloudCloudconnectionsNetworksPutAccepted: + return nil, value, nil + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for p_cloud_cloud_connections: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudCloudconnectionsPost creates a new cloud connection +*/ +func (a *Client) PcloudCloudconnectionsPost(params *PcloudCloudconnectionsPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudconnectionsPostOK, *PcloudCloudconnectionsPostCreated, *PcloudCloudconnectionsPostAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudconnectionsPostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.cloudconnections.post", + Method: "POST", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudconnectionsPostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, nil, nil, err + } + switch value := result.(type) { + case *PcloudCloudconnectionsPostOK: + return value, nil, nil, nil + case *PcloudCloudconnectionsPostCreated: + return nil, value, nil, nil + case *PcloudCloudconnectionsPostAccepted: + return nil, nil, value, nil + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for p_cloud_cloud_connections: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudCloudconnectionsPut updates a cloud connection +*/ +func (a *Client) PcloudCloudconnectionsPut(params *PcloudCloudconnectionsPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudconnectionsPutOK, *PcloudCloudconnectionsPutAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudconnectionsPutParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.cloudconnections.put", + Method: "PUT", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudconnectionsPutReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, nil, err + } + switch value := result.(type) { + case *PcloudCloudconnectionsPutOK: + return value, nil, nil + case *PcloudCloudconnectionsPutAccepted: + return nil, value, nil + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for p_cloud_cloud_connections: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudCloudconnectionsVirtualprivatecloudsGetall gets all virtual private cloud connections in this cloud instance +*/ +func (a *Client) PcloudCloudconnectionsVirtualprivatecloudsGetall(params *PcloudCloudconnectionsVirtualprivatecloudsGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudconnectionsVirtualprivatecloudsGetallOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudconnectionsVirtualprivatecloudsGetallParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.cloudconnections.virtualprivateclouds.getall", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections-virtual-private-clouds", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudconnectionsVirtualprivatecloudsGetallReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudCloudconnectionsVirtualprivatecloudsGetallOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.cloudconnections.virtualprivateclouds.getall: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_delete_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_delete_parameters.go new file mode 100644 index 00000000000..9cbc14c98f4 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_delete_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_cloud_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudCloudconnectionsDeleteParams creates a new PcloudCloudconnectionsDeleteParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudCloudconnectionsDeleteParams() *PcloudCloudconnectionsDeleteParams { + return &PcloudCloudconnectionsDeleteParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudconnectionsDeleteParamsWithTimeout creates a new PcloudCloudconnectionsDeleteParams object +// with the ability to set a timeout on a request. +func NewPcloudCloudconnectionsDeleteParamsWithTimeout(timeout time.Duration) *PcloudCloudconnectionsDeleteParams { + return &PcloudCloudconnectionsDeleteParams{ + timeout: timeout, + } +} + +// NewPcloudCloudconnectionsDeleteParamsWithContext creates a new PcloudCloudconnectionsDeleteParams object +// with the ability to set a context for a request. +func NewPcloudCloudconnectionsDeleteParamsWithContext(ctx context.Context) *PcloudCloudconnectionsDeleteParams { + return &PcloudCloudconnectionsDeleteParams{ + Context: ctx, + } +} + +// NewPcloudCloudconnectionsDeleteParamsWithHTTPClient creates a new PcloudCloudconnectionsDeleteParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudCloudconnectionsDeleteParamsWithHTTPClient(client *http.Client) *PcloudCloudconnectionsDeleteParams { + return &PcloudCloudconnectionsDeleteParams{ + HTTPClient: client, + } +} + +/* PcloudCloudconnectionsDeleteParams contains all the parameters to send to the API endpoint + for the pcloud cloudconnections delete operation. + + Typically these are written to a http.Request. +*/ +type PcloudCloudconnectionsDeleteParams struct { + + /* CloudConnectionID. + + Cloud Connection ID + */ + CloudConnectionID string + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud cloudconnections delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudconnectionsDeleteParams) WithDefaults() *PcloudCloudconnectionsDeleteParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud cloudconnections delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudconnectionsDeleteParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud cloudconnections delete params +func (o *PcloudCloudconnectionsDeleteParams) WithTimeout(timeout time.Duration) *PcloudCloudconnectionsDeleteParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudconnections delete params +func (o *PcloudCloudconnectionsDeleteParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudconnections delete params +func (o *PcloudCloudconnectionsDeleteParams) WithContext(ctx context.Context) *PcloudCloudconnectionsDeleteParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudconnections delete params +func (o *PcloudCloudconnectionsDeleteParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudconnections delete params +func (o *PcloudCloudconnectionsDeleteParams) WithHTTPClient(client *http.Client) *PcloudCloudconnectionsDeleteParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudconnections delete params +func (o *PcloudCloudconnectionsDeleteParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudConnectionID adds the cloudConnectionID to the pcloud cloudconnections delete params +func (o *PcloudCloudconnectionsDeleteParams) WithCloudConnectionID(cloudConnectionID string) *PcloudCloudconnectionsDeleteParams { + o.SetCloudConnectionID(cloudConnectionID) + return o +} + +// SetCloudConnectionID adds the cloudConnectionId to the pcloud cloudconnections delete params +func (o *PcloudCloudconnectionsDeleteParams) SetCloudConnectionID(cloudConnectionID string) { + o.CloudConnectionID = cloudConnectionID +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudconnections delete params +func (o *PcloudCloudconnectionsDeleteParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudconnectionsDeleteParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudconnections delete params +func (o *PcloudCloudconnectionsDeleteParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudconnectionsDeleteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_connection_id + if err := r.SetPathParam("cloud_connection_id", o.CloudConnectionID); err != nil { + return err + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_delete_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_delete_responses.go new file mode 100644 index 00000000000..6d5d1c69029 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_delete_responses.go @@ -0,0 +1,255 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_cloud_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudconnectionsDeleteReader is a Reader for the PcloudCloudconnectionsDelete structure. +type PcloudCloudconnectionsDeleteReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudconnectionsDeleteReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudCloudconnectionsDeleteOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 202: + result := NewPcloudCloudconnectionsDeleteAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudCloudconnectionsDeleteBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudCloudconnectionsDeleteUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 410: + result := NewPcloudCloudconnectionsDeleteGone() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudCloudconnectionsDeleteInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudCloudconnectionsDeleteOK creates a PcloudCloudconnectionsDeleteOK with default headers values +func NewPcloudCloudconnectionsDeleteOK() *PcloudCloudconnectionsDeleteOK { + return &PcloudCloudconnectionsDeleteOK{} +} + +/* PcloudCloudconnectionsDeleteOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudCloudconnectionsDeleteOK struct { + Payload models.Object +} + +func (o *PcloudCloudconnectionsDeleteOK) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}][%d] pcloudCloudconnectionsDeleteOK %+v", 200, o.Payload) +} +func (o *PcloudCloudconnectionsDeleteOK) GetPayload() models.Object { + return o.Payload +} + +func (o *PcloudCloudconnectionsDeleteOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsDeleteAccepted creates a PcloudCloudconnectionsDeleteAccepted with default headers values +func NewPcloudCloudconnectionsDeleteAccepted() *PcloudCloudconnectionsDeleteAccepted { + return &PcloudCloudconnectionsDeleteAccepted{} +} + +/* PcloudCloudconnectionsDeleteAccepted describes a response with status code 202, with default header values. + +Accepted +*/ +type PcloudCloudconnectionsDeleteAccepted struct { + Payload *models.JobReference +} + +func (o *PcloudCloudconnectionsDeleteAccepted) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}][%d] pcloudCloudconnectionsDeleteAccepted %+v", 202, o.Payload) +} +func (o *PcloudCloudconnectionsDeleteAccepted) GetPayload() *models.JobReference { + return o.Payload +} + +func (o *PcloudCloudconnectionsDeleteAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.JobReference) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsDeleteBadRequest creates a PcloudCloudconnectionsDeleteBadRequest with default headers values +func NewPcloudCloudconnectionsDeleteBadRequest() *PcloudCloudconnectionsDeleteBadRequest { + return &PcloudCloudconnectionsDeleteBadRequest{} +} + +/* PcloudCloudconnectionsDeleteBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudCloudconnectionsDeleteBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsDeleteBadRequest) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}][%d] pcloudCloudconnectionsDeleteBadRequest %+v", 400, o.Payload) +} +func (o *PcloudCloudconnectionsDeleteBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsDeleteBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsDeleteUnauthorized creates a PcloudCloudconnectionsDeleteUnauthorized with default headers values +func NewPcloudCloudconnectionsDeleteUnauthorized() *PcloudCloudconnectionsDeleteUnauthorized { + return &PcloudCloudconnectionsDeleteUnauthorized{} +} + +/* PcloudCloudconnectionsDeleteUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudCloudconnectionsDeleteUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsDeleteUnauthorized) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}][%d] pcloudCloudconnectionsDeleteUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudCloudconnectionsDeleteUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsDeleteUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsDeleteGone creates a PcloudCloudconnectionsDeleteGone with default headers values +func NewPcloudCloudconnectionsDeleteGone() *PcloudCloudconnectionsDeleteGone { + return &PcloudCloudconnectionsDeleteGone{} +} + +/* PcloudCloudconnectionsDeleteGone describes a response with status code 410, with default header values. + +Gone +*/ +type PcloudCloudconnectionsDeleteGone struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsDeleteGone) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}][%d] pcloudCloudconnectionsDeleteGone %+v", 410, o.Payload) +} +func (o *PcloudCloudconnectionsDeleteGone) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsDeleteGone) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsDeleteInternalServerError creates a PcloudCloudconnectionsDeleteInternalServerError with default headers values +func NewPcloudCloudconnectionsDeleteInternalServerError() *PcloudCloudconnectionsDeleteInternalServerError { + return &PcloudCloudconnectionsDeleteInternalServerError{} +} + +/* PcloudCloudconnectionsDeleteInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudCloudconnectionsDeleteInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsDeleteInternalServerError) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}][%d] pcloudCloudconnectionsDeleteInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudCloudconnectionsDeleteInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsDeleteInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_get_parameters.go new file mode 100644 index 00000000000..16a386f8d24 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_get_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_cloud_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudCloudconnectionsGetParams creates a new PcloudCloudconnectionsGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudCloudconnectionsGetParams() *PcloudCloudconnectionsGetParams { + return &PcloudCloudconnectionsGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudconnectionsGetParamsWithTimeout creates a new PcloudCloudconnectionsGetParams object +// with the ability to set a timeout on a request. +func NewPcloudCloudconnectionsGetParamsWithTimeout(timeout time.Duration) *PcloudCloudconnectionsGetParams { + return &PcloudCloudconnectionsGetParams{ + timeout: timeout, + } +} + +// NewPcloudCloudconnectionsGetParamsWithContext creates a new PcloudCloudconnectionsGetParams object +// with the ability to set a context for a request. +func NewPcloudCloudconnectionsGetParamsWithContext(ctx context.Context) *PcloudCloudconnectionsGetParams { + return &PcloudCloudconnectionsGetParams{ + Context: ctx, + } +} + +// NewPcloudCloudconnectionsGetParamsWithHTTPClient creates a new PcloudCloudconnectionsGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudCloudconnectionsGetParamsWithHTTPClient(client *http.Client) *PcloudCloudconnectionsGetParams { + return &PcloudCloudconnectionsGetParams{ + HTTPClient: client, + } +} + +/* PcloudCloudconnectionsGetParams contains all the parameters to send to the API endpoint + for the pcloud cloudconnections get operation. + + Typically these are written to a http.Request. +*/ +type PcloudCloudconnectionsGetParams struct { + + /* CloudConnectionID. + + Cloud Connection ID + */ + CloudConnectionID string + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud cloudconnections get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudconnectionsGetParams) WithDefaults() *PcloudCloudconnectionsGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud cloudconnections get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudconnectionsGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud cloudconnections get params +func (o *PcloudCloudconnectionsGetParams) WithTimeout(timeout time.Duration) *PcloudCloudconnectionsGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudconnections get params +func (o *PcloudCloudconnectionsGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudconnections get params +func (o *PcloudCloudconnectionsGetParams) WithContext(ctx context.Context) *PcloudCloudconnectionsGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudconnections get params +func (o *PcloudCloudconnectionsGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudconnections get params +func (o *PcloudCloudconnectionsGetParams) WithHTTPClient(client *http.Client) *PcloudCloudconnectionsGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudconnections get params +func (o *PcloudCloudconnectionsGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudConnectionID adds the cloudConnectionID to the pcloud cloudconnections get params +func (o *PcloudCloudconnectionsGetParams) WithCloudConnectionID(cloudConnectionID string) *PcloudCloudconnectionsGetParams { + o.SetCloudConnectionID(cloudConnectionID) + return o +} + +// SetCloudConnectionID adds the cloudConnectionId to the pcloud cloudconnections get params +func (o *PcloudCloudconnectionsGetParams) SetCloudConnectionID(cloudConnectionID string) { + o.CloudConnectionID = cloudConnectionID +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudconnections get params +func (o *PcloudCloudconnectionsGetParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudconnectionsGetParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudconnections get params +func (o *PcloudCloudconnectionsGetParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudconnectionsGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_connection_id + if err := r.SetPathParam("cloud_connection_id", o.CloudConnectionID); err != nil { + return err + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_get_responses.go new file mode 100644 index 00000000000..5a75e69a4c4 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_get_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_cloud_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudconnectionsGetReader is a Reader for the PcloudCloudconnectionsGet structure. +type PcloudCloudconnectionsGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudconnectionsGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudCloudconnectionsGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudCloudconnectionsGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudCloudconnectionsGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudCloudconnectionsGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudCloudconnectionsGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudCloudconnectionsGetOK creates a PcloudCloudconnectionsGetOK with default headers values +func NewPcloudCloudconnectionsGetOK() *PcloudCloudconnectionsGetOK { + return &PcloudCloudconnectionsGetOK{} +} + +/* PcloudCloudconnectionsGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudCloudconnectionsGetOK struct { + Payload *models.CloudConnection +} + +func (o *PcloudCloudconnectionsGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}][%d] pcloudCloudconnectionsGetOK %+v", 200, o.Payload) +} +func (o *PcloudCloudconnectionsGetOK) GetPayload() *models.CloudConnection { + return o.Payload +} + +func (o *PcloudCloudconnectionsGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.CloudConnection) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsGetBadRequest creates a PcloudCloudconnectionsGetBadRequest with default headers values +func NewPcloudCloudconnectionsGetBadRequest() *PcloudCloudconnectionsGetBadRequest { + return &PcloudCloudconnectionsGetBadRequest{} +} + +/* PcloudCloudconnectionsGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudCloudconnectionsGetBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsGetBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}][%d] pcloudCloudconnectionsGetBadRequest %+v", 400, o.Payload) +} +func (o *PcloudCloudconnectionsGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsGetUnauthorized creates a PcloudCloudconnectionsGetUnauthorized with default headers values +func NewPcloudCloudconnectionsGetUnauthorized() *PcloudCloudconnectionsGetUnauthorized { + return &PcloudCloudconnectionsGetUnauthorized{} +} + +/* PcloudCloudconnectionsGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudCloudconnectionsGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}][%d] pcloudCloudconnectionsGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudCloudconnectionsGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsGetNotFound creates a PcloudCloudconnectionsGetNotFound with default headers values +func NewPcloudCloudconnectionsGetNotFound() *PcloudCloudconnectionsGetNotFound { + return &PcloudCloudconnectionsGetNotFound{} +} + +/* PcloudCloudconnectionsGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudCloudconnectionsGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}][%d] pcloudCloudconnectionsGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudCloudconnectionsGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsGetInternalServerError creates a PcloudCloudconnectionsGetInternalServerError with default headers values +func NewPcloudCloudconnectionsGetInternalServerError() *PcloudCloudconnectionsGetInternalServerError { + return &PcloudCloudconnectionsGetInternalServerError{} +} + +/* PcloudCloudconnectionsGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudCloudconnectionsGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}][%d] pcloudCloudconnectionsGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudCloudconnectionsGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_getall_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_getall_parameters.go new file mode 100644 index 00000000000..ab74a7af066 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_getall_parameters.go @@ -0,0 +1,149 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_cloud_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudCloudconnectionsGetallParams creates a new PcloudCloudconnectionsGetallParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudCloudconnectionsGetallParams() *PcloudCloudconnectionsGetallParams { + return &PcloudCloudconnectionsGetallParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudconnectionsGetallParamsWithTimeout creates a new PcloudCloudconnectionsGetallParams object +// with the ability to set a timeout on a request. +func NewPcloudCloudconnectionsGetallParamsWithTimeout(timeout time.Duration) *PcloudCloudconnectionsGetallParams { + return &PcloudCloudconnectionsGetallParams{ + timeout: timeout, + } +} + +// NewPcloudCloudconnectionsGetallParamsWithContext creates a new PcloudCloudconnectionsGetallParams object +// with the ability to set a context for a request. +func NewPcloudCloudconnectionsGetallParamsWithContext(ctx context.Context) *PcloudCloudconnectionsGetallParams { + return &PcloudCloudconnectionsGetallParams{ + Context: ctx, + } +} + +// NewPcloudCloudconnectionsGetallParamsWithHTTPClient creates a new PcloudCloudconnectionsGetallParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudCloudconnectionsGetallParamsWithHTTPClient(client *http.Client) *PcloudCloudconnectionsGetallParams { + return &PcloudCloudconnectionsGetallParams{ + HTTPClient: client, + } +} + +/* PcloudCloudconnectionsGetallParams contains all the parameters to send to the API endpoint + for the pcloud cloudconnections getall operation. + + Typically these are written to a http.Request. +*/ +type PcloudCloudconnectionsGetallParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud cloudconnections getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudconnectionsGetallParams) WithDefaults() *PcloudCloudconnectionsGetallParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud cloudconnections getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudconnectionsGetallParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud cloudconnections getall params +func (o *PcloudCloudconnectionsGetallParams) WithTimeout(timeout time.Duration) *PcloudCloudconnectionsGetallParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudconnections getall params +func (o *PcloudCloudconnectionsGetallParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudconnections getall params +func (o *PcloudCloudconnectionsGetallParams) WithContext(ctx context.Context) *PcloudCloudconnectionsGetallParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudconnections getall params +func (o *PcloudCloudconnectionsGetallParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudconnections getall params +func (o *PcloudCloudconnectionsGetallParams) WithHTTPClient(client *http.Client) *PcloudCloudconnectionsGetallParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudconnections getall params +func (o *PcloudCloudconnectionsGetallParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudconnections getall params +func (o *PcloudCloudconnectionsGetallParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudconnectionsGetallParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudconnections getall params +func (o *PcloudCloudconnectionsGetallParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudconnectionsGetallParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_getall_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_getall_responses.go new file mode 100644 index 00000000000..f096d6de76a --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_getall_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_cloud_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudconnectionsGetallReader is a Reader for the PcloudCloudconnectionsGetall structure. +type PcloudCloudconnectionsGetallReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudconnectionsGetallReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudCloudconnectionsGetallOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudCloudconnectionsGetallBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudCloudconnectionsGetallUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 408: + result := NewPcloudCloudconnectionsGetallRequestTimeout() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudCloudconnectionsGetallInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudCloudconnectionsGetallOK creates a PcloudCloudconnectionsGetallOK with default headers values +func NewPcloudCloudconnectionsGetallOK() *PcloudCloudconnectionsGetallOK { + return &PcloudCloudconnectionsGetallOK{} +} + +/* PcloudCloudconnectionsGetallOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudCloudconnectionsGetallOK struct { + Payload *models.CloudConnections +} + +func (o *PcloudCloudconnectionsGetallOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections][%d] pcloudCloudconnectionsGetallOK %+v", 200, o.Payload) +} +func (o *PcloudCloudconnectionsGetallOK) GetPayload() *models.CloudConnections { + return o.Payload +} + +func (o *PcloudCloudconnectionsGetallOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.CloudConnections) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsGetallBadRequest creates a PcloudCloudconnectionsGetallBadRequest with default headers values +func NewPcloudCloudconnectionsGetallBadRequest() *PcloudCloudconnectionsGetallBadRequest { + return &PcloudCloudconnectionsGetallBadRequest{} +} + +/* PcloudCloudconnectionsGetallBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudCloudconnectionsGetallBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsGetallBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections][%d] pcloudCloudconnectionsGetallBadRequest %+v", 400, o.Payload) +} +func (o *PcloudCloudconnectionsGetallBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsGetallBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsGetallUnauthorized creates a PcloudCloudconnectionsGetallUnauthorized with default headers values +func NewPcloudCloudconnectionsGetallUnauthorized() *PcloudCloudconnectionsGetallUnauthorized { + return &PcloudCloudconnectionsGetallUnauthorized{} +} + +/* PcloudCloudconnectionsGetallUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudCloudconnectionsGetallUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsGetallUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections][%d] pcloudCloudconnectionsGetallUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudCloudconnectionsGetallUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsGetallUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsGetallRequestTimeout creates a PcloudCloudconnectionsGetallRequestTimeout with default headers values +func NewPcloudCloudconnectionsGetallRequestTimeout() *PcloudCloudconnectionsGetallRequestTimeout { + return &PcloudCloudconnectionsGetallRequestTimeout{} +} + +/* PcloudCloudconnectionsGetallRequestTimeout describes a response with status code 408, with default header values. + +Request Timeout +*/ +type PcloudCloudconnectionsGetallRequestTimeout struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsGetallRequestTimeout) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections][%d] pcloudCloudconnectionsGetallRequestTimeout %+v", 408, o.Payload) +} +func (o *PcloudCloudconnectionsGetallRequestTimeout) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsGetallRequestTimeout) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsGetallInternalServerError creates a PcloudCloudconnectionsGetallInternalServerError with default headers values +func NewPcloudCloudconnectionsGetallInternalServerError() *PcloudCloudconnectionsGetallInternalServerError { + return &PcloudCloudconnectionsGetallInternalServerError{} +} + +/* PcloudCloudconnectionsGetallInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudCloudconnectionsGetallInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsGetallInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections][%d] pcloudCloudconnectionsGetallInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudCloudconnectionsGetallInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsGetallInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_networks_delete_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_networks_delete_parameters.go new file mode 100644 index 00000000000..e3c9466d439 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_networks_delete_parameters.go @@ -0,0 +1,193 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_cloud_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudCloudconnectionsNetworksDeleteParams creates a new PcloudCloudconnectionsNetworksDeleteParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudCloudconnectionsNetworksDeleteParams() *PcloudCloudconnectionsNetworksDeleteParams { + return &PcloudCloudconnectionsNetworksDeleteParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudconnectionsNetworksDeleteParamsWithTimeout creates a new PcloudCloudconnectionsNetworksDeleteParams object +// with the ability to set a timeout on a request. +func NewPcloudCloudconnectionsNetworksDeleteParamsWithTimeout(timeout time.Duration) *PcloudCloudconnectionsNetworksDeleteParams { + return &PcloudCloudconnectionsNetworksDeleteParams{ + timeout: timeout, + } +} + +// NewPcloudCloudconnectionsNetworksDeleteParamsWithContext creates a new PcloudCloudconnectionsNetworksDeleteParams object +// with the ability to set a context for a request. +func NewPcloudCloudconnectionsNetworksDeleteParamsWithContext(ctx context.Context) *PcloudCloudconnectionsNetworksDeleteParams { + return &PcloudCloudconnectionsNetworksDeleteParams{ + Context: ctx, + } +} + +// NewPcloudCloudconnectionsNetworksDeleteParamsWithHTTPClient creates a new PcloudCloudconnectionsNetworksDeleteParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudCloudconnectionsNetworksDeleteParamsWithHTTPClient(client *http.Client) *PcloudCloudconnectionsNetworksDeleteParams { + return &PcloudCloudconnectionsNetworksDeleteParams{ + HTTPClient: client, + } +} + +/* PcloudCloudconnectionsNetworksDeleteParams contains all the parameters to send to the API endpoint + for the pcloud cloudconnections networks delete operation. + + Typically these are written to a http.Request. +*/ +type PcloudCloudconnectionsNetworksDeleteParams struct { + + /* CloudConnectionID. + + Cloud Connection ID + */ + CloudConnectionID string + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* NetworkID. + + Network ID + */ + NetworkID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud cloudconnections networks delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudconnectionsNetworksDeleteParams) WithDefaults() *PcloudCloudconnectionsNetworksDeleteParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud cloudconnections networks delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudconnectionsNetworksDeleteParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud cloudconnections networks delete params +func (o *PcloudCloudconnectionsNetworksDeleteParams) WithTimeout(timeout time.Duration) *PcloudCloudconnectionsNetworksDeleteParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudconnections networks delete params +func (o *PcloudCloudconnectionsNetworksDeleteParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudconnections networks delete params +func (o *PcloudCloudconnectionsNetworksDeleteParams) WithContext(ctx context.Context) *PcloudCloudconnectionsNetworksDeleteParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudconnections networks delete params +func (o *PcloudCloudconnectionsNetworksDeleteParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudconnections networks delete params +func (o *PcloudCloudconnectionsNetworksDeleteParams) WithHTTPClient(client *http.Client) *PcloudCloudconnectionsNetworksDeleteParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudconnections networks delete params +func (o *PcloudCloudconnectionsNetworksDeleteParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudConnectionID adds the cloudConnectionID to the pcloud cloudconnections networks delete params +func (o *PcloudCloudconnectionsNetworksDeleteParams) WithCloudConnectionID(cloudConnectionID string) *PcloudCloudconnectionsNetworksDeleteParams { + o.SetCloudConnectionID(cloudConnectionID) + return o +} + +// SetCloudConnectionID adds the cloudConnectionId to the pcloud cloudconnections networks delete params +func (o *PcloudCloudconnectionsNetworksDeleteParams) SetCloudConnectionID(cloudConnectionID string) { + o.CloudConnectionID = cloudConnectionID +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudconnections networks delete params +func (o *PcloudCloudconnectionsNetworksDeleteParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudconnectionsNetworksDeleteParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudconnections networks delete params +func (o *PcloudCloudconnectionsNetworksDeleteParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithNetworkID adds the networkID to the pcloud cloudconnections networks delete params +func (o *PcloudCloudconnectionsNetworksDeleteParams) WithNetworkID(networkID string) *PcloudCloudconnectionsNetworksDeleteParams { + o.SetNetworkID(networkID) + return o +} + +// SetNetworkID adds the networkId to the pcloud cloudconnections networks delete params +func (o *PcloudCloudconnectionsNetworksDeleteParams) SetNetworkID(networkID string) { + o.NetworkID = networkID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudconnectionsNetworksDeleteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_connection_id + if err := r.SetPathParam("cloud_connection_id", o.CloudConnectionID); err != nil { + return err + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param network_id + if err := r.SetPathParam("network_id", o.NetworkID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_networks_delete_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_networks_delete_responses.go new file mode 100644 index 00000000000..02137028515 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_networks_delete_responses.go @@ -0,0 +1,257 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_cloud_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudconnectionsNetworksDeleteReader is a Reader for the PcloudCloudconnectionsNetworksDelete structure. +type PcloudCloudconnectionsNetworksDeleteReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudconnectionsNetworksDeleteReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudCloudconnectionsNetworksDeleteOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 202: + result := NewPcloudCloudconnectionsNetworksDeleteAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudCloudconnectionsNetworksDeleteBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudCloudconnectionsNetworksDeleteUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 410: + result := NewPcloudCloudconnectionsNetworksDeleteGone() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudCloudconnectionsNetworksDeleteInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudCloudconnectionsNetworksDeleteOK creates a PcloudCloudconnectionsNetworksDeleteOK with default headers values +func NewPcloudCloudconnectionsNetworksDeleteOK() *PcloudCloudconnectionsNetworksDeleteOK { + return &PcloudCloudconnectionsNetworksDeleteOK{} +} + +/* PcloudCloudconnectionsNetworksDeleteOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudCloudconnectionsNetworksDeleteOK struct { + Payload *models.CloudConnection +} + +func (o *PcloudCloudconnectionsNetworksDeleteOK) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}/networks/{network_id}][%d] pcloudCloudconnectionsNetworksDeleteOK %+v", 200, o.Payload) +} +func (o *PcloudCloudconnectionsNetworksDeleteOK) GetPayload() *models.CloudConnection { + return o.Payload +} + +func (o *PcloudCloudconnectionsNetworksDeleteOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.CloudConnection) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsNetworksDeleteAccepted creates a PcloudCloudconnectionsNetworksDeleteAccepted with default headers values +func NewPcloudCloudconnectionsNetworksDeleteAccepted() *PcloudCloudconnectionsNetworksDeleteAccepted { + return &PcloudCloudconnectionsNetworksDeleteAccepted{} +} + +/* PcloudCloudconnectionsNetworksDeleteAccepted describes a response with status code 202, with default header values. + +Accepted +*/ +type PcloudCloudconnectionsNetworksDeleteAccepted struct { + Payload *models.JobReference +} + +func (o *PcloudCloudconnectionsNetworksDeleteAccepted) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}/networks/{network_id}][%d] pcloudCloudconnectionsNetworksDeleteAccepted %+v", 202, o.Payload) +} +func (o *PcloudCloudconnectionsNetworksDeleteAccepted) GetPayload() *models.JobReference { + return o.Payload +} + +func (o *PcloudCloudconnectionsNetworksDeleteAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.JobReference) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsNetworksDeleteBadRequest creates a PcloudCloudconnectionsNetworksDeleteBadRequest with default headers values +func NewPcloudCloudconnectionsNetworksDeleteBadRequest() *PcloudCloudconnectionsNetworksDeleteBadRequest { + return &PcloudCloudconnectionsNetworksDeleteBadRequest{} +} + +/* PcloudCloudconnectionsNetworksDeleteBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudCloudconnectionsNetworksDeleteBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsNetworksDeleteBadRequest) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}/networks/{network_id}][%d] pcloudCloudconnectionsNetworksDeleteBadRequest %+v", 400, o.Payload) +} +func (o *PcloudCloudconnectionsNetworksDeleteBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsNetworksDeleteBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsNetworksDeleteUnauthorized creates a PcloudCloudconnectionsNetworksDeleteUnauthorized with default headers values +func NewPcloudCloudconnectionsNetworksDeleteUnauthorized() *PcloudCloudconnectionsNetworksDeleteUnauthorized { + return &PcloudCloudconnectionsNetworksDeleteUnauthorized{} +} + +/* PcloudCloudconnectionsNetworksDeleteUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudCloudconnectionsNetworksDeleteUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsNetworksDeleteUnauthorized) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}/networks/{network_id}][%d] pcloudCloudconnectionsNetworksDeleteUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudCloudconnectionsNetworksDeleteUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsNetworksDeleteUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsNetworksDeleteGone creates a PcloudCloudconnectionsNetworksDeleteGone with default headers values +func NewPcloudCloudconnectionsNetworksDeleteGone() *PcloudCloudconnectionsNetworksDeleteGone { + return &PcloudCloudconnectionsNetworksDeleteGone{} +} + +/* PcloudCloudconnectionsNetworksDeleteGone describes a response with status code 410, with default header values. + +Gone +*/ +type PcloudCloudconnectionsNetworksDeleteGone struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsNetworksDeleteGone) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}/networks/{network_id}][%d] pcloudCloudconnectionsNetworksDeleteGone %+v", 410, o.Payload) +} +func (o *PcloudCloudconnectionsNetworksDeleteGone) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsNetworksDeleteGone) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsNetworksDeleteInternalServerError creates a PcloudCloudconnectionsNetworksDeleteInternalServerError with default headers values +func NewPcloudCloudconnectionsNetworksDeleteInternalServerError() *PcloudCloudconnectionsNetworksDeleteInternalServerError { + return &PcloudCloudconnectionsNetworksDeleteInternalServerError{} +} + +/* PcloudCloudconnectionsNetworksDeleteInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudCloudconnectionsNetworksDeleteInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsNetworksDeleteInternalServerError) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}/networks/{network_id}][%d] pcloudCloudconnectionsNetworksDeleteInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudCloudconnectionsNetworksDeleteInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsNetworksDeleteInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_networks_put_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_networks_put_parameters.go new file mode 100644 index 00000000000..c19e5e7ad4a --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_networks_put_parameters.go @@ -0,0 +1,193 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_cloud_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudCloudconnectionsNetworksPutParams creates a new PcloudCloudconnectionsNetworksPutParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudCloudconnectionsNetworksPutParams() *PcloudCloudconnectionsNetworksPutParams { + return &PcloudCloudconnectionsNetworksPutParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudconnectionsNetworksPutParamsWithTimeout creates a new PcloudCloudconnectionsNetworksPutParams object +// with the ability to set a timeout on a request. +func NewPcloudCloudconnectionsNetworksPutParamsWithTimeout(timeout time.Duration) *PcloudCloudconnectionsNetworksPutParams { + return &PcloudCloudconnectionsNetworksPutParams{ + timeout: timeout, + } +} + +// NewPcloudCloudconnectionsNetworksPutParamsWithContext creates a new PcloudCloudconnectionsNetworksPutParams object +// with the ability to set a context for a request. +func NewPcloudCloudconnectionsNetworksPutParamsWithContext(ctx context.Context) *PcloudCloudconnectionsNetworksPutParams { + return &PcloudCloudconnectionsNetworksPutParams{ + Context: ctx, + } +} + +// NewPcloudCloudconnectionsNetworksPutParamsWithHTTPClient creates a new PcloudCloudconnectionsNetworksPutParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudCloudconnectionsNetworksPutParamsWithHTTPClient(client *http.Client) *PcloudCloudconnectionsNetworksPutParams { + return &PcloudCloudconnectionsNetworksPutParams{ + HTTPClient: client, + } +} + +/* PcloudCloudconnectionsNetworksPutParams contains all the parameters to send to the API endpoint + for the pcloud cloudconnections networks put operation. + + Typically these are written to a http.Request. +*/ +type PcloudCloudconnectionsNetworksPutParams struct { + + /* CloudConnectionID. + + Cloud Connection ID + */ + CloudConnectionID string + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* NetworkID. + + Network ID + */ + NetworkID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud cloudconnections networks put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudconnectionsNetworksPutParams) WithDefaults() *PcloudCloudconnectionsNetworksPutParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud cloudconnections networks put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudconnectionsNetworksPutParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud cloudconnections networks put params +func (o *PcloudCloudconnectionsNetworksPutParams) WithTimeout(timeout time.Duration) *PcloudCloudconnectionsNetworksPutParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudconnections networks put params +func (o *PcloudCloudconnectionsNetworksPutParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudconnections networks put params +func (o *PcloudCloudconnectionsNetworksPutParams) WithContext(ctx context.Context) *PcloudCloudconnectionsNetworksPutParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudconnections networks put params +func (o *PcloudCloudconnectionsNetworksPutParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudconnections networks put params +func (o *PcloudCloudconnectionsNetworksPutParams) WithHTTPClient(client *http.Client) *PcloudCloudconnectionsNetworksPutParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudconnections networks put params +func (o *PcloudCloudconnectionsNetworksPutParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudConnectionID adds the cloudConnectionID to the pcloud cloudconnections networks put params +func (o *PcloudCloudconnectionsNetworksPutParams) WithCloudConnectionID(cloudConnectionID string) *PcloudCloudconnectionsNetworksPutParams { + o.SetCloudConnectionID(cloudConnectionID) + return o +} + +// SetCloudConnectionID adds the cloudConnectionId to the pcloud cloudconnections networks put params +func (o *PcloudCloudconnectionsNetworksPutParams) SetCloudConnectionID(cloudConnectionID string) { + o.CloudConnectionID = cloudConnectionID +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudconnections networks put params +func (o *PcloudCloudconnectionsNetworksPutParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudconnectionsNetworksPutParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudconnections networks put params +func (o *PcloudCloudconnectionsNetworksPutParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithNetworkID adds the networkID to the pcloud cloudconnections networks put params +func (o *PcloudCloudconnectionsNetworksPutParams) WithNetworkID(networkID string) *PcloudCloudconnectionsNetworksPutParams { + o.SetNetworkID(networkID) + return o +} + +// SetNetworkID adds the networkId to the pcloud cloudconnections networks put params +func (o *PcloudCloudconnectionsNetworksPutParams) SetNetworkID(networkID string) { + o.NetworkID = networkID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudconnectionsNetworksPutParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_connection_id + if err := r.SetPathParam("cloud_connection_id", o.CloudConnectionID); err != nil { + return err + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param network_id + if err := r.SetPathParam("network_id", o.NetworkID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_networks_put_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_networks_put_responses.go new file mode 100644 index 00000000000..e4abe1cc082 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_networks_put_responses.go @@ -0,0 +1,257 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_cloud_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudconnectionsNetworksPutReader is a Reader for the PcloudCloudconnectionsNetworksPut structure. +type PcloudCloudconnectionsNetworksPutReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudconnectionsNetworksPutReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudCloudconnectionsNetworksPutOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 202: + result := NewPcloudCloudconnectionsNetworksPutAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudCloudconnectionsNetworksPutBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudCloudconnectionsNetworksPutUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudCloudconnectionsNetworksPutUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudCloudconnectionsNetworksPutInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudCloudconnectionsNetworksPutOK creates a PcloudCloudconnectionsNetworksPutOK with default headers values +func NewPcloudCloudconnectionsNetworksPutOK() *PcloudCloudconnectionsNetworksPutOK { + return &PcloudCloudconnectionsNetworksPutOK{} +} + +/* PcloudCloudconnectionsNetworksPutOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudCloudconnectionsNetworksPutOK struct { + Payload *models.CloudConnection +} + +func (o *PcloudCloudconnectionsNetworksPutOK) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}/networks/{network_id}][%d] pcloudCloudconnectionsNetworksPutOK %+v", 200, o.Payload) +} +func (o *PcloudCloudconnectionsNetworksPutOK) GetPayload() *models.CloudConnection { + return o.Payload +} + +func (o *PcloudCloudconnectionsNetworksPutOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.CloudConnection) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsNetworksPutAccepted creates a PcloudCloudconnectionsNetworksPutAccepted with default headers values +func NewPcloudCloudconnectionsNetworksPutAccepted() *PcloudCloudconnectionsNetworksPutAccepted { + return &PcloudCloudconnectionsNetworksPutAccepted{} +} + +/* PcloudCloudconnectionsNetworksPutAccepted describes a response with status code 202, with default header values. + +Accepted +*/ +type PcloudCloudconnectionsNetworksPutAccepted struct { + Payload *models.JobReference +} + +func (o *PcloudCloudconnectionsNetworksPutAccepted) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}/networks/{network_id}][%d] pcloudCloudconnectionsNetworksPutAccepted %+v", 202, o.Payload) +} +func (o *PcloudCloudconnectionsNetworksPutAccepted) GetPayload() *models.JobReference { + return o.Payload +} + +func (o *PcloudCloudconnectionsNetworksPutAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.JobReference) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsNetworksPutBadRequest creates a PcloudCloudconnectionsNetworksPutBadRequest with default headers values +func NewPcloudCloudconnectionsNetworksPutBadRequest() *PcloudCloudconnectionsNetworksPutBadRequest { + return &PcloudCloudconnectionsNetworksPutBadRequest{} +} + +/* PcloudCloudconnectionsNetworksPutBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudCloudconnectionsNetworksPutBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsNetworksPutBadRequest) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}/networks/{network_id}][%d] pcloudCloudconnectionsNetworksPutBadRequest %+v", 400, o.Payload) +} +func (o *PcloudCloudconnectionsNetworksPutBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsNetworksPutBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsNetworksPutUnauthorized creates a PcloudCloudconnectionsNetworksPutUnauthorized with default headers values +func NewPcloudCloudconnectionsNetworksPutUnauthorized() *PcloudCloudconnectionsNetworksPutUnauthorized { + return &PcloudCloudconnectionsNetworksPutUnauthorized{} +} + +/* PcloudCloudconnectionsNetworksPutUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudCloudconnectionsNetworksPutUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsNetworksPutUnauthorized) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}/networks/{network_id}][%d] pcloudCloudconnectionsNetworksPutUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudCloudconnectionsNetworksPutUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsNetworksPutUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsNetworksPutUnprocessableEntity creates a PcloudCloudconnectionsNetworksPutUnprocessableEntity with default headers values +func NewPcloudCloudconnectionsNetworksPutUnprocessableEntity() *PcloudCloudconnectionsNetworksPutUnprocessableEntity { + return &PcloudCloudconnectionsNetworksPutUnprocessableEntity{} +} + +/* PcloudCloudconnectionsNetworksPutUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudCloudconnectionsNetworksPutUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsNetworksPutUnprocessableEntity) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}/networks/{network_id}][%d] pcloudCloudconnectionsNetworksPutUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudCloudconnectionsNetworksPutUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsNetworksPutUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsNetworksPutInternalServerError creates a PcloudCloudconnectionsNetworksPutInternalServerError with default headers values +func NewPcloudCloudconnectionsNetworksPutInternalServerError() *PcloudCloudconnectionsNetworksPutInternalServerError { + return &PcloudCloudconnectionsNetworksPutInternalServerError{} +} + +/* PcloudCloudconnectionsNetworksPutInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudCloudconnectionsNetworksPutInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsNetworksPutInternalServerError) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}/networks/{network_id}][%d] pcloudCloudconnectionsNetworksPutInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudCloudconnectionsNetworksPutInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsNetworksPutInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_post_parameters.go new file mode 100644 index 00000000000..71ee602f8c9 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_post_parameters.go @@ -0,0 +1,173 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_cloud_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudCloudconnectionsPostParams creates a new PcloudCloudconnectionsPostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudCloudconnectionsPostParams() *PcloudCloudconnectionsPostParams { + return &PcloudCloudconnectionsPostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudconnectionsPostParamsWithTimeout creates a new PcloudCloudconnectionsPostParams object +// with the ability to set a timeout on a request. +func NewPcloudCloudconnectionsPostParamsWithTimeout(timeout time.Duration) *PcloudCloudconnectionsPostParams { + return &PcloudCloudconnectionsPostParams{ + timeout: timeout, + } +} + +// NewPcloudCloudconnectionsPostParamsWithContext creates a new PcloudCloudconnectionsPostParams object +// with the ability to set a context for a request. +func NewPcloudCloudconnectionsPostParamsWithContext(ctx context.Context) *PcloudCloudconnectionsPostParams { + return &PcloudCloudconnectionsPostParams{ + Context: ctx, + } +} + +// NewPcloudCloudconnectionsPostParamsWithHTTPClient creates a new PcloudCloudconnectionsPostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudCloudconnectionsPostParamsWithHTTPClient(client *http.Client) *PcloudCloudconnectionsPostParams { + return &PcloudCloudconnectionsPostParams{ + HTTPClient: client, + } +} + +/* PcloudCloudconnectionsPostParams contains all the parameters to send to the API endpoint + for the pcloud cloudconnections post operation. + + Typically these are written to a http.Request. +*/ +type PcloudCloudconnectionsPostParams struct { + + /* Body. + + Parameters for the creation of a new cloud connection + */ + Body *models.CloudConnectionCreate + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud cloudconnections post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudconnectionsPostParams) WithDefaults() *PcloudCloudconnectionsPostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud cloudconnections post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudconnectionsPostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud cloudconnections post params +func (o *PcloudCloudconnectionsPostParams) WithTimeout(timeout time.Duration) *PcloudCloudconnectionsPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudconnections post params +func (o *PcloudCloudconnectionsPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudconnections post params +func (o *PcloudCloudconnectionsPostParams) WithContext(ctx context.Context) *PcloudCloudconnectionsPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudconnections post params +func (o *PcloudCloudconnectionsPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudconnections post params +func (o *PcloudCloudconnectionsPostParams) WithHTTPClient(client *http.Client) *PcloudCloudconnectionsPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudconnections post params +func (o *PcloudCloudconnectionsPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud cloudconnections post params +func (o *PcloudCloudconnectionsPostParams) WithBody(body *models.CloudConnectionCreate) *PcloudCloudconnectionsPostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud cloudconnections post params +func (o *PcloudCloudconnectionsPostParams) SetBody(body *models.CloudConnectionCreate) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudconnections post params +func (o *PcloudCloudconnectionsPostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudconnectionsPostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudconnections post params +func (o *PcloudCloudconnectionsPostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudconnectionsPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_post_responses.go new file mode 100644 index 00000000000..b0f46e4e926 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_post_responses.go @@ -0,0 +1,333 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_cloud_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudconnectionsPostReader is a Reader for the PcloudCloudconnectionsPost structure. +type PcloudCloudconnectionsPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudconnectionsPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudCloudconnectionsPostOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 201: + result := NewPcloudCloudconnectionsPostCreated() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 202: + result := NewPcloudCloudconnectionsPostAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudCloudconnectionsPostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudCloudconnectionsPostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewPcloudCloudconnectionsPostConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudCloudconnectionsPostUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudCloudconnectionsPostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudCloudconnectionsPostOK creates a PcloudCloudconnectionsPostOK with default headers values +func NewPcloudCloudconnectionsPostOK() *PcloudCloudconnectionsPostOK { + return &PcloudCloudconnectionsPostOK{} +} + +/* PcloudCloudconnectionsPostOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudCloudconnectionsPostOK struct { + Payload *models.CloudConnection +} + +func (o *PcloudCloudconnectionsPostOK) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections][%d] pcloudCloudconnectionsPostOK %+v", 200, o.Payload) +} +func (o *PcloudCloudconnectionsPostOK) GetPayload() *models.CloudConnection { + return o.Payload +} + +func (o *PcloudCloudconnectionsPostOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.CloudConnection) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsPostCreated creates a PcloudCloudconnectionsPostCreated with default headers values +func NewPcloudCloudconnectionsPostCreated() *PcloudCloudconnectionsPostCreated { + return &PcloudCloudconnectionsPostCreated{} +} + +/* PcloudCloudconnectionsPostCreated describes a response with status code 201, with default header values. + +Created +*/ +type PcloudCloudconnectionsPostCreated struct { + Payload *models.CloudConnection +} + +func (o *PcloudCloudconnectionsPostCreated) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections][%d] pcloudCloudconnectionsPostCreated %+v", 201, o.Payload) +} +func (o *PcloudCloudconnectionsPostCreated) GetPayload() *models.CloudConnection { + return o.Payload +} + +func (o *PcloudCloudconnectionsPostCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.CloudConnection) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsPostAccepted creates a PcloudCloudconnectionsPostAccepted with default headers values +func NewPcloudCloudconnectionsPostAccepted() *PcloudCloudconnectionsPostAccepted { + return &PcloudCloudconnectionsPostAccepted{} +} + +/* PcloudCloudconnectionsPostAccepted describes a response with status code 202, with default header values. + +Accepted +*/ +type PcloudCloudconnectionsPostAccepted struct { + Payload *models.CloudConnectionCreateResponse +} + +func (o *PcloudCloudconnectionsPostAccepted) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections][%d] pcloudCloudconnectionsPostAccepted %+v", 202, o.Payload) +} +func (o *PcloudCloudconnectionsPostAccepted) GetPayload() *models.CloudConnectionCreateResponse { + return o.Payload +} + +func (o *PcloudCloudconnectionsPostAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.CloudConnectionCreateResponse) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsPostBadRequest creates a PcloudCloudconnectionsPostBadRequest with default headers values +func NewPcloudCloudconnectionsPostBadRequest() *PcloudCloudconnectionsPostBadRequest { + return &PcloudCloudconnectionsPostBadRequest{} +} + +/* PcloudCloudconnectionsPostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudCloudconnectionsPostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsPostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections][%d] pcloudCloudconnectionsPostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudCloudconnectionsPostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsPostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsPostUnauthorized creates a PcloudCloudconnectionsPostUnauthorized with default headers values +func NewPcloudCloudconnectionsPostUnauthorized() *PcloudCloudconnectionsPostUnauthorized { + return &PcloudCloudconnectionsPostUnauthorized{} +} + +/* PcloudCloudconnectionsPostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudCloudconnectionsPostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsPostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections][%d] pcloudCloudconnectionsPostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudCloudconnectionsPostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsPostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsPostConflict creates a PcloudCloudconnectionsPostConflict with default headers values +func NewPcloudCloudconnectionsPostConflict() *PcloudCloudconnectionsPostConflict { + return &PcloudCloudconnectionsPostConflict{} +} + +/* PcloudCloudconnectionsPostConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type PcloudCloudconnectionsPostConflict struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsPostConflict) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections][%d] pcloudCloudconnectionsPostConflict %+v", 409, o.Payload) +} +func (o *PcloudCloudconnectionsPostConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsPostConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsPostUnprocessableEntity creates a PcloudCloudconnectionsPostUnprocessableEntity with default headers values +func NewPcloudCloudconnectionsPostUnprocessableEntity() *PcloudCloudconnectionsPostUnprocessableEntity { + return &PcloudCloudconnectionsPostUnprocessableEntity{} +} + +/* PcloudCloudconnectionsPostUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudCloudconnectionsPostUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsPostUnprocessableEntity) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections][%d] pcloudCloudconnectionsPostUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudCloudconnectionsPostUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsPostUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsPostInternalServerError creates a PcloudCloudconnectionsPostInternalServerError with default headers values +func NewPcloudCloudconnectionsPostInternalServerError() *PcloudCloudconnectionsPostInternalServerError { + return &PcloudCloudconnectionsPostInternalServerError{} +} + +/* PcloudCloudconnectionsPostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudCloudconnectionsPostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsPostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections][%d] pcloudCloudconnectionsPostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudCloudconnectionsPostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsPostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_put_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_put_parameters.go new file mode 100644 index 00000000000..136980886a0 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_put_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_cloud_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudCloudconnectionsPutParams creates a new PcloudCloudconnectionsPutParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudCloudconnectionsPutParams() *PcloudCloudconnectionsPutParams { + return &PcloudCloudconnectionsPutParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudconnectionsPutParamsWithTimeout creates a new PcloudCloudconnectionsPutParams object +// with the ability to set a timeout on a request. +func NewPcloudCloudconnectionsPutParamsWithTimeout(timeout time.Duration) *PcloudCloudconnectionsPutParams { + return &PcloudCloudconnectionsPutParams{ + timeout: timeout, + } +} + +// NewPcloudCloudconnectionsPutParamsWithContext creates a new PcloudCloudconnectionsPutParams object +// with the ability to set a context for a request. +func NewPcloudCloudconnectionsPutParamsWithContext(ctx context.Context) *PcloudCloudconnectionsPutParams { + return &PcloudCloudconnectionsPutParams{ + Context: ctx, + } +} + +// NewPcloudCloudconnectionsPutParamsWithHTTPClient creates a new PcloudCloudconnectionsPutParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudCloudconnectionsPutParamsWithHTTPClient(client *http.Client) *PcloudCloudconnectionsPutParams { + return &PcloudCloudconnectionsPutParams{ + HTTPClient: client, + } +} + +/* PcloudCloudconnectionsPutParams contains all the parameters to send to the API endpoint + for the pcloud cloudconnections put operation. + + Typically these are written to a http.Request. +*/ +type PcloudCloudconnectionsPutParams struct { + + /* Body. + + Parameters to update a Cloud Connection + */ + Body *models.CloudConnectionUpdate + + /* CloudConnectionID. + + Cloud Connection ID + */ + CloudConnectionID string + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud cloudconnections put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudconnectionsPutParams) WithDefaults() *PcloudCloudconnectionsPutParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud cloudconnections put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudconnectionsPutParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud cloudconnections put params +func (o *PcloudCloudconnectionsPutParams) WithTimeout(timeout time.Duration) *PcloudCloudconnectionsPutParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudconnections put params +func (o *PcloudCloudconnectionsPutParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudconnections put params +func (o *PcloudCloudconnectionsPutParams) WithContext(ctx context.Context) *PcloudCloudconnectionsPutParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudconnections put params +func (o *PcloudCloudconnectionsPutParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudconnections put params +func (o *PcloudCloudconnectionsPutParams) WithHTTPClient(client *http.Client) *PcloudCloudconnectionsPutParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudconnections put params +func (o *PcloudCloudconnectionsPutParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud cloudconnections put params +func (o *PcloudCloudconnectionsPutParams) WithBody(body *models.CloudConnectionUpdate) *PcloudCloudconnectionsPutParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud cloudconnections put params +func (o *PcloudCloudconnectionsPutParams) SetBody(body *models.CloudConnectionUpdate) { + o.Body = body +} + +// WithCloudConnectionID adds the cloudConnectionID to the pcloud cloudconnections put params +func (o *PcloudCloudconnectionsPutParams) WithCloudConnectionID(cloudConnectionID string) *PcloudCloudconnectionsPutParams { + o.SetCloudConnectionID(cloudConnectionID) + return o +} + +// SetCloudConnectionID adds the cloudConnectionId to the pcloud cloudconnections put params +func (o *PcloudCloudconnectionsPutParams) SetCloudConnectionID(cloudConnectionID string) { + o.CloudConnectionID = cloudConnectionID +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudconnections put params +func (o *PcloudCloudconnectionsPutParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudconnectionsPutParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudconnections put params +func (o *PcloudCloudconnectionsPutParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudconnectionsPutParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_connection_id + if err := r.SetPathParam("cloud_connection_id", o.CloudConnectionID); err != nil { + return err + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_put_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_put_responses.go new file mode 100644 index 00000000000..1eaec8d50d7 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_put_responses.go @@ -0,0 +1,371 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_cloud_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudconnectionsPutReader is a Reader for the PcloudCloudconnectionsPut structure. +type PcloudCloudconnectionsPutReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudconnectionsPutReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudCloudconnectionsPutOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 202: + result := NewPcloudCloudconnectionsPutAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudCloudconnectionsPutBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudCloudconnectionsPutUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudCloudconnectionsPutNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 405: + result := NewPcloudCloudconnectionsPutMethodNotAllowed() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewPcloudCloudconnectionsPutConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudCloudconnectionsPutUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudCloudconnectionsPutInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudCloudconnectionsPutOK creates a PcloudCloudconnectionsPutOK with default headers values +func NewPcloudCloudconnectionsPutOK() *PcloudCloudconnectionsPutOK { + return &PcloudCloudconnectionsPutOK{} +} + +/* PcloudCloudconnectionsPutOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudCloudconnectionsPutOK struct { + Payload *models.CloudConnection +} + +func (o *PcloudCloudconnectionsPutOK) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}][%d] pcloudCloudconnectionsPutOK %+v", 200, o.Payload) +} +func (o *PcloudCloudconnectionsPutOK) GetPayload() *models.CloudConnection { + return o.Payload +} + +func (o *PcloudCloudconnectionsPutOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.CloudConnection) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsPutAccepted creates a PcloudCloudconnectionsPutAccepted with default headers values +func NewPcloudCloudconnectionsPutAccepted() *PcloudCloudconnectionsPutAccepted { + return &PcloudCloudconnectionsPutAccepted{} +} + +/* PcloudCloudconnectionsPutAccepted describes a response with status code 202, with default header values. + +Accepted +*/ +type PcloudCloudconnectionsPutAccepted struct { + Payload *models.JobReference +} + +func (o *PcloudCloudconnectionsPutAccepted) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}][%d] pcloudCloudconnectionsPutAccepted %+v", 202, o.Payload) +} +func (o *PcloudCloudconnectionsPutAccepted) GetPayload() *models.JobReference { + return o.Payload +} + +func (o *PcloudCloudconnectionsPutAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.JobReference) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsPutBadRequest creates a PcloudCloudconnectionsPutBadRequest with default headers values +func NewPcloudCloudconnectionsPutBadRequest() *PcloudCloudconnectionsPutBadRequest { + return &PcloudCloudconnectionsPutBadRequest{} +} + +/* PcloudCloudconnectionsPutBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudCloudconnectionsPutBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsPutBadRequest) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}][%d] pcloudCloudconnectionsPutBadRequest %+v", 400, o.Payload) +} +func (o *PcloudCloudconnectionsPutBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsPutBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsPutUnauthorized creates a PcloudCloudconnectionsPutUnauthorized with default headers values +func NewPcloudCloudconnectionsPutUnauthorized() *PcloudCloudconnectionsPutUnauthorized { + return &PcloudCloudconnectionsPutUnauthorized{} +} + +/* PcloudCloudconnectionsPutUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudCloudconnectionsPutUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsPutUnauthorized) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}][%d] pcloudCloudconnectionsPutUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudCloudconnectionsPutUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsPutUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsPutNotFound creates a PcloudCloudconnectionsPutNotFound with default headers values +func NewPcloudCloudconnectionsPutNotFound() *PcloudCloudconnectionsPutNotFound { + return &PcloudCloudconnectionsPutNotFound{} +} + +/* PcloudCloudconnectionsPutNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudCloudconnectionsPutNotFound struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsPutNotFound) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}][%d] pcloudCloudconnectionsPutNotFound %+v", 404, o.Payload) +} +func (o *PcloudCloudconnectionsPutNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsPutNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsPutMethodNotAllowed creates a PcloudCloudconnectionsPutMethodNotAllowed with default headers values +func NewPcloudCloudconnectionsPutMethodNotAllowed() *PcloudCloudconnectionsPutMethodNotAllowed { + return &PcloudCloudconnectionsPutMethodNotAllowed{} +} + +/* PcloudCloudconnectionsPutMethodNotAllowed describes a response with status code 405, with default header values. + +Method Not Allowed +*/ +type PcloudCloudconnectionsPutMethodNotAllowed struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsPutMethodNotAllowed) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}][%d] pcloudCloudconnectionsPutMethodNotAllowed %+v", 405, o.Payload) +} +func (o *PcloudCloudconnectionsPutMethodNotAllowed) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsPutMethodNotAllowed) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsPutConflict creates a PcloudCloudconnectionsPutConflict with default headers values +func NewPcloudCloudconnectionsPutConflict() *PcloudCloudconnectionsPutConflict { + return &PcloudCloudconnectionsPutConflict{} +} + +/* PcloudCloudconnectionsPutConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type PcloudCloudconnectionsPutConflict struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsPutConflict) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}][%d] pcloudCloudconnectionsPutConflict %+v", 409, o.Payload) +} +func (o *PcloudCloudconnectionsPutConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsPutConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsPutUnprocessableEntity creates a PcloudCloudconnectionsPutUnprocessableEntity with default headers values +func NewPcloudCloudconnectionsPutUnprocessableEntity() *PcloudCloudconnectionsPutUnprocessableEntity { + return &PcloudCloudconnectionsPutUnprocessableEntity{} +} + +/* PcloudCloudconnectionsPutUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudCloudconnectionsPutUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsPutUnprocessableEntity) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}][%d] pcloudCloudconnectionsPutUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudCloudconnectionsPutUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsPutUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsPutInternalServerError creates a PcloudCloudconnectionsPutInternalServerError with default headers values +func NewPcloudCloudconnectionsPutInternalServerError() *PcloudCloudconnectionsPutInternalServerError { + return &PcloudCloudconnectionsPutInternalServerError{} +} + +/* PcloudCloudconnectionsPutInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudCloudconnectionsPutInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsPutInternalServerError) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections/{cloud_connection_id}][%d] pcloudCloudconnectionsPutInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudCloudconnectionsPutInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsPutInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_virtualprivateclouds_getall_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_virtualprivateclouds_getall_parameters.go new file mode 100644 index 00000000000..6cc7c04cd6a --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_virtualprivateclouds_getall_parameters.go @@ -0,0 +1,149 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_cloud_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudCloudconnectionsVirtualprivatecloudsGetallParams creates a new PcloudCloudconnectionsVirtualprivatecloudsGetallParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudCloudconnectionsVirtualprivatecloudsGetallParams() *PcloudCloudconnectionsVirtualprivatecloudsGetallParams { + return &PcloudCloudconnectionsVirtualprivatecloudsGetallParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudconnectionsVirtualprivatecloudsGetallParamsWithTimeout creates a new PcloudCloudconnectionsVirtualprivatecloudsGetallParams object +// with the ability to set a timeout on a request. +func NewPcloudCloudconnectionsVirtualprivatecloudsGetallParamsWithTimeout(timeout time.Duration) *PcloudCloudconnectionsVirtualprivatecloudsGetallParams { + return &PcloudCloudconnectionsVirtualprivatecloudsGetallParams{ + timeout: timeout, + } +} + +// NewPcloudCloudconnectionsVirtualprivatecloudsGetallParamsWithContext creates a new PcloudCloudconnectionsVirtualprivatecloudsGetallParams object +// with the ability to set a context for a request. +func NewPcloudCloudconnectionsVirtualprivatecloudsGetallParamsWithContext(ctx context.Context) *PcloudCloudconnectionsVirtualprivatecloudsGetallParams { + return &PcloudCloudconnectionsVirtualprivatecloudsGetallParams{ + Context: ctx, + } +} + +// NewPcloudCloudconnectionsVirtualprivatecloudsGetallParamsWithHTTPClient creates a new PcloudCloudconnectionsVirtualprivatecloudsGetallParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudCloudconnectionsVirtualprivatecloudsGetallParamsWithHTTPClient(client *http.Client) *PcloudCloudconnectionsVirtualprivatecloudsGetallParams { + return &PcloudCloudconnectionsVirtualprivatecloudsGetallParams{ + HTTPClient: client, + } +} + +/* PcloudCloudconnectionsVirtualprivatecloudsGetallParams contains all the parameters to send to the API endpoint + for the pcloud cloudconnections virtualprivateclouds getall operation. + + Typically these are written to a http.Request. +*/ +type PcloudCloudconnectionsVirtualprivatecloudsGetallParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud cloudconnections virtualprivateclouds getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudconnectionsVirtualprivatecloudsGetallParams) WithDefaults() *PcloudCloudconnectionsVirtualprivatecloudsGetallParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud cloudconnections virtualprivateclouds getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudconnectionsVirtualprivatecloudsGetallParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud cloudconnections virtualprivateclouds getall params +func (o *PcloudCloudconnectionsVirtualprivatecloudsGetallParams) WithTimeout(timeout time.Duration) *PcloudCloudconnectionsVirtualprivatecloudsGetallParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudconnections virtualprivateclouds getall params +func (o *PcloudCloudconnectionsVirtualprivatecloudsGetallParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudconnections virtualprivateclouds getall params +func (o *PcloudCloudconnectionsVirtualprivatecloudsGetallParams) WithContext(ctx context.Context) *PcloudCloudconnectionsVirtualprivatecloudsGetallParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudconnections virtualprivateclouds getall params +func (o *PcloudCloudconnectionsVirtualprivatecloudsGetallParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudconnections virtualprivateclouds getall params +func (o *PcloudCloudconnectionsVirtualprivatecloudsGetallParams) WithHTTPClient(client *http.Client) *PcloudCloudconnectionsVirtualprivatecloudsGetallParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudconnections virtualprivateclouds getall params +func (o *PcloudCloudconnectionsVirtualprivatecloudsGetallParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudconnections virtualprivateclouds getall params +func (o *PcloudCloudconnectionsVirtualprivatecloudsGetallParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudconnectionsVirtualprivatecloudsGetallParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudconnections virtualprivateclouds getall params +func (o *PcloudCloudconnectionsVirtualprivatecloudsGetallParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudconnectionsVirtualprivatecloudsGetallParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_virtualprivateclouds_getall_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_virtualprivateclouds_getall_responses.go new file mode 100644 index 00000000000..ad162ef31e7 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections/pcloud_cloudconnections_virtualprivateclouds_getall_responses.go @@ -0,0 +1,181 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_cloud_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudconnectionsVirtualprivatecloudsGetallReader is a Reader for the PcloudCloudconnectionsVirtualprivatecloudsGetall structure. +type PcloudCloudconnectionsVirtualprivatecloudsGetallReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudconnectionsVirtualprivatecloudsGetallReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudCloudconnectionsVirtualprivatecloudsGetallOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudCloudconnectionsVirtualprivatecloudsGetallBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudCloudconnectionsVirtualprivatecloudsGetallUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudCloudconnectionsVirtualprivatecloudsGetallInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudCloudconnectionsVirtualprivatecloudsGetallOK creates a PcloudCloudconnectionsVirtualprivatecloudsGetallOK with default headers values +func NewPcloudCloudconnectionsVirtualprivatecloudsGetallOK() *PcloudCloudconnectionsVirtualprivatecloudsGetallOK { + return &PcloudCloudconnectionsVirtualprivatecloudsGetallOK{} +} + +/* PcloudCloudconnectionsVirtualprivatecloudsGetallOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudCloudconnectionsVirtualprivatecloudsGetallOK struct { + Payload *models.CloudConnectionVirtualPrivateClouds +} + +func (o *PcloudCloudconnectionsVirtualprivatecloudsGetallOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections-virtual-private-clouds][%d] pcloudCloudconnectionsVirtualprivatecloudsGetallOK %+v", 200, o.Payload) +} +func (o *PcloudCloudconnectionsVirtualprivatecloudsGetallOK) GetPayload() *models.CloudConnectionVirtualPrivateClouds { + return o.Payload +} + +func (o *PcloudCloudconnectionsVirtualprivatecloudsGetallOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.CloudConnectionVirtualPrivateClouds) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsVirtualprivatecloudsGetallBadRequest creates a PcloudCloudconnectionsVirtualprivatecloudsGetallBadRequest with default headers values +func NewPcloudCloudconnectionsVirtualprivatecloudsGetallBadRequest() *PcloudCloudconnectionsVirtualprivatecloudsGetallBadRequest { + return &PcloudCloudconnectionsVirtualprivatecloudsGetallBadRequest{} +} + +/* PcloudCloudconnectionsVirtualprivatecloudsGetallBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudCloudconnectionsVirtualprivatecloudsGetallBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsVirtualprivatecloudsGetallBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections-virtual-private-clouds][%d] pcloudCloudconnectionsVirtualprivatecloudsGetallBadRequest %+v", 400, o.Payload) +} +func (o *PcloudCloudconnectionsVirtualprivatecloudsGetallBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsVirtualprivatecloudsGetallBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsVirtualprivatecloudsGetallUnauthorized creates a PcloudCloudconnectionsVirtualprivatecloudsGetallUnauthorized with default headers values +func NewPcloudCloudconnectionsVirtualprivatecloudsGetallUnauthorized() *PcloudCloudconnectionsVirtualprivatecloudsGetallUnauthorized { + return &PcloudCloudconnectionsVirtualprivatecloudsGetallUnauthorized{} +} + +/* PcloudCloudconnectionsVirtualprivatecloudsGetallUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudCloudconnectionsVirtualprivatecloudsGetallUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsVirtualprivatecloudsGetallUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections-virtual-private-clouds][%d] pcloudCloudconnectionsVirtualprivatecloudsGetallUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudCloudconnectionsVirtualprivatecloudsGetallUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsVirtualprivatecloudsGetallUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudconnectionsVirtualprivatecloudsGetallInternalServerError creates a PcloudCloudconnectionsVirtualprivatecloudsGetallInternalServerError with default headers values +func NewPcloudCloudconnectionsVirtualprivatecloudsGetallInternalServerError() *PcloudCloudconnectionsVirtualprivatecloudsGetallInternalServerError { + return &PcloudCloudconnectionsVirtualprivatecloudsGetallInternalServerError{} +} + +/* PcloudCloudconnectionsVirtualprivatecloudsGetallInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudCloudconnectionsVirtualprivatecloudsGetallInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudconnectionsVirtualprivatecloudsGetallInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/cloud-connections-virtual-private-clouds][%d] pcloudCloudconnectionsVirtualprivatecloudsGetallInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudCloudconnectionsVirtualprivatecloudsGetallInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudconnectionsVirtualprivatecloudsGetallInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_events/p_cloud_events_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_events/p_cloud_events_client.go new file mode 100644 index 00000000000..7305a15619f --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_events/p_cloud_events_client.go @@ -0,0 +1,121 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_events + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new p cloud events API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for p cloud events API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + PcloudEventsGet(params *PcloudEventsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudEventsGetOK, error) + + PcloudEventsGetquery(params *PcloudEventsGetqueryParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudEventsGetqueryOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + PcloudEventsGet gets a single event +*/ +func (a *Client) PcloudEventsGet(params *PcloudEventsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudEventsGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudEventsGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.events.get", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/events/{event_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudEventsGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudEventsGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.events.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudEventsGetquery gets events from this cloud instance since a specific timestamp +*/ +func (a *Client) PcloudEventsGetquery(params *PcloudEventsGetqueryParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudEventsGetqueryOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudEventsGetqueryParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.events.getquery", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/events", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudEventsGetqueryReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudEventsGetqueryOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.events.getquery: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_events/pcloud_events_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_events/pcloud_events_get_parameters.go new file mode 100644 index 00000000000..a2b5d98e841 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_events/pcloud_events_get_parameters.go @@ -0,0 +1,196 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_events + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudEventsGetParams creates a new PcloudEventsGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudEventsGetParams() *PcloudEventsGetParams { + return &PcloudEventsGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudEventsGetParamsWithTimeout creates a new PcloudEventsGetParams object +// with the ability to set a timeout on a request. +func NewPcloudEventsGetParamsWithTimeout(timeout time.Duration) *PcloudEventsGetParams { + return &PcloudEventsGetParams{ + timeout: timeout, + } +} + +// NewPcloudEventsGetParamsWithContext creates a new PcloudEventsGetParams object +// with the ability to set a context for a request. +func NewPcloudEventsGetParamsWithContext(ctx context.Context) *PcloudEventsGetParams { + return &PcloudEventsGetParams{ + Context: ctx, + } +} + +// NewPcloudEventsGetParamsWithHTTPClient creates a new PcloudEventsGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudEventsGetParamsWithHTTPClient(client *http.Client) *PcloudEventsGetParams { + return &PcloudEventsGetParams{ + HTTPClient: client, + } +} + +/* PcloudEventsGetParams contains all the parameters to send to the API endpoint + for the pcloud events get operation. + + Typically these are written to a http.Request. +*/ +type PcloudEventsGetParams struct { + + /* AcceptLanguage. + + The language requested for the return document + */ + AcceptLanguage *string + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* EventID. + + Event ID + */ + EventID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud events get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudEventsGetParams) WithDefaults() *PcloudEventsGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud events get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudEventsGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud events get params +func (o *PcloudEventsGetParams) WithTimeout(timeout time.Duration) *PcloudEventsGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud events get params +func (o *PcloudEventsGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud events get params +func (o *PcloudEventsGetParams) WithContext(ctx context.Context) *PcloudEventsGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud events get params +func (o *PcloudEventsGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud events get params +func (o *PcloudEventsGetParams) WithHTTPClient(client *http.Client) *PcloudEventsGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud events get params +func (o *PcloudEventsGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithAcceptLanguage adds the acceptLanguage to the pcloud events get params +func (o *PcloudEventsGetParams) WithAcceptLanguage(acceptLanguage *string) *PcloudEventsGetParams { + o.SetAcceptLanguage(acceptLanguage) + return o +} + +// SetAcceptLanguage adds the acceptLanguage to the pcloud events get params +func (o *PcloudEventsGetParams) SetAcceptLanguage(acceptLanguage *string) { + o.AcceptLanguage = acceptLanguage +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud events get params +func (o *PcloudEventsGetParams) WithCloudInstanceID(cloudInstanceID string) *PcloudEventsGetParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud events get params +func (o *PcloudEventsGetParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithEventID adds the eventID to the pcloud events get params +func (o *PcloudEventsGetParams) WithEventID(eventID string) *PcloudEventsGetParams { + o.SetEventID(eventID) + return o +} + +// SetEventID adds the eventId to the pcloud events get params +func (o *PcloudEventsGetParams) SetEventID(eventID string) { + o.EventID = eventID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudEventsGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.AcceptLanguage != nil { + + // header param Accept-Language + if err := r.SetHeaderParam("Accept-Language", *o.AcceptLanguage); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param event_id + if err := r.SetPathParam("event_id", o.EventID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_events/pcloud_events_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_events/pcloud_events_get_responses.go new file mode 100644 index 00000000000..ff28ed26483 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_events/pcloud_events_get_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_events + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudEventsGetReader is a Reader for the PcloudEventsGet structure. +type PcloudEventsGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudEventsGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudEventsGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudEventsGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudEventsGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudEventsGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudEventsGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudEventsGetOK creates a PcloudEventsGetOK with default headers values +func NewPcloudEventsGetOK() *PcloudEventsGetOK { + return &PcloudEventsGetOK{} +} + +/* PcloudEventsGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudEventsGetOK struct { + Payload *models.Event +} + +func (o *PcloudEventsGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/events/{event_id}][%d] pcloudEventsGetOK %+v", 200, o.Payload) +} +func (o *PcloudEventsGetOK) GetPayload() *models.Event { + return o.Payload +} + +func (o *PcloudEventsGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Event) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudEventsGetBadRequest creates a PcloudEventsGetBadRequest with default headers values +func NewPcloudEventsGetBadRequest() *PcloudEventsGetBadRequest { + return &PcloudEventsGetBadRequest{} +} + +/* PcloudEventsGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudEventsGetBadRequest struct { + Payload *models.Error +} + +func (o *PcloudEventsGetBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/events/{event_id}][%d] pcloudEventsGetBadRequest %+v", 400, o.Payload) +} +func (o *PcloudEventsGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudEventsGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudEventsGetUnauthorized creates a PcloudEventsGetUnauthorized with default headers values +func NewPcloudEventsGetUnauthorized() *PcloudEventsGetUnauthorized { + return &PcloudEventsGetUnauthorized{} +} + +/* PcloudEventsGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudEventsGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudEventsGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/events/{event_id}][%d] pcloudEventsGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudEventsGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudEventsGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudEventsGetNotFound creates a PcloudEventsGetNotFound with default headers values +func NewPcloudEventsGetNotFound() *PcloudEventsGetNotFound { + return &PcloudEventsGetNotFound{} +} + +/* PcloudEventsGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudEventsGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudEventsGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/events/{event_id}][%d] pcloudEventsGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudEventsGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudEventsGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudEventsGetInternalServerError creates a PcloudEventsGetInternalServerError with default headers values +func NewPcloudEventsGetInternalServerError() *PcloudEventsGetInternalServerError { + return &PcloudEventsGetInternalServerError{} +} + +/* PcloudEventsGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudEventsGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudEventsGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/events/{event_id}][%d] pcloudEventsGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudEventsGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudEventsGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_events/pcloud_events_getquery_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_events/pcloud_events_getquery_parameters.go new file mode 100644 index 00000000000..4ee037fa96f --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_events/pcloud_events_getquery_parameters.go @@ -0,0 +1,276 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_events + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudEventsGetqueryParams creates a new PcloudEventsGetqueryParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudEventsGetqueryParams() *PcloudEventsGetqueryParams { + return &PcloudEventsGetqueryParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudEventsGetqueryParamsWithTimeout creates a new PcloudEventsGetqueryParams object +// with the ability to set a timeout on a request. +func NewPcloudEventsGetqueryParamsWithTimeout(timeout time.Duration) *PcloudEventsGetqueryParams { + return &PcloudEventsGetqueryParams{ + timeout: timeout, + } +} + +// NewPcloudEventsGetqueryParamsWithContext creates a new PcloudEventsGetqueryParams object +// with the ability to set a context for a request. +func NewPcloudEventsGetqueryParamsWithContext(ctx context.Context) *PcloudEventsGetqueryParams { + return &PcloudEventsGetqueryParams{ + Context: ctx, + } +} + +// NewPcloudEventsGetqueryParamsWithHTTPClient creates a new PcloudEventsGetqueryParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudEventsGetqueryParamsWithHTTPClient(client *http.Client) *PcloudEventsGetqueryParams { + return &PcloudEventsGetqueryParams{ + HTTPClient: client, + } +} + +/* PcloudEventsGetqueryParams contains all the parameters to send to the API endpoint + for the pcloud events getquery operation. + + Typically these are written to a http.Request. +*/ +type PcloudEventsGetqueryParams struct { + + /* AcceptLanguage. + + The language requested for the return document + */ + AcceptLanguage *string + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* FromTime. + + A from query time in either ISO 8601 or unix epoch format + */ + FromTime *string + + /* Time. + + (deprecated - use from_time) A time in either ISO 8601 or unix epoch format + */ + Time *string + + /* ToTime. + + A to query time in either ISO 8601 or unix epoch format + */ + ToTime *string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud events getquery params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudEventsGetqueryParams) WithDefaults() *PcloudEventsGetqueryParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud events getquery params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudEventsGetqueryParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud events getquery params +func (o *PcloudEventsGetqueryParams) WithTimeout(timeout time.Duration) *PcloudEventsGetqueryParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud events getquery params +func (o *PcloudEventsGetqueryParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud events getquery params +func (o *PcloudEventsGetqueryParams) WithContext(ctx context.Context) *PcloudEventsGetqueryParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud events getquery params +func (o *PcloudEventsGetqueryParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud events getquery params +func (o *PcloudEventsGetqueryParams) WithHTTPClient(client *http.Client) *PcloudEventsGetqueryParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud events getquery params +func (o *PcloudEventsGetqueryParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithAcceptLanguage adds the acceptLanguage to the pcloud events getquery params +func (o *PcloudEventsGetqueryParams) WithAcceptLanguage(acceptLanguage *string) *PcloudEventsGetqueryParams { + o.SetAcceptLanguage(acceptLanguage) + return o +} + +// SetAcceptLanguage adds the acceptLanguage to the pcloud events getquery params +func (o *PcloudEventsGetqueryParams) SetAcceptLanguage(acceptLanguage *string) { + o.AcceptLanguage = acceptLanguage +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud events getquery params +func (o *PcloudEventsGetqueryParams) WithCloudInstanceID(cloudInstanceID string) *PcloudEventsGetqueryParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud events getquery params +func (o *PcloudEventsGetqueryParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithFromTime adds the fromTime to the pcloud events getquery params +func (o *PcloudEventsGetqueryParams) WithFromTime(fromTime *string) *PcloudEventsGetqueryParams { + o.SetFromTime(fromTime) + return o +} + +// SetFromTime adds the fromTime to the pcloud events getquery params +func (o *PcloudEventsGetqueryParams) SetFromTime(fromTime *string) { + o.FromTime = fromTime +} + +// WithTime adds the time to the pcloud events getquery params +func (o *PcloudEventsGetqueryParams) WithTime(time *string) *PcloudEventsGetqueryParams { + o.SetTime(time) + return o +} + +// SetTime adds the time to the pcloud events getquery params +func (o *PcloudEventsGetqueryParams) SetTime(time *string) { + o.Time = time +} + +// WithToTime adds the toTime to the pcloud events getquery params +func (o *PcloudEventsGetqueryParams) WithToTime(toTime *string) *PcloudEventsGetqueryParams { + o.SetToTime(toTime) + return o +} + +// SetToTime adds the toTime to the pcloud events getquery params +func (o *PcloudEventsGetqueryParams) SetToTime(toTime *string) { + o.ToTime = toTime +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudEventsGetqueryParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.AcceptLanguage != nil { + + // header param Accept-Language + if err := r.SetHeaderParam("Accept-Language", *o.AcceptLanguage); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if o.FromTime != nil { + + // query param from_time + var qrFromTime string + + if o.FromTime != nil { + qrFromTime = *o.FromTime + } + qFromTime := qrFromTime + if qFromTime != "" { + + if err := r.SetQueryParam("from_time", qFromTime); err != nil { + return err + } + } + } + + if o.Time != nil { + + // query param time + var qrTime string + + if o.Time != nil { + qrTime = *o.Time + } + qTime := qrTime + if qTime != "" { + + if err := r.SetQueryParam("time", qTime); err != nil { + return err + } + } + } + + if o.ToTime != nil { + + // query param to_time + var qrToTime string + + if o.ToTime != nil { + qrToTime = *o.ToTime + } + qToTime := qrToTime + if qToTime != "" { + + if err := r.SetQueryParam("to_time", qToTime); err != nil { + return err + } + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_events/pcloud_events_getquery_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_events/pcloud_events_getquery_responses.go new file mode 100644 index 00000000000..b018f267f24 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_events/pcloud_events_getquery_responses.go @@ -0,0 +1,181 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_events + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudEventsGetqueryReader is a Reader for the PcloudEventsGetquery structure. +type PcloudEventsGetqueryReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudEventsGetqueryReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudEventsGetqueryOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudEventsGetqueryBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudEventsGetqueryUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudEventsGetqueryInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudEventsGetqueryOK creates a PcloudEventsGetqueryOK with default headers values +func NewPcloudEventsGetqueryOK() *PcloudEventsGetqueryOK { + return &PcloudEventsGetqueryOK{} +} + +/* PcloudEventsGetqueryOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudEventsGetqueryOK struct { + Payload *models.Events +} + +func (o *PcloudEventsGetqueryOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/events][%d] pcloudEventsGetqueryOK %+v", 200, o.Payload) +} +func (o *PcloudEventsGetqueryOK) GetPayload() *models.Events { + return o.Payload +} + +func (o *PcloudEventsGetqueryOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Events) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudEventsGetqueryBadRequest creates a PcloudEventsGetqueryBadRequest with default headers values +func NewPcloudEventsGetqueryBadRequest() *PcloudEventsGetqueryBadRequest { + return &PcloudEventsGetqueryBadRequest{} +} + +/* PcloudEventsGetqueryBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudEventsGetqueryBadRequest struct { + Payload *models.Error +} + +func (o *PcloudEventsGetqueryBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/events][%d] pcloudEventsGetqueryBadRequest %+v", 400, o.Payload) +} +func (o *PcloudEventsGetqueryBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudEventsGetqueryBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudEventsGetqueryUnauthorized creates a PcloudEventsGetqueryUnauthorized with default headers values +func NewPcloudEventsGetqueryUnauthorized() *PcloudEventsGetqueryUnauthorized { + return &PcloudEventsGetqueryUnauthorized{} +} + +/* PcloudEventsGetqueryUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudEventsGetqueryUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudEventsGetqueryUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/events][%d] pcloudEventsGetqueryUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudEventsGetqueryUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudEventsGetqueryUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudEventsGetqueryInternalServerError creates a PcloudEventsGetqueryInternalServerError with default headers values +func NewPcloudEventsGetqueryInternalServerError() *PcloudEventsGetqueryInternalServerError { + return &PcloudEventsGetqueryInternalServerError{} +} + +/* PcloudEventsGetqueryInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudEventsGetqueryInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudEventsGetqueryInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/events][%d] pcloudEventsGetqueryInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudEventsGetqueryInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudEventsGetqueryInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/p_cloud_images_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/p_cloud_images_client.go new file mode 100644 index 00000000000..be0badf8135 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/p_cloud_images_client.go @@ -0,0 +1,573 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_images + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new p cloud images API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for p cloud images API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + PcloudCloudinstancesImagesDelete(params *PcloudCloudinstancesImagesDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesImagesDeleteOK, error) + + PcloudCloudinstancesImagesExportPost(params *PcloudCloudinstancesImagesExportPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesImagesExportPostAccepted, error) + + PcloudCloudinstancesImagesGet(params *PcloudCloudinstancesImagesGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesImagesGetOK, error) + + PcloudCloudinstancesImagesGetall(params *PcloudCloudinstancesImagesGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesImagesGetallOK, error) + + PcloudCloudinstancesImagesPost(params *PcloudCloudinstancesImagesPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesImagesPostOK, *PcloudCloudinstancesImagesPostCreated, error) + + PcloudCloudinstancesStockimagesGet(params *PcloudCloudinstancesStockimagesGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesStockimagesGetOK, error) + + PcloudCloudinstancesStockimagesGetall(params *PcloudCloudinstancesStockimagesGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesStockimagesGetallOK, error) + + PcloudImagesGet(params *PcloudImagesGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudImagesGetOK, error) + + PcloudImagesGetall(params *PcloudImagesGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudImagesGetallOK, error) + + PcloudV1CloudinstancesCosimagesGet(params *PcloudV1CloudinstancesCosimagesGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV1CloudinstancesCosimagesGetOK, error) + + PcloudV1CloudinstancesCosimagesPost(params *PcloudV1CloudinstancesCosimagesPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV1CloudinstancesCosimagesPostAccepted, error) + + PcloudV2ImagesExportGet(params *PcloudV2ImagesExportGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV2ImagesExportGetOK, error) + + PcloudV2ImagesExportPost(params *PcloudV2ImagesExportPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV2ImagesExportPostAccepted, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + PcloudCloudinstancesImagesDelete deletes an image from a cloud instance +*/ +func (a *Client) PcloudCloudinstancesImagesDelete(params *PcloudCloudinstancesImagesDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesImagesDeleteOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudinstancesImagesDeleteParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.cloudinstances.images.delete", + Method: "DELETE", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/images/{image_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudinstancesImagesDeleteReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudCloudinstancesImagesDeleteOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.cloudinstances.images.delete: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudCloudinstancesImagesExportPost exports an image +*/ +func (a *Client) PcloudCloudinstancesImagesExportPost(params *PcloudCloudinstancesImagesExportPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesImagesExportPostAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudinstancesImagesExportPostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.cloudinstances.images.export.post", + Method: "POST", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/images/{image_id}/export", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudinstancesImagesExportPostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudCloudinstancesImagesExportPostAccepted) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.cloudinstances.images.export.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudCloudinstancesImagesGet detaileds info of an image +*/ +func (a *Client) PcloudCloudinstancesImagesGet(params *PcloudCloudinstancesImagesGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesImagesGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudinstancesImagesGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.cloudinstances.images.get", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/images/{image_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudinstancesImagesGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudCloudinstancesImagesGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.cloudinstances.images.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudCloudinstancesImagesGetall lists all images for this cloud instance +*/ +func (a *Client) PcloudCloudinstancesImagesGetall(params *PcloudCloudinstancesImagesGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesImagesGetallOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudinstancesImagesGetallParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.cloudinstances.images.getall", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/images", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudinstancesImagesGetallReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudCloudinstancesImagesGetallOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.cloudinstances.images.getall: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudCloudinstancesImagesPost creates a new image from available images +*/ +func (a *Client) PcloudCloudinstancesImagesPost(params *PcloudCloudinstancesImagesPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesImagesPostOK, *PcloudCloudinstancesImagesPostCreated, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudinstancesImagesPostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.cloudinstances.images.post", + Method: "POST", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/images", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudinstancesImagesPostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, nil, err + } + switch value := result.(type) { + case *PcloudCloudinstancesImagesPostOK: + return value, nil, nil + case *PcloudCloudinstancesImagesPostCreated: + return nil, value, nil + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for p_cloud_images: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudCloudinstancesStockimagesGet detaileds info of an available stock image +*/ +func (a *Client) PcloudCloudinstancesStockimagesGet(params *PcloudCloudinstancesStockimagesGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesStockimagesGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudinstancesStockimagesGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.cloudinstances.stockimages.get", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/stock-images/{image_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudinstancesStockimagesGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudCloudinstancesStockimagesGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.cloudinstances.stockimages.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudCloudinstancesStockimagesGetall lists all available stock images +*/ +func (a *Client) PcloudCloudinstancesStockimagesGetall(params *PcloudCloudinstancesStockimagesGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesStockimagesGetallOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudinstancesStockimagesGetallParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.cloudinstances.stockimages.getall", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/stock-images", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudinstancesStockimagesGetallReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudCloudinstancesStockimagesGetallOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.cloudinstances.stockimages.getall: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudImagesGet deprecateds for pcloud v1 cloud instances cloud instance id stock images image id detailed info of an available stock image +*/ +func (a *Client) PcloudImagesGet(params *PcloudImagesGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudImagesGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudImagesGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.images.get", + Method: "GET", + PathPattern: "/pcloud/v1/images/{image_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudImagesGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudImagesGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.images.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudImagesGetall deprecateds for pcloud v1 cloud instances cloud instance id stock images list all available stock images +*/ +func (a *Client) PcloudImagesGetall(params *PcloudImagesGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudImagesGetallOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudImagesGetallParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.images.getall", + Method: "GET", + PathPattern: "/pcloud/v1/images", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudImagesGetallReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudImagesGetallOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.images.getall: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudV1CloudinstancesCosimagesGet gets detail of last cos image import job +*/ +func (a *Client) PcloudV1CloudinstancesCosimagesGet(params *PcloudV1CloudinstancesCosimagesGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV1CloudinstancesCosimagesGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudV1CloudinstancesCosimagesGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.v1.cloudinstances.cosimages.get", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/cos-images", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudV1CloudinstancesCosimagesGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudV1CloudinstancesCosimagesGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.v1.cloudinstances.cosimages.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudV1CloudinstancesCosimagesPost creates an cos image import job +*/ +func (a *Client) PcloudV1CloudinstancesCosimagesPost(params *PcloudV1CloudinstancesCosimagesPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV1CloudinstancesCosimagesPostAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudV1CloudinstancesCosimagesPostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.v1.cloudinstances.cosimages.post", + Method: "POST", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/cos-images", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudV1CloudinstancesCosimagesPostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudV1CloudinstancesCosimagesPostAccepted) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.v1.cloudinstances.cosimages.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudV2ImagesExportGet gets detail of last image export job +*/ +func (a *Client) PcloudV2ImagesExportGet(params *PcloudV2ImagesExportGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV2ImagesExportGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudV2ImagesExportGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.v2.images.export.get", + Method: "GET", + PathPattern: "/pcloud/v2/cloud-instances/{cloud_instance_id}/images/{image_id}/export", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudV2ImagesExportGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudV2ImagesExportGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.v2.images.export.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudV2ImagesExportPost adds image export job to the jobs queue +*/ +func (a *Client) PcloudV2ImagesExportPost(params *PcloudV2ImagesExportPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV2ImagesExportPostAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudV2ImagesExportPostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.v2.images.export.post", + Method: "POST", + PathPattern: "/pcloud/v2/cloud-instances/{cloud_instance_id}/images/{image_id}/export", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudV2ImagesExportPostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudV2ImagesExportPostAccepted) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.v2.images.export.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_images_delete_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_images_delete_parameters.go new file mode 100644 index 00000000000..36c1a384ab1 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_images_delete_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_images + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudCloudinstancesImagesDeleteParams creates a new PcloudCloudinstancesImagesDeleteParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudCloudinstancesImagesDeleteParams() *PcloudCloudinstancesImagesDeleteParams { + return &PcloudCloudinstancesImagesDeleteParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudinstancesImagesDeleteParamsWithTimeout creates a new PcloudCloudinstancesImagesDeleteParams object +// with the ability to set a timeout on a request. +func NewPcloudCloudinstancesImagesDeleteParamsWithTimeout(timeout time.Duration) *PcloudCloudinstancesImagesDeleteParams { + return &PcloudCloudinstancesImagesDeleteParams{ + timeout: timeout, + } +} + +// NewPcloudCloudinstancesImagesDeleteParamsWithContext creates a new PcloudCloudinstancesImagesDeleteParams object +// with the ability to set a context for a request. +func NewPcloudCloudinstancesImagesDeleteParamsWithContext(ctx context.Context) *PcloudCloudinstancesImagesDeleteParams { + return &PcloudCloudinstancesImagesDeleteParams{ + Context: ctx, + } +} + +// NewPcloudCloudinstancesImagesDeleteParamsWithHTTPClient creates a new PcloudCloudinstancesImagesDeleteParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudCloudinstancesImagesDeleteParamsWithHTTPClient(client *http.Client) *PcloudCloudinstancesImagesDeleteParams { + return &PcloudCloudinstancesImagesDeleteParams{ + HTTPClient: client, + } +} + +/* PcloudCloudinstancesImagesDeleteParams contains all the parameters to send to the API endpoint + for the pcloud cloudinstances images delete operation. + + Typically these are written to a http.Request. +*/ +type PcloudCloudinstancesImagesDeleteParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* ImageID. + + Image ID of a image + */ + ImageID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud cloudinstances images delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesImagesDeleteParams) WithDefaults() *PcloudCloudinstancesImagesDeleteParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud cloudinstances images delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesImagesDeleteParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud cloudinstances images delete params +func (o *PcloudCloudinstancesImagesDeleteParams) WithTimeout(timeout time.Duration) *PcloudCloudinstancesImagesDeleteParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudinstances images delete params +func (o *PcloudCloudinstancesImagesDeleteParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudinstances images delete params +func (o *PcloudCloudinstancesImagesDeleteParams) WithContext(ctx context.Context) *PcloudCloudinstancesImagesDeleteParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudinstances images delete params +func (o *PcloudCloudinstancesImagesDeleteParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudinstances images delete params +func (o *PcloudCloudinstancesImagesDeleteParams) WithHTTPClient(client *http.Client) *PcloudCloudinstancesImagesDeleteParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudinstances images delete params +func (o *PcloudCloudinstancesImagesDeleteParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudinstances images delete params +func (o *PcloudCloudinstancesImagesDeleteParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudinstancesImagesDeleteParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudinstances images delete params +func (o *PcloudCloudinstancesImagesDeleteParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithImageID adds the imageID to the pcloud cloudinstances images delete params +func (o *PcloudCloudinstancesImagesDeleteParams) WithImageID(imageID string) *PcloudCloudinstancesImagesDeleteParams { + o.SetImageID(imageID) + return o +} + +// SetImageID adds the imageId to the pcloud cloudinstances images delete params +func (o *PcloudCloudinstancesImagesDeleteParams) SetImageID(imageID string) { + o.ImageID = imageID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudinstancesImagesDeleteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param image_id + if err := r.SetPathParam("image_id", o.ImageID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_images_delete_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_images_delete_responses.go new file mode 100644 index 00000000000..2771980097f --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_images_delete_responses.go @@ -0,0 +1,217 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_images + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudinstancesImagesDeleteReader is a Reader for the PcloudCloudinstancesImagesDelete structure. +type PcloudCloudinstancesImagesDeleteReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudinstancesImagesDeleteReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudCloudinstancesImagesDeleteOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudCloudinstancesImagesDeleteBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudCloudinstancesImagesDeleteUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 410: + result := NewPcloudCloudinstancesImagesDeleteGone() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudCloudinstancesImagesDeleteInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudCloudinstancesImagesDeleteOK creates a PcloudCloudinstancesImagesDeleteOK with default headers values +func NewPcloudCloudinstancesImagesDeleteOK() *PcloudCloudinstancesImagesDeleteOK { + return &PcloudCloudinstancesImagesDeleteOK{} +} + +/* PcloudCloudinstancesImagesDeleteOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudCloudinstancesImagesDeleteOK struct { + Payload models.Object +} + +func (o *PcloudCloudinstancesImagesDeleteOK) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/images/{image_id}][%d] pcloudCloudinstancesImagesDeleteOK %+v", 200, o.Payload) +} +func (o *PcloudCloudinstancesImagesDeleteOK) GetPayload() models.Object { + return o.Payload +} + +func (o *PcloudCloudinstancesImagesDeleteOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesImagesDeleteBadRequest creates a PcloudCloudinstancesImagesDeleteBadRequest with default headers values +func NewPcloudCloudinstancesImagesDeleteBadRequest() *PcloudCloudinstancesImagesDeleteBadRequest { + return &PcloudCloudinstancesImagesDeleteBadRequest{} +} + +/* PcloudCloudinstancesImagesDeleteBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudCloudinstancesImagesDeleteBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesImagesDeleteBadRequest) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/images/{image_id}][%d] pcloudCloudinstancesImagesDeleteBadRequest %+v", 400, o.Payload) +} +func (o *PcloudCloudinstancesImagesDeleteBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesImagesDeleteBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesImagesDeleteUnauthorized creates a PcloudCloudinstancesImagesDeleteUnauthorized with default headers values +func NewPcloudCloudinstancesImagesDeleteUnauthorized() *PcloudCloudinstancesImagesDeleteUnauthorized { + return &PcloudCloudinstancesImagesDeleteUnauthorized{} +} + +/* PcloudCloudinstancesImagesDeleteUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudCloudinstancesImagesDeleteUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesImagesDeleteUnauthorized) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/images/{image_id}][%d] pcloudCloudinstancesImagesDeleteUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudCloudinstancesImagesDeleteUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesImagesDeleteUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesImagesDeleteGone creates a PcloudCloudinstancesImagesDeleteGone with default headers values +func NewPcloudCloudinstancesImagesDeleteGone() *PcloudCloudinstancesImagesDeleteGone { + return &PcloudCloudinstancesImagesDeleteGone{} +} + +/* PcloudCloudinstancesImagesDeleteGone describes a response with status code 410, with default header values. + +Gone +*/ +type PcloudCloudinstancesImagesDeleteGone struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesImagesDeleteGone) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/images/{image_id}][%d] pcloudCloudinstancesImagesDeleteGone %+v", 410, o.Payload) +} +func (o *PcloudCloudinstancesImagesDeleteGone) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesImagesDeleteGone) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesImagesDeleteInternalServerError creates a PcloudCloudinstancesImagesDeleteInternalServerError with default headers values +func NewPcloudCloudinstancesImagesDeleteInternalServerError() *PcloudCloudinstancesImagesDeleteInternalServerError { + return &PcloudCloudinstancesImagesDeleteInternalServerError{} +} + +/* PcloudCloudinstancesImagesDeleteInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudCloudinstancesImagesDeleteInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesImagesDeleteInternalServerError) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/images/{image_id}][%d] pcloudCloudinstancesImagesDeleteInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudCloudinstancesImagesDeleteInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesImagesDeleteInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_images_export_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_images_export_post_parameters.go new file mode 100644 index 00000000000..ec3a6247a8c --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_images_export_post_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_images + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudCloudinstancesImagesExportPostParams creates a new PcloudCloudinstancesImagesExportPostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudCloudinstancesImagesExportPostParams() *PcloudCloudinstancesImagesExportPostParams { + return &PcloudCloudinstancesImagesExportPostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudinstancesImagesExportPostParamsWithTimeout creates a new PcloudCloudinstancesImagesExportPostParams object +// with the ability to set a timeout on a request. +func NewPcloudCloudinstancesImagesExportPostParamsWithTimeout(timeout time.Duration) *PcloudCloudinstancesImagesExportPostParams { + return &PcloudCloudinstancesImagesExportPostParams{ + timeout: timeout, + } +} + +// NewPcloudCloudinstancesImagesExportPostParamsWithContext creates a new PcloudCloudinstancesImagesExportPostParams object +// with the ability to set a context for a request. +func NewPcloudCloudinstancesImagesExportPostParamsWithContext(ctx context.Context) *PcloudCloudinstancesImagesExportPostParams { + return &PcloudCloudinstancesImagesExportPostParams{ + Context: ctx, + } +} + +// NewPcloudCloudinstancesImagesExportPostParamsWithHTTPClient creates a new PcloudCloudinstancesImagesExportPostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudCloudinstancesImagesExportPostParamsWithHTTPClient(client *http.Client) *PcloudCloudinstancesImagesExportPostParams { + return &PcloudCloudinstancesImagesExportPostParams{ + HTTPClient: client, + } +} + +/* PcloudCloudinstancesImagesExportPostParams contains all the parameters to send to the API endpoint + for the pcloud cloudinstances images export post operation. + + Typically these are written to a http.Request. +*/ +type PcloudCloudinstancesImagesExportPostParams struct { + + /* Body. + + Parameters for exporting an image + */ + Body *models.ExportImage + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* ImageID. + + Image ID of a image + */ + ImageID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud cloudinstances images export post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesImagesExportPostParams) WithDefaults() *PcloudCloudinstancesImagesExportPostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud cloudinstances images export post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesImagesExportPostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud cloudinstances images export post params +func (o *PcloudCloudinstancesImagesExportPostParams) WithTimeout(timeout time.Duration) *PcloudCloudinstancesImagesExportPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudinstances images export post params +func (o *PcloudCloudinstancesImagesExportPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudinstances images export post params +func (o *PcloudCloudinstancesImagesExportPostParams) WithContext(ctx context.Context) *PcloudCloudinstancesImagesExportPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudinstances images export post params +func (o *PcloudCloudinstancesImagesExportPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudinstances images export post params +func (o *PcloudCloudinstancesImagesExportPostParams) WithHTTPClient(client *http.Client) *PcloudCloudinstancesImagesExportPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudinstances images export post params +func (o *PcloudCloudinstancesImagesExportPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud cloudinstances images export post params +func (o *PcloudCloudinstancesImagesExportPostParams) WithBody(body *models.ExportImage) *PcloudCloudinstancesImagesExportPostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud cloudinstances images export post params +func (o *PcloudCloudinstancesImagesExportPostParams) SetBody(body *models.ExportImage) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudinstances images export post params +func (o *PcloudCloudinstancesImagesExportPostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudinstancesImagesExportPostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudinstances images export post params +func (o *PcloudCloudinstancesImagesExportPostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithImageID adds the imageID to the pcloud cloudinstances images export post params +func (o *PcloudCloudinstancesImagesExportPostParams) WithImageID(imageID string) *PcloudCloudinstancesImagesExportPostParams { + o.SetImageID(imageID) + return o +} + +// SetImageID adds the imageId to the pcloud cloudinstances images export post params +func (o *PcloudCloudinstancesImagesExportPostParams) SetImageID(imageID string) { + o.ImageID = imageID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudinstancesImagesExportPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param image_id + if err := r.SetPathParam("image_id", o.ImageID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_images_export_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_images_export_post_responses.go new file mode 100644 index 00000000000..0b0a6a0b005 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_images_export_post_responses.go @@ -0,0 +1,255 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_images + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudinstancesImagesExportPostReader is a Reader for the PcloudCloudinstancesImagesExportPost structure. +type PcloudCloudinstancesImagesExportPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudinstancesImagesExportPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 202: + result := NewPcloudCloudinstancesImagesExportPostAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudCloudinstancesImagesExportPostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudCloudinstancesImagesExportPostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudCloudinstancesImagesExportPostNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudCloudinstancesImagesExportPostUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudCloudinstancesImagesExportPostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudCloudinstancesImagesExportPostAccepted creates a PcloudCloudinstancesImagesExportPostAccepted with default headers values +func NewPcloudCloudinstancesImagesExportPostAccepted() *PcloudCloudinstancesImagesExportPostAccepted { + return &PcloudCloudinstancesImagesExportPostAccepted{} +} + +/* PcloudCloudinstancesImagesExportPostAccepted describes a response with status code 202, with default header values. + +Accepted +*/ +type PcloudCloudinstancesImagesExportPostAccepted struct { + Payload models.Object +} + +func (o *PcloudCloudinstancesImagesExportPostAccepted) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/images/{image_id}/export][%d] pcloudCloudinstancesImagesExportPostAccepted %+v", 202, o.Payload) +} +func (o *PcloudCloudinstancesImagesExportPostAccepted) GetPayload() models.Object { + return o.Payload +} + +func (o *PcloudCloudinstancesImagesExportPostAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesImagesExportPostBadRequest creates a PcloudCloudinstancesImagesExportPostBadRequest with default headers values +func NewPcloudCloudinstancesImagesExportPostBadRequest() *PcloudCloudinstancesImagesExportPostBadRequest { + return &PcloudCloudinstancesImagesExportPostBadRequest{} +} + +/* PcloudCloudinstancesImagesExportPostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudCloudinstancesImagesExportPostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesImagesExportPostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/images/{image_id}/export][%d] pcloudCloudinstancesImagesExportPostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudCloudinstancesImagesExportPostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesImagesExportPostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesImagesExportPostUnauthorized creates a PcloudCloudinstancesImagesExportPostUnauthorized with default headers values +func NewPcloudCloudinstancesImagesExportPostUnauthorized() *PcloudCloudinstancesImagesExportPostUnauthorized { + return &PcloudCloudinstancesImagesExportPostUnauthorized{} +} + +/* PcloudCloudinstancesImagesExportPostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudCloudinstancesImagesExportPostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesImagesExportPostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/images/{image_id}/export][%d] pcloudCloudinstancesImagesExportPostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudCloudinstancesImagesExportPostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesImagesExportPostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesImagesExportPostNotFound creates a PcloudCloudinstancesImagesExportPostNotFound with default headers values +func NewPcloudCloudinstancesImagesExportPostNotFound() *PcloudCloudinstancesImagesExportPostNotFound { + return &PcloudCloudinstancesImagesExportPostNotFound{} +} + +/* PcloudCloudinstancesImagesExportPostNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudCloudinstancesImagesExportPostNotFound struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesImagesExportPostNotFound) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/images/{image_id}/export][%d] pcloudCloudinstancesImagesExportPostNotFound %+v", 404, o.Payload) +} +func (o *PcloudCloudinstancesImagesExportPostNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesImagesExportPostNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesImagesExportPostUnprocessableEntity creates a PcloudCloudinstancesImagesExportPostUnprocessableEntity with default headers values +func NewPcloudCloudinstancesImagesExportPostUnprocessableEntity() *PcloudCloudinstancesImagesExportPostUnprocessableEntity { + return &PcloudCloudinstancesImagesExportPostUnprocessableEntity{} +} + +/* PcloudCloudinstancesImagesExportPostUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudCloudinstancesImagesExportPostUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesImagesExportPostUnprocessableEntity) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/images/{image_id}/export][%d] pcloudCloudinstancesImagesExportPostUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudCloudinstancesImagesExportPostUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesImagesExportPostUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesImagesExportPostInternalServerError creates a PcloudCloudinstancesImagesExportPostInternalServerError with default headers values +func NewPcloudCloudinstancesImagesExportPostInternalServerError() *PcloudCloudinstancesImagesExportPostInternalServerError { + return &PcloudCloudinstancesImagesExportPostInternalServerError{} +} + +/* PcloudCloudinstancesImagesExportPostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudCloudinstancesImagesExportPostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesImagesExportPostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/images/{image_id}/export][%d] pcloudCloudinstancesImagesExportPostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudCloudinstancesImagesExportPostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesImagesExportPostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_images_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_images_get_parameters.go new file mode 100644 index 00000000000..decd92c083d --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_images_get_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_images + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudCloudinstancesImagesGetParams creates a new PcloudCloudinstancesImagesGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudCloudinstancesImagesGetParams() *PcloudCloudinstancesImagesGetParams { + return &PcloudCloudinstancesImagesGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudinstancesImagesGetParamsWithTimeout creates a new PcloudCloudinstancesImagesGetParams object +// with the ability to set a timeout on a request. +func NewPcloudCloudinstancesImagesGetParamsWithTimeout(timeout time.Duration) *PcloudCloudinstancesImagesGetParams { + return &PcloudCloudinstancesImagesGetParams{ + timeout: timeout, + } +} + +// NewPcloudCloudinstancesImagesGetParamsWithContext creates a new PcloudCloudinstancesImagesGetParams object +// with the ability to set a context for a request. +func NewPcloudCloudinstancesImagesGetParamsWithContext(ctx context.Context) *PcloudCloudinstancesImagesGetParams { + return &PcloudCloudinstancesImagesGetParams{ + Context: ctx, + } +} + +// NewPcloudCloudinstancesImagesGetParamsWithHTTPClient creates a new PcloudCloudinstancesImagesGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudCloudinstancesImagesGetParamsWithHTTPClient(client *http.Client) *PcloudCloudinstancesImagesGetParams { + return &PcloudCloudinstancesImagesGetParams{ + HTTPClient: client, + } +} + +/* PcloudCloudinstancesImagesGetParams contains all the parameters to send to the API endpoint + for the pcloud cloudinstances images get operation. + + Typically these are written to a http.Request. +*/ +type PcloudCloudinstancesImagesGetParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* ImageID. + + Image ID of a image + */ + ImageID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud cloudinstances images get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesImagesGetParams) WithDefaults() *PcloudCloudinstancesImagesGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud cloudinstances images get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesImagesGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud cloudinstances images get params +func (o *PcloudCloudinstancesImagesGetParams) WithTimeout(timeout time.Duration) *PcloudCloudinstancesImagesGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudinstances images get params +func (o *PcloudCloudinstancesImagesGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudinstances images get params +func (o *PcloudCloudinstancesImagesGetParams) WithContext(ctx context.Context) *PcloudCloudinstancesImagesGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudinstances images get params +func (o *PcloudCloudinstancesImagesGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudinstances images get params +func (o *PcloudCloudinstancesImagesGetParams) WithHTTPClient(client *http.Client) *PcloudCloudinstancesImagesGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudinstances images get params +func (o *PcloudCloudinstancesImagesGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudinstances images get params +func (o *PcloudCloudinstancesImagesGetParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudinstancesImagesGetParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudinstances images get params +func (o *PcloudCloudinstancesImagesGetParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithImageID adds the imageID to the pcloud cloudinstances images get params +func (o *PcloudCloudinstancesImagesGetParams) WithImageID(imageID string) *PcloudCloudinstancesImagesGetParams { + o.SetImageID(imageID) + return o +} + +// SetImageID adds the imageId to the pcloud cloudinstances images get params +func (o *PcloudCloudinstancesImagesGetParams) SetImageID(imageID string) { + o.ImageID = imageID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudinstancesImagesGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param image_id + if err := r.SetPathParam("image_id", o.ImageID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_images_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_images_get_responses.go new file mode 100644 index 00000000000..d4b52ee6e60 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_images_get_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_images + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudinstancesImagesGetReader is a Reader for the PcloudCloudinstancesImagesGet structure. +type PcloudCloudinstancesImagesGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudinstancesImagesGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudCloudinstancesImagesGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudCloudinstancesImagesGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudCloudinstancesImagesGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudCloudinstancesImagesGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudCloudinstancesImagesGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudCloudinstancesImagesGetOK creates a PcloudCloudinstancesImagesGetOK with default headers values +func NewPcloudCloudinstancesImagesGetOK() *PcloudCloudinstancesImagesGetOK { + return &PcloudCloudinstancesImagesGetOK{} +} + +/* PcloudCloudinstancesImagesGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudCloudinstancesImagesGetOK struct { + Payload *models.Image +} + +func (o *PcloudCloudinstancesImagesGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/images/{image_id}][%d] pcloudCloudinstancesImagesGetOK %+v", 200, o.Payload) +} +func (o *PcloudCloudinstancesImagesGetOK) GetPayload() *models.Image { + return o.Payload +} + +func (o *PcloudCloudinstancesImagesGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Image) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesImagesGetBadRequest creates a PcloudCloudinstancesImagesGetBadRequest with default headers values +func NewPcloudCloudinstancesImagesGetBadRequest() *PcloudCloudinstancesImagesGetBadRequest { + return &PcloudCloudinstancesImagesGetBadRequest{} +} + +/* PcloudCloudinstancesImagesGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudCloudinstancesImagesGetBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesImagesGetBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/images/{image_id}][%d] pcloudCloudinstancesImagesGetBadRequest %+v", 400, o.Payload) +} +func (o *PcloudCloudinstancesImagesGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesImagesGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesImagesGetUnauthorized creates a PcloudCloudinstancesImagesGetUnauthorized with default headers values +func NewPcloudCloudinstancesImagesGetUnauthorized() *PcloudCloudinstancesImagesGetUnauthorized { + return &PcloudCloudinstancesImagesGetUnauthorized{} +} + +/* PcloudCloudinstancesImagesGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudCloudinstancesImagesGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesImagesGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/images/{image_id}][%d] pcloudCloudinstancesImagesGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudCloudinstancesImagesGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesImagesGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesImagesGetNotFound creates a PcloudCloudinstancesImagesGetNotFound with default headers values +func NewPcloudCloudinstancesImagesGetNotFound() *PcloudCloudinstancesImagesGetNotFound { + return &PcloudCloudinstancesImagesGetNotFound{} +} + +/* PcloudCloudinstancesImagesGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudCloudinstancesImagesGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesImagesGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/images/{image_id}][%d] pcloudCloudinstancesImagesGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudCloudinstancesImagesGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesImagesGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesImagesGetInternalServerError creates a PcloudCloudinstancesImagesGetInternalServerError with default headers values +func NewPcloudCloudinstancesImagesGetInternalServerError() *PcloudCloudinstancesImagesGetInternalServerError { + return &PcloudCloudinstancesImagesGetInternalServerError{} +} + +/* PcloudCloudinstancesImagesGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudCloudinstancesImagesGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesImagesGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/images/{image_id}][%d] pcloudCloudinstancesImagesGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudCloudinstancesImagesGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesImagesGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_images_getall_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_images_getall_parameters.go new file mode 100644 index 00000000000..a0acea17e18 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_images_getall_parameters.go @@ -0,0 +1,149 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_images + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudCloudinstancesImagesGetallParams creates a new PcloudCloudinstancesImagesGetallParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudCloudinstancesImagesGetallParams() *PcloudCloudinstancesImagesGetallParams { + return &PcloudCloudinstancesImagesGetallParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudinstancesImagesGetallParamsWithTimeout creates a new PcloudCloudinstancesImagesGetallParams object +// with the ability to set a timeout on a request. +func NewPcloudCloudinstancesImagesGetallParamsWithTimeout(timeout time.Duration) *PcloudCloudinstancesImagesGetallParams { + return &PcloudCloudinstancesImagesGetallParams{ + timeout: timeout, + } +} + +// NewPcloudCloudinstancesImagesGetallParamsWithContext creates a new PcloudCloudinstancesImagesGetallParams object +// with the ability to set a context for a request. +func NewPcloudCloudinstancesImagesGetallParamsWithContext(ctx context.Context) *PcloudCloudinstancesImagesGetallParams { + return &PcloudCloudinstancesImagesGetallParams{ + Context: ctx, + } +} + +// NewPcloudCloudinstancesImagesGetallParamsWithHTTPClient creates a new PcloudCloudinstancesImagesGetallParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudCloudinstancesImagesGetallParamsWithHTTPClient(client *http.Client) *PcloudCloudinstancesImagesGetallParams { + return &PcloudCloudinstancesImagesGetallParams{ + HTTPClient: client, + } +} + +/* PcloudCloudinstancesImagesGetallParams contains all the parameters to send to the API endpoint + for the pcloud cloudinstances images getall operation. + + Typically these are written to a http.Request. +*/ +type PcloudCloudinstancesImagesGetallParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud cloudinstances images getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesImagesGetallParams) WithDefaults() *PcloudCloudinstancesImagesGetallParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud cloudinstances images getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesImagesGetallParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud cloudinstances images getall params +func (o *PcloudCloudinstancesImagesGetallParams) WithTimeout(timeout time.Duration) *PcloudCloudinstancesImagesGetallParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudinstances images getall params +func (o *PcloudCloudinstancesImagesGetallParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudinstances images getall params +func (o *PcloudCloudinstancesImagesGetallParams) WithContext(ctx context.Context) *PcloudCloudinstancesImagesGetallParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudinstances images getall params +func (o *PcloudCloudinstancesImagesGetallParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudinstances images getall params +func (o *PcloudCloudinstancesImagesGetallParams) WithHTTPClient(client *http.Client) *PcloudCloudinstancesImagesGetallParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudinstances images getall params +func (o *PcloudCloudinstancesImagesGetallParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudinstances images getall params +func (o *PcloudCloudinstancesImagesGetallParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudinstancesImagesGetallParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudinstances images getall params +func (o *PcloudCloudinstancesImagesGetallParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudinstancesImagesGetallParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_images_getall_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_images_getall_responses.go new file mode 100644 index 00000000000..a06568fe256 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_images_getall_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_images + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudinstancesImagesGetallReader is a Reader for the PcloudCloudinstancesImagesGetall structure. +type PcloudCloudinstancesImagesGetallReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudinstancesImagesGetallReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudCloudinstancesImagesGetallOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudCloudinstancesImagesGetallBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudCloudinstancesImagesGetallUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudCloudinstancesImagesGetallNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudCloudinstancesImagesGetallInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudCloudinstancesImagesGetallOK creates a PcloudCloudinstancesImagesGetallOK with default headers values +func NewPcloudCloudinstancesImagesGetallOK() *PcloudCloudinstancesImagesGetallOK { + return &PcloudCloudinstancesImagesGetallOK{} +} + +/* PcloudCloudinstancesImagesGetallOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudCloudinstancesImagesGetallOK struct { + Payload *models.Images +} + +func (o *PcloudCloudinstancesImagesGetallOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/images][%d] pcloudCloudinstancesImagesGetallOK %+v", 200, o.Payload) +} +func (o *PcloudCloudinstancesImagesGetallOK) GetPayload() *models.Images { + return o.Payload +} + +func (o *PcloudCloudinstancesImagesGetallOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Images) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesImagesGetallBadRequest creates a PcloudCloudinstancesImagesGetallBadRequest with default headers values +func NewPcloudCloudinstancesImagesGetallBadRequest() *PcloudCloudinstancesImagesGetallBadRequest { + return &PcloudCloudinstancesImagesGetallBadRequest{} +} + +/* PcloudCloudinstancesImagesGetallBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudCloudinstancesImagesGetallBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesImagesGetallBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/images][%d] pcloudCloudinstancesImagesGetallBadRequest %+v", 400, o.Payload) +} +func (o *PcloudCloudinstancesImagesGetallBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesImagesGetallBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesImagesGetallUnauthorized creates a PcloudCloudinstancesImagesGetallUnauthorized with default headers values +func NewPcloudCloudinstancesImagesGetallUnauthorized() *PcloudCloudinstancesImagesGetallUnauthorized { + return &PcloudCloudinstancesImagesGetallUnauthorized{} +} + +/* PcloudCloudinstancesImagesGetallUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudCloudinstancesImagesGetallUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesImagesGetallUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/images][%d] pcloudCloudinstancesImagesGetallUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudCloudinstancesImagesGetallUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesImagesGetallUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesImagesGetallNotFound creates a PcloudCloudinstancesImagesGetallNotFound with default headers values +func NewPcloudCloudinstancesImagesGetallNotFound() *PcloudCloudinstancesImagesGetallNotFound { + return &PcloudCloudinstancesImagesGetallNotFound{} +} + +/* PcloudCloudinstancesImagesGetallNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudCloudinstancesImagesGetallNotFound struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesImagesGetallNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/images][%d] pcloudCloudinstancesImagesGetallNotFound %+v", 404, o.Payload) +} +func (o *PcloudCloudinstancesImagesGetallNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesImagesGetallNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesImagesGetallInternalServerError creates a PcloudCloudinstancesImagesGetallInternalServerError with default headers values +func NewPcloudCloudinstancesImagesGetallInternalServerError() *PcloudCloudinstancesImagesGetallInternalServerError { + return &PcloudCloudinstancesImagesGetallInternalServerError{} +} + +/* PcloudCloudinstancesImagesGetallInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudCloudinstancesImagesGetallInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesImagesGetallInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/images][%d] pcloudCloudinstancesImagesGetallInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudCloudinstancesImagesGetallInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesImagesGetallInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_images_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_images_post_parameters.go new file mode 100644 index 00000000000..cd22b7b195b --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_images_post_parameters.go @@ -0,0 +1,173 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_images + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudCloudinstancesImagesPostParams creates a new PcloudCloudinstancesImagesPostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudCloudinstancesImagesPostParams() *PcloudCloudinstancesImagesPostParams { + return &PcloudCloudinstancesImagesPostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudinstancesImagesPostParamsWithTimeout creates a new PcloudCloudinstancesImagesPostParams object +// with the ability to set a timeout on a request. +func NewPcloudCloudinstancesImagesPostParamsWithTimeout(timeout time.Duration) *PcloudCloudinstancesImagesPostParams { + return &PcloudCloudinstancesImagesPostParams{ + timeout: timeout, + } +} + +// NewPcloudCloudinstancesImagesPostParamsWithContext creates a new PcloudCloudinstancesImagesPostParams object +// with the ability to set a context for a request. +func NewPcloudCloudinstancesImagesPostParamsWithContext(ctx context.Context) *PcloudCloudinstancesImagesPostParams { + return &PcloudCloudinstancesImagesPostParams{ + Context: ctx, + } +} + +// NewPcloudCloudinstancesImagesPostParamsWithHTTPClient creates a new PcloudCloudinstancesImagesPostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudCloudinstancesImagesPostParamsWithHTTPClient(client *http.Client) *PcloudCloudinstancesImagesPostParams { + return &PcloudCloudinstancesImagesPostParams{ + HTTPClient: client, + } +} + +/* PcloudCloudinstancesImagesPostParams contains all the parameters to send to the API endpoint + for the pcloud cloudinstances images post operation. + + Typically these are written to a http.Request. +*/ +type PcloudCloudinstancesImagesPostParams struct { + + /* Body. + + Parameters for the creation of a new image from available images + */ + Body *models.CreateImage + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud cloudinstances images post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesImagesPostParams) WithDefaults() *PcloudCloudinstancesImagesPostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud cloudinstances images post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesImagesPostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud cloudinstances images post params +func (o *PcloudCloudinstancesImagesPostParams) WithTimeout(timeout time.Duration) *PcloudCloudinstancesImagesPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudinstances images post params +func (o *PcloudCloudinstancesImagesPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudinstances images post params +func (o *PcloudCloudinstancesImagesPostParams) WithContext(ctx context.Context) *PcloudCloudinstancesImagesPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudinstances images post params +func (o *PcloudCloudinstancesImagesPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudinstances images post params +func (o *PcloudCloudinstancesImagesPostParams) WithHTTPClient(client *http.Client) *PcloudCloudinstancesImagesPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudinstances images post params +func (o *PcloudCloudinstancesImagesPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud cloudinstances images post params +func (o *PcloudCloudinstancesImagesPostParams) WithBody(body *models.CreateImage) *PcloudCloudinstancesImagesPostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud cloudinstances images post params +func (o *PcloudCloudinstancesImagesPostParams) SetBody(body *models.CreateImage) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudinstances images post params +func (o *PcloudCloudinstancesImagesPostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudinstancesImagesPostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudinstances images post params +func (o *PcloudCloudinstancesImagesPostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudinstancesImagesPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_images_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_images_post_responses.go new file mode 100644 index 00000000000..570d84672c7 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_images_post_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_images + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudinstancesImagesPostReader is a Reader for the PcloudCloudinstancesImagesPost structure. +type PcloudCloudinstancesImagesPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudinstancesImagesPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudCloudinstancesImagesPostOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 201: + result := NewPcloudCloudinstancesImagesPostCreated() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudCloudinstancesImagesPostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudCloudinstancesImagesPostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewPcloudCloudinstancesImagesPostConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudCloudinstancesImagesPostUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudCloudinstancesImagesPostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudCloudinstancesImagesPostOK creates a PcloudCloudinstancesImagesPostOK with default headers values +func NewPcloudCloudinstancesImagesPostOK() *PcloudCloudinstancesImagesPostOK { + return &PcloudCloudinstancesImagesPostOK{} +} + +/* PcloudCloudinstancesImagesPostOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudCloudinstancesImagesPostOK struct { + Payload *models.Image +} + +func (o *PcloudCloudinstancesImagesPostOK) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/images][%d] pcloudCloudinstancesImagesPostOK %+v", 200, o.Payload) +} +func (o *PcloudCloudinstancesImagesPostOK) GetPayload() *models.Image { + return o.Payload +} + +func (o *PcloudCloudinstancesImagesPostOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Image) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesImagesPostCreated creates a PcloudCloudinstancesImagesPostCreated with default headers values +func NewPcloudCloudinstancesImagesPostCreated() *PcloudCloudinstancesImagesPostCreated { + return &PcloudCloudinstancesImagesPostCreated{} +} + +/* PcloudCloudinstancesImagesPostCreated describes a response with status code 201, with default header values. + +Created +*/ +type PcloudCloudinstancesImagesPostCreated struct { + Payload *models.Image +} + +func (o *PcloudCloudinstancesImagesPostCreated) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/images][%d] pcloudCloudinstancesImagesPostCreated %+v", 201, o.Payload) +} +func (o *PcloudCloudinstancesImagesPostCreated) GetPayload() *models.Image { + return o.Payload +} + +func (o *PcloudCloudinstancesImagesPostCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Image) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesImagesPostBadRequest creates a PcloudCloudinstancesImagesPostBadRequest with default headers values +func NewPcloudCloudinstancesImagesPostBadRequest() *PcloudCloudinstancesImagesPostBadRequest { + return &PcloudCloudinstancesImagesPostBadRequest{} +} + +/* PcloudCloudinstancesImagesPostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudCloudinstancesImagesPostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesImagesPostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/images][%d] pcloudCloudinstancesImagesPostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudCloudinstancesImagesPostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesImagesPostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesImagesPostUnauthorized creates a PcloudCloudinstancesImagesPostUnauthorized with default headers values +func NewPcloudCloudinstancesImagesPostUnauthorized() *PcloudCloudinstancesImagesPostUnauthorized { + return &PcloudCloudinstancesImagesPostUnauthorized{} +} + +/* PcloudCloudinstancesImagesPostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudCloudinstancesImagesPostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesImagesPostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/images][%d] pcloudCloudinstancesImagesPostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudCloudinstancesImagesPostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesImagesPostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesImagesPostConflict creates a PcloudCloudinstancesImagesPostConflict with default headers values +func NewPcloudCloudinstancesImagesPostConflict() *PcloudCloudinstancesImagesPostConflict { + return &PcloudCloudinstancesImagesPostConflict{} +} + +/* PcloudCloudinstancesImagesPostConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type PcloudCloudinstancesImagesPostConflict struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesImagesPostConflict) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/images][%d] pcloudCloudinstancesImagesPostConflict %+v", 409, o.Payload) +} +func (o *PcloudCloudinstancesImagesPostConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesImagesPostConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesImagesPostUnprocessableEntity creates a PcloudCloudinstancesImagesPostUnprocessableEntity with default headers values +func NewPcloudCloudinstancesImagesPostUnprocessableEntity() *PcloudCloudinstancesImagesPostUnprocessableEntity { + return &PcloudCloudinstancesImagesPostUnprocessableEntity{} +} + +/* PcloudCloudinstancesImagesPostUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudCloudinstancesImagesPostUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesImagesPostUnprocessableEntity) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/images][%d] pcloudCloudinstancesImagesPostUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudCloudinstancesImagesPostUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesImagesPostUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesImagesPostInternalServerError creates a PcloudCloudinstancesImagesPostInternalServerError with default headers values +func NewPcloudCloudinstancesImagesPostInternalServerError() *PcloudCloudinstancesImagesPostInternalServerError { + return &PcloudCloudinstancesImagesPostInternalServerError{} +} + +/* PcloudCloudinstancesImagesPostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudCloudinstancesImagesPostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesImagesPostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/images][%d] pcloudCloudinstancesImagesPostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudCloudinstancesImagesPostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesImagesPostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_stockimages_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_stockimages_get_parameters.go new file mode 100644 index 00000000000..071d73d8024 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_stockimages_get_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_images + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudCloudinstancesStockimagesGetParams creates a new PcloudCloudinstancesStockimagesGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudCloudinstancesStockimagesGetParams() *PcloudCloudinstancesStockimagesGetParams { + return &PcloudCloudinstancesStockimagesGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudinstancesStockimagesGetParamsWithTimeout creates a new PcloudCloudinstancesStockimagesGetParams object +// with the ability to set a timeout on a request. +func NewPcloudCloudinstancesStockimagesGetParamsWithTimeout(timeout time.Duration) *PcloudCloudinstancesStockimagesGetParams { + return &PcloudCloudinstancesStockimagesGetParams{ + timeout: timeout, + } +} + +// NewPcloudCloudinstancesStockimagesGetParamsWithContext creates a new PcloudCloudinstancesStockimagesGetParams object +// with the ability to set a context for a request. +func NewPcloudCloudinstancesStockimagesGetParamsWithContext(ctx context.Context) *PcloudCloudinstancesStockimagesGetParams { + return &PcloudCloudinstancesStockimagesGetParams{ + Context: ctx, + } +} + +// NewPcloudCloudinstancesStockimagesGetParamsWithHTTPClient creates a new PcloudCloudinstancesStockimagesGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudCloudinstancesStockimagesGetParamsWithHTTPClient(client *http.Client) *PcloudCloudinstancesStockimagesGetParams { + return &PcloudCloudinstancesStockimagesGetParams{ + HTTPClient: client, + } +} + +/* PcloudCloudinstancesStockimagesGetParams contains all the parameters to send to the API endpoint + for the pcloud cloudinstances stockimages get operation. + + Typically these are written to a http.Request. +*/ +type PcloudCloudinstancesStockimagesGetParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* ImageID. + + Image ID of a image + */ + ImageID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud cloudinstances stockimages get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesStockimagesGetParams) WithDefaults() *PcloudCloudinstancesStockimagesGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud cloudinstances stockimages get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesStockimagesGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud cloudinstances stockimages get params +func (o *PcloudCloudinstancesStockimagesGetParams) WithTimeout(timeout time.Duration) *PcloudCloudinstancesStockimagesGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudinstances stockimages get params +func (o *PcloudCloudinstancesStockimagesGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudinstances stockimages get params +func (o *PcloudCloudinstancesStockimagesGetParams) WithContext(ctx context.Context) *PcloudCloudinstancesStockimagesGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudinstances stockimages get params +func (o *PcloudCloudinstancesStockimagesGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudinstances stockimages get params +func (o *PcloudCloudinstancesStockimagesGetParams) WithHTTPClient(client *http.Client) *PcloudCloudinstancesStockimagesGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudinstances stockimages get params +func (o *PcloudCloudinstancesStockimagesGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudinstances stockimages get params +func (o *PcloudCloudinstancesStockimagesGetParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudinstancesStockimagesGetParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudinstances stockimages get params +func (o *PcloudCloudinstancesStockimagesGetParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithImageID adds the imageID to the pcloud cloudinstances stockimages get params +func (o *PcloudCloudinstancesStockimagesGetParams) WithImageID(imageID string) *PcloudCloudinstancesStockimagesGetParams { + o.SetImageID(imageID) + return o +} + +// SetImageID adds the imageId to the pcloud cloudinstances stockimages get params +func (o *PcloudCloudinstancesStockimagesGetParams) SetImageID(imageID string) { + o.ImageID = imageID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudinstancesStockimagesGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param image_id + if err := r.SetPathParam("image_id", o.ImageID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_stockimages_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_stockimages_get_responses.go new file mode 100644 index 00000000000..2073da1cac2 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_stockimages_get_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_images + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudinstancesStockimagesGetReader is a Reader for the PcloudCloudinstancesStockimagesGet structure. +type PcloudCloudinstancesStockimagesGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudinstancesStockimagesGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudCloudinstancesStockimagesGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudCloudinstancesStockimagesGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudCloudinstancesStockimagesGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudCloudinstancesStockimagesGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudCloudinstancesStockimagesGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudCloudinstancesStockimagesGetOK creates a PcloudCloudinstancesStockimagesGetOK with default headers values +func NewPcloudCloudinstancesStockimagesGetOK() *PcloudCloudinstancesStockimagesGetOK { + return &PcloudCloudinstancesStockimagesGetOK{} +} + +/* PcloudCloudinstancesStockimagesGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudCloudinstancesStockimagesGetOK struct { + Payload *models.Image +} + +func (o *PcloudCloudinstancesStockimagesGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/stock-images/{image_id}][%d] pcloudCloudinstancesStockimagesGetOK %+v", 200, o.Payload) +} +func (o *PcloudCloudinstancesStockimagesGetOK) GetPayload() *models.Image { + return o.Payload +} + +func (o *PcloudCloudinstancesStockimagesGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Image) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesStockimagesGetBadRequest creates a PcloudCloudinstancesStockimagesGetBadRequest with default headers values +func NewPcloudCloudinstancesStockimagesGetBadRequest() *PcloudCloudinstancesStockimagesGetBadRequest { + return &PcloudCloudinstancesStockimagesGetBadRequest{} +} + +/* PcloudCloudinstancesStockimagesGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudCloudinstancesStockimagesGetBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesStockimagesGetBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/stock-images/{image_id}][%d] pcloudCloudinstancesStockimagesGetBadRequest %+v", 400, o.Payload) +} +func (o *PcloudCloudinstancesStockimagesGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesStockimagesGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesStockimagesGetUnauthorized creates a PcloudCloudinstancesStockimagesGetUnauthorized with default headers values +func NewPcloudCloudinstancesStockimagesGetUnauthorized() *PcloudCloudinstancesStockimagesGetUnauthorized { + return &PcloudCloudinstancesStockimagesGetUnauthorized{} +} + +/* PcloudCloudinstancesStockimagesGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudCloudinstancesStockimagesGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesStockimagesGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/stock-images/{image_id}][%d] pcloudCloudinstancesStockimagesGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudCloudinstancesStockimagesGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesStockimagesGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesStockimagesGetNotFound creates a PcloudCloudinstancesStockimagesGetNotFound with default headers values +func NewPcloudCloudinstancesStockimagesGetNotFound() *PcloudCloudinstancesStockimagesGetNotFound { + return &PcloudCloudinstancesStockimagesGetNotFound{} +} + +/* PcloudCloudinstancesStockimagesGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudCloudinstancesStockimagesGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesStockimagesGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/stock-images/{image_id}][%d] pcloudCloudinstancesStockimagesGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudCloudinstancesStockimagesGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesStockimagesGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesStockimagesGetInternalServerError creates a PcloudCloudinstancesStockimagesGetInternalServerError with default headers values +func NewPcloudCloudinstancesStockimagesGetInternalServerError() *PcloudCloudinstancesStockimagesGetInternalServerError { + return &PcloudCloudinstancesStockimagesGetInternalServerError{} +} + +/* PcloudCloudinstancesStockimagesGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudCloudinstancesStockimagesGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesStockimagesGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/stock-images/{image_id}][%d] pcloudCloudinstancesStockimagesGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudCloudinstancesStockimagesGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesStockimagesGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_stockimages_getall_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_stockimages_getall_parameters.go new file mode 100644 index 00000000000..cec512f7bd6 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_stockimages_getall_parameters.go @@ -0,0 +1,218 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_images + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewPcloudCloudinstancesStockimagesGetallParams creates a new PcloudCloudinstancesStockimagesGetallParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudCloudinstancesStockimagesGetallParams() *PcloudCloudinstancesStockimagesGetallParams { + return &PcloudCloudinstancesStockimagesGetallParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudinstancesStockimagesGetallParamsWithTimeout creates a new PcloudCloudinstancesStockimagesGetallParams object +// with the ability to set a timeout on a request. +func NewPcloudCloudinstancesStockimagesGetallParamsWithTimeout(timeout time.Duration) *PcloudCloudinstancesStockimagesGetallParams { + return &PcloudCloudinstancesStockimagesGetallParams{ + timeout: timeout, + } +} + +// NewPcloudCloudinstancesStockimagesGetallParamsWithContext creates a new PcloudCloudinstancesStockimagesGetallParams object +// with the ability to set a context for a request. +func NewPcloudCloudinstancesStockimagesGetallParamsWithContext(ctx context.Context) *PcloudCloudinstancesStockimagesGetallParams { + return &PcloudCloudinstancesStockimagesGetallParams{ + Context: ctx, + } +} + +// NewPcloudCloudinstancesStockimagesGetallParamsWithHTTPClient creates a new PcloudCloudinstancesStockimagesGetallParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudCloudinstancesStockimagesGetallParamsWithHTTPClient(client *http.Client) *PcloudCloudinstancesStockimagesGetallParams { + return &PcloudCloudinstancesStockimagesGetallParams{ + HTTPClient: client, + } +} + +/* PcloudCloudinstancesStockimagesGetallParams contains all the parameters to send to the API endpoint + for the pcloud cloudinstances stockimages getall operation. + + Typically these are written to a http.Request. +*/ +type PcloudCloudinstancesStockimagesGetallParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* Sap. + + Include SAP images with get available stock images + */ + Sap *bool + + /* Vtl. + + Include VTL images with get available stock images + */ + Vtl *bool + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud cloudinstances stockimages getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesStockimagesGetallParams) WithDefaults() *PcloudCloudinstancesStockimagesGetallParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud cloudinstances stockimages getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesStockimagesGetallParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud cloudinstances stockimages getall params +func (o *PcloudCloudinstancesStockimagesGetallParams) WithTimeout(timeout time.Duration) *PcloudCloudinstancesStockimagesGetallParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudinstances stockimages getall params +func (o *PcloudCloudinstancesStockimagesGetallParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudinstances stockimages getall params +func (o *PcloudCloudinstancesStockimagesGetallParams) WithContext(ctx context.Context) *PcloudCloudinstancesStockimagesGetallParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudinstances stockimages getall params +func (o *PcloudCloudinstancesStockimagesGetallParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudinstances stockimages getall params +func (o *PcloudCloudinstancesStockimagesGetallParams) WithHTTPClient(client *http.Client) *PcloudCloudinstancesStockimagesGetallParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudinstances stockimages getall params +func (o *PcloudCloudinstancesStockimagesGetallParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudinstances stockimages getall params +func (o *PcloudCloudinstancesStockimagesGetallParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudinstancesStockimagesGetallParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudinstances stockimages getall params +func (o *PcloudCloudinstancesStockimagesGetallParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithSap adds the sap to the pcloud cloudinstances stockimages getall params +func (o *PcloudCloudinstancesStockimagesGetallParams) WithSap(sap *bool) *PcloudCloudinstancesStockimagesGetallParams { + o.SetSap(sap) + return o +} + +// SetSap adds the sap to the pcloud cloudinstances stockimages getall params +func (o *PcloudCloudinstancesStockimagesGetallParams) SetSap(sap *bool) { + o.Sap = sap +} + +// WithVtl adds the vtl to the pcloud cloudinstances stockimages getall params +func (o *PcloudCloudinstancesStockimagesGetallParams) WithVtl(vtl *bool) *PcloudCloudinstancesStockimagesGetallParams { + o.SetVtl(vtl) + return o +} + +// SetVtl adds the vtl to the pcloud cloudinstances stockimages getall params +func (o *PcloudCloudinstancesStockimagesGetallParams) SetVtl(vtl *bool) { + o.Vtl = vtl +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudinstancesStockimagesGetallParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if o.Sap != nil { + + // query param sap + var qrSap bool + + if o.Sap != nil { + qrSap = *o.Sap + } + qSap := swag.FormatBool(qrSap) + if qSap != "" { + + if err := r.SetQueryParam("sap", qSap); err != nil { + return err + } + } + } + + if o.Vtl != nil { + + // query param vtl + var qrVtl bool + + if o.Vtl != nil { + qrVtl = *o.Vtl + } + qVtl := swag.FormatBool(qrVtl) + if qVtl != "" { + + if err := r.SetQueryParam("vtl", qVtl); err != nil { + return err + } + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_stockimages_getall_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_stockimages_getall_responses.go new file mode 100644 index 00000000000..b30c83880b7 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_cloudinstances_stockimages_getall_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_images + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudinstancesStockimagesGetallReader is a Reader for the PcloudCloudinstancesStockimagesGetall structure. +type PcloudCloudinstancesStockimagesGetallReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudinstancesStockimagesGetallReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudCloudinstancesStockimagesGetallOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudCloudinstancesStockimagesGetallBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudCloudinstancesStockimagesGetallUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudCloudinstancesStockimagesGetallNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudCloudinstancesStockimagesGetallInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudCloudinstancesStockimagesGetallOK creates a PcloudCloudinstancesStockimagesGetallOK with default headers values +func NewPcloudCloudinstancesStockimagesGetallOK() *PcloudCloudinstancesStockimagesGetallOK { + return &PcloudCloudinstancesStockimagesGetallOK{} +} + +/* PcloudCloudinstancesStockimagesGetallOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudCloudinstancesStockimagesGetallOK struct { + Payload *models.Images +} + +func (o *PcloudCloudinstancesStockimagesGetallOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/stock-images][%d] pcloudCloudinstancesStockimagesGetallOK %+v", 200, o.Payload) +} +func (o *PcloudCloudinstancesStockimagesGetallOK) GetPayload() *models.Images { + return o.Payload +} + +func (o *PcloudCloudinstancesStockimagesGetallOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Images) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesStockimagesGetallBadRequest creates a PcloudCloudinstancesStockimagesGetallBadRequest with default headers values +func NewPcloudCloudinstancesStockimagesGetallBadRequest() *PcloudCloudinstancesStockimagesGetallBadRequest { + return &PcloudCloudinstancesStockimagesGetallBadRequest{} +} + +/* PcloudCloudinstancesStockimagesGetallBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudCloudinstancesStockimagesGetallBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesStockimagesGetallBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/stock-images][%d] pcloudCloudinstancesStockimagesGetallBadRequest %+v", 400, o.Payload) +} +func (o *PcloudCloudinstancesStockimagesGetallBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesStockimagesGetallBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesStockimagesGetallUnauthorized creates a PcloudCloudinstancesStockimagesGetallUnauthorized with default headers values +func NewPcloudCloudinstancesStockimagesGetallUnauthorized() *PcloudCloudinstancesStockimagesGetallUnauthorized { + return &PcloudCloudinstancesStockimagesGetallUnauthorized{} +} + +/* PcloudCloudinstancesStockimagesGetallUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudCloudinstancesStockimagesGetallUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesStockimagesGetallUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/stock-images][%d] pcloudCloudinstancesStockimagesGetallUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudCloudinstancesStockimagesGetallUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesStockimagesGetallUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesStockimagesGetallNotFound creates a PcloudCloudinstancesStockimagesGetallNotFound with default headers values +func NewPcloudCloudinstancesStockimagesGetallNotFound() *PcloudCloudinstancesStockimagesGetallNotFound { + return &PcloudCloudinstancesStockimagesGetallNotFound{} +} + +/* PcloudCloudinstancesStockimagesGetallNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudCloudinstancesStockimagesGetallNotFound struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesStockimagesGetallNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/stock-images][%d] pcloudCloudinstancesStockimagesGetallNotFound %+v", 404, o.Payload) +} +func (o *PcloudCloudinstancesStockimagesGetallNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesStockimagesGetallNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesStockimagesGetallInternalServerError creates a PcloudCloudinstancesStockimagesGetallInternalServerError with default headers values +func NewPcloudCloudinstancesStockimagesGetallInternalServerError() *PcloudCloudinstancesStockimagesGetallInternalServerError { + return &PcloudCloudinstancesStockimagesGetallInternalServerError{} +} + +/* PcloudCloudinstancesStockimagesGetallInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudCloudinstancesStockimagesGetallInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesStockimagesGetallInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/stock-images][%d] pcloudCloudinstancesStockimagesGetallInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudCloudinstancesStockimagesGetallInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesStockimagesGetallInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_images_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_images_get_parameters.go new file mode 100644 index 00000000000..91192f6fdcc --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_images_get_parameters.go @@ -0,0 +1,149 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_images + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudImagesGetParams creates a new PcloudImagesGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudImagesGetParams() *PcloudImagesGetParams { + return &PcloudImagesGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudImagesGetParamsWithTimeout creates a new PcloudImagesGetParams object +// with the ability to set a timeout on a request. +func NewPcloudImagesGetParamsWithTimeout(timeout time.Duration) *PcloudImagesGetParams { + return &PcloudImagesGetParams{ + timeout: timeout, + } +} + +// NewPcloudImagesGetParamsWithContext creates a new PcloudImagesGetParams object +// with the ability to set a context for a request. +func NewPcloudImagesGetParamsWithContext(ctx context.Context) *PcloudImagesGetParams { + return &PcloudImagesGetParams{ + Context: ctx, + } +} + +// NewPcloudImagesGetParamsWithHTTPClient creates a new PcloudImagesGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudImagesGetParamsWithHTTPClient(client *http.Client) *PcloudImagesGetParams { + return &PcloudImagesGetParams{ + HTTPClient: client, + } +} + +/* PcloudImagesGetParams contains all the parameters to send to the API endpoint + for the pcloud images get operation. + + Typically these are written to a http.Request. +*/ +type PcloudImagesGetParams struct { + + /* ImageID. + + Image ID of a image + */ + ImageID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud images get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudImagesGetParams) WithDefaults() *PcloudImagesGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud images get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudImagesGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud images get params +func (o *PcloudImagesGetParams) WithTimeout(timeout time.Duration) *PcloudImagesGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud images get params +func (o *PcloudImagesGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud images get params +func (o *PcloudImagesGetParams) WithContext(ctx context.Context) *PcloudImagesGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud images get params +func (o *PcloudImagesGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud images get params +func (o *PcloudImagesGetParams) WithHTTPClient(client *http.Client) *PcloudImagesGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud images get params +func (o *PcloudImagesGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithImageID adds the imageID to the pcloud images get params +func (o *PcloudImagesGetParams) WithImageID(imageID string) *PcloudImagesGetParams { + o.SetImageID(imageID) + return o +} + +// SetImageID adds the imageId to the pcloud images get params +func (o *PcloudImagesGetParams) SetImageID(imageID string) { + o.ImageID = imageID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudImagesGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param image_id + if err := r.SetPathParam("image_id", o.ImageID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_images_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_images_get_responses.go new file mode 100644 index 00000000000..040e27c3fe4 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_images_get_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_images + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudImagesGetReader is a Reader for the PcloudImagesGet structure. +type PcloudImagesGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudImagesGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudImagesGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudImagesGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudImagesGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudImagesGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudImagesGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudImagesGetOK creates a PcloudImagesGetOK with default headers values +func NewPcloudImagesGetOK() *PcloudImagesGetOK { + return &PcloudImagesGetOK{} +} + +/* PcloudImagesGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudImagesGetOK struct { + Payload *models.Image +} + +func (o *PcloudImagesGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/images/{image_id}][%d] pcloudImagesGetOK %+v", 200, o.Payload) +} +func (o *PcloudImagesGetOK) GetPayload() *models.Image { + return o.Payload +} + +func (o *PcloudImagesGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Image) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudImagesGetBadRequest creates a PcloudImagesGetBadRequest with default headers values +func NewPcloudImagesGetBadRequest() *PcloudImagesGetBadRequest { + return &PcloudImagesGetBadRequest{} +} + +/* PcloudImagesGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudImagesGetBadRequest struct { + Payload *models.Error +} + +func (o *PcloudImagesGetBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/images/{image_id}][%d] pcloudImagesGetBadRequest %+v", 400, o.Payload) +} +func (o *PcloudImagesGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudImagesGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudImagesGetUnauthorized creates a PcloudImagesGetUnauthorized with default headers values +func NewPcloudImagesGetUnauthorized() *PcloudImagesGetUnauthorized { + return &PcloudImagesGetUnauthorized{} +} + +/* PcloudImagesGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudImagesGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudImagesGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/images/{image_id}][%d] pcloudImagesGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudImagesGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudImagesGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudImagesGetNotFound creates a PcloudImagesGetNotFound with default headers values +func NewPcloudImagesGetNotFound() *PcloudImagesGetNotFound { + return &PcloudImagesGetNotFound{} +} + +/* PcloudImagesGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudImagesGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudImagesGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/images/{image_id}][%d] pcloudImagesGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudImagesGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudImagesGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudImagesGetInternalServerError creates a PcloudImagesGetInternalServerError with default headers values +func NewPcloudImagesGetInternalServerError() *PcloudImagesGetInternalServerError { + return &PcloudImagesGetInternalServerError{} +} + +/* PcloudImagesGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudImagesGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudImagesGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/images/{image_id}][%d] pcloudImagesGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudImagesGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudImagesGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_images_getall_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_images_getall_parameters.go new file mode 100644 index 00000000000..cb90f6f5a67 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_images_getall_parameters.go @@ -0,0 +1,196 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_images + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewPcloudImagesGetallParams creates a new PcloudImagesGetallParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudImagesGetallParams() *PcloudImagesGetallParams { + return &PcloudImagesGetallParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudImagesGetallParamsWithTimeout creates a new PcloudImagesGetallParams object +// with the ability to set a timeout on a request. +func NewPcloudImagesGetallParamsWithTimeout(timeout time.Duration) *PcloudImagesGetallParams { + return &PcloudImagesGetallParams{ + timeout: timeout, + } +} + +// NewPcloudImagesGetallParamsWithContext creates a new PcloudImagesGetallParams object +// with the ability to set a context for a request. +func NewPcloudImagesGetallParamsWithContext(ctx context.Context) *PcloudImagesGetallParams { + return &PcloudImagesGetallParams{ + Context: ctx, + } +} + +// NewPcloudImagesGetallParamsWithHTTPClient creates a new PcloudImagesGetallParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudImagesGetallParamsWithHTTPClient(client *http.Client) *PcloudImagesGetallParams { + return &PcloudImagesGetallParams{ + HTTPClient: client, + } +} + +/* PcloudImagesGetallParams contains all the parameters to send to the API endpoint + for the pcloud images getall operation. + + Typically these are written to a http.Request. +*/ +type PcloudImagesGetallParams struct { + + /* Sap. + + Include SAP images with get available stock images + */ + Sap *bool + + /* Vtl. + + Include VTL images with get available stock images + */ + Vtl *bool + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud images getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudImagesGetallParams) WithDefaults() *PcloudImagesGetallParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud images getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudImagesGetallParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud images getall params +func (o *PcloudImagesGetallParams) WithTimeout(timeout time.Duration) *PcloudImagesGetallParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud images getall params +func (o *PcloudImagesGetallParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud images getall params +func (o *PcloudImagesGetallParams) WithContext(ctx context.Context) *PcloudImagesGetallParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud images getall params +func (o *PcloudImagesGetallParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud images getall params +func (o *PcloudImagesGetallParams) WithHTTPClient(client *http.Client) *PcloudImagesGetallParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud images getall params +func (o *PcloudImagesGetallParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithSap adds the sap to the pcloud images getall params +func (o *PcloudImagesGetallParams) WithSap(sap *bool) *PcloudImagesGetallParams { + o.SetSap(sap) + return o +} + +// SetSap adds the sap to the pcloud images getall params +func (o *PcloudImagesGetallParams) SetSap(sap *bool) { + o.Sap = sap +} + +// WithVtl adds the vtl to the pcloud images getall params +func (o *PcloudImagesGetallParams) WithVtl(vtl *bool) *PcloudImagesGetallParams { + o.SetVtl(vtl) + return o +} + +// SetVtl adds the vtl to the pcloud images getall params +func (o *PcloudImagesGetallParams) SetVtl(vtl *bool) { + o.Vtl = vtl +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudImagesGetallParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.Sap != nil { + + // query param sap + var qrSap bool + + if o.Sap != nil { + qrSap = *o.Sap + } + qSap := swag.FormatBool(qrSap) + if qSap != "" { + + if err := r.SetQueryParam("sap", qSap); err != nil { + return err + } + } + } + + if o.Vtl != nil { + + // query param vtl + var qrVtl bool + + if o.Vtl != nil { + qrVtl = *o.Vtl + } + qVtl := swag.FormatBool(qrVtl) + if qVtl != "" { + + if err := r.SetQueryParam("vtl", qVtl); err != nil { + return err + } + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_images_getall_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_images_getall_responses.go new file mode 100644 index 00000000000..5be159bd652 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_images_getall_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_images + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudImagesGetallReader is a Reader for the PcloudImagesGetall structure. +type PcloudImagesGetallReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudImagesGetallReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudImagesGetallOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudImagesGetallBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudImagesGetallUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudImagesGetallNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudImagesGetallInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudImagesGetallOK creates a PcloudImagesGetallOK with default headers values +func NewPcloudImagesGetallOK() *PcloudImagesGetallOK { + return &PcloudImagesGetallOK{} +} + +/* PcloudImagesGetallOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudImagesGetallOK struct { + Payload *models.Images +} + +func (o *PcloudImagesGetallOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/images][%d] pcloudImagesGetallOK %+v", 200, o.Payload) +} +func (o *PcloudImagesGetallOK) GetPayload() *models.Images { + return o.Payload +} + +func (o *PcloudImagesGetallOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Images) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudImagesGetallBadRequest creates a PcloudImagesGetallBadRequest with default headers values +func NewPcloudImagesGetallBadRequest() *PcloudImagesGetallBadRequest { + return &PcloudImagesGetallBadRequest{} +} + +/* PcloudImagesGetallBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudImagesGetallBadRequest struct { + Payload *models.Error +} + +func (o *PcloudImagesGetallBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/images][%d] pcloudImagesGetallBadRequest %+v", 400, o.Payload) +} +func (o *PcloudImagesGetallBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudImagesGetallBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudImagesGetallUnauthorized creates a PcloudImagesGetallUnauthorized with default headers values +func NewPcloudImagesGetallUnauthorized() *PcloudImagesGetallUnauthorized { + return &PcloudImagesGetallUnauthorized{} +} + +/* PcloudImagesGetallUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudImagesGetallUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudImagesGetallUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/images][%d] pcloudImagesGetallUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudImagesGetallUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudImagesGetallUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudImagesGetallNotFound creates a PcloudImagesGetallNotFound with default headers values +func NewPcloudImagesGetallNotFound() *PcloudImagesGetallNotFound { + return &PcloudImagesGetallNotFound{} +} + +/* PcloudImagesGetallNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudImagesGetallNotFound struct { + Payload *models.Error +} + +func (o *PcloudImagesGetallNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/images][%d] pcloudImagesGetallNotFound %+v", 404, o.Payload) +} +func (o *PcloudImagesGetallNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudImagesGetallNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudImagesGetallInternalServerError creates a PcloudImagesGetallInternalServerError with default headers values +func NewPcloudImagesGetallInternalServerError() *PcloudImagesGetallInternalServerError { + return &PcloudImagesGetallInternalServerError{} +} + +/* PcloudImagesGetallInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudImagesGetallInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudImagesGetallInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/images][%d] pcloudImagesGetallInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudImagesGetallInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudImagesGetallInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_v1_cloudinstances_cosimages_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_v1_cloudinstances_cosimages_get_parameters.go new file mode 100644 index 00000000000..dd5a1f9ad02 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_v1_cloudinstances_cosimages_get_parameters.go @@ -0,0 +1,149 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_images + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudV1CloudinstancesCosimagesGetParams creates a new PcloudV1CloudinstancesCosimagesGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudV1CloudinstancesCosimagesGetParams() *PcloudV1CloudinstancesCosimagesGetParams { + return &PcloudV1CloudinstancesCosimagesGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudV1CloudinstancesCosimagesGetParamsWithTimeout creates a new PcloudV1CloudinstancesCosimagesGetParams object +// with the ability to set a timeout on a request. +func NewPcloudV1CloudinstancesCosimagesGetParamsWithTimeout(timeout time.Duration) *PcloudV1CloudinstancesCosimagesGetParams { + return &PcloudV1CloudinstancesCosimagesGetParams{ + timeout: timeout, + } +} + +// NewPcloudV1CloudinstancesCosimagesGetParamsWithContext creates a new PcloudV1CloudinstancesCosimagesGetParams object +// with the ability to set a context for a request. +func NewPcloudV1CloudinstancesCosimagesGetParamsWithContext(ctx context.Context) *PcloudV1CloudinstancesCosimagesGetParams { + return &PcloudV1CloudinstancesCosimagesGetParams{ + Context: ctx, + } +} + +// NewPcloudV1CloudinstancesCosimagesGetParamsWithHTTPClient creates a new PcloudV1CloudinstancesCosimagesGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudV1CloudinstancesCosimagesGetParamsWithHTTPClient(client *http.Client) *PcloudV1CloudinstancesCosimagesGetParams { + return &PcloudV1CloudinstancesCosimagesGetParams{ + HTTPClient: client, + } +} + +/* PcloudV1CloudinstancesCosimagesGetParams contains all the parameters to send to the API endpoint + for the pcloud v1 cloudinstances cosimages get operation. + + Typically these are written to a http.Request. +*/ +type PcloudV1CloudinstancesCosimagesGetParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud v1 cloudinstances cosimages get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV1CloudinstancesCosimagesGetParams) WithDefaults() *PcloudV1CloudinstancesCosimagesGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud v1 cloudinstances cosimages get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV1CloudinstancesCosimagesGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud v1 cloudinstances cosimages get params +func (o *PcloudV1CloudinstancesCosimagesGetParams) WithTimeout(timeout time.Duration) *PcloudV1CloudinstancesCosimagesGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud v1 cloudinstances cosimages get params +func (o *PcloudV1CloudinstancesCosimagesGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud v1 cloudinstances cosimages get params +func (o *PcloudV1CloudinstancesCosimagesGetParams) WithContext(ctx context.Context) *PcloudV1CloudinstancesCosimagesGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud v1 cloudinstances cosimages get params +func (o *PcloudV1CloudinstancesCosimagesGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud v1 cloudinstances cosimages get params +func (o *PcloudV1CloudinstancesCosimagesGetParams) WithHTTPClient(client *http.Client) *PcloudV1CloudinstancesCosimagesGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud v1 cloudinstances cosimages get params +func (o *PcloudV1CloudinstancesCosimagesGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud v1 cloudinstances cosimages get params +func (o *PcloudV1CloudinstancesCosimagesGetParams) WithCloudInstanceID(cloudInstanceID string) *PcloudV1CloudinstancesCosimagesGetParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud v1 cloudinstances cosimages get params +func (o *PcloudV1CloudinstancesCosimagesGetParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudV1CloudinstancesCosimagesGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_v1_cloudinstances_cosimages_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_v1_cloudinstances_cosimages_get_responses.go new file mode 100644 index 00000000000..54dad0dc1a2 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_v1_cloudinstances_cosimages_get_responses.go @@ -0,0 +1,181 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_images + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudV1CloudinstancesCosimagesGetReader is a Reader for the PcloudV1CloudinstancesCosimagesGet structure. +type PcloudV1CloudinstancesCosimagesGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudV1CloudinstancesCosimagesGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudV1CloudinstancesCosimagesGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewPcloudV1CloudinstancesCosimagesGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudV1CloudinstancesCosimagesGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudV1CloudinstancesCosimagesGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudV1CloudinstancesCosimagesGetOK creates a PcloudV1CloudinstancesCosimagesGetOK with default headers values +func NewPcloudV1CloudinstancesCosimagesGetOK() *PcloudV1CloudinstancesCosimagesGetOK { + return &PcloudV1CloudinstancesCosimagesGetOK{} +} + +/* PcloudV1CloudinstancesCosimagesGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudV1CloudinstancesCosimagesGetOK struct { + Payload *models.Job +} + +func (o *PcloudV1CloudinstancesCosimagesGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/cos-images][%d] pcloudV1CloudinstancesCosimagesGetOK %+v", 200, o.Payload) +} +func (o *PcloudV1CloudinstancesCosimagesGetOK) GetPayload() *models.Job { + return o.Payload +} + +func (o *PcloudV1CloudinstancesCosimagesGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Job) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV1CloudinstancesCosimagesGetUnauthorized creates a PcloudV1CloudinstancesCosimagesGetUnauthorized with default headers values +func NewPcloudV1CloudinstancesCosimagesGetUnauthorized() *PcloudV1CloudinstancesCosimagesGetUnauthorized { + return &PcloudV1CloudinstancesCosimagesGetUnauthorized{} +} + +/* PcloudV1CloudinstancesCosimagesGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudV1CloudinstancesCosimagesGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudV1CloudinstancesCosimagesGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/cos-images][%d] pcloudV1CloudinstancesCosimagesGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudV1CloudinstancesCosimagesGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV1CloudinstancesCosimagesGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV1CloudinstancesCosimagesGetNotFound creates a PcloudV1CloudinstancesCosimagesGetNotFound with default headers values +func NewPcloudV1CloudinstancesCosimagesGetNotFound() *PcloudV1CloudinstancesCosimagesGetNotFound { + return &PcloudV1CloudinstancesCosimagesGetNotFound{} +} + +/* PcloudV1CloudinstancesCosimagesGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudV1CloudinstancesCosimagesGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudV1CloudinstancesCosimagesGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/cos-images][%d] pcloudV1CloudinstancesCosimagesGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudV1CloudinstancesCosimagesGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV1CloudinstancesCosimagesGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV1CloudinstancesCosimagesGetInternalServerError creates a PcloudV1CloudinstancesCosimagesGetInternalServerError with default headers values +func NewPcloudV1CloudinstancesCosimagesGetInternalServerError() *PcloudV1CloudinstancesCosimagesGetInternalServerError { + return &PcloudV1CloudinstancesCosimagesGetInternalServerError{} +} + +/* PcloudV1CloudinstancesCosimagesGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudV1CloudinstancesCosimagesGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudV1CloudinstancesCosimagesGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/cos-images][%d] pcloudV1CloudinstancesCosimagesGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudV1CloudinstancesCosimagesGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV1CloudinstancesCosimagesGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_v1_cloudinstances_cosimages_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_v1_cloudinstances_cosimages_post_parameters.go new file mode 100644 index 00000000000..199d9e7a724 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_v1_cloudinstances_cosimages_post_parameters.go @@ -0,0 +1,173 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_images + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudV1CloudinstancesCosimagesPostParams creates a new PcloudV1CloudinstancesCosimagesPostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudV1CloudinstancesCosimagesPostParams() *PcloudV1CloudinstancesCosimagesPostParams { + return &PcloudV1CloudinstancesCosimagesPostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudV1CloudinstancesCosimagesPostParamsWithTimeout creates a new PcloudV1CloudinstancesCosimagesPostParams object +// with the ability to set a timeout on a request. +func NewPcloudV1CloudinstancesCosimagesPostParamsWithTimeout(timeout time.Duration) *PcloudV1CloudinstancesCosimagesPostParams { + return &PcloudV1CloudinstancesCosimagesPostParams{ + timeout: timeout, + } +} + +// NewPcloudV1CloudinstancesCosimagesPostParamsWithContext creates a new PcloudV1CloudinstancesCosimagesPostParams object +// with the ability to set a context for a request. +func NewPcloudV1CloudinstancesCosimagesPostParamsWithContext(ctx context.Context) *PcloudV1CloudinstancesCosimagesPostParams { + return &PcloudV1CloudinstancesCosimagesPostParams{ + Context: ctx, + } +} + +// NewPcloudV1CloudinstancesCosimagesPostParamsWithHTTPClient creates a new PcloudV1CloudinstancesCosimagesPostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudV1CloudinstancesCosimagesPostParamsWithHTTPClient(client *http.Client) *PcloudV1CloudinstancesCosimagesPostParams { + return &PcloudV1CloudinstancesCosimagesPostParams{ + HTTPClient: client, + } +} + +/* PcloudV1CloudinstancesCosimagesPostParams contains all the parameters to send to the API endpoint + for the pcloud v1 cloudinstances cosimages post operation. + + Typically these are written to a http.Request. +*/ +type PcloudV1CloudinstancesCosimagesPostParams struct { + + /* Body. + + Parameters for the creation of a new cos-image import job + */ + Body *models.CreateCosImageImportJob + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud v1 cloudinstances cosimages post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV1CloudinstancesCosimagesPostParams) WithDefaults() *PcloudV1CloudinstancesCosimagesPostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud v1 cloudinstances cosimages post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV1CloudinstancesCosimagesPostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud v1 cloudinstances cosimages post params +func (o *PcloudV1CloudinstancesCosimagesPostParams) WithTimeout(timeout time.Duration) *PcloudV1CloudinstancesCosimagesPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud v1 cloudinstances cosimages post params +func (o *PcloudV1CloudinstancesCosimagesPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud v1 cloudinstances cosimages post params +func (o *PcloudV1CloudinstancesCosimagesPostParams) WithContext(ctx context.Context) *PcloudV1CloudinstancesCosimagesPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud v1 cloudinstances cosimages post params +func (o *PcloudV1CloudinstancesCosimagesPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud v1 cloudinstances cosimages post params +func (o *PcloudV1CloudinstancesCosimagesPostParams) WithHTTPClient(client *http.Client) *PcloudV1CloudinstancesCosimagesPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud v1 cloudinstances cosimages post params +func (o *PcloudV1CloudinstancesCosimagesPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud v1 cloudinstances cosimages post params +func (o *PcloudV1CloudinstancesCosimagesPostParams) WithBody(body *models.CreateCosImageImportJob) *PcloudV1CloudinstancesCosimagesPostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud v1 cloudinstances cosimages post params +func (o *PcloudV1CloudinstancesCosimagesPostParams) SetBody(body *models.CreateCosImageImportJob) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud v1 cloudinstances cosimages post params +func (o *PcloudV1CloudinstancesCosimagesPostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudV1CloudinstancesCosimagesPostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud v1 cloudinstances cosimages post params +func (o *PcloudV1CloudinstancesCosimagesPostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudV1CloudinstancesCosimagesPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_v1_cloudinstances_cosimages_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_v1_cloudinstances_cosimages_post_responses.go new file mode 100644 index 00000000000..ac1a8d0adac --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_v1_cloudinstances_cosimages_post_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_images + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudV1CloudinstancesCosimagesPostReader is a Reader for the PcloudV1CloudinstancesCosimagesPost structure. +type PcloudV1CloudinstancesCosimagesPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudV1CloudinstancesCosimagesPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 202: + result := NewPcloudV1CloudinstancesCosimagesPostAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudV1CloudinstancesCosimagesPostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudV1CloudinstancesCosimagesPostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewPcloudV1CloudinstancesCosimagesPostForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewPcloudV1CloudinstancesCosimagesPostConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudV1CloudinstancesCosimagesPostUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudV1CloudinstancesCosimagesPostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudV1CloudinstancesCosimagesPostAccepted creates a PcloudV1CloudinstancesCosimagesPostAccepted with default headers values +func NewPcloudV1CloudinstancesCosimagesPostAccepted() *PcloudV1CloudinstancesCosimagesPostAccepted { + return &PcloudV1CloudinstancesCosimagesPostAccepted{} +} + +/* PcloudV1CloudinstancesCosimagesPostAccepted describes a response with status code 202, with default header values. + +Accepted, cos-image import successfully added to the jobs queue +*/ +type PcloudV1CloudinstancesCosimagesPostAccepted struct { + Payload *models.JobReference +} + +func (o *PcloudV1CloudinstancesCosimagesPostAccepted) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/cos-images][%d] pcloudV1CloudinstancesCosimagesPostAccepted %+v", 202, o.Payload) +} +func (o *PcloudV1CloudinstancesCosimagesPostAccepted) GetPayload() *models.JobReference { + return o.Payload +} + +func (o *PcloudV1CloudinstancesCosimagesPostAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.JobReference) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV1CloudinstancesCosimagesPostBadRequest creates a PcloudV1CloudinstancesCosimagesPostBadRequest with default headers values +func NewPcloudV1CloudinstancesCosimagesPostBadRequest() *PcloudV1CloudinstancesCosimagesPostBadRequest { + return &PcloudV1CloudinstancesCosimagesPostBadRequest{} +} + +/* PcloudV1CloudinstancesCosimagesPostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudV1CloudinstancesCosimagesPostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudV1CloudinstancesCosimagesPostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/cos-images][%d] pcloudV1CloudinstancesCosimagesPostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudV1CloudinstancesCosimagesPostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV1CloudinstancesCosimagesPostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV1CloudinstancesCosimagesPostUnauthorized creates a PcloudV1CloudinstancesCosimagesPostUnauthorized with default headers values +func NewPcloudV1CloudinstancesCosimagesPostUnauthorized() *PcloudV1CloudinstancesCosimagesPostUnauthorized { + return &PcloudV1CloudinstancesCosimagesPostUnauthorized{} +} + +/* PcloudV1CloudinstancesCosimagesPostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudV1CloudinstancesCosimagesPostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudV1CloudinstancesCosimagesPostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/cos-images][%d] pcloudV1CloudinstancesCosimagesPostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudV1CloudinstancesCosimagesPostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV1CloudinstancesCosimagesPostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV1CloudinstancesCosimagesPostForbidden creates a PcloudV1CloudinstancesCosimagesPostForbidden with default headers values +func NewPcloudV1CloudinstancesCosimagesPostForbidden() *PcloudV1CloudinstancesCosimagesPostForbidden { + return &PcloudV1CloudinstancesCosimagesPostForbidden{} +} + +/* PcloudV1CloudinstancesCosimagesPostForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type PcloudV1CloudinstancesCosimagesPostForbidden struct { + Payload *models.Error +} + +func (o *PcloudV1CloudinstancesCosimagesPostForbidden) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/cos-images][%d] pcloudV1CloudinstancesCosimagesPostForbidden %+v", 403, o.Payload) +} +func (o *PcloudV1CloudinstancesCosimagesPostForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV1CloudinstancesCosimagesPostForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV1CloudinstancesCosimagesPostConflict creates a PcloudV1CloudinstancesCosimagesPostConflict with default headers values +func NewPcloudV1CloudinstancesCosimagesPostConflict() *PcloudV1CloudinstancesCosimagesPostConflict { + return &PcloudV1CloudinstancesCosimagesPostConflict{} +} + +/* PcloudV1CloudinstancesCosimagesPostConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type PcloudV1CloudinstancesCosimagesPostConflict struct { + Payload *models.Error +} + +func (o *PcloudV1CloudinstancesCosimagesPostConflict) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/cos-images][%d] pcloudV1CloudinstancesCosimagesPostConflict %+v", 409, o.Payload) +} +func (o *PcloudV1CloudinstancesCosimagesPostConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV1CloudinstancesCosimagesPostConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV1CloudinstancesCosimagesPostUnprocessableEntity creates a PcloudV1CloudinstancesCosimagesPostUnprocessableEntity with default headers values +func NewPcloudV1CloudinstancesCosimagesPostUnprocessableEntity() *PcloudV1CloudinstancesCosimagesPostUnprocessableEntity { + return &PcloudV1CloudinstancesCosimagesPostUnprocessableEntity{} +} + +/* PcloudV1CloudinstancesCosimagesPostUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudV1CloudinstancesCosimagesPostUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudV1CloudinstancesCosimagesPostUnprocessableEntity) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/cos-images][%d] pcloudV1CloudinstancesCosimagesPostUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudV1CloudinstancesCosimagesPostUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV1CloudinstancesCosimagesPostUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV1CloudinstancesCosimagesPostInternalServerError creates a PcloudV1CloudinstancesCosimagesPostInternalServerError with default headers values +func NewPcloudV1CloudinstancesCosimagesPostInternalServerError() *PcloudV1CloudinstancesCosimagesPostInternalServerError { + return &PcloudV1CloudinstancesCosimagesPostInternalServerError{} +} + +/* PcloudV1CloudinstancesCosimagesPostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudV1CloudinstancesCosimagesPostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudV1CloudinstancesCosimagesPostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/cos-images][%d] pcloudV1CloudinstancesCosimagesPostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudV1CloudinstancesCosimagesPostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV1CloudinstancesCosimagesPostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_v2_images_export_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_v2_images_export_get_parameters.go new file mode 100644 index 00000000000..6a7f12b258f --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_v2_images_export_get_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_images + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudV2ImagesExportGetParams creates a new PcloudV2ImagesExportGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudV2ImagesExportGetParams() *PcloudV2ImagesExportGetParams { + return &PcloudV2ImagesExportGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudV2ImagesExportGetParamsWithTimeout creates a new PcloudV2ImagesExportGetParams object +// with the ability to set a timeout on a request. +func NewPcloudV2ImagesExportGetParamsWithTimeout(timeout time.Duration) *PcloudV2ImagesExportGetParams { + return &PcloudV2ImagesExportGetParams{ + timeout: timeout, + } +} + +// NewPcloudV2ImagesExportGetParamsWithContext creates a new PcloudV2ImagesExportGetParams object +// with the ability to set a context for a request. +func NewPcloudV2ImagesExportGetParamsWithContext(ctx context.Context) *PcloudV2ImagesExportGetParams { + return &PcloudV2ImagesExportGetParams{ + Context: ctx, + } +} + +// NewPcloudV2ImagesExportGetParamsWithHTTPClient creates a new PcloudV2ImagesExportGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudV2ImagesExportGetParamsWithHTTPClient(client *http.Client) *PcloudV2ImagesExportGetParams { + return &PcloudV2ImagesExportGetParams{ + HTTPClient: client, + } +} + +/* PcloudV2ImagesExportGetParams contains all the parameters to send to the API endpoint + for the pcloud v2 images export get operation. + + Typically these are written to a http.Request. +*/ +type PcloudV2ImagesExportGetParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* ImageID. + + Image ID of a image + */ + ImageID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud v2 images export get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV2ImagesExportGetParams) WithDefaults() *PcloudV2ImagesExportGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud v2 images export get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV2ImagesExportGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud v2 images export get params +func (o *PcloudV2ImagesExportGetParams) WithTimeout(timeout time.Duration) *PcloudV2ImagesExportGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud v2 images export get params +func (o *PcloudV2ImagesExportGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud v2 images export get params +func (o *PcloudV2ImagesExportGetParams) WithContext(ctx context.Context) *PcloudV2ImagesExportGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud v2 images export get params +func (o *PcloudV2ImagesExportGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud v2 images export get params +func (o *PcloudV2ImagesExportGetParams) WithHTTPClient(client *http.Client) *PcloudV2ImagesExportGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud v2 images export get params +func (o *PcloudV2ImagesExportGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud v2 images export get params +func (o *PcloudV2ImagesExportGetParams) WithCloudInstanceID(cloudInstanceID string) *PcloudV2ImagesExportGetParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud v2 images export get params +func (o *PcloudV2ImagesExportGetParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithImageID adds the imageID to the pcloud v2 images export get params +func (o *PcloudV2ImagesExportGetParams) WithImageID(imageID string) *PcloudV2ImagesExportGetParams { + o.SetImageID(imageID) + return o +} + +// SetImageID adds the imageId to the pcloud v2 images export get params +func (o *PcloudV2ImagesExportGetParams) SetImageID(imageID string) { + o.ImageID = imageID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudV2ImagesExportGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param image_id + if err := r.SetPathParam("image_id", o.ImageID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_v2_images_export_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_v2_images_export_get_responses.go new file mode 100644 index 00000000000..a5c695a14bc --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_v2_images_export_get_responses.go @@ -0,0 +1,181 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_images + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudV2ImagesExportGetReader is a Reader for the PcloudV2ImagesExportGet structure. +type PcloudV2ImagesExportGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudV2ImagesExportGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudV2ImagesExportGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewPcloudV2ImagesExportGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudV2ImagesExportGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudV2ImagesExportGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudV2ImagesExportGetOK creates a PcloudV2ImagesExportGetOK with default headers values +func NewPcloudV2ImagesExportGetOK() *PcloudV2ImagesExportGetOK { + return &PcloudV2ImagesExportGetOK{} +} + +/* PcloudV2ImagesExportGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudV2ImagesExportGetOK struct { + Payload *models.Job +} + +func (o *PcloudV2ImagesExportGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v2/cloud-instances/{cloud_instance_id}/images/{image_id}/export][%d] pcloudV2ImagesExportGetOK %+v", 200, o.Payload) +} +func (o *PcloudV2ImagesExportGetOK) GetPayload() *models.Job { + return o.Payload +} + +func (o *PcloudV2ImagesExportGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Job) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2ImagesExportGetUnauthorized creates a PcloudV2ImagesExportGetUnauthorized with default headers values +func NewPcloudV2ImagesExportGetUnauthorized() *PcloudV2ImagesExportGetUnauthorized { + return &PcloudV2ImagesExportGetUnauthorized{} +} + +/* PcloudV2ImagesExportGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudV2ImagesExportGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudV2ImagesExportGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v2/cloud-instances/{cloud_instance_id}/images/{image_id}/export][%d] pcloudV2ImagesExportGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudV2ImagesExportGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2ImagesExportGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2ImagesExportGetNotFound creates a PcloudV2ImagesExportGetNotFound with default headers values +func NewPcloudV2ImagesExportGetNotFound() *PcloudV2ImagesExportGetNotFound { + return &PcloudV2ImagesExportGetNotFound{} +} + +/* PcloudV2ImagesExportGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudV2ImagesExportGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudV2ImagesExportGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v2/cloud-instances/{cloud_instance_id}/images/{image_id}/export][%d] pcloudV2ImagesExportGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudV2ImagesExportGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2ImagesExportGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2ImagesExportGetInternalServerError creates a PcloudV2ImagesExportGetInternalServerError with default headers values +func NewPcloudV2ImagesExportGetInternalServerError() *PcloudV2ImagesExportGetInternalServerError { + return &PcloudV2ImagesExportGetInternalServerError{} +} + +/* PcloudV2ImagesExportGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudV2ImagesExportGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudV2ImagesExportGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v2/cloud-instances/{cloud_instance_id}/images/{image_id}/export][%d] pcloudV2ImagesExportGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudV2ImagesExportGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2ImagesExportGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_v2_images_export_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_v2_images_export_post_parameters.go new file mode 100644 index 00000000000..da0c0be1502 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_v2_images_export_post_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_images + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudV2ImagesExportPostParams creates a new PcloudV2ImagesExportPostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudV2ImagesExportPostParams() *PcloudV2ImagesExportPostParams { + return &PcloudV2ImagesExportPostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudV2ImagesExportPostParamsWithTimeout creates a new PcloudV2ImagesExportPostParams object +// with the ability to set a timeout on a request. +func NewPcloudV2ImagesExportPostParamsWithTimeout(timeout time.Duration) *PcloudV2ImagesExportPostParams { + return &PcloudV2ImagesExportPostParams{ + timeout: timeout, + } +} + +// NewPcloudV2ImagesExportPostParamsWithContext creates a new PcloudV2ImagesExportPostParams object +// with the ability to set a context for a request. +func NewPcloudV2ImagesExportPostParamsWithContext(ctx context.Context) *PcloudV2ImagesExportPostParams { + return &PcloudV2ImagesExportPostParams{ + Context: ctx, + } +} + +// NewPcloudV2ImagesExportPostParamsWithHTTPClient creates a new PcloudV2ImagesExportPostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudV2ImagesExportPostParamsWithHTTPClient(client *http.Client) *PcloudV2ImagesExportPostParams { + return &PcloudV2ImagesExportPostParams{ + HTTPClient: client, + } +} + +/* PcloudV2ImagesExportPostParams contains all the parameters to send to the API endpoint + for the pcloud v2 images export post operation. + + Typically these are written to a http.Request. +*/ +type PcloudV2ImagesExportPostParams struct { + + /* Body. + + Parameters for the export + */ + Body *models.ExportImage + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* ImageID. + + Image ID of a image + */ + ImageID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud v2 images export post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV2ImagesExportPostParams) WithDefaults() *PcloudV2ImagesExportPostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud v2 images export post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV2ImagesExportPostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud v2 images export post params +func (o *PcloudV2ImagesExportPostParams) WithTimeout(timeout time.Duration) *PcloudV2ImagesExportPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud v2 images export post params +func (o *PcloudV2ImagesExportPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud v2 images export post params +func (o *PcloudV2ImagesExportPostParams) WithContext(ctx context.Context) *PcloudV2ImagesExportPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud v2 images export post params +func (o *PcloudV2ImagesExportPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud v2 images export post params +func (o *PcloudV2ImagesExportPostParams) WithHTTPClient(client *http.Client) *PcloudV2ImagesExportPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud v2 images export post params +func (o *PcloudV2ImagesExportPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud v2 images export post params +func (o *PcloudV2ImagesExportPostParams) WithBody(body *models.ExportImage) *PcloudV2ImagesExportPostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud v2 images export post params +func (o *PcloudV2ImagesExportPostParams) SetBody(body *models.ExportImage) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud v2 images export post params +func (o *PcloudV2ImagesExportPostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudV2ImagesExportPostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud v2 images export post params +func (o *PcloudV2ImagesExportPostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithImageID adds the imageID to the pcloud v2 images export post params +func (o *PcloudV2ImagesExportPostParams) WithImageID(imageID string) *PcloudV2ImagesExportPostParams { + o.SetImageID(imageID) + return o +} + +// SetImageID adds the imageId to the pcloud v2 images export post params +func (o *PcloudV2ImagesExportPostParams) SetImageID(imageID string) { + o.ImageID = imageID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudV2ImagesExportPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param image_id + if err := r.SetPathParam("image_id", o.ImageID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_v2_images_export_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_v2_images_export_post_responses.go new file mode 100644 index 00000000000..43957ae2cc2 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images/pcloud_v2_images_export_post_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_images + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudV2ImagesExportPostReader is a Reader for the PcloudV2ImagesExportPost structure. +type PcloudV2ImagesExportPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudV2ImagesExportPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 202: + result := NewPcloudV2ImagesExportPostAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudV2ImagesExportPostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudV2ImagesExportPostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudV2ImagesExportPostNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewPcloudV2ImagesExportPostConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudV2ImagesExportPostUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudV2ImagesExportPostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudV2ImagesExportPostAccepted creates a PcloudV2ImagesExportPostAccepted with default headers values +func NewPcloudV2ImagesExportPostAccepted() *PcloudV2ImagesExportPostAccepted { + return &PcloudV2ImagesExportPostAccepted{} +} + +/* PcloudV2ImagesExportPostAccepted describes a response with status code 202, with default header values. + +Accepted, image export successfully added to the jobs queue +*/ +type PcloudV2ImagesExportPostAccepted struct { + Payload *models.JobReference +} + +func (o *PcloudV2ImagesExportPostAccepted) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/images/{image_id}/export][%d] pcloudV2ImagesExportPostAccepted %+v", 202, o.Payload) +} +func (o *PcloudV2ImagesExportPostAccepted) GetPayload() *models.JobReference { + return o.Payload +} + +func (o *PcloudV2ImagesExportPostAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.JobReference) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2ImagesExportPostBadRequest creates a PcloudV2ImagesExportPostBadRequest with default headers values +func NewPcloudV2ImagesExportPostBadRequest() *PcloudV2ImagesExportPostBadRequest { + return &PcloudV2ImagesExportPostBadRequest{} +} + +/* PcloudV2ImagesExportPostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudV2ImagesExportPostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudV2ImagesExportPostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/images/{image_id}/export][%d] pcloudV2ImagesExportPostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudV2ImagesExportPostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2ImagesExportPostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2ImagesExportPostUnauthorized creates a PcloudV2ImagesExportPostUnauthorized with default headers values +func NewPcloudV2ImagesExportPostUnauthorized() *PcloudV2ImagesExportPostUnauthorized { + return &PcloudV2ImagesExportPostUnauthorized{} +} + +/* PcloudV2ImagesExportPostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudV2ImagesExportPostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudV2ImagesExportPostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/images/{image_id}/export][%d] pcloudV2ImagesExportPostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudV2ImagesExportPostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2ImagesExportPostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2ImagesExportPostNotFound creates a PcloudV2ImagesExportPostNotFound with default headers values +func NewPcloudV2ImagesExportPostNotFound() *PcloudV2ImagesExportPostNotFound { + return &PcloudV2ImagesExportPostNotFound{} +} + +/* PcloudV2ImagesExportPostNotFound describes a response with status code 404, with default header values. + +image id not found +*/ +type PcloudV2ImagesExportPostNotFound struct { + Payload *models.Error +} + +func (o *PcloudV2ImagesExportPostNotFound) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/images/{image_id}/export][%d] pcloudV2ImagesExportPostNotFound %+v", 404, o.Payload) +} +func (o *PcloudV2ImagesExportPostNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2ImagesExportPostNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2ImagesExportPostConflict creates a PcloudV2ImagesExportPostConflict with default headers values +func NewPcloudV2ImagesExportPostConflict() *PcloudV2ImagesExportPostConflict { + return &PcloudV2ImagesExportPostConflict{} +} + +/* PcloudV2ImagesExportPostConflict describes a response with status code 409, with default header values. + +Conflict, a conflict has prevented adding image export job +*/ +type PcloudV2ImagesExportPostConflict struct { + Payload *models.Error +} + +func (o *PcloudV2ImagesExportPostConflict) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/images/{image_id}/export][%d] pcloudV2ImagesExportPostConflict %+v", 409, o.Payload) +} +func (o *PcloudV2ImagesExportPostConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2ImagesExportPostConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2ImagesExportPostUnprocessableEntity creates a PcloudV2ImagesExportPostUnprocessableEntity with default headers values +func NewPcloudV2ImagesExportPostUnprocessableEntity() *PcloudV2ImagesExportPostUnprocessableEntity { + return &PcloudV2ImagesExportPostUnprocessableEntity{} +} + +/* PcloudV2ImagesExportPostUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudV2ImagesExportPostUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudV2ImagesExportPostUnprocessableEntity) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/images/{image_id}/export][%d] pcloudV2ImagesExportPostUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudV2ImagesExportPostUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2ImagesExportPostUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2ImagesExportPostInternalServerError creates a PcloudV2ImagesExportPostInternalServerError with default headers values +func NewPcloudV2ImagesExportPostInternalServerError() *PcloudV2ImagesExportPostInternalServerError { + return &PcloudV2ImagesExportPostInternalServerError{} +} + +/* PcloudV2ImagesExportPostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudV2ImagesExportPostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudV2ImagesExportPostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/images/{image_id}/export][%d] pcloudV2ImagesExportPostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudV2ImagesExportPostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2ImagesExportPostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_instances/p_cloud_instances_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_instances/p_cloud_instances_client.go new file mode 100644 index 00000000000..b8c3c3c8b1b --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_instances/p_cloud_instances_client.go @@ -0,0 +1,162 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new p cloud instances API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for p cloud instances API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + PcloudCloudinstancesDelete(params *PcloudCloudinstancesDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesDeleteOK, error) + + PcloudCloudinstancesGet(params *PcloudCloudinstancesGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesGetOK, error) + + PcloudCloudinstancesPut(params *PcloudCloudinstancesPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesPutOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + PcloudCloudinstancesDelete deletes a power cloud instance +*/ +func (a *Client) PcloudCloudinstancesDelete(params *PcloudCloudinstancesDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesDeleteOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudinstancesDeleteParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.cloudinstances.delete", + Method: "DELETE", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudinstancesDeleteReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudCloudinstancesDeleteOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.cloudinstances.delete: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudCloudinstancesGet gets a cloud instance s current state information +*/ +func (a *Client) PcloudCloudinstancesGet(params *PcloudCloudinstancesGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudinstancesGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.cloudinstances.get", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudinstancesGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudCloudinstancesGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.cloudinstances.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudCloudinstancesPut updates upgrade a cloud instance +*/ +func (a *Client) PcloudCloudinstancesPut(params *PcloudCloudinstancesPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesPutOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudinstancesPutParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.cloudinstances.put", + Method: "PUT", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudinstancesPutReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudCloudinstancesPutOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.cloudinstances.put: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_instances/pcloud_cloudinstances_delete_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_instances/pcloud_cloudinstances_delete_parameters.go new file mode 100644 index 00000000000..e375cf1652f --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_instances/pcloud_cloudinstances_delete_parameters.go @@ -0,0 +1,149 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudCloudinstancesDeleteParams creates a new PcloudCloudinstancesDeleteParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudCloudinstancesDeleteParams() *PcloudCloudinstancesDeleteParams { + return &PcloudCloudinstancesDeleteParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudinstancesDeleteParamsWithTimeout creates a new PcloudCloudinstancesDeleteParams object +// with the ability to set a timeout on a request. +func NewPcloudCloudinstancesDeleteParamsWithTimeout(timeout time.Duration) *PcloudCloudinstancesDeleteParams { + return &PcloudCloudinstancesDeleteParams{ + timeout: timeout, + } +} + +// NewPcloudCloudinstancesDeleteParamsWithContext creates a new PcloudCloudinstancesDeleteParams object +// with the ability to set a context for a request. +func NewPcloudCloudinstancesDeleteParamsWithContext(ctx context.Context) *PcloudCloudinstancesDeleteParams { + return &PcloudCloudinstancesDeleteParams{ + Context: ctx, + } +} + +// NewPcloudCloudinstancesDeleteParamsWithHTTPClient creates a new PcloudCloudinstancesDeleteParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudCloudinstancesDeleteParamsWithHTTPClient(client *http.Client) *PcloudCloudinstancesDeleteParams { + return &PcloudCloudinstancesDeleteParams{ + HTTPClient: client, + } +} + +/* PcloudCloudinstancesDeleteParams contains all the parameters to send to the API endpoint + for the pcloud cloudinstances delete operation. + + Typically these are written to a http.Request. +*/ +type PcloudCloudinstancesDeleteParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud cloudinstances delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesDeleteParams) WithDefaults() *PcloudCloudinstancesDeleteParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud cloudinstances delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesDeleteParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud cloudinstances delete params +func (o *PcloudCloudinstancesDeleteParams) WithTimeout(timeout time.Duration) *PcloudCloudinstancesDeleteParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudinstances delete params +func (o *PcloudCloudinstancesDeleteParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudinstances delete params +func (o *PcloudCloudinstancesDeleteParams) WithContext(ctx context.Context) *PcloudCloudinstancesDeleteParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudinstances delete params +func (o *PcloudCloudinstancesDeleteParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudinstances delete params +func (o *PcloudCloudinstancesDeleteParams) WithHTTPClient(client *http.Client) *PcloudCloudinstancesDeleteParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudinstances delete params +func (o *PcloudCloudinstancesDeleteParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudinstances delete params +func (o *PcloudCloudinstancesDeleteParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudinstancesDeleteParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudinstances delete params +func (o *PcloudCloudinstancesDeleteParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudinstancesDeleteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_instances/pcloud_cloudinstances_delete_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_instances/pcloud_cloudinstances_delete_responses.go new file mode 100644 index 00000000000..6bd8adbbadf --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_instances/pcloud_cloudinstances_delete_responses.go @@ -0,0 +1,217 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudinstancesDeleteReader is a Reader for the PcloudCloudinstancesDelete structure. +type PcloudCloudinstancesDeleteReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudinstancesDeleteReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudCloudinstancesDeleteOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudCloudinstancesDeleteBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudCloudinstancesDeleteUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 410: + result := NewPcloudCloudinstancesDeleteGone() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudCloudinstancesDeleteInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudCloudinstancesDeleteOK creates a PcloudCloudinstancesDeleteOK with default headers values +func NewPcloudCloudinstancesDeleteOK() *PcloudCloudinstancesDeleteOK { + return &PcloudCloudinstancesDeleteOK{} +} + +/* PcloudCloudinstancesDeleteOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudCloudinstancesDeleteOK struct { + Payload models.Object +} + +func (o *PcloudCloudinstancesDeleteOK) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}][%d] pcloudCloudinstancesDeleteOK %+v", 200, o.Payload) +} +func (o *PcloudCloudinstancesDeleteOK) GetPayload() models.Object { + return o.Payload +} + +func (o *PcloudCloudinstancesDeleteOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesDeleteBadRequest creates a PcloudCloudinstancesDeleteBadRequest with default headers values +func NewPcloudCloudinstancesDeleteBadRequest() *PcloudCloudinstancesDeleteBadRequest { + return &PcloudCloudinstancesDeleteBadRequest{} +} + +/* PcloudCloudinstancesDeleteBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudCloudinstancesDeleteBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesDeleteBadRequest) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}][%d] pcloudCloudinstancesDeleteBadRequest %+v", 400, o.Payload) +} +func (o *PcloudCloudinstancesDeleteBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesDeleteBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesDeleteUnauthorized creates a PcloudCloudinstancesDeleteUnauthorized with default headers values +func NewPcloudCloudinstancesDeleteUnauthorized() *PcloudCloudinstancesDeleteUnauthorized { + return &PcloudCloudinstancesDeleteUnauthorized{} +} + +/* PcloudCloudinstancesDeleteUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudCloudinstancesDeleteUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesDeleteUnauthorized) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}][%d] pcloudCloudinstancesDeleteUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudCloudinstancesDeleteUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesDeleteUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesDeleteGone creates a PcloudCloudinstancesDeleteGone with default headers values +func NewPcloudCloudinstancesDeleteGone() *PcloudCloudinstancesDeleteGone { + return &PcloudCloudinstancesDeleteGone{} +} + +/* PcloudCloudinstancesDeleteGone describes a response with status code 410, with default header values. + +Gone +*/ +type PcloudCloudinstancesDeleteGone struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesDeleteGone) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}][%d] pcloudCloudinstancesDeleteGone %+v", 410, o.Payload) +} +func (o *PcloudCloudinstancesDeleteGone) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesDeleteGone) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesDeleteInternalServerError creates a PcloudCloudinstancesDeleteInternalServerError with default headers values +func NewPcloudCloudinstancesDeleteInternalServerError() *PcloudCloudinstancesDeleteInternalServerError { + return &PcloudCloudinstancesDeleteInternalServerError{} +} + +/* PcloudCloudinstancesDeleteInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudCloudinstancesDeleteInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesDeleteInternalServerError) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}][%d] pcloudCloudinstancesDeleteInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudCloudinstancesDeleteInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesDeleteInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_instances/pcloud_cloudinstances_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_instances/pcloud_cloudinstances_get_parameters.go new file mode 100644 index 00000000000..4eda9ee4e00 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_instances/pcloud_cloudinstances_get_parameters.go @@ -0,0 +1,149 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudCloudinstancesGetParams creates a new PcloudCloudinstancesGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudCloudinstancesGetParams() *PcloudCloudinstancesGetParams { + return &PcloudCloudinstancesGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudinstancesGetParamsWithTimeout creates a new PcloudCloudinstancesGetParams object +// with the ability to set a timeout on a request. +func NewPcloudCloudinstancesGetParamsWithTimeout(timeout time.Duration) *PcloudCloudinstancesGetParams { + return &PcloudCloudinstancesGetParams{ + timeout: timeout, + } +} + +// NewPcloudCloudinstancesGetParamsWithContext creates a new PcloudCloudinstancesGetParams object +// with the ability to set a context for a request. +func NewPcloudCloudinstancesGetParamsWithContext(ctx context.Context) *PcloudCloudinstancesGetParams { + return &PcloudCloudinstancesGetParams{ + Context: ctx, + } +} + +// NewPcloudCloudinstancesGetParamsWithHTTPClient creates a new PcloudCloudinstancesGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudCloudinstancesGetParamsWithHTTPClient(client *http.Client) *PcloudCloudinstancesGetParams { + return &PcloudCloudinstancesGetParams{ + HTTPClient: client, + } +} + +/* PcloudCloudinstancesGetParams contains all the parameters to send to the API endpoint + for the pcloud cloudinstances get operation. + + Typically these are written to a http.Request. +*/ +type PcloudCloudinstancesGetParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud cloudinstances get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesGetParams) WithDefaults() *PcloudCloudinstancesGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud cloudinstances get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud cloudinstances get params +func (o *PcloudCloudinstancesGetParams) WithTimeout(timeout time.Duration) *PcloudCloudinstancesGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudinstances get params +func (o *PcloudCloudinstancesGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudinstances get params +func (o *PcloudCloudinstancesGetParams) WithContext(ctx context.Context) *PcloudCloudinstancesGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudinstances get params +func (o *PcloudCloudinstancesGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudinstances get params +func (o *PcloudCloudinstancesGetParams) WithHTTPClient(client *http.Client) *PcloudCloudinstancesGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudinstances get params +func (o *PcloudCloudinstancesGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudinstances get params +func (o *PcloudCloudinstancesGetParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudinstancesGetParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudinstances get params +func (o *PcloudCloudinstancesGetParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudinstancesGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_instances/pcloud_cloudinstances_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_instances/pcloud_cloudinstances_get_responses.go new file mode 100644 index 00000000000..c7056df69fe --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_instances/pcloud_cloudinstances_get_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudinstancesGetReader is a Reader for the PcloudCloudinstancesGet structure. +type PcloudCloudinstancesGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudinstancesGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudCloudinstancesGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudCloudinstancesGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudCloudinstancesGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudCloudinstancesGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudCloudinstancesGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudCloudinstancesGetOK creates a PcloudCloudinstancesGetOK with default headers values +func NewPcloudCloudinstancesGetOK() *PcloudCloudinstancesGetOK { + return &PcloudCloudinstancesGetOK{} +} + +/* PcloudCloudinstancesGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudCloudinstancesGetOK struct { + Payload *models.CloudInstance +} + +func (o *PcloudCloudinstancesGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}][%d] pcloudCloudinstancesGetOK %+v", 200, o.Payload) +} +func (o *PcloudCloudinstancesGetOK) GetPayload() *models.CloudInstance { + return o.Payload +} + +func (o *PcloudCloudinstancesGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.CloudInstance) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesGetBadRequest creates a PcloudCloudinstancesGetBadRequest with default headers values +func NewPcloudCloudinstancesGetBadRequest() *PcloudCloudinstancesGetBadRequest { + return &PcloudCloudinstancesGetBadRequest{} +} + +/* PcloudCloudinstancesGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudCloudinstancesGetBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesGetBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}][%d] pcloudCloudinstancesGetBadRequest %+v", 400, o.Payload) +} +func (o *PcloudCloudinstancesGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesGetUnauthorized creates a PcloudCloudinstancesGetUnauthorized with default headers values +func NewPcloudCloudinstancesGetUnauthorized() *PcloudCloudinstancesGetUnauthorized { + return &PcloudCloudinstancesGetUnauthorized{} +} + +/* PcloudCloudinstancesGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudCloudinstancesGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}][%d] pcloudCloudinstancesGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudCloudinstancesGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesGetNotFound creates a PcloudCloudinstancesGetNotFound with default headers values +func NewPcloudCloudinstancesGetNotFound() *PcloudCloudinstancesGetNotFound { + return &PcloudCloudinstancesGetNotFound{} +} + +/* PcloudCloudinstancesGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudCloudinstancesGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}][%d] pcloudCloudinstancesGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudCloudinstancesGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesGetInternalServerError creates a PcloudCloudinstancesGetInternalServerError with default headers values +func NewPcloudCloudinstancesGetInternalServerError() *PcloudCloudinstancesGetInternalServerError { + return &PcloudCloudinstancesGetInternalServerError{} +} + +/* PcloudCloudinstancesGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudCloudinstancesGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}][%d] pcloudCloudinstancesGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudCloudinstancesGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_instances/pcloud_cloudinstances_put_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_instances/pcloud_cloudinstances_put_parameters.go new file mode 100644 index 00000000000..4e47d1af78c --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_instances/pcloud_cloudinstances_put_parameters.go @@ -0,0 +1,173 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudCloudinstancesPutParams creates a new PcloudCloudinstancesPutParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudCloudinstancesPutParams() *PcloudCloudinstancesPutParams { + return &PcloudCloudinstancesPutParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudinstancesPutParamsWithTimeout creates a new PcloudCloudinstancesPutParams object +// with the ability to set a timeout on a request. +func NewPcloudCloudinstancesPutParamsWithTimeout(timeout time.Duration) *PcloudCloudinstancesPutParams { + return &PcloudCloudinstancesPutParams{ + timeout: timeout, + } +} + +// NewPcloudCloudinstancesPutParamsWithContext creates a new PcloudCloudinstancesPutParams object +// with the ability to set a context for a request. +func NewPcloudCloudinstancesPutParamsWithContext(ctx context.Context) *PcloudCloudinstancesPutParams { + return &PcloudCloudinstancesPutParams{ + Context: ctx, + } +} + +// NewPcloudCloudinstancesPutParamsWithHTTPClient creates a new PcloudCloudinstancesPutParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudCloudinstancesPutParamsWithHTTPClient(client *http.Client) *PcloudCloudinstancesPutParams { + return &PcloudCloudinstancesPutParams{ + HTTPClient: client, + } +} + +/* PcloudCloudinstancesPutParams contains all the parameters to send to the API endpoint + for the pcloud cloudinstances put operation. + + Typically these are written to a http.Request. +*/ +type PcloudCloudinstancesPutParams struct { + + /* Body. + + Parameters for updating a Power Cloud Instance + */ + Body *models.CloudInstanceUpdate + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud cloudinstances put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesPutParams) WithDefaults() *PcloudCloudinstancesPutParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud cloudinstances put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesPutParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud cloudinstances put params +func (o *PcloudCloudinstancesPutParams) WithTimeout(timeout time.Duration) *PcloudCloudinstancesPutParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudinstances put params +func (o *PcloudCloudinstancesPutParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudinstances put params +func (o *PcloudCloudinstancesPutParams) WithContext(ctx context.Context) *PcloudCloudinstancesPutParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudinstances put params +func (o *PcloudCloudinstancesPutParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudinstances put params +func (o *PcloudCloudinstancesPutParams) WithHTTPClient(client *http.Client) *PcloudCloudinstancesPutParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudinstances put params +func (o *PcloudCloudinstancesPutParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud cloudinstances put params +func (o *PcloudCloudinstancesPutParams) WithBody(body *models.CloudInstanceUpdate) *PcloudCloudinstancesPutParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud cloudinstances put params +func (o *PcloudCloudinstancesPutParams) SetBody(body *models.CloudInstanceUpdate) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudinstances put params +func (o *PcloudCloudinstancesPutParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudinstancesPutParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudinstances put params +func (o *PcloudCloudinstancesPutParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudinstancesPutParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_instances/pcloud_cloudinstances_put_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_instances/pcloud_cloudinstances_put_responses.go new file mode 100644 index 00000000000..8d6cf4b567a --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_instances/pcloud_cloudinstances_put_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudinstancesPutReader is a Reader for the PcloudCloudinstancesPut structure. +type PcloudCloudinstancesPutReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudinstancesPutReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudCloudinstancesPutOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudCloudinstancesPutBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudCloudinstancesPutUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudCloudinstancesPutUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudCloudinstancesPutInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudCloudinstancesPutOK creates a PcloudCloudinstancesPutOK with default headers values +func NewPcloudCloudinstancesPutOK() *PcloudCloudinstancesPutOK { + return &PcloudCloudinstancesPutOK{} +} + +/* PcloudCloudinstancesPutOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudCloudinstancesPutOK struct { + Payload *models.CloudInstance +} + +func (o *PcloudCloudinstancesPutOK) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}][%d] pcloudCloudinstancesPutOK %+v", 200, o.Payload) +} +func (o *PcloudCloudinstancesPutOK) GetPayload() *models.CloudInstance { + return o.Payload +} + +func (o *PcloudCloudinstancesPutOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.CloudInstance) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesPutBadRequest creates a PcloudCloudinstancesPutBadRequest with default headers values +func NewPcloudCloudinstancesPutBadRequest() *PcloudCloudinstancesPutBadRequest { + return &PcloudCloudinstancesPutBadRequest{} +} + +/* PcloudCloudinstancesPutBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudCloudinstancesPutBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesPutBadRequest) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}][%d] pcloudCloudinstancesPutBadRequest %+v", 400, o.Payload) +} +func (o *PcloudCloudinstancesPutBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesPutBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesPutUnauthorized creates a PcloudCloudinstancesPutUnauthorized with default headers values +func NewPcloudCloudinstancesPutUnauthorized() *PcloudCloudinstancesPutUnauthorized { + return &PcloudCloudinstancesPutUnauthorized{} +} + +/* PcloudCloudinstancesPutUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudCloudinstancesPutUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesPutUnauthorized) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}][%d] pcloudCloudinstancesPutUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudCloudinstancesPutUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesPutUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesPutUnprocessableEntity creates a PcloudCloudinstancesPutUnprocessableEntity with default headers values +func NewPcloudCloudinstancesPutUnprocessableEntity() *PcloudCloudinstancesPutUnprocessableEntity { + return &PcloudCloudinstancesPutUnprocessableEntity{} +} + +/* PcloudCloudinstancesPutUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudCloudinstancesPutUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesPutUnprocessableEntity) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}][%d] pcloudCloudinstancesPutUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudCloudinstancesPutUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesPutUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesPutInternalServerError creates a PcloudCloudinstancesPutInternalServerError with default headers values +func NewPcloudCloudinstancesPutInternalServerError() *PcloudCloudinstancesPutInternalServerError { + return &PcloudCloudinstancesPutInternalServerError{} +} + +/* PcloudCloudinstancesPutInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudCloudinstancesPutInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesPutInternalServerError) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}][%d] pcloudCloudinstancesPutInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudCloudinstancesPutInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesPutInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_jobs/p_cloud_jobs_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_jobs/p_cloud_jobs_client.go new file mode 100644 index 00000000000..0d4c362afd2 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_jobs/p_cloud_jobs_client.go @@ -0,0 +1,162 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_jobs + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new p cloud jobs API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for p cloud jobs API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + PcloudCloudinstancesJobsDelete(params *PcloudCloudinstancesJobsDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesJobsDeleteOK, error) + + PcloudCloudinstancesJobsGet(params *PcloudCloudinstancesJobsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesJobsGetOK, error) + + PcloudCloudinstancesJobsGetall(params *PcloudCloudinstancesJobsGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesJobsGetallOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + PcloudCloudinstancesJobsDelete deletes a cloud instance job +*/ +func (a *Client) PcloudCloudinstancesJobsDelete(params *PcloudCloudinstancesJobsDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesJobsDeleteOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudinstancesJobsDeleteParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.cloudinstances.jobs.delete", + Method: "DELETE", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/jobs/{job_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudinstancesJobsDeleteReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudCloudinstancesJobsDeleteOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.cloudinstances.jobs.delete: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudCloudinstancesJobsGet lists the detail of a job +*/ +func (a *Client) PcloudCloudinstancesJobsGet(params *PcloudCloudinstancesJobsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesJobsGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudinstancesJobsGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.cloudinstances.jobs.get", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/jobs/{job_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudinstancesJobsGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudCloudinstancesJobsGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.cloudinstances.jobs.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudCloudinstancesJobsGetall lists up to the last 5 jobs initiated by the cloud instance +*/ +func (a *Client) PcloudCloudinstancesJobsGetall(params *PcloudCloudinstancesJobsGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesJobsGetallOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudinstancesJobsGetallParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.cloudinstances.jobs.getall", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/jobs", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudinstancesJobsGetallReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudCloudinstancesJobsGetallOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.cloudinstances.jobs.getall: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_jobs/pcloud_cloudinstances_jobs_delete_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_jobs/pcloud_cloudinstances_jobs_delete_parameters.go new file mode 100644 index 00000000000..9e3b31e1ef7 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_jobs/pcloud_cloudinstances_jobs_delete_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_jobs + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudCloudinstancesJobsDeleteParams creates a new PcloudCloudinstancesJobsDeleteParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudCloudinstancesJobsDeleteParams() *PcloudCloudinstancesJobsDeleteParams { + return &PcloudCloudinstancesJobsDeleteParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudinstancesJobsDeleteParamsWithTimeout creates a new PcloudCloudinstancesJobsDeleteParams object +// with the ability to set a timeout on a request. +func NewPcloudCloudinstancesJobsDeleteParamsWithTimeout(timeout time.Duration) *PcloudCloudinstancesJobsDeleteParams { + return &PcloudCloudinstancesJobsDeleteParams{ + timeout: timeout, + } +} + +// NewPcloudCloudinstancesJobsDeleteParamsWithContext creates a new PcloudCloudinstancesJobsDeleteParams object +// with the ability to set a context for a request. +func NewPcloudCloudinstancesJobsDeleteParamsWithContext(ctx context.Context) *PcloudCloudinstancesJobsDeleteParams { + return &PcloudCloudinstancesJobsDeleteParams{ + Context: ctx, + } +} + +// NewPcloudCloudinstancesJobsDeleteParamsWithHTTPClient creates a new PcloudCloudinstancesJobsDeleteParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudCloudinstancesJobsDeleteParamsWithHTTPClient(client *http.Client) *PcloudCloudinstancesJobsDeleteParams { + return &PcloudCloudinstancesJobsDeleteParams{ + HTTPClient: client, + } +} + +/* PcloudCloudinstancesJobsDeleteParams contains all the parameters to send to the API endpoint + for the pcloud cloudinstances jobs delete operation. + + Typically these are written to a http.Request. +*/ +type PcloudCloudinstancesJobsDeleteParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* JobID. + + PCloud Job ID + */ + JobID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud cloudinstances jobs delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesJobsDeleteParams) WithDefaults() *PcloudCloudinstancesJobsDeleteParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud cloudinstances jobs delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesJobsDeleteParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud cloudinstances jobs delete params +func (o *PcloudCloudinstancesJobsDeleteParams) WithTimeout(timeout time.Duration) *PcloudCloudinstancesJobsDeleteParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudinstances jobs delete params +func (o *PcloudCloudinstancesJobsDeleteParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudinstances jobs delete params +func (o *PcloudCloudinstancesJobsDeleteParams) WithContext(ctx context.Context) *PcloudCloudinstancesJobsDeleteParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudinstances jobs delete params +func (o *PcloudCloudinstancesJobsDeleteParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudinstances jobs delete params +func (o *PcloudCloudinstancesJobsDeleteParams) WithHTTPClient(client *http.Client) *PcloudCloudinstancesJobsDeleteParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudinstances jobs delete params +func (o *PcloudCloudinstancesJobsDeleteParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudinstances jobs delete params +func (o *PcloudCloudinstancesJobsDeleteParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudinstancesJobsDeleteParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudinstances jobs delete params +func (o *PcloudCloudinstancesJobsDeleteParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithJobID adds the jobID to the pcloud cloudinstances jobs delete params +func (o *PcloudCloudinstancesJobsDeleteParams) WithJobID(jobID string) *PcloudCloudinstancesJobsDeleteParams { + o.SetJobID(jobID) + return o +} + +// SetJobID adds the jobId to the pcloud cloudinstances jobs delete params +func (o *PcloudCloudinstancesJobsDeleteParams) SetJobID(jobID string) { + o.JobID = jobID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudinstancesJobsDeleteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param job_id + if err := r.SetPathParam("job_id", o.JobID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_jobs/pcloud_cloudinstances_jobs_delete_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_jobs/pcloud_cloudinstances_jobs_delete_responses.go new file mode 100644 index 00000000000..da6ffd992dd --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_jobs/pcloud_cloudinstances_jobs_delete_responses.go @@ -0,0 +1,255 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_jobs + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudinstancesJobsDeleteReader is a Reader for the PcloudCloudinstancesJobsDelete structure. +type PcloudCloudinstancesJobsDeleteReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudinstancesJobsDeleteReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudCloudinstancesJobsDeleteOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudCloudinstancesJobsDeleteBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudCloudinstancesJobsDeleteUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudCloudinstancesJobsDeleteNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewPcloudCloudinstancesJobsDeleteConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudCloudinstancesJobsDeleteInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudCloudinstancesJobsDeleteOK creates a PcloudCloudinstancesJobsDeleteOK with default headers values +func NewPcloudCloudinstancesJobsDeleteOK() *PcloudCloudinstancesJobsDeleteOK { + return &PcloudCloudinstancesJobsDeleteOK{} +} + +/* PcloudCloudinstancesJobsDeleteOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudCloudinstancesJobsDeleteOK struct { + Payload models.Object +} + +func (o *PcloudCloudinstancesJobsDeleteOK) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/jobs/{job_id}][%d] pcloudCloudinstancesJobsDeleteOK %+v", 200, o.Payload) +} +func (o *PcloudCloudinstancesJobsDeleteOK) GetPayload() models.Object { + return o.Payload +} + +func (o *PcloudCloudinstancesJobsDeleteOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesJobsDeleteBadRequest creates a PcloudCloudinstancesJobsDeleteBadRequest with default headers values +func NewPcloudCloudinstancesJobsDeleteBadRequest() *PcloudCloudinstancesJobsDeleteBadRequest { + return &PcloudCloudinstancesJobsDeleteBadRequest{} +} + +/* PcloudCloudinstancesJobsDeleteBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudCloudinstancesJobsDeleteBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesJobsDeleteBadRequest) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/jobs/{job_id}][%d] pcloudCloudinstancesJobsDeleteBadRequest %+v", 400, o.Payload) +} +func (o *PcloudCloudinstancesJobsDeleteBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesJobsDeleteBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesJobsDeleteUnauthorized creates a PcloudCloudinstancesJobsDeleteUnauthorized with default headers values +func NewPcloudCloudinstancesJobsDeleteUnauthorized() *PcloudCloudinstancesJobsDeleteUnauthorized { + return &PcloudCloudinstancesJobsDeleteUnauthorized{} +} + +/* PcloudCloudinstancesJobsDeleteUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudCloudinstancesJobsDeleteUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesJobsDeleteUnauthorized) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/jobs/{job_id}][%d] pcloudCloudinstancesJobsDeleteUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudCloudinstancesJobsDeleteUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesJobsDeleteUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesJobsDeleteNotFound creates a PcloudCloudinstancesJobsDeleteNotFound with default headers values +func NewPcloudCloudinstancesJobsDeleteNotFound() *PcloudCloudinstancesJobsDeleteNotFound { + return &PcloudCloudinstancesJobsDeleteNotFound{} +} + +/* PcloudCloudinstancesJobsDeleteNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudCloudinstancesJobsDeleteNotFound struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesJobsDeleteNotFound) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/jobs/{job_id}][%d] pcloudCloudinstancesJobsDeleteNotFound %+v", 404, o.Payload) +} +func (o *PcloudCloudinstancesJobsDeleteNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesJobsDeleteNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesJobsDeleteConflict creates a PcloudCloudinstancesJobsDeleteConflict with default headers values +func NewPcloudCloudinstancesJobsDeleteConflict() *PcloudCloudinstancesJobsDeleteConflict { + return &PcloudCloudinstancesJobsDeleteConflict{} +} + +/* PcloudCloudinstancesJobsDeleteConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type PcloudCloudinstancesJobsDeleteConflict struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesJobsDeleteConflict) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/jobs/{job_id}][%d] pcloudCloudinstancesJobsDeleteConflict %+v", 409, o.Payload) +} +func (o *PcloudCloudinstancesJobsDeleteConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesJobsDeleteConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesJobsDeleteInternalServerError creates a PcloudCloudinstancesJobsDeleteInternalServerError with default headers values +func NewPcloudCloudinstancesJobsDeleteInternalServerError() *PcloudCloudinstancesJobsDeleteInternalServerError { + return &PcloudCloudinstancesJobsDeleteInternalServerError{} +} + +/* PcloudCloudinstancesJobsDeleteInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudCloudinstancesJobsDeleteInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesJobsDeleteInternalServerError) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/jobs/{job_id}][%d] pcloudCloudinstancesJobsDeleteInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudCloudinstancesJobsDeleteInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesJobsDeleteInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_jobs/pcloud_cloudinstances_jobs_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_jobs/pcloud_cloudinstances_jobs_get_parameters.go new file mode 100644 index 00000000000..8b584354795 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_jobs/pcloud_cloudinstances_jobs_get_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_jobs + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudCloudinstancesJobsGetParams creates a new PcloudCloudinstancesJobsGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudCloudinstancesJobsGetParams() *PcloudCloudinstancesJobsGetParams { + return &PcloudCloudinstancesJobsGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudinstancesJobsGetParamsWithTimeout creates a new PcloudCloudinstancesJobsGetParams object +// with the ability to set a timeout on a request. +func NewPcloudCloudinstancesJobsGetParamsWithTimeout(timeout time.Duration) *PcloudCloudinstancesJobsGetParams { + return &PcloudCloudinstancesJobsGetParams{ + timeout: timeout, + } +} + +// NewPcloudCloudinstancesJobsGetParamsWithContext creates a new PcloudCloudinstancesJobsGetParams object +// with the ability to set a context for a request. +func NewPcloudCloudinstancesJobsGetParamsWithContext(ctx context.Context) *PcloudCloudinstancesJobsGetParams { + return &PcloudCloudinstancesJobsGetParams{ + Context: ctx, + } +} + +// NewPcloudCloudinstancesJobsGetParamsWithHTTPClient creates a new PcloudCloudinstancesJobsGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudCloudinstancesJobsGetParamsWithHTTPClient(client *http.Client) *PcloudCloudinstancesJobsGetParams { + return &PcloudCloudinstancesJobsGetParams{ + HTTPClient: client, + } +} + +/* PcloudCloudinstancesJobsGetParams contains all the parameters to send to the API endpoint + for the pcloud cloudinstances jobs get operation. + + Typically these are written to a http.Request. +*/ +type PcloudCloudinstancesJobsGetParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* JobID. + + PCloud Job ID + */ + JobID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud cloudinstances jobs get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesJobsGetParams) WithDefaults() *PcloudCloudinstancesJobsGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud cloudinstances jobs get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesJobsGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud cloudinstances jobs get params +func (o *PcloudCloudinstancesJobsGetParams) WithTimeout(timeout time.Duration) *PcloudCloudinstancesJobsGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudinstances jobs get params +func (o *PcloudCloudinstancesJobsGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudinstances jobs get params +func (o *PcloudCloudinstancesJobsGetParams) WithContext(ctx context.Context) *PcloudCloudinstancesJobsGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudinstances jobs get params +func (o *PcloudCloudinstancesJobsGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudinstances jobs get params +func (o *PcloudCloudinstancesJobsGetParams) WithHTTPClient(client *http.Client) *PcloudCloudinstancesJobsGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudinstances jobs get params +func (o *PcloudCloudinstancesJobsGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudinstances jobs get params +func (o *PcloudCloudinstancesJobsGetParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudinstancesJobsGetParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudinstances jobs get params +func (o *PcloudCloudinstancesJobsGetParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithJobID adds the jobID to the pcloud cloudinstances jobs get params +func (o *PcloudCloudinstancesJobsGetParams) WithJobID(jobID string) *PcloudCloudinstancesJobsGetParams { + o.SetJobID(jobID) + return o +} + +// SetJobID adds the jobId to the pcloud cloudinstances jobs get params +func (o *PcloudCloudinstancesJobsGetParams) SetJobID(jobID string) { + o.JobID = jobID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudinstancesJobsGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param job_id + if err := r.SetPathParam("job_id", o.JobID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_jobs/pcloud_cloudinstances_jobs_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_jobs/pcloud_cloudinstances_jobs_get_responses.go new file mode 100644 index 00000000000..b232653f032 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_jobs/pcloud_cloudinstances_jobs_get_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_jobs + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudinstancesJobsGetReader is a Reader for the PcloudCloudinstancesJobsGet structure. +type PcloudCloudinstancesJobsGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudinstancesJobsGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudCloudinstancesJobsGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudCloudinstancesJobsGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudCloudinstancesJobsGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudCloudinstancesJobsGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudCloudinstancesJobsGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudCloudinstancesJobsGetOK creates a PcloudCloudinstancesJobsGetOK with default headers values +func NewPcloudCloudinstancesJobsGetOK() *PcloudCloudinstancesJobsGetOK { + return &PcloudCloudinstancesJobsGetOK{} +} + +/* PcloudCloudinstancesJobsGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudCloudinstancesJobsGetOK struct { + Payload *models.Job +} + +func (o *PcloudCloudinstancesJobsGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/jobs/{job_id}][%d] pcloudCloudinstancesJobsGetOK %+v", 200, o.Payload) +} +func (o *PcloudCloudinstancesJobsGetOK) GetPayload() *models.Job { + return o.Payload +} + +func (o *PcloudCloudinstancesJobsGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Job) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesJobsGetBadRequest creates a PcloudCloudinstancesJobsGetBadRequest with default headers values +func NewPcloudCloudinstancesJobsGetBadRequest() *PcloudCloudinstancesJobsGetBadRequest { + return &PcloudCloudinstancesJobsGetBadRequest{} +} + +/* PcloudCloudinstancesJobsGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudCloudinstancesJobsGetBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesJobsGetBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/jobs/{job_id}][%d] pcloudCloudinstancesJobsGetBadRequest %+v", 400, o.Payload) +} +func (o *PcloudCloudinstancesJobsGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesJobsGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesJobsGetUnauthorized creates a PcloudCloudinstancesJobsGetUnauthorized with default headers values +func NewPcloudCloudinstancesJobsGetUnauthorized() *PcloudCloudinstancesJobsGetUnauthorized { + return &PcloudCloudinstancesJobsGetUnauthorized{} +} + +/* PcloudCloudinstancesJobsGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudCloudinstancesJobsGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesJobsGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/jobs/{job_id}][%d] pcloudCloudinstancesJobsGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudCloudinstancesJobsGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesJobsGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesJobsGetNotFound creates a PcloudCloudinstancesJobsGetNotFound with default headers values +func NewPcloudCloudinstancesJobsGetNotFound() *PcloudCloudinstancesJobsGetNotFound { + return &PcloudCloudinstancesJobsGetNotFound{} +} + +/* PcloudCloudinstancesJobsGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudCloudinstancesJobsGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesJobsGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/jobs/{job_id}][%d] pcloudCloudinstancesJobsGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudCloudinstancesJobsGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesJobsGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesJobsGetInternalServerError creates a PcloudCloudinstancesJobsGetInternalServerError with default headers values +func NewPcloudCloudinstancesJobsGetInternalServerError() *PcloudCloudinstancesJobsGetInternalServerError { + return &PcloudCloudinstancesJobsGetInternalServerError{} +} + +/* PcloudCloudinstancesJobsGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudCloudinstancesJobsGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesJobsGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/jobs/{job_id}][%d] pcloudCloudinstancesJobsGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudCloudinstancesJobsGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesJobsGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_jobs/pcloud_cloudinstances_jobs_getall_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_jobs/pcloud_cloudinstances_jobs_getall_parameters.go new file mode 100644 index 00000000000..50646a09eb0 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_jobs/pcloud_cloudinstances_jobs_getall_parameters.go @@ -0,0 +1,251 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_jobs + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudCloudinstancesJobsGetallParams creates a new PcloudCloudinstancesJobsGetallParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudCloudinstancesJobsGetallParams() *PcloudCloudinstancesJobsGetallParams { + return &PcloudCloudinstancesJobsGetallParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudinstancesJobsGetallParamsWithTimeout creates a new PcloudCloudinstancesJobsGetallParams object +// with the ability to set a timeout on a request. +func NewPcloudCloudinstancesJobsGetallParamsWithTimeout(timeout time.Duration) *PcloudCloudinstancesJobsGetallParams { + return &PcloudCloudinstancesJobsGetallParams{ + timeout: timeout, + } +} + +// NewPcloudCloudinstancesJobsGetallParamsWithContext creates a new PcloudCloudinstancesJobsGetallParams object +// with the ability to set a context for a request. +func NewPcloudCloudinstancesJobsGetallParamsWithContext(ctx context.Context) *PcloudCloudinstancesJobsGetallParams { + return &PcloudCloudinstancesJobsGetallParams{ + Context: ctx, + } +} + +// NewPcloudCloudinstancesJobsGetallParamsWithHTTPClient creates a new PcloudCloudinstancesJobsGetallParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudCloudinstancesJobsGetallParamsWithHTTPClient(client *http.Client) *PcloudCloudinstancesJobsGetallParams { + return &PcloudCloudinstancesJobsGetallParams{ + HTTPClient: client, + } +} + +/* PcloudCloudinstancesJobsGetallParams contains all the parameters to send to the API endpoint + for the pcloud cloudinstances jobs getall operation. + + Typically these are written to a http.Request. +*/ +type PcloudCloudinstancesJobsGetallParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* OperationAction. + + Operation action to filter jobs (optional) vmCapture - includes operation action value (vmCapture) imageExport - includes operation action value (imageExport) imageImport - includes operation action value (imageImport) storage - includes operation action values (vmCapture,imageExport,imageImport) + */ + OperationAction *string + + /* OperationID. + + Operation ID to filter jobs (optional) + */ + OperationID *string + + /* OperationTarget. + + Operation target to filter jobs (optional) + */ + OperationTarget *string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud cloudinstances jobs getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesJobsGetallParams) WithDefaults() *PcloudCloudinstancesJobsGetallParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud cloudinstances jobs getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesJobsGetallParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud cloudinstances jobs getall params +func (o *PcloudCloudinstancesJobsGetallParams) WithTimeout(timeout time.Duration) *PcloudCloudinstancesJobsGetallParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudinstances jobs getall params +func (o *PcloudCloudinstancesJobsGetallParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudinstances jobs getall params +func (o *PcloudCloudinstancesJobsGetallParams) WithContext(ctx context.Context) *PcloudCloudinstancesJobsGetallParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudinstances jobs getall params +func (o *PcloudCloudinstancesJobsGetallParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudinstances jobs getall params +func (o *PcloudCloudinstancesJobsGetallParams) WithHTTPClient(client *http.Client) *PcloudCloudinstancesJobsGetallParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudinstances jobs getall params +func (o *PcloudCloudinstancesJobsGetallParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudinstances jobs getall params +func (o *PcloudCloudinstancesJobsGetallParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudinstancesJobsGetallParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudinstances jobs getall params +func (o *PcloudCloudinstancesJobsGetallParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithOperationAction adds the operationAction to the pcloud cloudinstances jobs getall params +func (o *PcloudCloudinstancesJobsGetallParams) WithOperationAction(operationAction *string) *PcloudCloudinstancesJobsGetallParams { + o.SetOperationAction(operationAction) + return o +} + +// SetOperationAction adds the operationAction to the pcloud cloudinstances jobs getall params +func (o *PcloudCloudinstancesJobsGetallParams) SetOperationAction(operationAction *string) { + o.OperationAction = operationAction +} + +// WithOperationID adds the operationID to the pcloud cloudinstances jobs getall params +func (o *PcloudCloudinstancesJobsGetallParams) WithOperationID(operationID *string) *PcloudCloudinstancesJobsGetallParams { + o.SetOperationID(operationID) + return o +} + +// SetOperationID adds the operationId to the pcloud cloudinstances jobs getall params +func (o *PcloudCloudinstancesJobsGetallParams) SetOperationID(operationID *string) { + o.OperationID = operationID +} + +// WithOperationTarget adds the operationTarget to the pcloud cloudinstances jobs getall params +func (o *PcloudCloudinstancesJobsGetallParams) WithOperationTarget(operationTarget *string) *PcloudCloudinstancesJobsGetallParams { + o.SetOperationTarget(operationTarget) + return o +} + +// SetOperationTarget adds the operationTarget to the pcloud cloudinstances jobs getall params +func (o *PcloudCloudinstancesJobsGetallParams) SetOperationTarget(operationTarget *string) { + o.OperationTarget = operationTarget +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudinstancesJobsGetallParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if o.OperationAction != nil { + + // query param operation.action + var qrOperationAction string + + if o.OperationAction != nil { + qrOperationAction = *o.OperationAction + } + qOperationAction := qrOperationAction + if qOperationAction != "" { + + if err := r.SetQueryParam("operation.action", qOperationAction); err != nil { + return err + } + } + } + + if o.OperationID != nil { + + // query param operation.id + var qrOperationID string + + if o.OperationID != nil { + qrOperationID = *o.OperationID + } + qOperationID := qrOperationID + if qOperationID != "" { + + if err := r.SetQueryParam("operation.id", qOperationID); err != nil { + return err + } + } + } + + if o.OperationTarget != nil { + + // query param operation.target + var qrOperationTarget string + + if o.OperationTarget != nil { + qrOperationTarget = *o.OperationTarget + } + qOperationTarget := qrOperationTarget + if qOperationTarget != "" { + + if err := r.SetQueryParam("operation.target", qOperationTarget); err != nil { + return err + } + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_jobs/pcloud_cloudinstances_jobs_getall_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_jobs/pcloud_cloudinstances_jobs_getall_responses.go new file mode 100644 index 00000000000..d3b942e52ff --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_jobs/pcloud_cloudinstances_jobs_getall_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_jobs + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudinstancesJobsGetallReader is a Reader for the PcloudCloudinstancesJobsGetall structure. +type PcloudCloudinstancesJobsGetallReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudinstancesJobsGetallReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudCloudinstancesJobsGetallOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudCloudinstancesJobsGetallBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudCloudinstancesJobsGetallUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudCloudinstancesJobsGetallNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudCloudinstancesJobsGetallInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudCloudinstancesJobsGetallOK creates a PcloudCloudinstancesJobsGetallOK with default headers values +func NewPcloudCloudinstancesJobsGetallOK() *PcloudCloudinstancesJobsGetallOK { + return &PcloudCloudinstancesJobsGetallOK{} +} + +/* PcloudCloudinstancesJobsGetallOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudCloudinstancesJobsGetallOK struct { + Payload *models.Jobs +} + +func (o *PcloudCloudinstancesJobsGetallOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/jobs][%d] pcloudCloudinstancesJobsGetallOK %+v", 200, o.Payload) +} +func (o *PcloudCloudinstancesJobsGetallOK) GetPayload() *models.Jobs { + return o.Payload +} + +func (o *PcloudCloudinstancesJobsGetallOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Jobs) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesJobsGetallBadRequest creates a PcloudCloudinstancesJobsGetallBadRequest with default headers values +func NewPcloudCloudinstancesJobsGetallBadRequest() *PcloudCloudinstancesJobsGetallBadRequest { + return &PcloudCloudinstancesJobsGetallBadRequest{} +} + +/* PcloudCloudinstancesJobsGetallBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudCloudinstancesJobsGetallBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesJobsGetallBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/jobs][%d] pcloudCloudinstancesJobsGetallBadRequest %+v", 400, o.Payload) +} +func (o *PcloudCloudinstancesJobsGetallBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesJobsGetallBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesJobsGetallUnauthorized creates a PcloudCloudinstancesJobsGetallUnauthorized with default headers values +func NewPcloudCloudinstancesJobsGetallUnauthorized() *PcloudCloudinstancesJobsGetallUnauthorized { + return &PcloudCloudinstancesJobsGetallUnauthorized{} +} + +/* PcloudCloudinstancesJobsGetallUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudCloudinstancesJobsGetallUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesJobsGetallUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/jobs][%d] pcloudCloudinstancesJobsGetallUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudCloudinstancesJobsGetallUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesJobsGetallUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesJobsGetallNotFound creates a PcloudCloudinstancesJobsGetallNotFound with default headers values +func NewPcloudCloudinstancesJobsGetallNotFound() *PcloudCloudinstancesJobsGetallNotFound { + return &PcloudCloudinstancesJobsGetallNotFound{} +} + +/* PcloudCloudinstancesJobsGetallNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudCloudinstancesJobsGetallNotFound struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesJobsGetallNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/jobs][%d] pcloudCloudinstancesJobsGetallNotFound %+v", 404, o.Payload) +} +func (o *PcloudCloudinstancesJobsGetallNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesJobsGetallNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesJobsGetallInternalServerError creates a PcloudCloudinstancesJobsGetallInternalServerError with default headers values +func NewPcloudCloudinstancesJobsGetallInternalServerError() *PcloudCloudinstancesJobsGetallInternalServerError { + return &PcloudCloudinstancesJobsGetallInternalServerError{} +} + +/* PcloudCloudinstancesJobsGetallInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudCloudinstancesJobsGetallInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesJobsGetallInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/jobs][%d] pcloudCloudinstancesJobsGetallInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudCloudinstancesJobsGetallInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesJobsGetallInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/p_cloud_networks_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/p_cloud_networks_client.go new file mode 100644 index 00000000000..5a08ce2c9b4 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/p_cloud_networks_client.go @@ -0,0 +1,450 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_networks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new p cloud networks API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for p cloud networks API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + PcloudNetworksDelete(params *PcloudNetworksDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudNetworksDeleteOK, error) + + PcloudNetworksGet(params *PcloudNetworksGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudNetworksGetOK, error) + + PcloudNetworksGetall(params *PcloudNetworksGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudNetworksGetallOK, error) + + PcloudNetworksPortsDelete(params *PcloudNetworksPortsDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudNetworksPortsDeleteOK, error) + + PcloudNetworksPortsGet(params *PcloudNetworksPortsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudNetworksPortsGetOK, error) + + PcloudNetworksPortsGetall(params *PcloudNetworksPortsGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudNetworksPortsGetallOK, error) + + PcloudNetworksPortsPost(params *PcloudNetworksPortsPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudNetworksPortsPostCreated, error) + + PcloudNetworksPortsPut(params *PcloudNetworksPortsPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudNetworksPortsPutOK, error) + + PcloudNetworksPost(params *PcloudNetworksPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudNetworksPostOK, *PcloudNetworksPostCreated, error) + + PcloudNetworksPut(params *PcloudNetworksPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudNetworksPutOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + PcloudNetworksDelete deletes a network +*/ +func (a *Client) PcloudNetworksDelete(params *PcloudNetworksDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudNetworksDeleteOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudNetworksDeleteParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.networks.delete", + Method: "DELETE", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudNetworksDeleteReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudNetworksDeleteOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.networks.delete: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudNetworksGet gets a network s current state information +*/ +func (a *Client) PcloudNetworksGet(params *PcloudNetworksGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudNetworksGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudNetworksGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.networks.get", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudNetworksGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudNetworksGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.networks.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudNetworksGetall gets all networks in this cloud instance +*/ +func (a *Client) PcloudNetworksGetall(params *PcloudNetworksGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudNetworksGetallOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudNetworksGetallParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.networks.getall", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/networks", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudNetworksGetallReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudNetworksGetallOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.networks.getall: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudNetworksPortsDelete deletes a network port +*/ +func (a *Client) PcloudNetworksPortsDelete(params *PcloudNetworksPortsDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudNetworksPortsDeleteOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudNetworksPortsDeleteParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.networks.ports.delete", + Method: "DELETE", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}/ports/{port_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudNetworksPortsDeleteReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudNetworksPortsDeleteOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.networks.ports.delete: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudNetworksPortsGet gets a port s information +*/ +func (a *Client) PcloudNetworksPortsGet(params *PcloudNetworksPortsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudNetworksPortsGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudNetworksPortsGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.networks.ports.get", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}/ports/{port_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudNetworksPortsGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudNetworksPortsGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.networks.ports.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudNetworksPortsGetall gets all ports for this network +*/ +func (a *Client) PcloudNetworksPortsGetall(params *PcloudNetworksPortsGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudNetworksPortsGetallOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudNetworksPortsGetallParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.networks.ports.getall", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}/ports", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudNetworksPortsGetallReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudNetworksPortsGetallOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.networks.ports.getall: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudNetworksPortsPost performs port addition deletion and listing +*/ +func (a *Client) PcloudNetworksPortsPost(params *PcloudNetworksPortsPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudNetworksPortsPostCreated, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudNetworksPortsPostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.networks.ports.post", + Method: "POST", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}/ports", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudNetworksPortsPostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudNetworksPortsPostCreated) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.networks.ports.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudNetworksPortsPut updates a port s information +*/ +func (a *Client) PcloudNetworksPortsPut(params *PcloudNetworksPortsPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudNetworksPortsPutOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudNetworksPortsPutParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.networks.ports.put", + Method: "PUT", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}/ports/{port_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudNetworksPortsPutReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudNetworksPortsPutOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.networks.ports.put: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudNetworksPost creates a new network +*/ +func (a *Client) PcloudNetworksPost(params *PcloudNetworksPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudNetworksPostOK, *PcloudNetworksPostCreated, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudNetworksPostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.networks.post", + Method: "POST", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/networks", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudNetworksPostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, nil, err + } + switch value := result.(type) { + case *PcloudNetworksPostOK: + return value, nil, nil + case *PcloudNetworksPostCreated: + return nil, value, nil + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for p_cloud_networks: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudNetworksPut updates a network +*/ +func (a *Client) PcloudNetworksPut(params *PcloudNetworksPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudNetworksPutOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudNetworksPutParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.networks.put", + Method: "PUT", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudNetworksPutReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudNetworksPutOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.networks.put: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_delete_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_delete_parameters.go new file mode 100644 index 00000000000..ed9fd5e8b66 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_delete_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_networks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudNetworksDeleteParams creates a new PcloudNetworksDeleteParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudNetworksDeleteParams() *PcloudNetworksDeleteParams { + return &PcloudNetworksDeleteParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudNetworksDeleteParamsWithTimeout creates a new PcloudNetworksDeleteParams object +// with the ability to set a timeout on a request. +func NewPcloudNetworksDeleteParamsWithTimeout(timeout time.Duration) *PcloudNetworksDeleteParams { + return &PcloudNetworksDeleteParams{ + timeout: timeout, + } +} + +// NewPcloudNetworksDeleteParamsWithContext creates a new PcloudNetworksDeleteParams object +// with the ability to set a context for a request. +func NewPcloudNetworksDeleteParamsWithContext(ctx context.Context) *PcloudNetworksDeleteParams { + return &PcloudNetworksDeleteParams{ + Context: ctx, + } +} + +// NewPcloudNetworksDeleteParamsWithHTTPClient creates a new PcloudNetworksDeleteParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudNetworksDeleteParamsWithHTTPClient(client *http.Client) *PcloudNetworksDeleteParams { + return &PcloudNetworksDeleteParams{ + HTTPClient: client, + } +} + +/* PcloudNetworksDeleteParams contains all the parameters to send to the API endpoint + for the pcloud networks delete operation. + + Typically these are written to a http.Request. +*/ +type PcloudNetworksDeleteParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* NetworkID. + + Network ID + */ + NetworkID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud networks delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudNetworksDeleteParams) WithDefaults() *PcloudNetworksDeleteParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud networks delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudNetworksDeleteParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud networks delete params +func (o *PcloudNetworksDeleteParams) WithTimeout(timeout time.Duration) *PcloudNetworksDeleteParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud networks delete params +func (o *PcloudNetworksDeleteParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud networks delete params +func (o *PcloudNetworksDeleteParams) WithContext(ctx context.Context) *PcloudNetworksDeleteParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud networks delete params +func (o *PcloudNetworksDeleteParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud networks delete params +func (o *PcloudNetworksDeleteParams) WithHTTPClient(client *http.Client) *PcloudNetworksDeleteParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud networks delete params +func (o *PcloudNetworksDeleteParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud networks delete params +func (o *PcloudNetworksDeleteParams) WithCloudInstanceID(cloudInstanceID string) *PcloudNetworksDeleteParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud networks delete params +func (o *PcloudNetworksDeleteParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithNetworkID adds the networkID to the pcloud networks delete params +func (o *PcloudNetworksDeleteParams) WithNetworkID(networkID string) *PcloudNetworksDeleteParams { + o.SetNetworkID(networkID) + return o +} + +// SetNetworkID adds the networkId to the pcloud networks delete params +func (o *PcloudNetworksDeleteParams) SetNetworkID(networkID string) { + o.NetworkID = networkID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudNetworksDeleteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param network_id + if err := r.SetPathParam("network_id", o.NetworkID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_delete_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_delete_responses.go new file mode 100644 index 00000000000..67dba95234b --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_delete_responses.go @@ -0,0 +1,217 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_networks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudNetworksDeleteReader is a Reader for the PcloudNetworksDelete structure. +type PcloudNetworksDeleteReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudNetworksDeleteReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudNetworksDeleteOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudNetworksDeleteBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudNetworksDeleteUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 410: + result := NewPcloudNetworksDeleteGone() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudNetworksDeleteInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudNetworksDeleteOK creates a PcloudNetworksDeleteOK with default headers values +func NewPcloudNetworksDeleteOK() *PcloudNetworksDeleteOK { + return &PcloudNetworksDeleteOK{} +} + +/* PcloudNetworksDeleteOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudNetworksDeleteOK struct { + Payload models.Object +} + +func (o *PcloudNetworksDeleteOK) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}][%d] pcloudNetworksDeleteOK %+v", 200, o.Payload) +} +func (o *PcloudNetworksDeleteOK) GetPayload() models.Object { + return o.Payload +} + +func (o *PcloudNetworksDeleteOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksDeleteBadRequest creates a PcloudNetworksDeleteBadRequest with default headers values +func NewPcloudNetworksDeleteBadRequest() *PcloudNetworksDeleteBadRequest { + return &PcloudNetworksDeleteBadRequest{} +} + +/* PcloudNetworksDeleteBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudNetworksDeleteBadRequest struct { + Payload *models.Error +} + +func (o *PcloudNetworksDeleteBadRequest) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}][%d] pcloudNetworksDeleteBadRequest %+v", 400, o.Payload) +} +func (o *PcloudNetworksDeleteBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksDeleteBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksDeleteUnauthorized creates a PcloudNetworksDeleteUnauthorized with default headers values +func NewPcloudNetworksDeleteUnauthorized() *PcloudNetworksDeleteUnauthorized { + return &PcloudNetworksDeleteUnauthorized{} +} + +/* PcloudNetworksDeleteUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudNetworksDeleteUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudNetworksDeleteUnauthorized) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}][%d] pcloudNetworksDeleteUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudNetworksDeleteUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksDeleteUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksDeleteGone creates a PcloudNetworksDeleteGone with default headers values +func NewPcloudNetworksDeleteGone() *PcloudNetworksDeleteGone { + return &PcloudNetworksDeleteGone{} +} + +/* PcloudNetworksDeleteGone describes a response with status code 410, with default header values. + +Gone +*/ +type PcloudNetworksDeleteGone struct { + Payload *models.Error +} + +func (o *PcloudNetworksDeleteGone) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}][%d] pcloudNetworksDeleteGone %+v", 410, o.Payload) +} +func (o *PcloudNetworksDeleteGone) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksDeleteGone) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksDeleteInternalServerError creates a PcloudNetworksDeleteInternalServerError with default headers values +func NewPcloudNetworksDeleteInternalServerError() *PcloudNetworksDeleteInternalServerError { + return &PcloudNetworksDeleteInternalServerError{} +} + +/* PcloudNetworksDeleteInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudNetworksDeleteInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudNetworksDeleteInternalServerError) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}][%d] pcloudNetworksDeleteInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudNetworksDeleteInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksDeleteInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_get_parameters.go new file mode 100644 index 00000000000..a9694c898a4 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_get_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_networks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudNetworksGetParams creates a new PcloudNetworksGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudNetworksGetParams() *PcloudNetworksGetParams { + return &PcloudNetworksGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudNetworksGetParamsWithTimeout creates a new PcloudNetworksGetParams object +// with the ability to set a timeout on a request. +func NewPcloudNetworksGetParamsWithTimeout(timeout time.Duration) *PcloudNetworksGetParams { + return &PcloudNetworksGetParams{ + timeout: timeout, + } +} + +// NewPcloudNetworksGetParamsWithContext creates a new PcloudNetworksGetParams object +// with the ability to set a context for a request. +func NewPcloudNetworksGetParamsWithContext(ctx context.Context) *PcloudNetworksGetParams { + return &PcloudNetworksGetParams{ + Context: ctx, + } +} + +// NewPcloudNetworksGetParamsWithHTTPClient creates a new PcloudNetworksGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudNetworksGetParamsWithHTTPClient(client *http.Client) *PcloudNetworksGetParams { + return &PcloudNetworksGetParams{ + HTTPClient: client, + } +} + +/* PcloudNetworksGetParams contains all the parameters to send to the API endpoint + for the pcloud networks get operation. + + Typically these are written to a http.Request. +*/ +type PcloudNetworksGetParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* NetworkID. + + Network ID + */ + NetworkID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud networks get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudNetworksGetParams) WithDefaults() *PcloudNetworksGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud networks get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudNetworksGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud networks get params +func (o *PcloudNetworksGetParams) WithTimeout(timeout time.Duration) *PcloudNetworksGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud networks get params +func (o *PcloudNetworksGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud networks get params +func (o *PcloudNetworksGetParams) WithContext(ctx context.Context) *PcloudNetworksGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud networks get params +func (o *PcloudNetworksGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud networks get params +func (o *PcloudNetworksGetParams) WithHTTPClient(client *http.Client) *PcloudNetworksGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud networks get params +func (o *PcloudNetworksGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud networks get params +func (o *PcloudNetworksGetParams) WithCloudInstanceID(cloudInstanceID string) *PcloudNetworksGetParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud networks get params +func (o *PcloudNetworksGetParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithNetworkID adds the networkID to the pcloud networks get params +func (o *PcloudNetworksGetParams) WithNetworkID(networkID string) *PcloudNetworksGetParams { + o.SetNetworkID(networkID) + return o +} + +// SetNetworkID adds the networkId to the pcloud networks get params +func (o *PcloudNetworksGetParams) SetNetworkID(networkID string) { + o.NetworkID = networkID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudNetworksGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param network_id + if err := r.SetPathParam("network_id", o.NetworkID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_get_responses.go new file mode 100644 index 00000000000..d66f5f1b203 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_get_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_networks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudNetworksGetReader is a Reader for the PcloudNetworksGet structure. +type PcloudNetworksGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudNetworksGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudNetworksGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudNetworksGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudNetworksGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudNetworksGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudNetworksGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudNetworksGetOK creates a PcloudNetworksGetOK with default headers values +func NewPcloudNetworksGetOK() *PcloudNetworksGetOK { + return &PcloudNetworksGetOK{} +} + +/* PcloudNetworksGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudNetworksGetOK struct { + Payload *models.Network +} + +func (o *PcloudNetworksGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}][%d] pcloudNetworksGetOK %+v", 200, o.Payload) +} +func (o *PcloudNetworksGetOK) GetPayload() *models.Network { + return o.Payload +} + +func (o *PcloudNetworksGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Network) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksGetBadRequest creates a PcloudNetworksGetBadRequest with default headers values +func NewPcloudNetworksGetBadRequest() *PcloudNetworksGetBadRequest { + return &PcloudNetworksGetBadRequest{} +} + +/* PcloudNetworksGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudNetworksGetBadRequest struct { + Payload *models.Error +} + +func (o *PcloudNetworksGetBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}][%d] pcloudNetworksGetBadRequest %+v", 400, o.Payload) +} +func (o *PcloudNetworksGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksGetUnauthorized creates a PcloudNetworksGetUnauthorized with default headers values +func NewPcloudNetworksGetUnauthorized() *PcloudNetworksGetUnauthorized { + return &PcloudNetworksGetUnauthorized{} +} + +/* PcloudNetworksGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudNetworksGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudNetworksGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}][%d] pcloudNetworksGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudNetworksGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksGetNotFound creates a PcloudNetworksGetNotFound with default headers values +func NewPcloudNetworksGetNotFound() *PcloudNetworksGetNotFound { + return &PcloudNetworksGetNotFound{} +} + +/* PcloudNetworksGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudNetworksGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudNetworksGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}][%d] pcloudNetworksGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudNetworksGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksGetInternalServerError creates a PcloudNetworksGetInternalServerError with default headers values +func NewPcloudNetworksGetInternalServerError() *PcloudNetworksGetInternalServerError { + return &PcloudNetworksGetInternalServerError{} +} + +/* PcloudNetworksGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudNetworksGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudNetworksGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}][%d] pcloudNetworksGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudNetworksGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_getall_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_getall_parameters.go new file mode 100644 index 00000000000..3ec2e1b918a --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_getall_parameters.go @@ -0,0 +1,183 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_networks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudNetworksGetallParams creates a new PcloudNetworksGetallParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudNetworksGetallParams() *PcloudNetworksGetallParams { + return &PcloudNetworksGetallParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudNetworksGetallParamsWithTimeout creates a new PcloudNetworksGetallParams object +// with the ability to set a timeout on a request. +func NewPcloudNetworksGetallParamsWithTimeout(timeout time.Duration) *PcloudNetworksGetallParams { + return &PcloudNetworksGetallParams{ + timeout: timeout, + } +} + +// NewPcloudNetworksGetallParamsWithContext creates a new PcloudNetworksGetallParams object +// with the ability to set a context for a request. +func NewPcloudNetworksGetallParamsWithContext(ctx context.Context) *PcloudNetworksGetallParams { + return &PcloudNetworksGetallParams{ + Context: ctx, + } +} + +// NewPcloudNetworksGetallParamsWithHTTPClient creates a new PcloudNetworksGetallParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudNetworksGetallParamsWithHTTPClient(client *http.Client) *PcloudNetworksGetallParams { + return &PcloudNetworksGetallParams{ + HTTPClient: client, + } +} + +/* PcloudNetworksGetallParams contains all the parameters to send to the API endpoint + for the pcloud networks getall operation. + + Typically these are written to a http.Request. +*/ +type PcloudNetworksGetallParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* Filter. + + A filter expression that filters resources listed in the response + */ + Filter *string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud networks getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudNetworksGetallParams) WithDefaults() *PcloudNetworksGetallParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud networks getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudNetworksGetallParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud networks getall params +func (o *PcloudNetworksGetallParams) WithTimeout(timeout time.Duration) *PcloudNetworksGetallParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud networks getall params +func (o *PcloudNetworksGetallParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud networks getall params +func (o *PcloudNetworksGetallParams) WithContext(ctx context.Context) *PcloudNetworksGetallParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud networks getall params +func (o *PcloudNetworksGetallParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud networks getall params +func (o *PcloudNetworksGetallParams) WithHTTPClient(client *http.Client) *PcloudNetworksGetallParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud networks getall params +func (o *PcloudNetworksGetallParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud networks getall params +func (o *PcloudNetworksGetallParams) WithCloudInstanceID(cloudInstanceID string) *PcloudNetworksGetallParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud networks getall params +func (o *PcloudNetworksGetallParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithFilter adds the filter to the pcloud networks getall params +func (o *PcloudNetworksGetallParams) WithFilter(filter *string) *PcloudNetworksGetallParams { + o.SetFilter(filter) + return o +} + +// SetFilter adds the filter to the pcloud networks getall params +func (o *PcloudNetworksGetallParams) SetFilter(filter *string) { + o.Filter = filter +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudNetworksGetallParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if o.Filter != nil { + + // query param filter + var qrFilter string + + if o.Filter != nil { + qrFilter = *o.Filter + } + qFilter := qrFilter + if qFilter != "" { + + if err := r.SetQueryParam("filter", qFilter); err != nil { + return err + } + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_getall_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_getall_responses.go new file mode 100644 index 00000000000..fd07134b23a --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_getall_responses.go @@ -0,0 +1,181 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_networks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudNetworksGetallReader is a Reader for the PcloudNetworksGetall structure. +type PcloudNetworksGetallReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudNetworksGetallReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudNetworksGetallOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudNetworksGetallBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudNetworksGetallUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudNetworksGetallInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudNetworksGetallOK creates a PcloudNetworksGetallOK with default headers values +func NewPcloudNetworksGetallOK() *PcloudNetworksGetallOK { + return &PcloudNetworksGetallOK{} +} + +/* PcloudNetworksGetallOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudNetworksGetallOK struct { + Payload *models.Networks +} + +func (o *PcloudNetworksGetallOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/networks][%d] pcloudNetworksGetallOK %+v", 200, o.Payload) +} +func (o *PcloudNetworksGetallOK) GetPayload() *models.Networks { + return o.Payload +} + +func (o *PcloudNetworksGetallOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Networks) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksGetallBadRequest creates a PcloudNetworksGetallBadRequest with default headers values +func NewPcloudNetworksGetallBadRequest() *PcloudNetworksGetallBadRequest { + return &PcloudNetworksGetallBadRequest{} +} + +/* PcloudNetworksGetallBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudNetworksGetallBadRequest struct { + Payload *models.Error +} + +func (o *PcloudNetworksGetallBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/networks][%d] pcloudNetworksGetallBadRequest %+v", 400, o.Payload) +} +func (o *PcloudNetworksGetallBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksGetallBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksGetallUnauthorized creates a PcloudNetworksGetallUnauthorized with default headers values +func NewPcloudNetworksGetallUnauthorized() *PcloudNetworksGetallUnauthorized { + return &PcloudNetworksGetallUnauthorized{} +} + +/* PcloudNetworksGetallUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudNetworksGetallUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudNetworksGetallUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/networks][%d] pcloudNetworksGetallUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudNetworksGetallUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksGetallUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksGetallInternalServerError creates a PcloudNetworksGetallInternalServerError with default headers values +func NewPcloudNetworksGetallInternalServerError() *PcloudNetworksGetallInternalServerError { + return &PcloudNetworksGetallInternalServerError{} +} + +/* PcloudNetworksGetallInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudNetworksGetallInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudNetworksGetallInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/networks][%d] pcloudNetworksGetallInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudNetworksGetallInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksGetallInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_ports_delete_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_ports_delete_parameters.go new file mode 100644 index 00000000000..2782cd9eb0d --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_ports_delete_parameters.go @@ -0,0 +1,193 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_networks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudNetworksPortsDeleteParams creates a new PcloudNetworksPortsDeleteParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudNetworksPortsDeleteParams() *PcloudNetworksPortsDeleteParams { + return &PcloudNetworksPortsDeleteParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudNetworksPortsDeleteParamsWithTimeout creates a new PcloudNetworksPortsDeleteParams object +// with the ability to set a timeout on a request. +func NewPcloudNetworksPortsDeleteParamsWithTimeout(timeout time.Duration) *PcloudNetworksPortsDeleteParams { + return &PcloudNetworksPortsDeleteParams{ + timeout: timeout, + } +} + +// NewPcloudNetworksPortsDeleteParamsWithContext creates a new PcloudNetworksPortsDeleteParams object +// with the ability to set a context for a request. +func NewPcloudNetworksPortsDeleteParamsWithContext(ctx context.Context) *PcloudNetworksPortsDeleteParams { + return &PcloudNetworksPortsDeleteParams{ + Context: ctx, + } +} + +// NewPcloudNetworksPortsDeleteParamsWithHTTPClient creates a new PcloudNetworksPortsDeleteParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudNetworksPortsDeleteParamsWithHTTPClient(client *http.Client) *PcloudNetworksPortsDeleteParams { + return &PcloudNetworksPortsDeleteParams{ + HTTPClient: client, + } +} + +/* PcloudNetworksPortsDeleteParams contains all the parameters to send to the API endpoint + for the pcloud networks ports delete operation. + + Typically these are written to a http.Request. +*/ +type PcloudNetworksPortsDeleteParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* NetworkID. + + Network ID + */ + NetworkID string + + /* PortID. + + Port ID + */ + PortID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud networks ports delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudNetworksPortsDeleteParams) WithDefaults() *PcloudNetworksPortsDeleteParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud networks ports delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudNetworksPortsDeleteParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud networks ports delete params +func (o *PcloudNetworksPortsDeleteParams) WithTimeout(timeout time.Duration) *PcloudNetworksPortsDeleteParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud networks ports delete params +func (o *PcloudNetworksPortsDeleteParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud networks ports delete params +func (o *PcloudNetworksPortsDeleteParams) WithContext(ctx context.Context) *PcloudNetworksPortsDeleteParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud networks ports delete params +func (o *PcloudNetworksPortsDeleteParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud networks ports delete params +func (o *PcloudNetworksPortsDeleteParams) WithHTTPClient(client *http.Client) *PcloudNetworksPortsDeleteParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud networks ports delete params +func (o *PcloudNetworksPortsDeleteParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud networks ports delete params +func (o *PcloudNetworksPortsDeleteParams) WithCloudInstanceID(cloudInstanceID string) *PcloudNetworksPortsDeleteParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud networks ports delete params +func (o *PcloudNetworksPortsDeleteParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithNetworkID adds the networkID to the pcloud networks ports delete params +func (o *PcloudNetworksPortsDeleteParams) WithNetworkID(networkID string) *PcloudNetworksPortsDeleteParams { + o.SetNetworkID(networkID) + return o +} + +// SetNetworkID adds the networkId to the pcloud networks ports delete params +func (o *PcloudNetworksPortsDeleteParams) SetNetworkID(networkID string) { + o.NetworkID = networkID +} + +// WithPortID adds the portID to the pcloud networks ports delete params +func (o *PcloudNetworksPortsDeleteParams) WithPortID(portID string) *PcloudNetworksPortsDeleteParams { + o.SetPortID(portID) + return o +} + +// SetPortID adds the portId to the pcloud networks ports delete params +func (o *PcloudNetworksPortsDeleteParams) SetPortID(portID string) { + o.PortID = portID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudNetworksPortsDeleteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param network_id + if err := r.SetPathParam("network_id", o.NetworkID); err != nil { + return err + } + + // path param port_id + if err := r.SetPathParam("port_id", o.PortID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_ports_delete_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_ports_delete_responses.go new file mode 100644 index 00000000000..45c94b0225b --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_ports_delete_responses.go @@ -0,0 +1,217 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_networks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudNetworksPortsDeleteReader is a Reader for the PcloudNetworksPortsDelete structure. +type PcloudNetworksPortsDeleteReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudNetworksPortsDeleteReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudNetworksPortsDeleteOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudNetworksPortsDeleteBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudNetworksPortsDeleteUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 410: + result := NewPcloudNetworksPortsDeleteGone() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudNetworksPortsDeleteInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudNetworksPortsDeleteOK creates a PcloudNetworksPortsDeleteOK with default headers values +func NewPcloudNetworksPortsDeleteOK() *PcloudNetworksPortsDeleteOK { + return &PcloudNetworksPortsDeleteOK{} +} + +/* PcloudNetworksPortsDeleteOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudNetworksPortsDeleteOK struct { + Payload models.Object +} + +func (o *PcloudNetworksPortsDeleteOK) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}/ports/{port_id}][%d] pcloudNetworksPortsDeleteOK %+v", 200, o.Payload) +} +func (o *PcloudNetworksPortsDeleteOK) GetPayload() models.Object { + return o.Payload +} + +func (o *PcloudNetworksPortsDeleteOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksPortsDeleteBadRequest creates a PcloudNetworksPortsDeleteBadRequest with default headers values +func NewPcloudNetworksPortsDeleteBadRequest() *PcloudNetworksPortsDeleteBadRequest { + return &PcloudNetworksPortsDeleteBadRequest{} +} + +/* PcloudNetworksPortsDeleteBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudNetworksPortsDeleteBadRequest struct { + Payload *models.Error +} + +func (o *PcloudNetworksPortsDeleteBadRequest) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}/ports/{port_id}][%d] pcloudNetworksPortsDeleteBadRequest %+v", 400, o.Payload) +} +func (o *PcloudNetworksPortsDeleteBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksPortsDeleteBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksPortsDeleteUnauthorized creates a PcloudNetworksPortsDeleteUnauthorized with default headers values +func NewPcloudNetworksPortsDeleteUnauthorized() *PcloudNetworksPortsDeleteUnauthorized { + return &PcloudNetworksPortsDeleteUnauthorized{} +} + +/* PcloudNetworksPortsDeleteUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudNetworksPortsDeleteUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudNetworksPortsDeleteUnauthorized) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}/ports/{port_id}][%d] pcloudNetworksPortsDeleteUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudNetworksPortsDeleteUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksPortsDeleteUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksPortsDeleteGone creates a PcloudNetworksPortsDeleteGone with default headers values +func NewPcloudNetworksPortsDeleteGone() *PcloudNetworksPortsDeleteGone { + return &PcloudNetworksPortsDeleteGone{} +} + +/* PcloudNetworksPortsDeleteGone describes a response with status code 410, with default header values. + +Gone +*/ +type PcloudNetworksPortsDeleteGone struct { + Payload *models.Error +} + +func (o *PcloudNetworksPortsDeleteGone) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}/ports/{port_id}][%d] pcloudNetworksPortsDeleteGone %+v", 410, o.Payload) +} +func (o *PcloudNetworksPortsDeleteGone) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksPortsDeleteGone) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksPortsDeleteInternalServerError creates a PcloudNetworksPortsDeleteInternalServerError with default headers values +func NewPcloudNetworksPortsDeleteInternalServerError() *PcloudNetworksPortsDeleteInternalServerError { + return &PcloudNetworksPortsDeleteInternalServerError{} +} + +/* PcloudNetworksPortsDeleteInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudNetworksPortsDeleteInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudNetworksPortsDeleteInternalServerError) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}/ports/{port_id}][%d] pcloudNetworksPortsDeleteInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudNetworksPortsDeleteInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksPortsDeleteInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_ports_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_ports_get_parameters.go new file mode 100644 index 00000000000..cced0387781 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_ports_get_parameters.go @@ -0,0 +1,193 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_networks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudNetworksPortsGetParams creates a new PcloudNetworksPortsGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudNetworksPortsGetParams() *PcloudNetworksPortsGetParams { + return &PcloudNetworksPortsGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudNetworksPortsGetParamsWithTimeout creates a new PcloudNetworksPortsGetParams object +// with the ability to set a timeout on a request. +func NewPcloudNetworksPortsGetParamsWithTimeout(timeout time.Duration) *PcloudNetworksPortsGetParams { + return &PcloudNetworksPortsGetParams{ + timeout: timeout, + } +} + +// NewPcloudNetworksPortsGetParamsWithContext creates a new PcloudNetworksPortsGetParams object +// with the ability to set a context for a request. +func NewPcloudNetworksPortsGetParamsWithContext(ctx context.Context) *PcloudNetworksPortsGetParams { + return &PcloudNetworksPortsGetParams{ + Context: ctx, + } +} + +// NewPcloudNetworksPortsGetParamsWithHTTPClient creates a new PcloudNetworksPortsGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudNetworksPortsGetParamsWithHTTPClient(client *http.Client) *PcloudNetworksPortsGetParams { + return &PcloudNetworksPortsGetParams{ + HTTPClient: client, + } +} + +/* PcloudNetworksPortsGetParams contains all the parameters to send to the API endpoint + for the pcloud networks ports get operation. + + Typically these are written to a http.Request. +*/ +type PcloudNetworksPortsGetParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* NetworkID. + + Network ID + */ + NetworkID string + + /* PortID. + + Port ID + */ + PortID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud networks ports get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudNetworksPortsGetParams) WithDefaults() *PcloudNetworksPortsGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud networks ports get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudNetworksPortsGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud networks ports get params +func (o *PcloudNetworksPortsGetParams) WithTimeout(timeout time.Duration) *PcloudNetworksPortsGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud networks ports get params +func (o *PcloudNetworksPortsGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud networks ports get params +func (o *PcloudNetworksPortsGetParams) WithContext(ctx context.Context) *PcloudNetworksPortsGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud networks ports get params +func (o *PcloudNetworksPortsGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud networks ports get params +func (o *PcloudNetworksPortsGetParams) WithHTTPClient(client *http.Client) *PcloudNetworksPortsGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud networks ports get params +func (o *PcloudNetworksPortsGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud networks ports get params +func (o *PcloudNetworksPortsGetParams) WithCloudInstanceID(cloudInstanceID string) *PcloudNetworksPortsGetParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud networks ports get params +func (o *PcloudNetworksPortsGetParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithNetworkID adds the networkID to the pcloud networks ports get params +func (o *PcloudNetworksPortsGetParams) WithNetworkID(networkID string) *PcloudNetworksPortsGetParams { + o.SetNetworkID(networkID) + return o +} + +// SetNetworkID adds the networkId to the pcloud networks ports get params +func (o *PcloudNetworksPortsGetParams) SetNetworkID(networkID string) { + o.NetworkID = networkID +} + +// WithPortID adds the portID to the pcloud networks ports get params +func (o *PcloudNetworksPortsGetParams) WithPortID(portID string) *PcloudNetworksPortsGetParams { + o.SetPortID(portID) + return o +} + +// SetPortID adds the portId to the pcloud networks ports get params +func (o *PcloudNetworksPortsGetParams) SetPortID(portID string) { + o.PortID = portID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudNetworksPortsGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param network_id + if err := r.SetPathParam("network_id", o.NetworkID); err != nil { + return err + } + + // path param port_id + if err := r.SetPathParam("port_id", o.PortID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_ports_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_ports_get_responses.go new file mode 100644 index 00000000000..70ff78c3f8a --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_ports_get_responses.go @@ -0,0 +1,181 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_networks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudNetworksPortsGetReader is a Reader for the PcloudNetworksPortsGet structure. +type PcloudNetworksPortsGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudNetworksPortsGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudNetworksPortsGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewPcloudNetworksPortsGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudNetworksPortsGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudNetworksPortsGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudNetworksPortsGetOK creates a PcloudNetworksPortsGetOK with default headers values +func NewPcloudNetworksPortsGetOK() *PcloudNetworksPortsGetOK { + return &PcloudNetworksPortsGetOK{} +} + +/* PcloudNetworksPortsGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudNetworksPortsGetOK struct { + Payload *models.NetworkPort +} + +func (o *PcloudNetworksPortsGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}/ports/{port_id}][%d] pcloudNetworksPortsGetOK %+v", 200, o.Payload) +} +func (o *PcloudNetworksPortsGetOK) GetPayload() *models.NetworkPort { + return o.Payload +} + +func (o *PcloudNetworksPortsGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.NetworkPort) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksPortsGetUnauthorized creates a PcloudNetworksPortsGetUnauthorized with default headers values +func NewPcloudNetworksPortsGetUnauthorized() *PcloudNetworksPortsGetUnauthorized { + return &PcloudNetworksPortsGetUnauthorized{} +} + +/* PcloudNetworksPortsGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudNetworksPortsGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudNetworksPortsGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}/ports/{port_id}][%d] pcloudNetworksPortsGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudNetworksPortsGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksPortsGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksPortsGetNotFound creates a PcloudNetworksPortsGetNotFound with default headers values +func NewPcloudNetworksPortsGetNotFound() *PcloudNetworksPortsGetNotFound { + return &PcloudNetworksPortsGetNotFound{} +} + +/* PcloudNetworksPortsGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudNetworksPortsGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudNetworksPortsGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}/ports/{port_id}][%d] pcloudNetworksPortsGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudNetworksPortsGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksPortsGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksPortsGetInternalServerError creates a PcloudNetworksPortsGetInternalServerError with default headers values +func NewPcloudNetworksPortsGetInternalServerError() *PcloudNetworksPortsGetInternalServerError { + return &PcloudNetworksPortsGetInternalServerError{} +} + +/* PcloudNetworksPortsGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudNetworksPortsGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudNetworksPortsGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}/ports/{port_id}][%d] pcloudNetworksPortsGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudNetworksPortsGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksPortsGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_ports_getall_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_ports_getall_parameters.go new file mode 100644 index 00000000000..bae1e68171f --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_ports_getall_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_networks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudNetworksPortsGetallParams creates a new PcloudNetworksPortsGetallParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudNetworksPortsGetallParams() *PcloudNetworksPortsGetallParams { + return &PcloudNetworksPortsGetallParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudNetworksPortsGetallParamsWithTimeout creates a new PcloudNetworksPortsGetallParams object +// with the ability to set a timeout on a request. +func NewPcloudNetworksPortsGetallParamsWithTimeout(timeout time.Duration) *PcloudNetworksPortsGetallParams { + return &PcloudNetworksPortsGetallParams{ + timeout: timeout, + } +} + +// NewPcloudNetworksPortsGetallParamsWithContext creates a new PcloudNetworksPortsGetallParams object +// with the ability to set a context for a request. +func NewPcloudNetworksPortsGetallParamsWithContext(ctx context.Context) *PcloudNetworksPortsGetallParams { + return &PcloudNetworksPortsGetallParams{ + Context: ctx, + } +} + +// NewPcloudNetworksPortsGetallParamsWithHTTPClient creates a new PcloudNetworksPortsGetallParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudNetworksPortsGetallParamsWithHTTPClient(client *http.Client) *PcloudNetworksPortsGetallParams { + return &PcloudNetworksPortsGetallParams{ + HTTPClient: client, + } +} + +/* PcloudNetworksPortsGetallParams contains all the parameters to send to the API endpoint + for the pcloud networks ports getall operation. + + Typically these are written to a http.Request. +*/ +type PcloudNetworksPortsGetallParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* NetworkID. + + Network ID + */ + NetworkID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud networks ports getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudNetworksPortsGetallParams) WithDefaults() *PcloudNetworksPortsGetallParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud networks ports getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudNetworksPortsGetallParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud networks ports getall params +func (o *PcloudNetworksPortsGetallParams) WithTimeout(timeout time.Duration) *PcloudNetworksPortsGetallParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud networks ports getall params +func (o *PcloudNetworksPortsGetallParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud networks ports getall params +func (o *PcloudNetworksPortsGetallParams) WithContext(ctx context.Context) *PcloudNetworksPortsGetallParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud networks ports getall params +func (o *PcloudNetworksPortsGetallParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud networks ports getall params +func (o *PcloudNetworksPortsGetallParams) WithHTTPClient(client *http.Client) *PcloudNetworksPortsGetallParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud networks ports getall params +func (o *PcloudNetworksPortsGetallParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud networks ports getall params +func (o *PcloudNetworksPortsGetallParams) WithCloudInstanceID(cloudInstanceID string) *PcloudNetworksPortsGetallParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud networks ports getall params +func (o *PcloudNetworksPortsGetallParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithNetworkID adds the networkID to the pcloud networks ports getall params +func (o *PcloudNetworksPortsGetallParams) WithNetworkID(networkID string) *PcloudNetworksPortsGetallParams { + o.SetNetworkID(networkID) + return o +} + +// SetNetworkID adds the networkId to the pcloud networks ports getall params +func (o *PcloudNetworksPortsGetallParams) SetNetworkID(networkID string) { + o.NetworkID = networkID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudNetworksPortsGetallParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param network_id + if err := r.SetPathParam("network_id", o.NetworkID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_ports_getall_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_ports_getall_responses.go new file mode 100644 index 00000000000..4c5a21006cf --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_ports_getall_responses.go @@ -0,0 +1,181 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_networks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudNetworksPortsGetallReader is a Reader for the PcloudNetworksPortsGetall structure. +type PcloudNetworksPortsGetallReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudNetworksPortsGetallReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudNetworksPortsGetallOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudNetworksPortsGetallBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudNetworksPortsGetallUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudNetworksPortsGetallInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudNetworksPortsGetallOK creates a PcloudNetworksPortsGetallOK with default headers values +func NewPcloudNetworksPortsGetallOK() *PcloudNetworksPortsGetallOK { + return &PcloudNetworksPortsGetallOK{} +} + +/* PcloudNetworksPortsGetallOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudNetworksPortsGetallOK struct { + Payload *models.NetworkPorts +} + +func (o *PcloudNetworksPortsGetallOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}/ports][%d] pcloudNetworksPortsGetallOK %+v", 200, o.Payload) +} +func (o *PcloudNetworksPortsGetallOK) GetPayload() *models.NetworkPorts { + return o.Payload +} + +func (o *PcloudNetworksPortsGetallOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.NetworkPorts) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksPortsGetallBadRequest creates a PcloudNetworksPortsGetallBadRequest with default headers values +func NewPcloudNetworksPortsGetallBadRequest() *PcloudNetworksPortsGetallBadRequest { + return &PcloudNetworksPortsGetallBadRequest{} +} + +/* PcloudNetworksPortsGetallBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudNetworksPortsGetallBadRequest struct { + Payload *models.Error +} + +func (o *PcloudNetworksPortsGetallBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}/ports][%d] pcloudNetworksPortsGetallBadRequest %+v", 400, o.Payload) +} +func (o *PcloudNetworksPortsGetallBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksPortsGetallBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksPortsGetallUnauthorized creates a PcloudNetworksPortsGetallUnauthorized with default headers values +func NewPcloudNetworksPortsGetallUnauthorized() *PcloudNetworksPortsGetallUnauthorized { + return &PcloudNetworksPortsGetallUnauthorized{} +} + +/* PcloudNetworksPortsGetallUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudNetworksPortsGetallUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudNetworksPortsGetallUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}/ports][%d] pcloudNetworksPortsGetallUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudNetworksPortsGetallUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksPortsGetallUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksPortsGetallInternalServerError creates a PcloudNetworksPortsGetallInternalServerError with default headers values +func NewPcloudNetworksPortsGetallInternalServerError() *PcloudNetworksPortsGetallInternalServerError { + return &PcloudNetworksPortsGetallInternalServerError{} +} + +/* PcloudNetworksPortsGetallInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudNetworksPortsGetallInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudNetworksPortsGetallInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}/ports][%d] pcloudNetworksPortsGetallInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudNetworksPortsGetallInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksPortsGetallInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_ports_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_ports_post_parameters.go new file mode 100644 index 00000000000..ffeb93590c3 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_ports_post_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_networks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudNetworksPortsPostParams creates a new PcloudNetworksPortsPostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudNetworksPortsPostParams() *PcloudNetworksPortsPostParams { + return &PcloudNetworksPortsPostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudNetworksPortsPostParamsWithTimeout creates a new PcloudNetworksPortsPostParams object +// with the ability to set a timeout on a request. +func NewPcloudNetworksPortsPostParamsWithTimeout(timeout time.Duration) *PcloudNetworksPortsPostParams { + return &PcloudNetworksPortsPostParams{ + timeout: timeout, + } +} + +// NewPcloudNetworksPortsPostParamsWithContext creates a new PcloudNetworksPortsPostParams object +// with the ability to set a context for a request. +func NewPcloudNetworksPortsPostParamsWithContext(ctx context.Context) *PcloudNetworksPortsPostParams { + return &PcloudNetworksPortsPostParams{ + Context: ctx, + } +} + +// NewPcloudNetworksPortsPostParamsWithHTTPClient creates a new PcloudNetworksPortsPostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudNetworksPortsPostParamsWithHTTPClient(client *http.Client) *PcloudNetworksPortsPostParams { + return &PcloudNetworksPortsPostParams{ + HTTPClient: client, + } +} + +/* PcloudNetworksPortsPostParams contains all the parameters to send to the API endpoint + for the pcloud networks ports post operation. + + Typically these are written to a http.Request. +*/ +type PcloudNetworksPortsPostParams struct { + + /* Body. + + Create a Network Port + */ + Body *models.NetworkPortCreate + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* NetworkID. + + Network ID + */ + NetworkID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud networks ports post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudNetworksPortsPostParams) WithDefaults() *PcloudNetworksPortsPostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud networks ports post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudNetworksPortsPostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud networks ports post params +func (o *PcloudNetworksPortsPostParams) WithTimeout(timeout time.Duration) *PcloudNetworksPortsPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud networks ports post params +func (o *PcloudNetworksPortsPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud networks ports post params +func (o *PcloudNetworksPortsPostParams) WithContext(ctx context.Context) *PcloudNetworksPortsPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud networks ports post params +func (o *PcloudNetworksPortsPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud networks ports post params +func (o *PcloudNetworksPortsPostParams) WithHTTPClient(client *http.Client) *PcloudNetworksPortsPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud networks ports post params +func (o *PcloudNetworksPortsPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud networks ports post params +func (o *PcloudNetworksPortsPostParams) WithBody(body *models.NetworkPortCreate) *PcloudNetworksPortsPostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud networks ports post params +func (o *PcloudNetworksPortsPostParams) SetBody(body *models.NetworkPortCreate) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud networks ports post params +func (o *PcloudNetworksPortsPostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudNetworksPortsPostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud networks ports post params +func (o *PcloudNetworksPortsPostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithNetworkID adds the networkID to the pcloud networks ports post params +func (o *PcloudNetworksPortsPostParams) WithNetworkID(networkID string) *PcloudNetworksPortsPostParams { + o.SetNetworkID(networkID) + return o +} + +// SetNetworkID adds the networkId to the pcloud networks ports post params +func (o *PcloudNetworksPortsPostParams) SetNetworkID(networkID string) { + o.NetworkID = networkID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudNetworksPortsPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param network_id + if err := r.SetPathParam("network_id", o.NetworkID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_ports_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_ports_post_responses.go new file mode 100644 index 00000000000..a284e8b3ac2 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_ports_post_responses.go @@ -0,0 +1,257 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_networks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudNetworksPortsPostReader is a Reader for the PcloudNetworksPortsPost structure. +type PcloudNetworksPortsPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudNetworksPortsPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 201: + result := NewPcloudNetworksPortsPostCreated() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudNetworksPortsPostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudNetworksPortsPostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewPcloudNetworksPortsPostConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudNetworksPortsPostUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudNetworksPortsPostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudNetworksPortsPostCreated creates a PcloudNetworksPortsPostCreated with default headers values +func NewPcloudNetworksPortsPostCreated() *PcloudNetworksPortsPostCreated { + return &PcloudNetworksPortsPostCreated{} +} + +/* PcloudNetworksPortsPostCreated describes a response with status code 201, with default header values. + +Created +*/ +type PcloudNetworksPortsPostCreated struct { + Payload *models.NetworkPort +} + +func (o *PcloudNetworksPortsPostCreated) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}/ports][%d] pcloudNetworksPortsPostCreated %+v", 201, o.Payload) +} +func (o *PcloudNetworksPortsPostCreated) GetPayload() *models.NetworkPort { + return o.Payload +} + +func (o *PcloudNetworksPortsPostCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.NetworkPort) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksPortsPostBadRequest creates a PcloudNetworksPortsPostBadRequest with default headers values +func NewPcloudNetworksPortsPostBadRequest() *PcloudNetworksPortsPostBadRequest { + return &PcloudNetworksPortsPostBadRequest{} +} + +/* PcloudNetworksPortsPostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudNetworksPortsPostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudNetworksPortsPostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}/ports][%d] pcloudNetworksPortsPostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudNetworksPortsPostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksPortsPostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksPortsPostUnauthorized creates a PcloudNetworksPortsPostUnauthorized with default headers values +func NewPcloudNetworksPortsPostUnauthorized() *PcloudNetworksPortsPostUnauthorized { + return &PcloudNetworksPortsPostUnauthorized{} +} + +/* PcloudNetworksPortsPostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudNetworksPortsPostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudNetworksPortsPostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}/ports][%d] pcloudNetworksPortsPostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudNetworksPortsPostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksPortsPostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksPortsPostConflict creates a PcloudNetworksPortsPostConflict with default headers values +func NewPcloudNetworksPortsPostConflict() *PcloudNetworksPortsPostConflict { + return &PcloudNetworksPortsPostConflict{} +} + +/* PcloudNetworksPortsPostConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type PcloudNetworksPortsPostConflict struct { + Payload *models.Error +} + +func (o *PcloudNetworksPortsPostConflict) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}/ports][%d] pcloudNetworksPortsPostConflict %+v", 409, o.Payload) +} +func (o *PcloudNetworksPortsPostConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksPortsPostConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksPortsPostUnprocessableEntity creates a PcloudNetworksPortsPostUnprocessableEntity with default headers values +func NewPcloudNetworksPortsPostUnprocessableEntity() *PcloudNetworksPortsPostUnprocessableEntity { + return &PcloudNetworksPortsPostUnprocessableEntity{} +} + +/* PcloudNetworksPortsPostUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudNetworksPortsPostUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudNetworksPortsPostUnprocessableEntity) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}/ports][%d] pcloudNetworksPortsPostUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudNetworksPortsPostUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksPortsPostUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksPortsPostInternalServerError creates a PcloudNetworksPortsPostInternalServerError with default headers values +func NewPcloudNetworksPortsPostInternalServerError() *PcloudNetworksPortsPostInternalServerError { + return &PcloudNetworksPortsPostInternalServerError{} +} + +/* PcloudNetworksPortsPostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudNetworksPortsPostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudNetworksPortsPostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}/ports][%d] pcloudNetworksPortsPostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudNetworksPortsPostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksPortsPostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_ports_put_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_ports_put_parameters.go new file mode 100644 index 00000000000..fce7c87e67f --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_ports_put_parameters.go @@ -0,0 +1,217 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_networks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudNetworksPortsPutParams creates a new PcloudNetworksPortsPutParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudNetworksPortsPutParams() *PcloudNetworksPortsPutParams { + return &PcloudNetworksPortsPutParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudNetworksPortsPutParamsWithTimeout creates a new PcloudNetworksPortsPutParams object +// with the ability to set a timeout on a request. +func NewPcloudNetworksPortsPutParamsWithTimeout(timeout time.Duration) *PcloudNetworksPortsPutParams { + return &PcloudNetworksPortsPutParams{ + timeout: timeout, + } +} + +// NewPcloudNetworksPortsPutParamsWithContext creates a new PcloudNetworksPortsPutParams object +// with the ability to set a context for a request. +func NewPcloudNetworksPortsPutParamsWithContext(ctx context.Context) *PcloudNetworksPortsPutParams { + return &PcloudNetworksPortsPutParams{ + Context: ctx, + } +} + +// NewPcloudNetworksPortsPutParamsWithHTTPClient creates a new PcloudNetworksPortsPutParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudNetworksPortsPutParamsWithHTTPClient(client *http.Client) *PcloudNetworksPortsPutParams { + return &PcloudNetworksPortsPutParams{ + HTTPClient: client, + } +} + +/* PcloudNetworksPortsPutParams contains all the parameters to send to the API endpoint + for the pcloud networks ports put operation. + + Typically these are written to a http.Request. +*/ +type PcloudNetworksPortsPutParams struct { + + /* Body. + + Parameters for updating a Port + */ + Body *models.NetworkPortUpdate + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* NetworkID. + + Network ID + */ + NetworkID string + + /* PortID. + + Port ID + */ + PortID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud networks ports put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudNetworksPortsPutParams) WithDefaults() *PcloudNetworksPortsPutParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud networks ports put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudNetworksPortsPutParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud networks ports put params +func (o *PcloudNetworksPortsPutParams) WithTimeout(timeout time.Duration) *PcloudNetworksPortsPutParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud networks ports put params +func (o *PcloudNetworksPortsPutParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud networks ports put params +func (o *PcloudNetworksPortsPutParams) WithContext(ctx context.Context) *PcloudNetworksPortsPutParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud networks ports put params +func (o *PcloudNetworksPortsPutParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud networks ports put params +func (o *PcloudNetworksPortsPutParams) WithHTTPClient(client *http.Client) *PcloudNetworksPortsPutParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud networks ports put params +func (o *PcloudNetworksPortsPutParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud networks ports put params +func (o *PcloudNetworksPortsPutParams) WithBody(body *models.NetworkPortUpdate) *PcloudNetworksPortsPutParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud networks ports put params +func (o *PcloudNetworksPortsPutParams) SetBody(body *models.NetworkPortUpdate) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud networks ports put params +func (o *PcloudNetworksPortsPutParams) WithCloudInstanceID(cloudInstanceID string) *PcloudNetworksPortsPutParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud networks ports put params +func (o *PcloudNetworksPortsPutParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithNetworkID adds the networkID to the pcloud networks ports put params +func (o *PcloudNetworksPortsPutParams) WithNetworkID(networkID string) *PcloudNetworksPortsPutParams { + o.SetNetworkID(networkID) + return o +} + +// SetNetworkID adds the networkId to the pcloud networks ports put params +func (o *PcloudNetworksPortsPutParams) SetNetworkID(networkID string) { + o.NetworkID = networkID +} + +// WithPortID adds the portID to the pcloud networks ports put params +func (o *PcloudNetworksPortsPutParams) WithPortID(portID string) *PcloudNetworksPortsPutParams { + o.SetPortID(portID) + return o +} + +// SetPortID adds the portId to the pcloud networks ports put params +func (o *PcloudNetworksPortsPutParams) SetPortID(portID string) { + o.PortID = portID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudNetworksPortsPutParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param network_id + if err := r.SetPathParam("network_id", o.NetworkID); err != nil { + return err + } + + // path param port_id + if err := r.SetPathParam("port_id", o.PortID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_ports_put_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_ports_put_responses.go new file mode 100644 index 00000000000..4fc8e47d290 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_ports_put_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_networks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudNetworksPortsPutReader is a Reader for the PcloudNetworksPortsPut structure. +type PcloudNetworksPortsPutReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudNetworksPortsPutReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudNetworksPortsPutOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudNetworksPortsPutBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudNetworksPortsPutUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudNetworksPortsPutUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudNetworksPortsPutInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudNetworksPortsPutOK creates a PcloudNetworksPortsPutOK with default headers values +func NewPcloudNetworksPortsPutOK() *PcloudNetworksPortsPutOK { + return &PcloudNetworksPortsPutOK{} +} + +/* PcloudNetworksPortsPutOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudNetworksPortsPutOK struct { + Payload *models.NetworkPort +} + +func (o *PcloudNetworksPortsPutOK) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}/ports/{port_id}][%d] pcloudNetworksPortsPutOK %+v", 200, o.Payload) +} +func (o *PcloudNetworksPortsPutOK) GetPayload() *models.NetworkPort { + return o.Payload +} + +func (o *PcloudNetworksPortsPutOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.NetworkPort) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksPortsPutBadRequest creates a PcloudNetworksPortsPutBadRequest with default headers values +func NewPcloudNetworksPortsPutBadRequest() *PcloudNetworksPortsPutBadRequest { + return &PcloudNetworksPortsPutBadRequest{} +} + +/* PcloudNetworksPortsPutBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudNetworksPortsPutBadRequest struct { + Payload *models.Error +} + +func (o *PcloudNetworksPortsPutBadRequest) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}/ports/{port_id}][%d] pcloudNetworksPortsPutBadRequest %+v", 400, o.Payload) +} +func (o *PcloudNetworksPortsPutBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksPortsPutBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksPortsPutUnauthorized creates a PcloudNetworksPortsPutUnauthorized with default headers values +func NewPcloudNetworksPortsPutUnauthorized() *PcloudNetworksPortsPutUnauthorized { + return &PcloudNetworksPortsPutUnauthorized{} +} + +/* PcloudNetworksPortsPutUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudNetworksPortsPutUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudNetworksPortsPutUnauthorized) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}/ports/{port_id}][%d] pcloudNetworksPortsPutUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudNetworksPortsPutUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksPortsPutUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksPortsPutUnprocessableEntity creates a PcloudNetworksPortsPutUnprocessableEntity with default headers values +func NewPcloudNetworksPortsPutUnprocessableEntity() *PcloudNetworksPortsPutUnprocessableEntity { + return &PcloudNetworksPortsPutUnprocessableEntity{} +} + +/* PcloudNetworksPortsPutUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudNetworksPortsPutUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudNetworksPortsPutUnprocessableEntity) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}/ports/{port_id}][%d] pcloudNetworksPortsPutUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudNetworksPortsPutUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksPortsPutUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksPortsPutInternalServerError creates a PcloudNetworksPortsPutInternalServerError with default headers values +func NewPcloudNetworksPortsPutInternalServerError() *PcloudNetworksPortsPutInternalServerError { + return &PcloudNetworksPortsPutInternalServerError{} +} + +/* PcloudNetworksPortsPutInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudNetworksPortsPutInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudNetworksPortsPutInternalServerError) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}/ports/{port_id}][%d] pcloudNetworksPortsPutInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudNetworksPortsPutInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksPortsPutInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_post_parameters.go new file mode 100644 index 00000000000..dea14d36adf --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_post_parameters.go @@ -0,0 +1,173 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_networks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudNetworksPostParams creates a new PcloudNetworksPostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudNetworksPostParams() *PcloudNetworksPostParams { + return &PcloudNetworksPostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudNetworksPostParamsWithTimeout creates a new PcloudNetworksPostParams object +// with the ability to set a timeout on a request. +func NewPcloudNetworksPostParamsWithTimeout(timeout time.Duration) *PcloudNetworksPostParams { + return &PcloudNetworksPostParams{ + timeout: timeout, + } +} + +// NewPcloudNetworksPostParamsWithContext creates a new PcloudNetworksPostParams object +// with the ability to set a context for a request. +func NewPcloudNetworksPostParamsWithContext(ctx context.Context) *PcloudNetworksPostParams { + return &PcloudNetworksPostParams{ + Context: ctx, + } +} + +// NewPcloudNetworksPostParamsWithHTTPClient creates a new PcloudNetworksPostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudNetworksPostParamsWithHTTPClient(client *http.Client) *PcloudNetworksPostParams { + return &PcloudNetworksPostParams{ + HTTPClient: client, + } +} + +/* PcloudNetworksPostParams contains all the parameters to send to the API endpoint + for the pcloud networks post operation. + + Typically these are written to a http.Request. +*/ +type PcloudNetworksPostParams struct { + + /* Body. + + Parameters for the creation of a new network + */ + Body *models.NetworkCreate + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud networks post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudNetworksPostParams) WithDefaults() *PcloudNetworksPostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud networks post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudNetworksPostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud networks post params +func (o *PcloudNetworksPostParams) WithTimeout(timeout time.Duration) *PcloudNetworksPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud networks post params +func (o *PcloudNetworksPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud networks post params +func (o *PcloudNetworksPostParams) WithContext(ctx context.Context) *PcloudNetworksPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud networks post params +func (o *PcloudNetworksPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud networks post params +func (o *PcloudNetworksPostParams) WithHTTPClient(client *http.Client) *PcloudNetworksPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud networks post params +func (o *PcloudNetworksPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud networks post params +func (o *PcloudNetworksPostParams) WithBody(body *models.NetworkCreate) *PcloudNetworksPostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud networks post params +func (o *PcloudNetworksPostParams) SetBody(body *models.NetworkCreate) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud networks post params +func (o *PcloudNetworksPostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudNetworksPostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud networks post params +func (o *PcloudNetworksPostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudNetworksPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_post_responses.go new file mode 100644 index 00000000000..27a0da33a61 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_post_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_networks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudNetworksPostReader is a Reader for the PcloudNetworksPost structure. +type PcloudNetworksPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudNetworksPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudNetworksPostOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 201: + result := NewPcloudNetworksPostCreated() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudNetworksPostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudNetworksPostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewPcloudNetworksPostConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudNetworksPostUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudNetworksPostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudNetworksPostOK creates a PcloudNetworksPostOK with default headers values +func NewPcloudNetworksPostOK() *PcloudNetworksPostOK { + return &PcloudNetworksPostOK{} +} + +/* PcloudNetworksPostOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudNetworksPostOK struct { + Payload *models.Network +} + +func (o *PcloudNetworksPostOK) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/networks][%d] pcloudNetworksPostOK %+v", 200, o.Payload) +} +func (o *PcloudNetworksPostOK) GetPayload() *models.Network { + return o.Payload +} + +func (o *PcloudNetworksPostOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Network) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksPostCreated creates a PcloudNetworksPostCreated with default headers values +func NewPcloudNetworksPostCreated() *PcloudNetworksPostCreated { + return &PcloudNetworksPostCreated{} +} + +/* PcloudNetworksPostCreated describes a response with status code 201, with default header values. + +Created +*/ +type PcloudNetworksPostCreated struct { + Payload *models.Network +} + +func (o *PcloudNetworksPostCreated) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/networks][%d] pcloudNetworksPostCreated %+v", 201, o.Payload) +} +func (o *PcloudNetworksPostCreated) GetPayload() *models.Network { + return o.Payload +} + +func (o *PcloudNetworksPostCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Network) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksPostBadRequest creates a PcloudNetworksPostBadRequest with default headers values +func NewPcloudNetworksPostBadRequest() *PcloudNetworksPostBadRequest { + return &PcloudNetworksPostBadRequest{} +} + +/* PcloudNetworksPostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudNetworksPostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudNetworksPostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/networks][%d] pcloudNetworksPostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudNetworksPostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksPostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksPostUnauthorized creates a PcloudNetworksPostUnauthorized with default headers values +func NewPcloudNetworksPostUnauthorized() *PcloudNetworksPostUnauthorized { + return &PcloudNetworksPostUnauthorized{} +} + +/* PcloudNetworksPostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudNetworksPostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudNetworksPostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/networks][%d] pcloudNetworksPostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudNetworksPostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksPostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksPostConflict creates a PcloudNetworksPostConflict with default headers values +func NewPcloudNetworksPostConflict() *PcloudNetworksPostConflict { + return &PcloudNetworksPostConflict{} +} + +/* PcloudNetworksPostConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type PcloudNetworksPostConflict struct { + Payload *models.Error +} + +func (o *PcloudNetworksPostConflict) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/networks][%d] pcloudNetworksPostConflict %+v", 409, o.Payload) +} +func (o *PcloudNetworksPostConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksPostConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksPostUnprocessableEntity creates a PcloudNetworksPostUnprocessableEntity with default headers values +func NewPcloudNetworksPostUnprocessableEntity() *PcloudNetworksPostUnprocessableEntity { + return &PcloudNetworksPostUnprocessableEntity{} +} + +/* PcloudNetworksPostUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudNetworksPostUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudNetworksPostUnprocessableEntity) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/networks][%d] pcloudNetworksPostUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudNetworksPostUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksPostUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksPostInternalServerError creates a PcloudNetworksPostInternalServerError with default headers values +func NewPcloudNetworksPostInternalServerError() *PcloudNetworksPostInternalServerError { + return &PcloudNetworksPostInternalServerError{} +} + +/* PcloudNetworksPostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudNetworksPostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudNetworksPostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/networks][%d] pcloudNetworksPostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudNetworksPostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksPostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_put_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_put_parameters.go new file mode 100644 index 00000000000..00ef70f90f8 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_put_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_networks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudNetworksPutParams creates a new PcloudNetworksPutParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudNetworksPutParams() *PcloudNetworksPutParams { + return &PcloudNetworksPutParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudNetworksPutParamsWithTimeout creates a new PcloudNetworksPutParams object +// with the ability to set a timeout on a request. +func NewPcloudNetworksPutParamsWithTimeout(timeout time.Duration) *PcloudNetworksPutParams { + return &PcloudNetworksPutParams{ + timeout: timeout, + } +} + +// NewPcloudNetworksPutParamsWithContext creates a new PcloudNetworksPutParams object +// with the ability to set a context for a request. +func NewPcloudNetworksPutParamsWithContext(ctx context.Context) *PcloudNetworksPutParams { + return &PcloudNetworksPutParams{ + Context: ctx, + } +} + +// NewPcloudNetworksPutParamsWithHTTPClient creates a new PcloudNetworksPutParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudNetworksPutParamsWithHTTPClient(client *http.Client) *PcloudNetworksPutParams { + return &PcloudNetworksPutParams{ + HTTPClient: client, + } +} + +/* PcloudNetworksPutParams contains all the parameters to send to the API endpoint + for the pcloud networks put operation. + + Typically these are written to a http.Request. +*/ +type PcloudNetworksPutParams struct { + + /* Body. + + Parameters to update a Network + */ + Body *models.NetworkUpdate + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* NetworkID. + + Network ID + */ + NetworkID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud networks put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudNetworksPutParams) WithDefaults() *PcloudNetworksPutParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud networks put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudNetworksPutParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud networks put params +func (o *PcloudNetworksPutParams) WithTimeout(timeout time.Duration) *PcloudNetworksPutParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud networks put params +func (o *PcloudNetworksPutParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud networks put params +func (o *PcloudNetworksPutParams) WithContext(ctx context.Context) *PcloudNetworksPutParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud networks put params +func (o *PcloudNetworksPutParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud networks put params +func (o *PcloudNetworksPutParams) WithHTTPClient(client *http.Client) *PcloudNetworksPutParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud networks put params +func (o *PcloudNetworksPutParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud networks put params +func (o *PcloudNetworksPutParams) WithBody(body *models.NetworkUpdate) *PcloudNetworksPutParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud networks put params +func (o *PcloudNetworksPutParams) SetBody(body *models.NetworkUpdate) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud networks put params +func (o *PcloudNetworksPutParams) WithCloudInstanceID(cloudInstanceID string) *PcloudNetworksPutParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud networks put params +func (o *PcloudNetworksPutParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithNetworkID adds the networkID to the pcloud networks put params +func (o *PcloudNetworksPutParams) WithNetworkID(networkID string) *PcloudNetworksPutParams { + o.SetNetworkID(networkID) + return o +} + +// SetNetworkID adds the networkId to the pcloud networks put params +func (o *PcloudNetworksPutParams) SetNetworkID(networkID string) { + o.NetworkID = networkID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudNetworksPutParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param network_id + if err := r.SetPathParam("network_id", o.NetworkID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_put_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_put_responses.go new file mode 100644 index 00000000000..935956e0abc --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks/pcloud_networks_put_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_networks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudNetworksPutReader is a Reader for the PcloudNetworksPut structure. +type PcloudNetworksPutReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudNetworksPutReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudNetworksPutOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudNetworksPutBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudNetworksPutUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudNetworksPutUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudNetworksPutInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudNetworksPutOK creates a PcloudNetworksPutOK with default headers values +func NewPcloudNetworksPutOK() *PcloudNetworksPutOK { + return &PcloudNetworksPutOK{} +} + +/* PcloudNetworksPutOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudNetworksPutOK struct { + Payload *models.Network +} + +func (o *PcloudNetworksPutOK) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}][%d] pcloudNetworksPutOK %+v", 200, o.Payload) +} +func (o *PcloudNetworksPutOK) GetPayload() *models.Network { + return o.Payload +} + +func (o *PcloudNetworksPutOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Network) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksPutBadRequest creates a PcloudNetworksPutBadRequest with default headers values +func NewPcloudNetworksPutBadRequest() *PcloudNetworksPutBadRequest { + return &PcloudNetworksPutBadRequest{} +} + +/* PcloudNetworksPutBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudNetworksPutBadRequest struct { + Payload *models.Error +} + +func (o *PcloudNetworksPutBadRequest) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}][%d] pcloudNetworksPutBadRequest %+v", 400, o.Payload) +} +func (o *PcloudNetworksPutBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksPutBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksPutUnauthorized creates a PcloudNetworksPutUnauthorized with default headers values +func NewPcloudNetworksPutUnauthorized() *PcloudNetworksPutUnauthorized { + return &PcloudNetworksPutUnauthorized{} +} + +/* PcloudNetworksPutUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudNetworksPutUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudNetworksPutUnauthorized) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}][%d] pcloudNetworksPutUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudNetworksPutUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksPutUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksPutUnprocessableEntity creates a PcloudNetworksPutUnprocessableEntity with default headers values +func NewPcloudNetworksPutUnprocessableEntity() *PcloudNetworksPutUnprocessableEntity { + return &PcloudNetworksPutUnprocessableEntity{} +} + +/* PcloudNetworksPutUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudNetworksPutUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudNetworksPutUnprocessableEntity) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}][%d] pcloudNetworksPutUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudNetworksPutUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksPutUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudNetworksPutInternalServerError creates a PcloudNetworksPutInternalServerError with default headers values +func NewPcloudNetworksPutInternalServerError() *PcloudNetworksPutInternalServerError { + return &PcloudNetworksPutInternalServerError{} +} + +/* PcloudNetworksPutInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudNetworksPutInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudNetworksPutInternalServerError) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}][%d] pcloudNetworksPutInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudNetworksPutInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudNetworksPutInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/p_cloudp_vm_instances_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/p_cloudp_vm_instances_client.go new file mode 100644 index 00000000000..4e52d968233 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/p_cloudp_vm_instances_client.go @@ -0,0 +1,904 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new p cloud p vm instances API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for p cloud p vm instances API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + PcloudPvminstancesActionPost(params *PcloudPvminstancesActionPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesActionPostOK, error) + + PcloudPvminstancesCapturePost(params *PcloudPvminstancesCapturePostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesCapturePostOK, *PcloudPvminstancesCapturePostAccepted, error) + + PcloudPvminstancesClonePost(params *PcloudPvminstancesClonePostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesClonePostAccepted, error) + + PcloudPvminstancesConsoleGet(params *PcloudPvminstancesConsoleGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesConsoleGetOK, error) + + PcloudPvminstancesConsolePost(params *PcloudPvminstancesConsolePostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesConsolePostCreated, error) + + PcloudPvminstancesConsolePut(params *PcloudPvminstancesConsolePutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesConsolePutOK, error) + + PcloudPvminstancesDelete(params *PcloudPvminstancesDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesDeleteOK, error) + + PcloudPvminstancesGet(params *PcloudPvminstancesGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesGetOK, error) + + PcloudPvminstancesGetall(params *PcloudPvminstancesGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesGetallOK, error) + + PcloudPvminstancesNetworksDelete(params *PcloudPvminstancesNetworksDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesNetworksDeleteOK, error) + + PcloudPvminstancesNetworksGet(params *PcloudPvminstancesNetworksGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesNetworksGetOK, error) + + PcloudPvminstancesNetworksGetall(params *PcloudPvminstancesNetworksGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesNetworksGetallOK, error) + + PcloudPvminstancesNetworksPost(params *PcloudPvminstancesNetworksPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesNetworksPostCreated, error) + + PcloudPvminstancesOperationsPost(params *PcloudPvminstancesOperationsPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesOperationsPostOK, error) + + PcloudPvminstancesPost(params *PcloudPvminstancesPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesPostOK, *PcloudPvminstancesPostCreated, *PcloudPvminstancesPostAccepted, error) + + PcloudPvminstancesPut(params *PcloudPvminstancesPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesPutAccepted, error) + + PcloudPvminstancesSnapshotsGetall(params *PcloudPvminstancesSnapshotsGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesSnapshotsGetallOK, error) + + PcloudPvminstancesSnapshotsPost(params *PcloudPvminstancesSnapshotsPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesSnapshotsPostAccepted, error) + + PcloudPvminstancesSnapshotsRestorePost(params *PcloudPvminstancesSnapshotsRestorePostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesSnapshotsRestorePostAccepted, error) + + PcloudV2PvminstancesCaptureGet(params *PcloudV2PvminstancesCaptureGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV2PvminstancesCaptureGetOK, error) + + PcloudV2PvminstancesCapturePost(params *PcloudV2PvminstancesCapturePostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV2PvminstancesCapturePostAccepted, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + PcloudPvminstancesActionPost performs an action start stop reboot immediate shutdown reset on a p VM instance +*/ +func (a *Client) PcloudPvminstancesActionPost(params *PcloudPvminstancesActionPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesActionPostOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudPvminstancesActionPostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.pvminstances.action.post", + Method: "POST", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/action", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudPvminstancesActionPostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudPvminstancesActionPostOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.pvminstances.action.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudPvminstancesCapturePost captures a p VM instance and create a deployable image +*/ +func (a *Client) PcloudPvminstancesCapturePost(params *PcloudPvminstancesCapturePostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesCapturePostOK, *PcloudPvminstancesCapturePostAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudPvminstancesCapturePostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.pvminstances.capture.post", + Method: "POST", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/capture", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudPvminstancesCapturePostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, nil, err + } + switch value := result.(type) { + case *PcloudPvminstancesCapturePostOK: + return value, nil, nil + case *PcloudPvminstancesCapturePostAccepted: + return nil, value, nil + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for p_cloud_p_vm_instances: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudPvminstancesClonePost clones a p VM instance +*/ +func (a *Client) PcloudPvminstancesClonePost(params *PcloudPvminstancesClonePostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesClonePostAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudPvminstancesClonePostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.pvminstances.clone.post", + Method: "POST", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/clone", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudPvminstancesClonePostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudPvminstancesClonePostAccepted) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.pvminstances.clone.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudPvminstancesConsoleGet lists all console languages +*/ +func (a *Client) PcloudPvminstancesConsoleGet(params *PcloudPvminstancesConsoleGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesConsoleGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudPvminstancesConsoleGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.pvminstances.console.get", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/console", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudPvminstancesConsoleGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudPvminstancesConsoleGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.pvminstances.console.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudPvminstancesConsolePost generates the no v n c console URL +*/ +func (a *Client) PcloudPvminstancesConsolePost(params *PcloudPvminstancesConsolePostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesConsolePostCreated, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudPvminstancesConsolePostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.pvminstances.console.post", + Method: "POST", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/console", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudPvminstancesConsolePostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudPvminstancesConsolePostCreated) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.pvminstances.console.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudPvminstancesConsolePut updates p VM instance console laguage code +*/ +func (a *Client) PcloudPvminstancesConsolePut(params *PcloudPvminstancesConsolePutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesConsolePutOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudPvminstancesConsolePutParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.pvminstances.console.put", + Method: "PUT", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/console", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudPvminstancesConsolePutReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudPvminstancesConsolePutOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.pvminstances.console.put: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudPvminstancesDelete deletes a p cloud p VM instance +*/ +func (a *Client) PcloudPvminstancesDelete(params *PcloudPvminstancesDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesDeleteOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudPvminstancesDeleteParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.pvminstances.delete", + Method: "DELETE", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudPvminstancesDeleteReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudPvminstancesDeleteOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.pvminstances.delete: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudPvminstancesGet gets a p VM instance s current state information +*/ +func (a *Client) PcloudPvminstancesGet(params *PcloudPvminstancesGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudPvminstancesGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.pvminstances.get", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudPvminstancesGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudPvminstancesGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.pvminstances.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudPvminstancesGetall gets all the pvm instances for this cloud instance +*/ +func (a *Client) PcloudPvminstancesGetall(params *PcloudPvminstancesGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesGetallOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudPvminstancesGetallParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.pvminstances.getall", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudPvminstancesGetallReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudPvminstancesGetallOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.pvminstances.getall: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudPvminstancesNetworksDelete removes all address of network from a p VM instance +*/ +func (a *Client) PcloudPvminstancesNetworksDelete(params *PcloudPvminstancesNetworksDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesNetworksDeleteOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudPvminstancesNetworksDeleteParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.pvminstances.networks.delete", + Method: "DELETE", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/networks/{network_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudPvminstancesNetworksDeleteReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudPvminstancesNetworksDeleteOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.pvminstances.networks.delete: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudPvminstancesNetworksGet gets a p VM instance s network information +*/ +func (a *Client) PcloudPvminstancesNetworksGet(params *PcloudPvminstancesNetworksGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesNetworksGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudPvminstancesNetworksGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.pvminstances.networks.get", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/networks/{network_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudPvminstancesNetworksGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudPvminstancesNetworksGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.pvminstances.networks.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudPvminstancesNetworksGetall gets all networks for this p VM instance +*/ +func (a *Client) PcloudPvminstancesNetworksGetall(params *PcloudPvminstancesNetworksGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesNetworksGetallOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudPvminstancesNetworksGetallParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.pvminstances.networks.getall", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/networks", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudPvminstancesNetworksGetallReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudPvminstancesNetworksGetallOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.pvminstances.networks.getall: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudPvminstancesNetworksPost performs network addition +*/ +func (a *Client) PcloudPvminstancesNetworksPost(params *PcloudPvminstancesNetworksPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesNetworksPostCreated, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudPvminstancesNetworksPostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.pvminstances.networks.post", + Method: "POST", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/networks", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudPvminstancesNetworksPostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudPvminstancesNetworksPostCreated) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.pvminstances.networks.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudPvminstancesOperationsPost performs an operation on a p VM instance +*/ +func (a *Client) PcloudPvminstancesOperationsPost(params *PcloudPvminstancesOperationsPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesOperationsPostOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudPvminstancesOperationsPostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.pvminstances.operations.post", + Method: "POST", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/operations", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudPvminstancesOperationsPostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudPvminstancesOperationsPostOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.pvminstances.operations.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudPvminstancesPost creates a new power VM instance +*/ +func (a *Client) PcloudPvminstancesPost(params *PcloudPvminstancesPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesPostOK, *PcloudPvminstancesPostCreated, *PcloudPvminstancesPostAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudPvminstancesPostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.pvminstances.post", + Method: "POST", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudPvminstancesPostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, nil, nil, err + } + switch value := result.(type) { + case *PcloudPvminstancesPostOK: + return value, nil, nil, nil + case *PcloudPvminstancesPostCreated: + return nil, value, nil, nil + case *PcloudPvminstancesPostAccepted: + return nil, nil, value, nil + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for p_cloud_p_vm_instances: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudPvminstancesPut updates a p cloud p VM instance +*/ +func (a *Client) PcloudPvminstancesPut(params *PcloudPvminstancesPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesPutAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudPvminstancesPutParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.pvminstances.put", + Method: "PUT", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudPvminstancesPutReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudPvminstancesPutAccepted) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.pvminstances.put: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudPvminstancesSnapshotsGetall gets all snapshots for this p VM instance +*/ +func (a *Client) PcloudPvminstancesSnapshotsGetall(params *PcloudPvminstancesSnapshotsGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesSnapshotsGetallOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudPvminstancesSnapshotsGetallParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.pvminstances.snapshots.getall", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/snapshots", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudPvminstancesSnapshotsGetallReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudPvminstancesSnapshotsGetallOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.pvminstances.snapshots.getall: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudPvminstancesSnapshotsPost creates a p VM instance snapshot +*/ +func (a *Client) PcloudPvminstancesSnapshotsPost(params *PcloudPvminstancesSnapshotsPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesSnapshotsPostAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudPvminstancesSnapshotsPostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.pvminstances.snapshots.post", + Method: "POST", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/snapshots", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudPvminstancesSnapshotsPostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudPvminstancesSnapshotsPostAccepted) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.pvminstances.snapshots.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudPvminstancesSnapshotsRestorePost restores a p VM instance snapshot +*/ +func (a *Client) PcloudPvminstancesSnapshotsRestorePost(params *PcloudPvminstancesSnapshotsRestorePostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesSnapshotsRestorePostAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudPvminstancesSnapshotsRestorePostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.pvminstances.snapshots.restore.post", + Method: "POST", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/snapshots/{snapshot_id}/restore", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudPvminstancesSnapshotsRestorePostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudPvminstancesSnapshotsRestorePostAccepted) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.pvminstances.snapshots.restore.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudV2PvminstancesCaptureGet gets detail of last capture job +*/ +func (a *Client) PcloudV2PvminstancesCaptureGet(params *PcloudV2PvminstancesCaptureGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV2PvminstancesCaptureGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudV2PvminstancesCaptureGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.v2.pvminstances.capture.get", + Method: "GET", + PathPattern: "/pcloud/v2/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/capture", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudV2PvminstancesCaptureGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudV2PvminstancesCaptureGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.v2.pvminstances.capture.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudV2PvminstancesCapturePost adds a capture pvm instance to the jobs queue +*/ +func (a *Client) PcloudV2PvminstancesCapturePost(params *PcloudV2PvminstancesCapturePostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV2PvminstancesCapturePostAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudV2PvminstancesCapturePostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.v2.pvminstances.capture.post", + Method: "POST", + PathPattern: "/pcloud/v2/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/capture", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudV2PvminstancesCapturePostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudV2PvminstancesCapturePostAccepted) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.v2.pvminstances.capture.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_action_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_action_post_parameters.go new file mode 100644 index 00000000000..27ae8aa3274 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_action_post_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudPvminstancesActionPostParams creates a new PcloudPvminstancesActionPostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudPvminstancesActionPostParams() *PcloudPvminstancesActionPostParams { + return &PcloudPvminstancesActionPostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudPvminstancesActionPostParamsWithTimeout creates a new PcloudPvminstancesActionPostParams object +// with the ability to set a timeout on a request. +func NewPcloudPvminstancesActionPostParamsWithTimeout(timeout time.Duration) *PcloudPvminstancesActionPostParams { + return &PcloudPvminstancesActionPostParams{ + timeout: timeout, + } +} + +// NewPcloudPvminstancesActionPostParamsWithContext creates a new PcloudPvminstancesActionPostParams object +// with the ability to set a context for a request. +func NewPcloudPvminstancesActionPostParamsWithContext(ctx context.Context) *PcloudPvminstancesActionPostParams { + return &PcloudPvminstancesActionPostParams{ + Context: ctx, + } +} + +// NewPcloudPvminstancesActionPostParamsWithHTTPClient creates a new PcloudPvminstancesActionPostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudPvminstancesActionPostParamsWithHTTPClient(client *http.Client) *PcloudPvminstancesActionPostParams { + return &PcloudPvminstancesActionPostParams{ + HTTPClient: client, + } +} + +/* PcloudPvminstancesActionPostParams contains all the parameters to send to the API endpoint + for the pcloud pvminstances action post operation. + + Typically these are written to a http.Request. +*/ +type PcloudPvminstancesActionPostParams struct { + + /* Body. + + Parameters for the desired action + */ + Body *models.PVMInstanceAction + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* PvmInstanceID. + + PCloud PVM Instance ID + */ + PvmInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud pvminstances action post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesActionPostParams) WithDefaults() *PcloudPvminstancesActionPostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud pvminstances action post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesActionPostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud pvminstances action post params +func (o *PcloudPvminstancesActionPostParams) WithTimeout(timeout time.Duration) *PcloudPvminstancesActionPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud pvminstances action post params +func (o *PcloudPvminstancesActionPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud pvminstances action post params +func (o *PcloudPvminstancesActionPostParams) WithContext(ctx context.Context) *PcloudPvminstancesActionPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud pvminstances action post params +func (o *PcloudPvminstancesActionPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud pvminstances action post params +func (o *PcloudPvminstancesActionPostParams) WithHTTPClient(client *http.Client) *PcloudPvminstancesActionPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud pvminstances action post params +func (o *PcloudPvminstancesActionPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud pvminstances action post params +func (o *PcloudPvminstancesActionPostParams) WithBody(body *models.PVMInstanceAction) *PcloudPvminstancesActionPostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud pvminstances action post params +func (o *PcloudPvminstancesActionPostParams) SetBody(body *models.PVMInstanceAction) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud pvminstances action post params +func (o *PcloudPvminstancesActionPostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudPvminstancesActionPostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud pvminstances action post params +func (o *PcloudPvminstancesActionPostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithPvmInstanceID adds the pvmInstanceID to the pcloud pvminstances action post params +func (o *PcloudPvminstancesActionPostParams) WithPvmInstanceID(pvmInstanceID string) *PcloudPvminstancesActionPostParams { + o.SetPvmInstanceID(pvmInstanceID) + return o +} + +// SetPvmInstanceID adds the pvmInstanceId to the pcloud pvminstances action post params +func (o *PcloudPvminstancesActionPostParams) SetPvmInstanceID(pvmInstanceID string) { + o.PvmInstanceID = pvmInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudPvminstancesActionPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param pvm_instance_id + if err := r.SetPathParam("pvm_instance_id", o.PvmInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_action_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_action_post_responses.go new file mode 100644 index 00000000000..3f0e3a3f825 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_action_post_responses.go @@ -0,0 +1,217 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudPvminstancesActionPostReader is a Reader for the PcloudPvminstancesActionPost structure. +type PcloudPvminstancesActionPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudPvminstancesActionPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudPvminstancesActionPostOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudPvminstancesActionPostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudPvminstancesActionPostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudPvminstancesActionPostNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudPvminstancesActionPostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudPvminstancesActionPostOK creates a PcloudPvminstancesActionPostOK with default headers values +func NewPcloudPvminstancesActionPostOK() *PcloudPvminstancesActionPostOK { + return &PcloudPvminstancesActionPostOK{} +} + +/* PcloudPvminstancesActionPostOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudPvminstancesActionPostOK struct { + Payload models.Object +} + +func (o *PcloudPvminstancesActionPostOK) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/action][%d] pcloudPvminstancesActionPostOK %+v", 200, o.Payload) +} +func (o *PcloudPvminstancesActionPostOK) GetPayload() models.Object { + return o.Payload +} + +func (o *PcloudPvminstancesActionPostOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesActionPostBadRequest creates a PcloudPvminstancesActionPostBadRequest with default headers values +func NewPcloudPvminstancesActionPostBadRequest() *PcloudPvminstancesActionPostBadRequest { + return &PcloudPvminstancesActionPostBadRequest{} +} + +/* PcloudPvminstancesActionPostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudPvminstancesActionPostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesActionPostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/action][%d] pcloudPvminstancesActionPostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudPvminstancesActionPostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesActionPostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesActionPostUnauthorized creates a PcloudPvminstancesActionPostUnauthorized with default headers values +func NewPcloudPvminstancesActionPostUnauthorized() *PcloudPvminstancesActionPostUnauthorized { + return &PcloudPvminstancesActionPostUnauthorized{} +} + +/* PcloudPvminstancesActionPostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudPvminstancesActionPostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesActionPostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/action][%d] pcloudPvminstancesActionPostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudPvminstancesActionPostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesActionPostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesActionPostNotFound creates a PcloudPvminstancesActionPostNotFound with default headers values +func NewPcloudPvminstancesActionPostNotFound() *PcloudPvminstancesActionPostNotFound { + return &PcloudPvminstancesActionPostNotFound{} +} + +/* PcloudPvminstancesActionPostNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudPvminstancesActionPostNotFound struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesActionPostNotFound) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/action][%d] pcloudPvminstancesActionPostNotFound %+v", 404, o.Payload) +} +func (o *PcloudPvminstancesActionPostNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesActionPostNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesActionPostInternalServerError creates a PcloudPvminstancesActionPostInternalServerError with default headers values +func NewPcloudPvminstancesActionPostInternalServerError() *PcloudPvminstancesActionPostInternalServerError { + return &PcloudPvminstancesActionPostInternalServerError{} +} + +/* PcloudPvminstancesActionPostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudPvminstancesActionPostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesActionPostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/action][%d] pcloudPvminstancesActionPostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudPvminstancesActionPostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesActionPostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_capture_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_capture_post_parameters.go new file mode 100644 index 00000000000..501695e66b3 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_capture_post_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudPvminstancesCapturePostParams creates a new PcloudPvminstancesCapturePostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudPvminstancesCapturePostParams() *PcloudPvminstancesCapturePostParams { + return &PcloudPvminstancesCapturePostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudPvminstancesCapturePostParamsWithTimeout creates a new PcloudPvminstancesCapturePostParams object +// with the ability to set a timeout on a request. +func NewPcloudPvminstancesCapturePostParamsWithTimeout(timeout time.Duration) *PcloudPvminstancesCapturePostParams { + return &PcloudPvminstancesCapturePostParams{ + timeout: timeout, + } +} + +// NewPcloudPvminstancesCapturePostParamsWithContext creates a new PcloudPvminstancesCapturePostParams object +// with the ability to set a context for a request. +func NewPcloudPvminstancesCapturePostParamsWithContext(ctx context.Context) *PcloudPvminstancesCapturePostParams { + return &PcloudPvminstancesCapturePostParams{ + Context: ctx, + } +} + +// NewPcloudPvminstancesCapturePostParamsWithHTTPClient creates a new PcloudPvminstancesCapturePostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudPvminstancesCapturePostParamsWithHTTPClient(client *http.Client) *PcloudPvminstancesCapturePostParams { + return &PcloudPvminstancesCapturePostParams{ + HTTPClient: client, + } +} + +/* PcloudPvminstancesCapturePostParams contains all the parameters to send to the API endpoint + for the pcloud pvminstances capture post operation. + + Typically these are written to a http.Request. +*/ +type PcloudPvminstancesCapturePostParams struct { + + /* Body. + + Parameters for the capture PVMInstance + */ + Body *models.PVMInstanceCapture + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* PvmInstanceID. + + PCloud PVM Instance ID + */ + PvmInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud pvminstances capture post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesCapturePostParams) WithDefaults() *PcloudPvminstancesCapturePostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud pvminstances capture post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesCapturePostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud pvminstances capture post params +func (o *PcloudPvminstancesCapturePostParams) WithTimeout(timeout time.Duration) *PcloudPvminstancesCapturePostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud pvminstances capture post params +func (o *PcloudPvminstancesCapturePostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud pvminstances capture post params +func (o *PcloudPvminstancesCapturePostParams) WithContext(ctx context.Context) *PcloudPvminstancesCapturePostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud pvminstances capture post params +func (o *PcloudPvminstancesCapturePostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud pvminstances capture post params +func (o *PcloudPvminstancesCapturePostParams) WithHTTPClient(client *http.Client) *PcloudPvminstancesCapturePostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud pvminstances capture post params +func (o *PcloudPvminstancesCapturePostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud pvminstances capture post params +func (o *PcloudPvminstancesCapturePostParams) WithBody(body *models.PVMInstanceCapture) *PcloudPvminstancesCapturePostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud pvminstances capture post params +func (o *PcloudPvminstancesCapturePostParams) SetBody(body *models.PVMInstanceCapture) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud pvminstances capture post params +func (o *PcloudPvminstancesCapturePostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudPvminstancesCapturePostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud pvminstances capture post params +func (o *PcloudPvminstancesCapturePostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithPvmInstanceID adds the pvmInstanceID to the pcloud pvminstances capture post params +func (o *PcloudPvminstancesCapturePostParams) WithPvmInstanceID(pvmInstanceID string) *PcloudPvminstancesCapturePostParams { + o.SetPvmInstanceID(pvmInstanceID) + return o +} + +// SetPvmInstanceID adds the pvmInstanceId to the pcloud pvminstances capture post params +func (o *PcloudPvminstancesCapturePostParams) SetPvmInstanceID(pvmInstanceID string) { + o.PvmInstanceID = pvmInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudPvminstancesCapturePostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param pvm_instance_id + if err := r.SetPathParam("pvm_instance_id", o.PvmInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_capture_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_capture_post_responses.go new file mode 100644 index 00000000000..436187f56ac --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_capture_post_responses.go @@ -0,0 +1,253 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudPvminstancesCapturePostReader is a Reader for the PcloudPvminstancesCapturePost structure. +type PcloudPvminstancesCapturePostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudPvminstancesCapturePostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudPvminstancesCapturePostOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 202: + result := NewPcloudPvminstancesCapturePostAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudPvminstancesCapturePostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudPvminstancesCapturePostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudPvminstancesCapturePostUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudPvminstancesCapturePostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudPvminstancesCapturePostOK creates a PcloudPvminstancesCapturePostOK with default headers values +func NewPcloudPvminstancesCapturePostOK() *PcloudPvminstancesCapturePostOK { + return &PcloudPvminstancesCapturePostOK{} +} + +/* PcloudPvminstancesCapturePostOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudPvminstancesCapturePostOK struct { + Payload models.Object +} + +func (o *PcloudPvminstancesCapturePostOK) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/capture][%d] pcloudPvminstancesCapturePostOK %+v", 200, o.Payload) +} +func (o *PcloudPvminstancesCapturePostOK) GetPayload() models.Object { + return o.Payload +} + +func (o *PcloudPvminstancesCapturePostOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesCapturePostAccepted creates a PcloudPvminstancesCapturePostAccepted with default headers values +func NewPcloudPvminstancesCapturePostAccepted() *PcloudPvminstancesCapturePostAccepted { + return &PcloudPvminstancesCapturePostAccepted{} +} + +/* PcloudPvminstancesCapturePostAccepted describes a response with status code 202, with default header values. + +Accepted, upload to cloud storage in progress +*/ +type PcloudPvminstancesCapturePostAccepted struct { + Payload models.Object +} + +func (o *PcloudPvminstancesCapturePostAccepted) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/capture][%d] pcloudPvminstancesCapturePostAccepted %+v", 202, o.Payload) +} +func (o *PcloudPvminstancesCapturePostAccepted) GetPayload() models.Object { + return o.Payload +} + +func (o *PcloudPvminstancesCapturePostAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesCapturePostBadRequest creates a PcloudPvminstancesCapturePostBadRequest with default headers values +func NewPcloudPvminstancesCapturePostBadRequest() *PcloudPvminstancesCapturePostBadRequest { + return &PcloudPvminstancesCapturePostBadRequest{} +} + +/* PcloudPvminstancesCapturePostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudPvminstancesCapturePostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesCapturePostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/capture][%d] pcloudPvminstancesCapturePostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudPvminstancesCapturePostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesCapturePostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesCapturePostUnauthorized creates a PcloudPvminstancesCapturePostUnauthorized with default headers values +func NewPcloudPvminstancesCapturePostUnauthorized() *PcloudPvminstancesCapturePostUnauthorized { + return &PcloudPvminstancesCapturePostUnauthorized{} +} + +/* PcloudPvminstancesCapturePostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudPvminstancesCapturePostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesCapturePostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/capture][%d] pcloudPvminstancesCapturePostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudPvminstancesCapturePostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesCapturePostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesCapturePostUnprocessableEntity creates a PcloudPvminstancesCapturePostUnprocessableEntity with default headers values +func NewPcloudPvminstancesCapturePostUnprocessableEntity() *PcloudPvminstancesCapturePostUnprocessableEntity { + return &PcloudPvminstancesCapturePostUnprocessableEntity{} +} + +/* PcloudPvminstancesCapturePostUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudPvminstancesCapturePostUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesCapturePostUnprocessableEntity) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/capture][%d] pcloudPvminstancesCapturePostUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudPvminstancesCapturePostUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesCapturePostUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesCapturePostInternalServerError creates a PcloudPvminstancesCapturePostInternalServerError with default headers values +func NewPcloudPvminstancesCapturePostInternalServerError() *PcloudPvminstancesCapturePostInternalServerError { + return &PcloudPvminstancesCapturePostInternalServerError{} +} + +/* PcloudPvminstancesCapturePostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudPvminstancesCapturePostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesCapturePostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/capture][%d] pcloudPvminstancesCapturePostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudPvminstancesCapturePostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesCapturePostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_clone_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_clone_post_parameters.go new file mode 100644 index 00000000000..b51625f4cec --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_clone_post_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudPvminstancesClonePostParams creates a new PcloudPvminstancesClonePostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudPvminstancesClonePostParams() *PcloudPvminstancesClonePostParams { + return &PcloudPvminstancesClonePostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudPvminstancesClonePostParamsWithTimeout creates a new PcloudPvminstancesClonePostParams object +// with the ability to set a timeout on a request. +func NewPcloudPvminstancesClonePostParamsWithTimeout(timeout time.Duration) *PcloudPvminstancesClonePostParams { + return &PcloudPvminstancesClonePostParams{ + timeout: timeout, + } +} + +// NewPcloudPvminstancesClonePostParamsWithContext creates a new PcloudPvminstancesClonePostParams object +// with the ability to set a context for a request. +func NewPcloudPvminstancesClonePostParamsWithContext(ctx context.Context) *PcloudPvminstancesClonePostParams { + return &PcloudPvminstancesClonePostParams{ + Context: ctx, + } +} + +// NewPcloudPvminstancesClonePostParamsWithHTTPClient creates a new PcloudPvminstancesClonePostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudPvminstancesClonePostParamsWithHTTPClient(client *http.Client) *PcloudPvminstancesClonePostParams { + return &PcloudPvminstancesClonePostParams{ + HTTPClient: client, + } +} + +/* PcloudPvminstancesClonePostParams contains all the parameters to send to the API endpoint + for the pcloud pvminstances clone post operation. + + Typically these are written to a http.Request. +*/ +type PcloudPvminstancesClonePostParams struct { + + /* Body. + + Clone PVM Instance parameters + */ + Body *models.PVMInstanceClone + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* PvmInstanceID. + + PCloud PVM Instance ID + */ + PvmInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud pvminstances clone post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesClonePostParams) WithDefaults() *PcloudPvminstancesClonePostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud pvminstances clone post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesClonePostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud pvminstances clone post params +func (o *PcloudPvminstancesClonePostParams) WithTimeout(timeout time.Duration) *PcloudPvminstancesClonePostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud pvminstances clone post params +func (o *PcloudPvminstancesClonePostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud pvminstances clone post params +func (o *PcloudPvminstancesClonePostParams) WithContext(ctx context.Context) *PcloudPvminstancesClonePostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud pvminstances clone post params +func (o *PcloudPvminstancesClonePostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud pvminstances clone post params +func (o *PcloudPvminstancesClonePostParams) WithHTTPClient(client *http.Client) *PcloudPvminstancesClonePostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud pvminstances clone post params +func (o *PcloudPvminstancesClonePostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud pvminstances clone post params +func (o *PcloudPvminstancesClonePostParams) WithBody(body *models.PVMInstanceClone) *PcloudPvminstancesClonePostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud pvminstances clone post params +func (o *PcloudPvminstancesClonePostParams) SetBody(body *models.PVMInstanceClone) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud pvminstances clone post params +func (o *PcloudPvminstancesClonePostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudPvminstancesClonePostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud pvminstances clone post params +func (o *PcloudPvminstancesClonePostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithPvmInstanceID adds the pvmInstanceID to the pcloud pvminstances clone post params +func (o *PcloudPvminstancesClonePostParams) WithPvmInstanceID(pvmInstanceID string) *PcloudPvminstancesClonePostParams { + o.SetPvmInstanceID(pvmInstanceID) + return o +} + +// SetPvmInstanceID adds the pvmInstanceId to the pcloud pvminstances clone post params +func (o *PcloudPvminstancesClonePostParams) SetPvmInstanceID(pvmInstanceID string) { + o.PvmInstanceID = pvmInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudPvminstancesClonePostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param pvm_instance_id + if err := r.SetPathParam("pvm_instance_id", o.PvmInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_clone_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_clone_post_responses.go new file mode 100644 index 00000000000..4d4e0510a68 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_clone_post_responses.go @@ -0,0 +1,257 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudPvminstancesClonePostReader is a Reader for the PcloudPvminstancesClonePost structure. +type PcloudPvminstancesClonePostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudPvminstancesClonePostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 202: + result := NewPcloudPvminstancesClonePostAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudPvminstancesClonePostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudPvminstancesClonePostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewPcloudPvminstancesClonePostConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudPvminstancesClonePostUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudPvminstancesClonePostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudPvminstancesClonePostAccepted creates a PcloudPvminstancesClonePostAccepted with default headers values +func NewPcloudPvminstancesClonePostAccepted() *PcloudPvminstancesClonePostAccepted { + return &PcloudPvminstancesClonePostAccepted{} +} + +/* PcloudPvminstancesClonePostAccepted describes a response with status code 202, with default header values. + +Accepted +*/ +type PcloudPvminstancesClonePostAccepted struct { + Payload *models.PVMInstance +} + +func (o *PcloudPvminstancesClonePostAccepted) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/clone][%d] pcloudPvminstancesClonePostAccepted %+v", 202, o.Payload) +} +func (o *PcloudPvminstancesClonePostAccepted) GetPayload() *models.PVMInstance { + return o.Payload +} + +func (o *PcloudPvminstancesClonePostAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.PVMInstance) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesClonePostBadRequest creates a PcloudPvminstancesClonePostBadRequest with default headers values +func NewPcloudPvminstancesClonePostBadRequest() *PcloudPvminstancesClonePostBadRequest { + return &PcloudPvminstancesClonePostBadRequest{} +} + +/* PcloudPvminstancesClonePostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudPvminstancesClonePostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesClonePostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/clone][%d] pcloudPvminstancesClonePostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudPvminstancesClonePostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesClonePostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesClonePostUnauthorized creates a PcloudPvminstancesClonePostUnauthorized with default headers values +func NewPcloudPvminstancesClonePostUnauthorized() *PcloudPvminstancesClonePostUnauthorized { + return &PcloudPvminstancesClonePostUnauthorized{} +} + +/* PcloudPvminstancesClonePostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudPvminstancesClonePostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesClonePostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/clone][%d] pcloudPvminstancesClonePostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudPvminstancesClonePostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesClonePostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesClonePostConflict creates a PcloudPvminstancesClonePostConflict with default headers values +func NewPcloudPvminstancesClonePostConflict() *PcloudPvminstancesClonePostConflict { + return &PcloudPvminstancesClonePostConflict{} +} + +/* PcloudPvminstancesClonePostConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type PcloudPvminstancesClonePostConflict struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesClonePostConflict) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/clone][%d] pcloudPvminstancesClonePostConflict %+v", 409, o.Payload) +} +func (o *PcloudPvminstancesClonePostConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesClonePostConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesClonePostUnprocessableEntity creates a PcloudPvminstancesClonePostUnprocessableEntity with default headers values +func NewPcloudPvminstancesClonePostUnprocessableEntity() *PcloudPvminstancesClonePostUnprocessableEntity { + return &PcloudPvminstancesClonePostUnprocessableEntity{} +} + +/* PcloudPvminstancesClonePostUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudPvminstancesClonePostUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesClonePostUnprocessableEntity) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/clone][%d] pcloudPvminstancesClonePostUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudPvminstancesClonePostUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesClonePostUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesClonePostInternalServerError creates a PcloudPvminstancesClonePostInternalServerError with default headers values +func NewPcloudPvminstancesClonePostInternalServerError() *PcloudPvminstancesClonePostInternalServerError { + return &PcloudPvminstancesClonePostInternalServerError{} +} + +/* PcloudPvminstancesClonePostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudPvminstancesClonePostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesClonePostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/clone][%d] pcloudPvminstancesClonePostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudPvminstancesClonePostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesClonePostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_console_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_console_get_parameters.go new file mode 100644 index 00000000000..80d994b2c28 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_console_get_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudPvminstancesConsoleGetParams creates a new PcloudPvminstancesConsoleGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudPvminstancesConsoleGetParams() *PcloudPvminstancesConsoleGetParams { + return &PcloudPvminstancesConsoleGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudPvminstancesConsoleGetParamsWithTimeout creates a new PcloudPvminstancesConsoleGetParams object +// with the ability to set a timeout on a request. +func NewPcloudPvminstancesConsoleGetParamsWithTimeout(timeout time.Duration) *PcloudPvminstancesConsoleGetParams { + return &PcloudPvminstancesConsoleGetParams{ + timeout: timeout, + } +} + +// NewPcloudPvminstancesConsoleGetParamsWithContext creates a new PcloudPvminstancesConsoleGetParams object +// with the ability to set a context for a request. +func NewPcloudPvminstancesConsoleGetParamsWithContext(ctx context.Context) *PcloudPvminstancesConsoleGetParams { + return &PcloudPvminstancesConsoleGetParams{ + Context: ctx, + } +} + +// NewPcloudPvminstancesConsoleGetParamsWithHTTPClient creates a new PcloudPvminstancesConsoleGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudPvminstancesConsoleGetParamsWithHTTPClient(client *http.Client) *PcloudPvminstancesConsoleGetParams { + return &PcloudPvminstancesConsoleGetParams{ + HTTPClient: client, + } +} + +/* PcloudPvminstancesConsoleGetParams contains all the parameters to send to the API endpoint + for the pcloud pvminstances console get operation. + + Typically these are written to a http.Request. +*/ +type PcloudPvminstancesConsoleGetParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* PvmInstanceID. + + PCloud PVM Instance ID + */ + PvmInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud pvminstances console get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesConsoleGetParams) WithDefaults() *PcloudPvminstancesConsoleGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud pvminstances console get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesConsoleGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud pvminstances console get params +func (o *PcloudPvminstancesConsoleGetParams) WithTimeout(timeout time.Duration) *PcloudPvminstancesConsoleGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud pvminstances console get params +func (o *PcloudPvminstancesConsoleGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud pvminstances console get params +func (o *PcloudPvminstancesConsoleGetParams) WithContext(ctx context.Context) *PcloudPvminstancesConsoleGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud pvminstances console get params +func (o *PcloudPvminstancesConsoleGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud pvminstances console get params +func (o *PcloudPvminstancesConsoleGetParams) WithHTTPClient(client *http.Client) *PcloudPvminstancesConsoleGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud pvminstances console get params +func (o *PcloudPvminstancesConsoleGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud pvminstances console get params +func (o *PcloudPvminstancesConsoleGetParams) WithCloudInstanceID(cloudInstanceID string) *PcloudPvminstancesConsoleGetParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud pvminstances console get params +func (o *PcloudPvminstancesConsoleGetParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithPvmInstanceID adds the pvmInstanceID to the pcloud pvminstances console get params +func (o *PcloudPvminstancesConsoleGetParams) WithPvmInstanceID(pvmInstanceID string) *PcloudPvminstancesConsoleGetParams { + o.SetPvmInstanceID(pvmInstanceID) + return o +} + +// SetPvmInstanceID adds the pvmInstanceId to the pcloud pvminstances console get params +func (o *PcloudPvminstancesConsoleGetParams) SetPvmInstanceID(pvmInstanceID string) { + o.PvmInstanceID = pvmInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudPvminstancesConsoleGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param pvm_instance_id + if err := r.SetPathParam("pvm_instance_id", o.PvmInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_console_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_console_get_responses.go new file mode 100644 index 00000000000..1caf34981c1 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_console_get_responses.go @@ -0,0 +1,181 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudPvminstancesConsoleGetReader is a Reader for the PcloudPvminstancesConsoleGet structure. +type PcloudPvminstancesConsoleGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudPvminstancesConsoleGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudPvminstancesConsoleGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudPvminstancesConsoleGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudPvminstancesConsoleGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudPvminstancesConsoleGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudPvminstancesConsoleGetOK creates a PcloudPvminstancesConsoleGetOK with default headers values +func NewPcloudPvminstancesConsoleGetOK() *PcloudPvminstancesConsoleGetOK { + return &PcloudPvminstancesConsoleGetOK{} +} + +/* PcloudPvminstancesConsoleGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudPvminstancesConsoleGetOK struct { + Payload *models.ConsoleLanguages +} + +func (o *PcloudPvminstancesConsoleGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/console][%d] pcloudPvminstancesConsoleGetOK %+v", 200, o.Payload) +} +func (o *PcloudPvminstancesConsoleGetOK) GetPayload() *models.ConsoleLanguages { + return o.Payload +} + +func (o *PcloudPvminstancesConsoleGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ConsoleLanguages) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesConsoleGetBadRequest creates a PcloudPvminstancesConsoleGetBadRequest with default headers values +func NewPcloudPvminstancesConsoleGetBadRequest() *PcloudPvminstancesConsoleGetBadRequest { + return &PcloudPvminstancesConsoleGetBadRequest{} +} + +/* PcloudPvminstancesConsoleGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudPvminstancesConsoleGetBadRequest struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesConsoleGetBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/console][%d] pcloudPvminstancesConsoleGetBadRequest %+v", 400, o.Payload) +} +func (o *PcloudPvminstancesConsoleGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesConsoleGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesConsoleGetUnauthorized creates a PcloudPvminstancesConsoleGetUnauthorized with default headers values +func NewPcloudPvminstancesConsoleGetUnauthorized() *PcloudPvminstancesConsoleGetUnauthorized { + return &PcloudPvminstancesConsoleGetUnauthorized{} +} + +/* PcloudPvminstancesConsoleGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudPvminstancesConsoleGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesConsoleGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/console][%d] pcloudPvminstancesConsoleGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudPvminstancesConsoleGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesConsoleGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesConsoleGetInternalServerError creates a PcloudPvminstancesConsoleGetInternalServerError with default headers values +func NewPcloudPvminstancesConsoleGetInternalServerError() *PcloudPvminstancesConsoleGetInternalServerError { + return &PcloudPvminstancesConsoleGetInternalServerError{} +} + +/* PcloudPvminstancesConsoleGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudPvminstancesConsoleGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesConsoleGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/console][%d] pcloudPvminstancesConsoleGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudPvminstancesConsoleGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesConsoleGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_console_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_console_post_parameters.go new file mode 100644 index 00000000000..86a27e66340 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_console_post_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudPvminstancesConsolePostParams creates a new PcloudPvminstancesConsolePostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudPvminstancesConsolePostParams() *PcloudPvminstancesConsolePostParams { + return &PcloudPvminstancesConsolePostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudPvminstancesConsolePostParamsWithTimeout creates a new PcloudPvminstancesConsolePostParams object +// with the ability to set a timeout on a request. +func NewPcloudPvminstancesConsolePostParamsWithTimeout(timeout time.Duration) *PcloudPvminstancesConsolePostParams { + return &PcloudPvminstancesConsolePostParams{ + timeout: timeout, + } +} + +// NewPcloudPvminstancesConsolePostParamsWithContext creates a new PcloudPvminstancesConsolePostParams object +// with the ability to set a context for a request. +func NewPcloudPvminstancesConsolePostParamsWithContext(ctx context.Context) *PcloudPvminstancesConsolePostParams { + return &PcloudPvminstancesConsolePostParams{ + Context: ctx, + } +} + +// NewPcloudPvminstancesConsolePostParamsWithHTTPClient creates a new PcloudPvminstancesConsolePostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudPvminstancesConsolePostParamsWithHTTPClient(client *http.Client) *PcloudPvminstancesConsolePostParams { + return &PcloudPvminstancesConsolePostParams{ + HTTPClient: client, + } +} + +/* PcloudPvminstancesConsolePostParams contains all the parameters to send to the API endpoint + for the pcloud pvminstances console post operation. + + Typically these are written to a http.Request. +*/ +type PcloudPvminstancesConsolePostParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* PvmInstanceID. + + PCloud PVM Instance ID + */ + PvmInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud pvminstances console post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesConsolePostParams) WithDefaults() *PcloudPvminstancesConsolePostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud pvminstances console post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesConsolePostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud pvminstances console post params +func (o *PcloudPvminstancesConsolePostParams) WithTimeout(timeout time.Duration) *PcloudPvminstancesConsolePostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud pvminstances console post params +func (o *PcloudPvminstancesConsolePostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud pvminstances console post params +func (o *PcloudPvminstancesConsolePostParams) WithContext(ctx context.Context) *PcloudPvminstancesConsolePostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud pvminstances console post params +func (o *PcloudPvminstancesConsolePostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud pvminstances console post params +func (o *PcloudPvminstancesConsolePostParams) WithHTTPClient(client *http.Client) *PcloudPvminstancesConsolePostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud pvminstances console post params +func (o *PcloudPvminstancesConsolePostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud pvminstances console post params +func (o *PcloudPvminstancesConsolePostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudPvminstancesConsolePostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud pvminstances console post params +func (o *PcloudPvminstancesConsolePostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithPvmInstanceID adds the pvmInstanceID to the pcloud pvminstances console post params +func (o *PcloudPvminstancesConsolePostParams) WithPvmInstanceID(pvmInstanceID string) *PcloudPvminstancesConsolePostParams { + o.SetPvmInstanceID(pvmInstanceID) + return o +} + +// SetPvmInstanceID adds the pvmInstanceId to the pcloud pvminstances console post params +func (o *PcloudPvminstancesConsolePostParams) SetPvmInstanceID(pvmInstanceID string) { + o.PvmInstanceID = pvmInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudPvminstancesConsolePostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param pvm_instance_id + if err := r.SetPathParam("pvm_instance_id", o.PvmInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_console_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_console_post_responses.go new file mode 100644 index 00000000000..590e7f5b1eb --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_console_post_responses.go @@ -0,0 +1,181 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudPvminstancesConsolePostReader is a Reader for the PcloudPvminstancesConsolePost structure. +type PcloudPvminstancesConsolePostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudPvminstancesConsolePostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 201: + result := NewPcloudPvminstancesConsolePostCreated() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewPcloudPvminstancesConsolePostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudPvminstancesConsolePostUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudPvminstancesConsolePostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudPvminstancesConsolePostCreated creates a PcloudPvminstancesConsolePostCreated with default headers values +func NewPcloudPvminstancesConsolePostCreated() *PcloudPvminstancesConsolePostCreated { + return &PcloudPvminstancesConsolePostCreated{} +} + +/* PcloudPvminstancesConsolePostCreated describes a response with status code 201, with default header values. + +Created +*/ +type PcloudPvminstancesConsolePostCreated struct { + Payload *models.PVMInstanceConsole +} + +func (o *PcloudPvminstancesConsolePostCreated) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/console][%d] pcloudPvminstancesConsolePostCreated %+v", 201, o.Payload) +} +func (o *PcloudPvminstancesConsolePostCreated) GetPayload() *models.PVMInstanceConsole { + return o.Payload +} + +func (o *PcloudPvminstancesConsolePostCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.PVMInstanceConsole) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesConsolePostUnauthorized creates a PcloudPvminstancesConsolePostUnauthorized with default headers values +func NewPcloudPvminstancesConsolePostUnauthorized() *PcloudPvminstancesConsolePostUnauthorized { + return &PcloudPvminstancesConsolePostUnauthorized{} +} + +/* PcloudPvminstancesConsolePostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudPvminstancesConsolePostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesConsolePostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/console][%d] pcloudPvminstancesConsolePostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudPvminstancesConsolePostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesConsolePostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesConsolePostUnprocessableEntity creates a PcloudPvminstancesConsolePostUnprocessableEntity with default headers values +func NewPcloudPvminstancesConsolePostUnprocessableEntity() *PcloudPvminstancesConsolePostUnprocessableEntity { + return &PcloudPvminstancesConsolePostUnprocessableEntity{} +} + +/* PcloudPvminstancesConsolePostUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudPvminstancesConsolePostUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesConsolePostUnprocessableEntity) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/console][%d] pcloudPvminstancesConsolePostUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudPvminstancesConsolePostUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesConsolePostUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesConsolePostInternalServerError creates a PcloudPvminstancesConsolePostInternalServerError with default headers values +func NewPcloudPvminstancesConsolePostInternalServerError() *PcloudPvminstancesConsolePostInternalServerError { + return &PcloudPvminstancesConsolePostInternalServerError{} +} + +/* PcloudPvminstancesConsolePostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudPvminstancesConsolePostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesConsolePostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/console][%d] pcloudPvminstancesConsolePostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudPvminstancesConsolePostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesConsolePostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_console_put_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_console_put_parameters.go new file mode 100644 index 00000000000..a6f703784f5 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_console_put_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudPvminstancesConsolePutParams creates a new PcloudPvminstancesConsolePutParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudPvminstancesConsolePutParams() *PcloudPvminstancesConsolePutParams { + return &PcloudPvminstancesConsolePutParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudPvminstancesConsolePutParamsWithTimeout creates a new PcloudPvminstancesConsolePutParams object +// with the ability to set a timeout on a request. +func NewPcloudPvminstancesConsolePutParamsWithTimeout(timeout time.Duration) *PcloudPvminstancesConsolePutParams { + return &PcloudPvminstancesConsolePutParams{ + timeout: timeout, + } +} + +// NewPcloudPvminstancesConsolePutParamsWithContext creates a new PcloudPvminstancesConsolePutParams object +// with the ability to set a context for a request. +func NewPcloudPvminstancesConsolePutParamsWithContext(ctx context.Context) *PcloudPvminstancesConsolePutParams { + return &PcloudPvminstancesConsolePutParams{ + Context: ctx, + } +} + +// NewPcloudPvminstancesConsolePutParamsWithHTTPClient creates a new PcloudPvminstancesConsolePutParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudPvminstancesConsolePutParamsWithHTTPClient(client *http.Client) *PcloudPvminstancesConsolePutParams { + return &PcloudPvminstancesConsolePutParams{ + HTTPClient: client, + } +} + +/* PcloudPvminstancesConsolePutParams contains all the parameters to send to the API endpoint + for the pcloud pvminstances console put operation. + + Typically these are written to a http.Request. +*/ +type PcloudPvminstancesConsolePutParams struct { + + /* Body. + + Parameters to update a PVMInstance console required codepage + */ + Body *models.ConsoleLanguage + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* PvmInstanceID. + + PCloud PVM Instance ID + */ + PvmInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud pvminstances console put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesConsolePutParams) WithDefaults() *PcloudPvminstancesConsolePutParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud pvminstances console put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesConsolePutParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud pvminstances console put params +func (o *PcloudPvminstancesConsolePutParams) WithTimeout(timeout time.Duration) *PcloudPvminstancesConsolePutParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud pvminstances console put params +func (o *PcloudPvminstancesConsolePutParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud pvminstances console put params +func (o *PcloudPvminstancesConsolePutParams) WithContext(ctx context.Context) *PcloudPvminstancesConsolePutParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud pvminstances console put params +func (o *PcloudPvminstancesConsolePutParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud pvminstances console put params +func (o *PcloudPvminstancesConsolePutParams) WithHTTPClient(client *http.Client) *PcloudPvminstancesConsolePutParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud pvminstances console put params +func (o *PcloudPvminstancesConsolePutParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud pvminstances console put params +func (o *PcloudPvminstancesConsolePutParams) WithBody(body *models.ConsoleLanguage) *PcloudPvminstancesConsolePutParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud pvminstances console put params +func (o *PcloudPvminstancesConsolePutParams) SetBody(body *models.ConsoleLanguage) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud pvminstances console put params +func (o *PcloudPvminstancesConsolePutParams) WithCloudInstanceID(cloudInstanceID string) *PcloudPvminstancesConsolePutParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud pvminstances console put params +func (o *PcloudPvminstancesConsolePutParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithPvmInstanceID adds the pvmInstanceID to the pcloud pvminstances console put params +func (o *PcloudPvminstancesConsolePutParams) WithPvmInstanceID(pvmInstanceID string) *PcloudPvminstancesConsolePutParams { + o.SetPvmInstanceID(pvmInstanceID) + return o +} + +// SetPvmInstanceID adds the pvmInstanceId to the pcloud pvminstances console put params +func (o *PcloudPvminstancesConsolePutParams) SetPvmInstanceID(pvmInstanceID string) { + o.PvmInstanceID = pvmInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudPvminstancesConsolePutParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param pvm_instance_id + if err := r.SetPathParam("pvm_instance_id", o.PvmInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_console_put_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_console_put_responses.go new file mode 100644 index 00000000000..c3331bef565 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_console_put_responses.go @@ -0,0 +1,181 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudPvminstancesConsolePutReader is a Reader for the PcloudPvminstancesConsolePut structure. +type PcloudPvminstancesConsolePutReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudPvminstancesConsolePutReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudPvminstancesConsolePutOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudPvminstancesConsolePutBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudPvminstancesConsolePutUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudPvminstancesConsolePutInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudPvminstancesConsolePutOK creates a PcloudPvminstancesConsolePutOK with default headers values +func NewPcloudPvminstancesConsolePutOK() *PcloudPvminstancesConsolePutOK { + return &PcloudPvminstancesConsolePutOK{} +} + +/* PcloudPvminstancesConsolePutOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudPvminstancesConsolePutOK struct { + Payload *models.ConsoleLanguage +} + +func (o *PcloudPvminstancesConsolePutOK) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/console][%d] pcloudPvminstancesConsolePutOK %+v", 200, o.Payload) +} +func (o *PcloudPvminstancesConsolePutOK) GetPayload() *models.ConsoleLanguage { + return o.Payload +} + +func (o *PcloudPvminstancesConsolePutOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ConsoleLanguage) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesConsolePutBadRequest creates a PcloudPvminstancesConsolePutBadRequest with default headers values +func NewPcloudPvminstancesConsolePutBadRequest() *PcloudPvminstancesConsolePutBadRequest { + return &PcloudPvminstancesConsolePutBadRequest{} +} + +/* PcloudPvminstancesConsolePutBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudPvminstancesConsolePutBadRequest struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesConsolePutBadRequest) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/console][%d] pcloudPvminstancesConsolePutBadRequest %+v", 400, o.Payload) +} +func (o *PcloudPvminstancesConsolePutBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesConsolePutBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesConsolePutUnauthorized creates a PcloudPvminstancesConsolePutUnauthorized with default headers values +func NewPcloudPvminstancesConsolePutUnauthorized() *PcloudPvminstancesConsolePutUnauthorized { + return &PcloudPvminstancesConsolePutUnauthorized{} +} + +/* PcloudPvminstancesConsolePutUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudPvminstancesConsolePutUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesConsolePutUnauthorized) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/console][%d] pcloudPvminstancesConsolePutUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudPvminstancesConsolePutUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesConsolePutUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesConsolePutInternalServerError creates a PcloudPvminstancesConsolePutInternalServerError with default headers values +func NewPcloudPvminstancesConsolePutInternalServerError() *PcloudPvminstancesConsolePutInternalServerError { + return &PcloudPvminstancesConsolePutInternalServerError{} +} + +/* PcloudPvminstancesConsolePutInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudPvminstancesConsolePutInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesConsolePutInternalServerError) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/console][%d] pcloudPvminstancesConsolePutInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudPvminstancesConsolePutInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesConsolePutInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_delete_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_delete_parameters.go new file mode 100644 index 00000000000..8c369a0106d --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_delete_parameters.go @@ -0,0 +1,206 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewPcloudPvminstancesDeleteParams creates a new PcloudPvminstancesDeleteParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudPvminstancesDeleteParams() *PcloudPvminstancesDeleteParams { + return &PcloudPvminstancesDeleteParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudPvminstancesDeleteParamsWithTimeout creates a new PcloudPvminstancesDeleteParams object +// with the ability to set a timeout on a request. +func NewPcloudPvminstancesDeleteParamsWithTimeout(timeout time.Duration) *PcloudPvminstancesDeleteParams { + return &PcloudPvminstancesDeleteParams{ + timeout: timeout, + } +} + +// NewPcloudPvminstancesDeleteParamsWithContext creates a new PcloudPvminstancesDeleteParams object +// with the ability to set a context for a request. +func NewPcloudPvminstancesDeleteParamsWithContext(ctx context.Context) *PcloudPvminstancesDeleteParams { + return &PcloudPvminstancesDeleteParams{ + Context: ctx, + } +} + +// NewPcloudPvminstancesDeleteParamsWithHTTPClient creates a new PcloudPvminstancesDeleteParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudPvminstancesDeleteParamsWithHTTPClient(client *http.Client) *PcloudPvminstancesDeleteParams { + return &PcloudPvminstancesDeleteParams{ + HTTPClient: client, + } +} + +/* PcloudPvminstancesDeleteParams contains all the parameters to send to the API endpoint + for the pcloud pvminstances delete operation. + + Typically these are written to a http.Request. +*/ +type PcloudPvminstancesDeleteParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* DeleteDataVolumes. + + Indicates if all data volumes attached to the PVMInstance should be deleted when deleting the PVMInstance. Shared data volumes will be deleted if there are no other PVMInstances attached. + */ + DeleteDataVolumes *bool + + /* PvmInstanceID. + + PCloud PVM Instance ID + */ + PvmInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud pvminstances delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesDeleteParams) WithDefaults() *PcloudPvminstancesDeleteParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud pvminstances delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesDeleteParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud pvminstances delete params +func (o *PcloudPvminstancesDeleteParams) WithTimeout(timeout time.Duration) *PcloudPvminstancesDeleteParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud pvminstances delete params +func (o *PcloudPvminstancesDeleteParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud pvminstances delete params +func (o *PcloudPvminstancesDeleteParams) WithContext(ctx context.Context) *PcloudPvminstancesDeleteParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud pvminstances delete params +func (o *PcloudPvminstancesDeleteParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud pvminstances delete params +func (o *PcloudPvminstancesDeleteParams) WithHTTPClient(client *http.Client) *PcloudPvminstancesDeleteParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud pvminstances delete params +func (o *PcloudPvminstancesDeleteParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud pvminstances delete params +func (o *PcloudPvminstancesDeleteParams) WithCloudInstanceID(cloudInstanceID string) *PcloudPvminstancesDeleteParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud pvminstances delete params +func (o *PcloudPvminstancesDeleteParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithDeleteDataVolumes adds the deleteDataVolumes to the pcloud pvminstances delete params +func (o *PcloudPvminstancesDeleteParams) WithDeleteDataVolumes(deleteDataVolumes *bool) *PcloudPvminstancesDeleteParams { + o.SetDeleteDataVolumes(deleteDataVolumes) + return o +} + +// SetDeleteDataVolumes adds the deleteDataVolumes to the pcloud pvminstances delete params +func (o *PcloudPvminstancesDeleteParams) SetDeleteDataVolumes(deleteDataVolumes *bool) { + o.DeleteDataVolumes = deleteDataVolumes +} + +// WithPvmInstanceID adds the pvmInstanceID to the pcloud pvminstances delete params +func (o *PcloudPvminstancesDeleteParams) WithPvmInstanceID(pvmInstanceID string) *PcloudPvminstancesDeleteParams { + o.SetPvmInstanceID(pvmInstanceID) + return o +} + +// SetPvmInstanceID adds the pvmInstanceId to the pcloud pvminstances delete params +func (o *PcloudPvminstancesDeleteParams) SetPvmInstanceID(pvmInstanceID string) { + o.PvmInstanceID = pvmInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudPvminstancesDeleteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if o.DeleteDataVolumes != nil { + + // query param delete_data_volumes + var qrDeleteDataVolumes bool + + if o.DeleteDataVolumes != nil { + qrDeleteDataVolumes = *o.DeleteDataVolumes + } + qDeleteDataVolumes := swag.FormatBool(qrDeleteDataVolumes) + if qDeleteDataVolumes != "" { + + if err := r.SetQueryParam("delete_data_volumes", qDeleteDataVolumes); err != nil { + return err + } + } + } + + // path param pvm_instance_id + if err := r.SetPathParam("pvm_instance_id", o.PvmInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_delete_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_delete_responses.go new file mode 100644 index 00000000000..18189dcdeb9 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_delete_responses.go @@ -0,0 +1,255 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudPvminstancesDeleteReader is a Reader for the PcloudPvminstancesDelete structure. +type PcloudPvminstancesDeleteReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudPvminstancesDeleteReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudPvminstancesDeleteOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudPvminstancesDeleteBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudPvminstancesDeleteUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudPvminstancesDeleteNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 410: + result := NewPcloudPvminstancesDeleteGone() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudPvminstancesDeleteInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudPvminstancesDeleteOK creates a PcloudPvminstancesDeleteOK with default headers values +func NewPcloudPvminstancesDeleteOK() *PcloudPvminstancesDeleteOK { + return &PcloudPvminstancesDeleteOK{} +} + +/* PcloudPvminstancesDeleteOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudPvminstancesDeleteOK struct { + Payload models.Object +} + +func (o *PcloudPvminstancesDeleteOK) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}][%d] pcloudPvminstancesDeleteOK %+v", 200, o.Payload) +} +func (o *PcloudPvminstancesDeleteOK) GetPayload() models.Object { + return o.Payload +} + +func (o *PcloudPvminstancesDeleteOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesDeleteBadRequest creates a PcloudPvminstancesDeleteBadRequest with default headers values +func NewPcloudPvminstancesDeleteBadRequest() *PcloudPvminstancesDeleteBadRequest { + return &PcloudPvminstancesDeleteBadRequest{} +} + +/* PcloudPvminstancesDeleteBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudPvminstancesDeleteBadRequest struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesDeleteBadRequest) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}][%d] pcloudPvminstancesDeleteBadRequest %+v", 400, o.Payload) +} +func (o *PcloudPvminstancesDeleteBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesDeleteBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesDeleteUnauthorized creates a PcloudPvminstancesDeleteUnauthorized with default headers values +func NewPcloudPvminstancesDeleteUnauthorized() *PcloudPvminstancesDeleteUnauthorized { + return &PcloudPvminstancesDeleteUnauthorized{} +} + +/* PcloudPvminstancesDeleteUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudPvminstancesDeleteUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesDeleteUnauthorized) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}][%d] pcloudPvminstancesDeleteUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudPvminstancesDeleteUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesDeleteUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesDeleteNotFound creates a PcloudPvminstancesDeleteNotFound with default headers values +func NewPcloudPvminstancesDeleteNotFound() *PcloudPvminstancesDeleteNotFound { + return &PcloudPvminstancesDeleteNotFound{} +} + +/* PcloudPvminstancesDeleteNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudPvminstancesDeleteNotFound struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesDeleteNotFound) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}][%d] pcloudPvminstancesDeleteNotFound %+v", 404, o.Payload) +} +func (o *PcloudPvminstancesDeleteNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesDeleteNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesDeleteGone creates a PcloudPvminstancesDeleteGone with default headers values +func NewPcloudPvminstancesDeleteGone() *PcloudPvminstancesDeleteGone { + return &PcloudPvminstancesDeleteGone{} +} + +/* PcloudPvminstancesDeleteGone describes a response with status code 410, with default header values. + +Gone +*/ +type PcloudPvminstancesDeleteGone struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesDeleteGone) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}][%d] pcloudPvminstancesDeleteGone %+v", 410, o.Payload) +} +func (o *PcloudPvminstancesDeleteGone) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesDeleteGone) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesDeleteInternalServerError creates a PcloudPvminstancesDeleteInternalServerError with default headers values +func NewPcloudPvminstancesDeleteInternalServerError() *PcloudPvminstancesDeleteInternalServerError { + return &PcloudPvminstancesDeleteInternalServerError{} +} + +/* PcloudPvminstancesDeleteInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudPvminstancesDeleteInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesDeleteInternalServerError) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}][%d] pcloudPvminstancesDeleteInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudPvminstancesDeleteInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesDeleteInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_get_parameters.go new file mode 100644 index 00000000000..ebbc6f4a779 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_get_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudPvminstancesGetParams creates a new PcloudPvminstancesGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudPvminstancesGetParams() *PcloudPvminstancesGetParams { + return &PcloudPvminstancesGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudPvminstancesGetParamsWithTimeout creates a new PcloudPvminstancesGetParams object +// with the ability to set a timeout on a request. +func NewPcloudPvminstancesGetParamsWithTimeout(timeout time.Duration) *PcloudPvminstancesGetParams { + return &PcloudPvminstancesGetParams{ + timeout: timeout, + } +} + +// NewPcloudPvminstancesGetParamsWithContext creates a new PcloudPvminstancesGetParams object +// with the ability to set a context for a request. +func NewPcloudPvminstancesGetParamsWithContext(ctx context.Context) *PcloudPvminstancesGetParams { + return &PcloudPvminstancesGetParams{ + Context: ctx, + } +} + +// NewPcloudPvminstancesGetParamsWithHTTPClient creates a new PcloudPvminstancesGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudPvminstancesGetParamsWithHTTPClient(client *http.Client) *PcloudPvminstancesGetParams { + return &PcloudPvminstancesGetParams{ + HTTPClient: client, + } +} + +/* PcloudPvminstancesGetParams contains all the parameters to send to the API endpoint + for the pcloud pvminstances get operation. + + Typically these are written to a http.Request. +*/ +type PcloudPvminstancesGetParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* PvmInstanceID. + + PCloud PVM Instance ID + */ + PvmInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud pvminstances get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesGetParams) WithDefaults() *PcloudPvminstancesGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud pvminstances get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud pvminstances get params +func (o *PcloudPvminstancesGetParams) WithTimeout(timeout time.Duration) *PcloudPvminstancesGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud pvminstances get params +func (o *PcloudPvminstancesGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud pvminstances get params +func (o *PcloudPvminstancesGetParams) WithContext(ctx context.Context) *PcloudPvminstancesGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud pvminstances get params +func (o *PcloudPvminstancesGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud pvminstances get params +func (o *PcloudPvminstancesGetParams) WithHTTPClient(client *http.Client) *PcloudPvminstancesGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud pvminstances get params +func (o *PcloudPvminstancesGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud pvminstances get params +func (o *PcloudPvminstancesGetParams) WithCloudInstanceID(cloudInstanceID string) *PcloudPvminstancesGetParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud pvminstances get params +func (o *PcloudPvminstancesGetParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithPvmInstanceID adds the pvmInstanceID to the pcloud pvminstances get params +func (o *PcloudPvminstancesGetParams) WithPvmInstanceID(pvmInstanceID string) *PcloudPvminstancesGetParams { + o.SetPvmInstanceID(pvmInstanceID) + return o +} + +// SetPvmInstanceID adds the pvmInstanceId to the pcloud pvminstances get params +func (o *PcloudPvminstancesGetParams) SetPvmInstanceID(pvmInstanceID string) { + o.PvmInstanceID = pvmInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudPvminstancesGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param pvm_instance_id + if err := r.SetPathParam("pvm_instance_id", o.PvmInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_get_responses.go new file mode 100644 index 00000000000..ddd375ee49b --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_get_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudPvminstancesGetReader is a Reader for the PcloudPvminstancesGet structure. +type PcloudPvminstancesGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudPvminstancesGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudPvminstancesGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudPvminstancesGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudPvminstancesGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudPvminstancesGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudPvminstancesGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudPvminstancesGetOK creates a PcloudPvminstancesGetOK with default headers values +func NewPcloudPvminstancesGetOK() *PcloudPvminstancesGetOK { + return &PcloudPvminstancesGetOK{} +} + +/* PcloudPvminstancesGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudPvminstancesGetOK struct { + Payload *models.PVMInstance +} + +func (o *PcloudPvminstancesGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}][%d] pcloudPvminstancesGetOK %+v", 200, o.Payload) +} +func (o *PcloudPvminstancesGetOK) GetPayload() *models.PVMInstance { + return o.Payload +} + +func (o *PcloudPvminstancesGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.PVMInstance) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesGetBadRequest creates a PcloudPvminstancesGetBadRequest with default headers values +func NewPcloudPvminstancesGetBadRequest() *PcloudPvminstancesGetBadRequest { + return &PcloudPvminstancesGetBadRequest{} +} + +/* PcloudPvminstancesGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudPvminstancesGetBadRequest struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesGetBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}][%d] pcloudPvminstancesGetBadRequest %+v", 400, o.Payload) +} +func (o *PcloudPvminstancesGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesGetUnauthorized creates a PcloudPvminstancesGetUnauthorized with default headers values +func NewPcloudPvminstancesGetUnauthorized() *PcloudPvminstancesGetUnauthorized { + return &PcloudPvminstancesGetUnauthorized{} +} + +/* PcloudPvminstancesGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudPvminstancesGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}][%d] pcloudPvminstancesGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudPvminstancesGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesGetNotFound creates a PcloudPvminstancesGetNotFound with default headers values +func NewPcloudPvminstancesGetNotFound() *PcloudPvminstancesGetNotFound { + return &PcloudPvminstancesGetNotFound{} +} + +/* PcloudPvminstancesGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudPvminstancesGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}][%d] pcloudPvminstancesGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudPvminstancesGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesGetInternalServerError creates a PcloudPvminstancesGetInternalServerError with default headers values +func NewPcloudPvminstancesGetInternalServerError() *PcloudPvminstancesGetInternalServerError { + return &PcloudPvminstancesGetInternalServerError{} +} + +/* PcloudPvminstancesGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudPvminstancesGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}][%d] pcloudPvminstancesGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudPvminstancesGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_getall_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_getall_parameters.go new file mode 100644 index 00000000000..88205d338e5 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_getall_parameters.go @@ -0,0 +1,149 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudPvminstancesGetallParams creates a new PcloudPvminstancesGetallParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudPvminstancesGetallParams() *PcloudPvminstancesGetallParams { + return &PcloudPvminstancesGetallParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudPvminstancesGetallParamsWithTimeout creates a new PcloudPvminstancesGetallParams object +// with the ability to set a timeout on a request. +func NewPcloudPvminstancesGetallParamsWithTimeout(timeout time.Duration) *PcloudPvminstancesGetallParams { + return &PcloudPvminstancesGetallParams{ + timeout: timeout, + } +} + +// NewPcloudPvminstancesGetallParamsWithContext creates a new PcloudPvminstancesGetallParams object +// with the ability to set a context for a request. +func NewPcloudPvminstancesGetallParamsWithContext(ctx context.Context) *PcloudPvminstancesGetallParams { + return &PcloudPvminstancesGetallParams{ + Context: ctx, + } +} + +// NewPcloudPvminstancesGetallParamsWithHTTPClient creates a new PcloudPvminstancesGetallParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudPvminstancesGetallParamsWithHTTPClient(client *http.Client) *PcloudPvminstancesGetallParams { + return &PcloudPvminstancesGetallParams{ + HTTPClient: client, + } +} + +/* PcloudPvminstancesGetallParams contains all the parameters to send to the API endpoint + for the pcloud pvminstances getall operation. + + Typically these are written to a http.Request. +*/ +type PcloudPvminstancesGetallParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud pvminstances getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesGetallParams) WithDefaults() *PcloudPvminstancesGetallParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud pvminstances getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesGetallParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud pvminstances getall params +func (o *PcloudPvminstancesGetallParams) WithTimeout(timeout time.Duration) *PcloudPvminstancesGetallParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud pvminstances getall params +func (o *PcloudPvminstancesGetallParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud pvminstances getall params +func (o *PcloudPvminstancesGetallParams) WithContext(ctx context.Context) *PcloudPvminstancesGetallParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud pvminstances getall params +func (o *PcloudPvminstancesGetallParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud pvminstances getall params +func (o *PcloudPvminstancesGetallParams) WithHTTPClient(client *http.Client) *PcloudPvminstancesGetallParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud pvminstances getall params +func (o *PcloudPvminstancesGetallParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud pvminstances getall params +func (o *PcloudPvminstancesGetallParams) WithCloudInstanceID(cloudInstanceID string) *PcloudPvminstancesGetallParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud pvminstances getall params +func (o *PcloudPvminstancesGetallParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudPvminstancesGetallParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_getall_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_getall_responses.go new file mode 100644 index 00000000000..f55d76239f3 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_getall_responses.go @@ -0,0 +1,181 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudPvminstancesGetallReader is a Reader for the PcloudPvminstancesGetall structure. +type PcloudPvminstancesGetallReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudPvminstancesGetallReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudPvminstancesGetallOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudPvminstancesGetallBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudPvminstancesGetallUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudPvminstancesGetallInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudPvminstancesGetallOK creates a PcloudPvminstancesGetallOK with default headers values +func NewPcloudPvminstancesGetallOK() *PcloudPvminstancesGetallOK { + return &PcloudPvminstancesGetallOK{} +} + +/* PcloudPvminstancesGetallOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudPvminstancesGetallOK struct { + Payload *models.PVMInstances +} + +func (o *PcloudPvminstancesGetallOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances][%d] pcloudPvminstancesGetallOK %+v", 200, o.Payload) +} +func (o *PcloudPvminstancesGetallOK) GetPayload() *models.PVMInstances { + return o.Payload +} + +func (o *PcloudPvminstancesGetallOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.PVMInstances) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesGetallBadRequest creates a PcloudPvminstancesGetallBadRequest with default headers values +func NewPcloudPvminstancesGetallBadRequest() *PcloudPvminstancesGetallBadRequest { + return &PcloudPvminstancesGetallBadRequest{} +} + +/* PcloudPvminstancesGetallBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudPvminstancesGetallBadRequest struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesGetallBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances][%d] pcloudPvminstancesGetallBadRequest %+v", 400, o.Payload) +} +func (o *PcloudPvminstancesGetallBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesGetallBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesGetallUnauthorized creates a PcloudPvminstancesGetallUnauthorized with default headers values +func NewPcloudPvminstancesGetallUnauthorized() *PcloudPvminstancesGetallUnauthorized { + return &PcloudPvminstancesGetallUnauthorized{} +} + +/* PcloudPvminstancesGetallUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudPvminstancesGetallUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesGetallUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances][%d] pcloudPvminstancesGetallUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudPvminstancesGetallUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesGetallUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesGetallInternalServerError creates a PcloudPvminstancesGetallInternalServerError with default headers values +func NewPcloudPvminstancesGetallInternalServerError() *PcloudPvminstancesGetallInternalServerError { + return &PcloudPvminstancesGetallInternalServerError{} +} + +/* PcloudPvminstancesGetallInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudPvminstancesGetallInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesGetallInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances][%d] pcloudPvminstancesGetallInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudPvminstancesGetallInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesGetallInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_networks_delete_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_networks_delete_parameters.go new file mode 100644 index 00000000000..5b6b0ee46c5 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_networks_delete_parameters.go @@ -0,0 +1,217 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudPvminstancesNetworksDeleteParams creates a new PcloudPvminstancesNetworksDeleteParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudPvminstancesNetworksDeleteParams() *PcloudPvminstancesNetworksDeleteParams { + return &PcloudPvminstancesNetworksDeleteParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudPvminstancesNetworksDeleteParamsWithTimeout creates a new PcloudPvminstancesNetworksDeleteParams object +// with the ability to set a timeout on a request. +func NewPcloudPvminstancesNetworksDeleteParamsWithTimeout(timeout time.Duration) *PcloudPvminstancesNetworksDeleteParams { + return &PcloudPvminstancesNetworksDeleteParams{ + timeout: timeout, + } +} + +// NewPcloudPvminstancesNetworksDeleteParamsWithContext creates a new PcloudPvminstancesNetworksDeleteParams object +// with the ability to set a context for a request. +func NewPcloudPvminstancesNetworksDeleteParamsWithContext(ctx context.Context) *PcloudPvminstancesNetworksDeleteParams { + return &PcloudPvminstancesNetworksDeleteParams{ + Context: ctx, + } +} + +// NewPcloudPvminstancesNetworksDeleteParamsWithHTTPClient creates a new PcloudPvminstancesNetworksDeleteParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudPvminstancesNetworksDeleteParamsWithHTTPClient(client *http.Client) *PcloudPvminstancesNetworksDeleteParams { + return &PcloudPvminstancesNetworksDeleteParams{ + HTTPClient: client, + } +} + +/* PcloudPvminstancesNetworksDeleteParams contains all the parameters to send to the API endpoint + for the pcloud pvminstances networks delete operation. + + Typically these are written to a http.Request. +*/ +type PcloudPvminstancesNetworksDeleteParams struct { + + /* Body. + + Remove a network from PVM Instance parameters + */ + Body *models.PVMInstanceRemoveNetwork + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* NetworkID. + + Network ID + */ + NetworkID string + + /* PvmInstanceID. + + PCloud PVM Instance ID + */ + PvmInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud pvminstances networks delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesNetworksDeleteParams) WithDefaults() *PcloudPvminstancesNetworksDeleteParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud pvminstances networks delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesNetworksDeleteParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud pvminstances networks delete params +func (o *PcloudPvminstancesNetworksDeleteParams) WithTimeout(timeout time.Duration) *PcloudPvminstancesNetworksDeleteParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud pvminstances networks delete params +func (o *PcloudPvminstancesNetworksDeleteParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud pvminstances networks delete params +func (o *PcloudPvminstancesNetworksDeleteParams) WithContext(ctx context.Context) *PcloudPvminstancesNetworksDeleteParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud pvminstances networks delete params +func (o *PcloudPvminstancesNetworksDeleteParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud pvminstances networks delete params +func (o *PcloudPvminstancesNetworksDeleteParams) WithHTTPClient(client *http.Client) *PcloudPvminstancesNetworksDeleteParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud pvminstances networks delete params +func (o *PcloudPvminstancesNetworksDeleteParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud pvminstances networks delete params +func (o *PcloudPvminstancesNetworksDeleteParams) WithBody(body *models.PVMInstanceRemoveNetwork) *PcloudPvminstancesNetworksDeleteParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud pvminstances networks delete params +func (o *PcloudPvminstancesNetworksDeleteParams) SetBody(body *models.PVMInstanceRemoveNetwork) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud pvminstances networks delete params +func (o *PcloudPvminstancesNetworksDeleteParams) WithCloudInstanceID(cloudInstanceID string) *PcloudPvminstancesNetworksDeleteParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud pvminstances networks delete params +func (o *PcloudPvminstancesNetworksDeleteParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithNetworkID adds the networkID to the pcloud pvminstances networks delete params +func (o *PcloudPvminstancesNetworksDeleteParams) WithNetworkID(networkID string) *PcloudPvminstancesNetworksDeleteParams { + o.SetNetworkID(networkID) + return o +} + +// SetNetworkID adds the networkId to the pcloud pvminstances networks delete params +func (o *PcloudPvminstancesNetworksDeleteParams) SetNetworkID(networkID string) { + o.NetworkID = networkID +} + +// WithPvmInstanceID adds the pvmInstanceID to the pcloud pvminstances networks delete params +func (o *PcloudPvminstancesNetworksDeleteParams) WithPvmInstanceID(pvmInstanceID string) *PcloudPvminstancesNetworksDeleteParams { + o.SetPvmInstanceID(pvmInstanceID) + return o +} + +// SetPvmInstanceID adds the pvmInstanceId to the pcloud pvminstances networks delete params +func (o *PcloudPvminstancesNetworksDeleteParams) SetPvmInstanceID(pvmInstanceID string) { + o.PvmInstanceID = pvmInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudPvminstancesNetworksDeleteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param network_id + if err := r.SetPathParam("network_id", o.NetworkID); err != nil { + return err + } + + // path param pvm_instance_id + if err := r.SetPathParam("pvm_instance_id", o.PvmInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_networks_delete_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_networks_delete_responses.go new file mode 100644 index 00000000000..e3ce9d7eae7 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_networks_delete_responses.go @@ -0,0 +1,217 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudPvminstancesNetworksDeleteReader is a Reader for the PcloudPvminstancesNetworksDelete structure. +type PcloudPvminstancesNetworksDeleteReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudPvminstancesNetworksDeleteReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudPvminstancesNetworksDeleteOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudPvminstancesNetworksDeleteBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudPvminstancesNetworksDeleteUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 410: + result := NewPcloudPvminstancesNetworksDeleteGone() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudPvminstancesNetworksDeleteInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudPvminstancesNetworksDeleteOK creates a PcloudPvminstancesNetworksDeleteOK with default headers values +func NewPcloudPvminstancesNetworksDeleteOK() *PcloudPvminstancesNetworksDeleteOK { + return &PcloudPvminstancesNetworksDeleteOK{} +} + +/* PcloudPvminstancesNetworksDeleteOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudPvminstancesNetworksDeleteOK struct { + Payload models.Object +} + +func (o *PcloudPvminstancesNetworksDeleteOK) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/networks/{network_id}][%d] pcloudPvminstancesNetworksDeleteOK %+v", 200, o.Payload) +} +func (o *PcloudPvminstancesNetworksDeleteOK) GetPayload() models.Object { + return o.Payload +} + +func (o *PcloudPvminstancesNetworksDeleteOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesNetworksDeleteBadRequest creates a PcloudPvminstancesNetworksDeleteBadRequest with default headers values +func NewPcloudPvminstancesNetworksDeleteBadRequest() *PcloudPvminstancesNetworksDeleteBadRequest { + return &PcloudPvminstancesNetworksDeleteBadRequest{} +} + +/* PcloudPvminstancesNetworksDeleteBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudPvminstancesNetworksDeleteBadRequest struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesNetworksDeleteBadRequest) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/networks/{network_id}][%d] pcloudPvminstancesNetworksDeleteBadRequest %+v", 400, o.Payload) +} +func (o *PcloudPvminstancesNetworksDeleteBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesNetworksDeleteBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesNetworksDeleteUnauthorized creates a PcloudPvminstancesNetworksDeleteUnauthorized with default headers values +func NewPcloudPvminstancesNetworksDeleteUnauthorized() *PcloudPvminstancesNetworksDeleteUnauthorized { + return &PcloudPvminstancesNetworksDeleteUnauthorized{} +} + +/* PcloudPvminstancesNetworksDeleteUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudPvminstancesNetworksDeleteUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesNetworksDeleteUnauthorized) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/networks/{network_id}][%d] pcloudPvminstancesNetworksDeleteUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudPvminstancesNetworksDeleteUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesNetworksDeleteUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesNetworksDeleteGone creates a PcloudPvminstancesNetworksDeleteGone with default headers values +func NewPcloudPvminstancesNetworksDeleteGone() *PcloudPvminstancesNetworksDeleteGone { + return &PcloudPvminstancesNetworksDeleteGone{} +} + +/* PcloudPvminstancesNetworksDeleteGone describes a response with status code 410, with default header values. + +Gone +*/ +type PcloudPvminstancesNetworksDeleteGone struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesNetworksDeleteGone) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/networks/{network_id}][%d] pcloudPvminstancesNetworksDeleteGone %+v", 410, o.Payload) +} +func (o *PcloudPvminstancesNetworksDeleteGone) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesNetworksDeleteGone) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesNetworksDeleteInternalServerError creates a PcloudPvminstancesNetworksDeleteInternalServerError with default headers values +func NewPcloudPvminstancesNetworksDeleteInternalServerError() *PcloudPvminstancesNetworksDeleteInternalServerError { + return &PcloudPvminstancesNetworksDeleteInternalServerError{} +} + +/* PcloudPvminstancesNetworksDeleteInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudPvminstancesNetworksDeleteInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesNetworksDeleteInternalServerError) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/networks/{network_id}][%d] pcloudPvminstancesNetworksDeleteInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudPvminstancesNetworksDeleteInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesNetworksDeleteInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_networks_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_networks_get_parameters.go new file mode 100644 index 00000000000..c9a444ef56d --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_networks_get_parameters.go @@ -0,0 +1,193 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudPvminstancesNetworksGetParams creates a new PcloudPvminstancesNetworksGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudPvminstancesNetworksGetParams() *PcloudPvminstancesNetworksGetParams { + return &PcloudPvminstancesNetworksGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudPvminstancesNetworksGetParamsWithTimeout creates a new PcloudPvminstancesNetworksGetParams object +// with the ability to set a timeout on a request. +func NewPcloudPvminstancesNetworksGetParamsWithTimeout(timeout time.Duration) *PcloudPvminstancesNetworksGetParams { + return &PcloudPvminstancesNetworksGetParams{ + timeout: timeout, + } +} + +// NewPcloudPvminstancesNetworksGetParamsWithContext creates a new PcloudPvminstancesNetworksGetParams object +// with the ability to set a context for a request. +func NewPcloudPvminstancesNetworksGetParamsWithContext(ctx context.Context) *PcloudPvminstancesNetworksGetParams { + return &PcloudPvminstancesNetworksGetParams{ + Context: ctx, + } +} + +// NewPcloudPvminstancesNetworksGetParamsWithHTTPClient creates a new PcloudPvminstancesNetworksGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudPvminstancesNetworksGetParamsWithHTTPClient(client *http.Client) *PcloudPvminstancesNetworksGetParams { + return &PcloudPvminstancesNetworksGetParams{ + HTTPClient: client, + } +} + +/* PcloudPvminstancesNetworksGetParams contains all the parameters to send to the API endpoint + for the pcloud pvminstances networks get operation. + + Typically these are written to a http.Request. +*/ +type PcloudPvminstancesNetworksGetParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* NetworkID. + + Network ID + */ + NetworkID string + + /* PvmInstanceID. + + PCloud PVM Instance ID + */ + PvmInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud pvminstances networks get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesNetworksGetParams) WithDefaults() *PcloudPvminstancesNetworksGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud pvminstances networks get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesNetworksGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud pvminstances networks get params +func (o *PcloudPvminstancesNetworksGetParams) WithTimeout(timeout time.Duration) *PcloudPvminstancesNetworksGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud pvminstances networks get params +func (o *PcloudPvminstancesNetworksGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud pvminstances networks get params +func (o *PcloudPvminstancesNetworksGetParams) WithContext(ctx context.Context) *PcloudPvminstancesNetworksGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud pvminstances networks get params +func (o *PcloudPvminstancesNetworksGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud pvminstances networks get params +func (o *PcloudPvminstancesNetworksGetParams) WithHTTPClient(client *http.Client) *PcloudPvminstancesNetworksGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud pvminstances networks get params +func (o *PcloudPvminstancesNetworksGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud pvminstances networks get params +func (o *PcloudPvminstancesNetworksGetParams) WithCloudInstanceID(cloudInstanceID string) *PcloudPvminstancesNetworksGetParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud pvminstances networks get params +func (o *PcloudPvminstancesNetworksGetParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithNetworkID adds the networkID to the pcloud pvminstances networks get params +func (o *PcloudPvminstancesNetworksGetParams) WithNetworkID(networkID string) *PcloudPvminstancesNetworksGetParams { + o.SetNetworkID(networkID) + return o +} + +// SetNetworkID adds the networkId to the pcloud pvminstances networks get params +func (o *PcloudPvminstancesNetworksGetParams) SetNetworkID(networkID string) { + o.NetworkID = networkID +} + +// WithPvmInstanceID adds the pvmInstanceID to the pcloud pvminstances networks get params +func (o *PcloudPvminstancesNetworksGetParams) WithPvmInstanceID(pvmInstanceID string) *PcloudPvminstancesNetworksGetParams { + o.SetPvmInstanceID(pvmInstanceID) + return o +} + +// SetPvmInstanceID adds the pvmInstanceId to the pcloud pvminstances networks get params +func (o *PcloudPvminstancesNetworksGetParams) SetPvmInstanceID(pvmInstanceID string) { + o.PvmInstanceID = pvmInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudPvminstancesNetworksGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param network_id + if err := r.SetPathParam("network_id", o.NetworkID); err != nil { + return err + } + + // path param pvm_instance_id + if err := r.SetPathParam("pvm_instance_id", o.PvmInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_networks_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_networks_get_responses.go new file mode 100644 index 00000000000..1587866e424 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_networks_get_responses.go @@ -0,0 +1,181 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudPvminstancesNetworksGetReader is a Reader for the PcloudPvminstancesNetworksGet structure. +type PcloudPvminstancesNetworksGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudPvminstancesNetworksGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudPvminstancesNetworksGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewPcloudPvminstancesNetworksGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudPvminstancesNetworksGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudPvminstancesNetworksGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudPvminstancesNetworksGetOK creates a PcloudPvminstancesNetworksGetOK with default headers values +func NewPcloudPvminstancesNetworksGetOK() *PcloudPvminstancesNetworksGetOK { + return &PcloudPvminstancesNetworksGetOK{} +} + +/* PcloudPvminstancesNetworksGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudPvminstancesNetworksGetOK struct { + Payload *models.PVMInstanceNetworks +} + +func (o *PcloudPvminstancesNetworksGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/networks/{network_id}][%d] pcloudPvminstancesNetworksGetOK %+v", 200, o.Payload) +} +func (o *PcloudPvminstancesNetworksGetOK) GetPayload() *models.PVMInstanceNetworks { + return o.Payload +} + +func (o *PcloudPvminstancesNetworksGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.PVMInstanceNetworks) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesNetworksGetUnauthorized creates a PcloudPvminstancesNetworksGetUnauthorized with default headers values +func NewPcloudPvminstancesNetworksGetUnauthorized() *PcloudPvminstancesNetworksGetUnauthorized { + return &PcloudPvminstancesNetworksGetUnauthorized{} +} + +/* PcloudPvminstancesNetworksGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudPvminstancesNetworksGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesNetworksGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/networks/{network_id}][%d] pcloudPvminstancesNetworksGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudPvminstancesNetworksGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesNetworksGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesNetworksGetNotFound creates a PcloudPvminstancesNetworksGetNotFound with default headers values +func NewPcloudPvminstancesNetworksGetNotFound() *PcloudPvminstancesNetworksGetNotFound { + return &PcloudPvminstancesNetworksGetNotFound{} +} + +/* PcloudPvminstancesNetworksGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudPvminstancesNetworksGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesNetworksGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/networks/{network_id}][%d] pcloudPvminstancesNetworksGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudPvminstancesNetworksGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesNetworksGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesNetworksGetInternalServerError creates a PcloudPvminstancesNetworksGetInternalServerError with default headers values +func NewPcloudPvminstancesNetworksGetInternalServerError() *PcloudPvminstancesNetworksGetInternalServerError { + return &PcloudPvminstancesNetworksGetInternalServerError{} +} + +/* PcloudPvminstancesNetworksGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudPvminstancesNetworksGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesNetworksGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/networks/{network_id}][%d] pcloudPvminstancesNetworksGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudPvminstancesNetworksGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesNetworksGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_networks_getall_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_networks_getall_parameters.go new file mode 100644 index 00000000000..97fe7898ddb --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_networks_getall_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudPvminstancesNetworksGetallParams creates a new PcloudPvminstancesNetworksGetallParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudPvminstancesNetworksGetallParams() *PcloudPvminstancesNetworksGetallParams { + return &PcloudPvminstancesNetworksGetallParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudPvminstancesNetworksGetallParamsWithTimeout creates a new PcloudPvminstancesNetworksGetallParams object +// with the ability to set a timeout on a request. +func NewPcloudPvminstancesNetworksGetallParamsWithTimeout(timeout time.Duration) *PcloudPvminstancesNetworksGetallParams { + return &PcloudPvminstancesNetworksGetallParams{ + timeout: timeout, + } +} + +// NewPcloudPvminstancesNetworksGetallParamsWithContext creates a new PcloudPvminstancesNetworksGetallParams object +// with the ability to set a context for a request. +func NewPcloudPvminstancesNetworksGetallParamsWithContext(ctx context.Context) *PcloudPvminstancesNetworksGetallParams { + return &PcloudPvminstancesNetworksGetallParams{ + Context: ctx, + } +} + +// NewPcloudPvminstancesNetworksGetallParamsWithHTTPClient creates a new PcloudPvminstancesNetworksGetallParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudPvminstancesNetworksGetallParamsWithHTTPClient(client *http.Client) *PcloudPvminstancesNetworksGetallParams { + return &PcloudPvminstancesNetworksGetallParams{ + HTTPClient: client, + } +} + +/* PcloudPvminstancesNetworksGetallParams contains all the parameters to send to the API endpoint + for the pcloud pvminstances networks getall operation. + + Typically these are written to a http.Request. +*/ +type PcloudPvminstancesNetworksGetallParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* PvmInstanceID. + + PCloud PVM Instance ID + */ + PvmInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud pvminstances networks getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesNetworksGetallParams) WithDefaults() *PcloudPvminstancesNetworksGetallParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud pvminstances networks getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesNetworksGetallParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud pvminstances networks getall params +func (o *PcloudPvminstancesNetworksGetallParams) WithTimeout(timeout time.Duration) *PcloudPvminstancesNetworksGetallParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud pvminstances networks getall params +func (o *PcloudPvminstancesNetworksGetallParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud pvminstances networks getall params +func (o *PcloudPvminstancesNetworksGetallParams) WithContext(ctx context.Context) *PcloudPvminstancesNetworksGetallParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud pvminstances networks getall params +func (o *PcloudPvminstancesNetworksGetallParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud pvminstances networks getall params +func (o *PcloudPvminstancesNetworksGetallParams) WithHTTPClient(client *http.Client) *PcloudPvminstancesNetworksGetallParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud pvminstances networks getall params +func (o *PcloudPvminstancesNetworksGetallParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud pvminstances networks getall params +func (o *PcloudPvminstancesNetworksGetallParams) WithCloudInstanceID(cloudInstanceID string) *PcloudPvminstancesNetworksGetallParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud pvminstances networks getall params +func (o *PcloudPvminstancesNetworksGetallParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithPvmInstanceID adds the pvmInstanceID to the pcloud pvminstances networks getall params +func (o *PcloudPvminstancesNetworksGetallParams) WithPvmInstanceID(pvmInstanceID string) *PcloudPvminstancesNetworksGetallParams { + o.SetPvmInstanceID(pvmInstanceID) + return o +} + +// SetPvmInstanceID adds the pvmInstanceId to the pcloud pvminstances networks getall params +func (o *PcloudPvminstancesNetworksGetallParams) SetPvmInstanceID(pvmInstanceID string) { + o.PvmInstanceID = pvmInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudPvminstancesNetworksGetallParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param pvm_instance_id + if err := r.SetPathParam("pvm_instance_id", o.PvmInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_networks_getall_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_networks_getall_responses.go new file mode 100644 index 00000000000..79103867be2 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_networks_getall_responses.go @@ -0,0 +1,181 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudPvminstancesNetworksGetallReader is a Reader for the PcloudPvminstancesNetworksGetall structure. +type PcloudPvminstancesNetworksGetallReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudPvminstancesNetworksGetallReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudPvminstancesNetworksGetallOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudPvminstancesNetworksGetallBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudPvminstancesNetworksGetallUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudPvminstancesNetworksGetallInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudPvminstancesNetworksGetallOK creates a PcloudPvminstancesNetworksGetallOK with default headers values +func NewPcloudPvminstancesNetworksGetallOK() *PcloudPvminstancesNetworksGetallOK { + return &PcloudPvminstancesNetworksGetallOK{} +} + +/* PcloudPvminstancesNetworksGetallOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudPvminstancesNetworksGetallOK struct { + Payload *models.PVMInstanceNetworks +} + +func (o *PcloudPvminstancesNetworksGetallOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/networks][%d] pcloudPvminstancesNetworksGetallOK %+v", 200, o.Payload) +} +func (o *PcloudPvminstancesNetworksGetallOK) GetPayload() *models.PVMInstanceNetworks { + return o.Payload +} + +func (o *PcloudPvminstancesNetworksGetallOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.PVMInstanceNetworks) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesNetworksGetallBadRequest creates a PcloudPvminstancesNetworksGetallBadRequest with default headers values +func NewPcloudPvminstancesNetworksGetallBadRequest() *PcloudPvminstancesNetworksGetallBadRequest { + return &PcloudPvminstancesNetworksGetallBadRequest{} +} + +/* PcloudPvminstancesNetworksGetallBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudPvminstancesNetworksGetallBadRequest struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesNetworksGetallBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/networks][%d] pcloudPvminstancesNetworksGetallBadRequest %+v", 400, o.Payload) +} +func (o *PcloudPvminstancesNetworksGetallBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesNetworksGetallBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesNetworksGetallUnauthorized creates a PcloudPvminstancesNetworksGetallUnauthorized with default headers values +func NewPcloudPvminstancesNetworksGetallUnauthorized() *PcloudPvminstancesNetworksGetallUnauthorized { + return &PcloudPvminstancesNetworksGetallUnauthorized{} +} + +/* PcloudPvminstancesNetworksGetallUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudPvminstancesNetworksGetallUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesNetworksGetallUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/networks][%d] pcloudPvminstancesNetworksGetallUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudPvminstancesNetworksGetallUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesNetworksGetallUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesNetworksGetallInternalServerError creates a PcloudPvminstancesNetworksGetallInternalServerError with default headers values +func NewPcloudPvminstancesNetworksGetallInternalServerError() *PcloudPvminstancesNetworksGetallInternalServerError { + return &PcloudPvminstancesNetworksGetallInternalServerError{} +} + +/* PcloudPvminstancesNetworksGetallInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudPvminstancesNetworksGetallInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesNetworksGetallInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/networks][%d] pcloudPvminstancesNetworksGetallInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudPvminstancesNetworksGetallInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesNetworksGetallInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_networks_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_networks_post_parameters.go new file mode 100644 index 00000000000..23c0b0d4828 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_networks_post_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudPvminstancesNetworksPostParams creates a new PcloudPvminstancesNetworksPostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudPvminstancesNetworksPostParams() *PcloudPvminstancesNetworksPostParams { + return &PcloudPvminstancesNetworksPostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudPvminstancesNetworksPostParamsWithTimeout creates a new PcloudPvminstancesNetworksPostParams object +// with the ability to set a timeout on a request. +func NewPcloudPvminstancesNetworksPostParamsWithTimeout(timeout time.Duration) *PcloudPvminstancesNetworksPostParams { + return &PcloudPvminstancesNetworksPostParams{ + timeout: timeout, + } +} + +// NewPcloudPvminstancesNetworksPostParamsWithContext creates a new PcloudPvminstancesNetworksPostParams object +// with the ability to set a context for a request. +func NewPcloudPvminstancesNetworksPostParamsWithContext(ctx context.Context) *PcloudPvminstancesNetworksPostParams { + return &PcloudPvminstancesNetworksPostParams{ + Context: ctx, + } +} + +// NewPcloudPvminstancesNetworksPostParamsWithHTTPClient creates a new PcloudPvminstancesNetworksPostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudPvminstancesNetworksPostParamsWithHTTPClient(client *http.Client) *PcloudPvminstancesNetworksPostParams { + return &PcloudPvminstancesNetworksPostParams{ + HTTPClient: client, + } +} + +/* PcloudPvminstancesNetworksPostParams contains all the parameters to send to the API endpoint + for the pcloud pvminstances networks post operation. + + Typically these are written to a http.Request. +*/ +type PcloudPvminstancesNetworksPostParams struct { + + /* Body. + + Add network to PVM Instance parameters + */ + Body *models.PVMInstanceAddNetwork + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* PvmInstanceID. + + PCloud PVM Instance ID + */ + PvmInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud pvminstances networks post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesNetworksPostParams) WithDefaults() *PcloudPvminstancesNetworksPostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud pvminstances networks post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesNetworksPostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud pvminstances networks post params +func (o *PcloudPvminstancesNetworksPostParams) WithTimeout(timeout time.Duration) *PcloudPvminstancesNetworksPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud pvminstances networks post params +func (o *PcloudPvminstancesNetworksPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud pvminstances networks post params +func (o *PcloudPvminstancesNetworksPostParams) WithContext(ctx context.Context) *PcloudPvminstancesNetworksPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud pvminstances networks post params +func (o *PcloudPvminstancesNetworksPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud pvminstances networks post params +func (o *PcloudPvminstancesNetworksPostParams) WithHTTPClient(client *http.Client) *PcloudPvminstancesNetworksPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud pvminstances networks post params +func (o *PcloudPvminstancesNetworksPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud pvminstances networks post params +func (o *PcloudPvminstancesNetworksPostParams) WithBody(body *models.PVMInstanceAddNetwork) *PcloudPvminstancesNetworksPostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud pvminstances networks post params +func (o *PcloudPvminstancesNetworksPostParams) SetBody(body *models.PVMInstanceAddNetwork) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud pvminstances networks post params +func (o *PcloudPvminstancesNetworksPostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudPvminstancesNetworksPostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud pvminstances networks post params +func (o *PcloudPvminstancesNetworksPostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithPvmInstanceID adds the pvmInstanceID to the pcloud pvminstances networks post params +func (o *PcloudPvminstancesNetworksPostParams) WithPvmInstanceID(pvmInstanceID string) *PcloudPvminstancesNetworksPostParams { + o.SetPvmInstanceID(pvmInstanceID) + return o +} + +// SetPvmInstanceID adds the pvmInstanceId to the pcloud pvminstances networks post params +func (o *PcloudPvminstancesNetworksPostParams) SetPvmInstanceID(pvmInstanceID string) { + o.PvmInstanceID = pvmInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudPvminstancesNetworksPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param pvm_instance_id + if err := r.SetPathParam("pvm_instance_id", o.PvmInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_networks_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_networks_post_responses.go new file mode 100644 index 00000000000..4bd3ed07c33 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_networks_post_responses.go @@ -0,0 +1,257 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudPvminstancesNetworksPostReader is a Reader for the PcloudPvminstancesNetworksPost structure. +type PcloudPvminstancesNetworksPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudPvminstancesNetworksPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 201: + result := NewPcloudPvminstancesNetworksPostCreated() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudPvminstancesNetworksPostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudPvminstancesNetworksPostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewPcloudPvminstancesNetworksPostConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudPvminstancesNetworksPostUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudPvminstancesNetworksPostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudPvminstancesNetworksPostCreated creates a PcloudPvminstancesNetworksPostCreated with default headers values +func NewPcloudPvminstancesNetworksPostCreated() *PcloudPvminstancesNetworksPostCreated { + return &PcloudPvminstancesNetworksPostCreated{} +} + +/* PcloudPvminstancesNetworksPostCreated describes a response with status code 201, with default header values. + +Created +*/ +type PcloudPvminstancesNetworksPostCreated struct { + Payload *models.PVMInstanceNetwork +} + +func (o *PcloudPvminstancesNetworksPostCreated) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/networks][%d] pcloudPvminstancesNetworksPostCreated %+v", 201, o.Payload) +} +func (o *PcloudPvminstancesNetworksPostCreated) GetPayload() *models.PVMInstanceNetwork { + return o.Payload +} + +func (o *PcloudPvminstancesNetworksPostCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.PVMInstanceNetwork) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesNetworksPostBadRequest creates a PcloudPvminstancesNetworksPostBadRequest with default headers values +func NewPcloudPvminstancesNetworksPostBadRequest() *PcloudPvminstancesNetworksPostBadRequest { + return &PcloudPvminstancesNetworksPostBadRequest{} +} + +/* PcloudPvminstancesNetworksPostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudPvminstancesNetworksPostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesNetworksPostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/networks][%d] pcloudPvminstancesNetworksPostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudPvminstancesNetworksPostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesNetworksPostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesNetworksPostUnauthorized creates a PcloudPvminstancesNetworksPostUnauthorized with default headers values +func NewPcloudPvminstancesNetworksPostUnauthorized() *PcloudPvminstancesNetworksPostUnauthorized { + return &PcloudPvminstancesNetworksPostUnauthorized{} +} + +/* PcloudPvminstancesNetworksPostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudPvminstancesNetworksPostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesNetworksPostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/networks][%d] pcloudPvminstancesNetworksPostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudPvminstancesNetworksPostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesNetworksPostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesNetworksPostConflict creates a PcloudPvminstancesNetworksPostConflict with default headers values +func NewPcloudPvminstancesNetworksPostConflict() *PcloudPvminstancesNetworksPostConflict { + return &PcloudPvminstancesNetworksPostConflict{} +} + +/* PcloudPvminstancesNetworksPostConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type PcloudPvminstancesNetworksPostConflict struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesNetworksPostConflict) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/networks][%d] pcloudPvminstancesNetworksPostConflict %+v", 409, o.Payload) +} +func (o *PcloudPvminstancesNetworksPostConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesNetworksPostConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesNetworksPostUnprocessableEntity creates a PcloudPvminstancesNetworksPostUnprocessableEntity with default headers values +func NewPcloudPvminstancesNetworksPostUnprocessableEntity() *PcloudPvminstancesNetworksPostUnprocessableEntity { + return &PcloudPvminstancesNetworksPostUnprocessableEntity{} +} + +/* PcloudPvminstancesNetworksPostUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudPvminstancesNetworksPostUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesNetworksPostUnprocessableEntity) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/networks][%d] pcloudPvminstancesNetworksPostUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudPvminstancesNetworksPostUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesNetworksPostUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesNetworksPostInternalServerError creates a PcloudPvminstancesNetworksPostInternalServerError with default headers values +func NewPcloudPvminstancesNetworksPostInternalServerError() *PcloudPvminstancesNetworksPostInternalServerError { + return &PcloudPvminstancesNetworksPostInternalServerError{} +} + +/* PcloudPvminstancesNetworksPostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudPvminstancesNetworksPostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesNetworksPostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/networks][%d] pcloudPvminstancesNetworksPostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudPvminstancesNetworksPostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesNetworksPostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_operations_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_operations_post_parameters.go new file mode 100644 index 00000000000..adf9227844c --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_operations_post_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudPvminstancesOperationsPostParams creates a new PcloudPvminstancesOperationsPostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudPvminstancesOperationsPostParams() *PcloudPvminstancesOperationsPostParams { + return &PcloudPvminstancesOperationsPostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudPvminstancesOperationsPostParamsWithTimeout creates a new PcloudPvminstancesOperationsPostParams object +// with the ability to set a timeout on a request. +func NewPcloudPvminstancesOperationsPostParamsWithTimeout(timeout time.Duration) *PcloudPvminstancesOperationsPostParams { + return &PcloudPvminstancesOperationsPostParams{ + timeout: timeout, + } +} + +// NewPcloudPvminstancesOperationsPostParamsWithContext creates a new PcloudPvminstancesOperationsPostParams object +// with the ability to set a context for a request. +func NewPcloudPvminstancesOperationsPostParamsWithContext(ctx context.Context) *PcloudPvminstancesOperationsPostParams { + return &PcloudPvminstancesOperationsPostParams{ + Context: ctx, + } +} + +// NewPcloudPvminstancesOperationsPostParamsWithHTTPClient creates a new PcloudPvminstancesOperationsPostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudPvminstancesOperationsPostParamsWithHTTPClient(client *http.Client) *PcloudPvminstancesOperationsPostParams { + return &PcloudPvminstancesOperationsPostParams{ + HTTPClient: client, + } +} + +/* PcloudPvminstancesOperationsPostParams contains all the parameters to send to the API endpoint + for the pcloud pvminstances operations post operation. + + Typically these are written to a http.Request. +*/ +type PcloudPvminstancesOperationsPostParams struct { + + /* Body. + + Parameters for the desired operations + */ + Body *models.PVMInstanceOperation + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* PvmInstanceID. + + PCloud PVM Instance ID + */ + PvmInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud pvminstances operations post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesOperationsPostParams) WithDefaults() *PcloudPvminstancesOperationsPostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud pvminstances operations post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesOperationsPostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud pvminstances operations post params +func (o *PcloudPvminstancesOperationsPostParams) WithTimeout(timeout time.Duration) *PcloudPvminstancesOperationsPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud pvminstances operations post params +func (o *PcloudPvminstancesOperationsPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud pvminstances operations post params +func (o *PcloudPvminstancesOperationsPostParams) WithContext(ctx context.Context) *PcloudPvminstancesOperationsPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud pvminstances operations post params +func (o *PcloudPvminstancesOperationsPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud pvminstances operations post params +func (o *PcloudPvminstancesOperationsPostParams) WithHTTPClient(client *http.Client) *PcloudPvminstancesOperationsPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud pvminstances operations post params +func (o *PcloudPvminstancesOperationsPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud pvminstances operations post params +func (o *PcloudPvminstancesOperationsPostParams) WithBody(body *models.PVMInstanceOperation) *PcloudPvminstancesOperationsPostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud pvminstances operations post params +func (o *PcloudPvminstancesOperationsPostParams) SetBody(body *models.PVMInstanceOperation) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud pvminstances operations post params +func (o *PcloudPvminstancesOperationsPostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudPvminstancesOperationsPostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud pvminstances operations post params +func (o *PcloudPvminstancesOperationsPostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithPvmInstanceID adds the pvmInstanceID to the pcloud pvminstances operations post params +func (o *PcloudPvminstancesOperationsPostParams) WithPvmInstanceID(pvmInstanceID string) *PcloudPvminstancesOperationsPostParams { + o.SetPvmInstanceID(pvmInstanceID) + return o +} + +// SetPvmInstanceID adds the pvmInstanceId to the pcloud pvminstances operations post params +func (o *PcloudPvminstancesOperationsPostParams) SetPvmInstanceID(pvmInstanceID string) { + o.PvmInstanceID = pvmInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudPvminstancesOperationsPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param pvm_instance_id + if err := r.SetPathParam("pvm_instance_id", o.PvmInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_operations_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_operations_post_responses.go new file mode 100644 index 00000000000..a68b4319111 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_operations_post_responses.go @@ -0,0 +1,255 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudPvminstancesOperationsPostReader is a Reader for the PcloudPvminstancesOperationsPost structure. +type PcloudPvminstancesOperationsPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudPvminstancesOperationsPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudPvminstancesOperationsPostOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudPvminstancesOperationsPostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudPvminstancesOperationsPostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudPvminstancesOperationsPostNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudPvminstancesOperationsPostUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudPvminstancesOperationsPostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudPvminstancesOperationsPostOK creates a PcloudPvminstancesOperationsPostOK with default headers values +func NewPcloudPvminstancesOperationsPostOK() *PcloudPvminstancesOperationsPostOK { + return &PcloudPvminstancesOperationsPostOK{} +} + +/* PcloudPvminstancesOperationsPostOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudPvminstancesOperationsPostOK struct { + Payload models.Object +} + +func (o *PcloudPvminstancesOperationsPostOK) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/operations][%d] pcloudPvminstancesOperationsPostOK %+v", 200, o.Payload) +} +func (o *PcloudPvminstancesOperationsPostOK) GetPayload() models.Object { + return o.Payload +} + +func (o *PcloudPvminstancesOperationsPostOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesOperationsPostBadRequest creates a PcloudPvminstancesOperationsPostBadRequest with default headers values +func NewPcloudPvminstancesOperationsPostBadRequest() *PcloudPvminstancesOperationsPostBadRequest { + return &PcloudPvminstancesOperationsPostBadRequest{} +} + +/* PcloudPvminstancesOperationsPostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudPvminstancesOperationsPostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesOperationsPostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/operations][%d] pcloudPvminstancesOperationsPostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudPvminstancesOperationsPostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesOperationsPostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesOperationsPostUnauthorized creates a PcloudPvminstancesOperationsPostUnauthorized with default headers values +func NewPcloudPvminstancesOperationsPostUnauthorized() *PcloudPvminstancesOperationsPostUnauthorized { + return &PcloudPvminstancesOperationsPostUnauthorized{} +} + +/* PcloudPvminstancesOperationsPostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudPvminstancesOperationsPostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesOperationsPostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/operations][%d] pcloudPvminstancesOperationsPostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudPvminstancesOperationsPostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesOperationsPostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesOperationsPostNotFound creates a PcloudPvminstancesOperationsPostNotFound with default headers values +func NewPcloudPvminstancesOperationsPostNotFound() *PcloudPvminstancesOperationsPostNotFound { + return &PcloudPvminstancesOperationsPostNotFound{} +} + +/* PcloudPvminstancesOperationsPostNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudPvminstancesOperationsPostNotFound struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesOperationsPostNotFound) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/operations][%d] pcloudPvminstancesOperationsPostNotFound %+v", 404, o.Payload) +} +func (o *PcloudPvminstancesOperationsPostNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesOperationsPostNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesOperationsPostUnprocessableEntity creates a PcloudPvminstancesOperationsPostUnprocessableEntity with default headers values +func NewPcloudPvminstancesOperationsPostUnprocessableEntity() *PcloudPvminstancesOperationsPostUnprocessableEntity { + return &PcloudPvminstancesOperationsPostUnprocessableEntity{} +} + +/* PcloudPvminstancesOperationsPostUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudPvminstancesOperationsPostUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesOperationsPostUnprocessableEntity) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/operations][%d] pcloudPvminstancesOperationsPostUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudPvminstancesOperationsPostUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesOperationsPostUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesOperationsPostInternalServerError creates a PcloudPvminstancesOperationsPostInternalServerError with default headers values +func NewPcloudPvminstancesOperationsPostInternalServerError() *PcloudPvminstancesOperationsPostInternalServerError { + return &PcloudPvminstancesOperationsPostInternalServerError{} +} + +/* PcloudPvminstancesOperationsPostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudPvminstancesOperationsPostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesOperationsPostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/operations][%d] pcloudPvminstancesOperationsPostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudPvminstancesOperationsPostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesOperationsPostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_post_parameters.go new file mode 100644 index 00000000000..4720dc28ac5 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_post_parameters.go @@ -0,0 +1,208 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudPvminstancesPostParams creates a new PcloudPvminstancesPostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudPvminstancesPostParams() *PcloudPvminstancesPostParams { + return &PcloudPvminstancesPostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudPvminstancesPostParamsWithTimeout creates a new PcloudPvminstancesPostParams object +// with the ability to set a timeout on a request. +func NewPcloudPvminstancesPostParamsWithTimeout(timeout time.Duration) *PcloudPvminstancesPostParams { + return &PcloudPvminstancesPostParams{ + timeout: timeout, + } +} + +// NewPcloudPvminstancesPostParamsWithContext creates a new PcloudPvminstancesPostParams object +// with the ability to set a context for a request. +func NewPcloudPvminstancesPostParamsWithContext(ctx context.Context) *PcloudPvminstancesPostParams { + return &PcloudPvminstancesPostParams{ + Context: ctx, + } +} + +// NewPcloudPvminstancesPostParamsWithHTTPClient creates a new PcloudPvminstancesPostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudPvminstancesPostParamsWithHTTPClient(client *http.Client) *PcloudPvminstancesPostParams { + return &PcloudPvminstancesPostParams{ + HTTPClient: client, + } +} + +/* PcloudPvminstancesPostParams contains all the parameters to send to the API endpoint + for the pcloud pvminstances post operation. + + Typically these are written to a http.Request. +*/ +type PcloudPvminstancesPostParams struct { + + /* Body. + + Parameters for the creation of a new Power VM Instance + */ + Body *models.PVMInstanceCreate + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* SkipHostValidation. + + Option to skip host validation on PVMInstance Create API + */ + SkipHostValidation *bool + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud pvminstances post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesPostParams) WithDefaults() *PcloudPvminstancesPostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud pvminstances post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesPostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud pvminstances post params +func (o *PcloudPvminstancesPostParams) WithTimeout(timeout time.Duration) *PcloudPvminstancesPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud pvminstances post params +func (o *PcloudPvminstancesPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud pvminstances post params +func (o *PcloudPvminstancesPostParams) WithContext(ctx context.Context) *PcloudPvminstancesPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud pvminstances post params +func (o *PcloudPvminstancesPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud pvminstances post params +func (o *PcloudPvminstancesPostParams) WithHTTPClient(client *http.Client) *PcloudPvminstancesPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud pvminstances post params +func (o *PcloudPvminstancesPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud pvminstances post params +func (o *PcloudPvminstancesPostParams) WithBody(body *models.PVMInstanceCreate) *PcloudPvminstancesPostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud pvminstances post params +func (o *PcloudPvminstancesPostParams) SetBody(body *models.PVMInstanceCreate) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud pvminstances post params +func (o *PcloudPvminstancesPostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudPvminstancesPostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud pvminstances post params +func (o *PcloudPvminstancesPostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithSkipHostValidation adds the skipHostValidation to the pcloud pvminstances post params +func (o *PcloudPvminstancesPostParams) WithSkipHostValidation(skipHostValidation *bool) *PcloudPvminstancesPostParams { + o.SetSkipHostValidation(skipHostValidation) + return o +} + +// SetSkipHostValidation adds the skipHostValidation to the pcloud pvminstances post params +func (o *PcloudPvminstancesPostParams) SetSkipHostValidation(skipHostValidation *bool) { + o.SkipHostValidation = skipHostValidation +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudPvminstancesPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if o.SkipHostValidation != nil { + + // query param skipHostValidation + var qrSkipHostValidation bool + + if o.SkipHostValidation != nil { + qrSkipHostValidation = *o.SkipHostValidation + } + qSkipHostValidation := swag.FormatBool(qrSkipHostValidation) + if qSkipHostValidation != "" { + + if err := r.SetQueryParam("skipHostValidation", qSkipHostValidation); err != nil { + return err + } + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_post_responses.go new file mode 100644 index 00000000000..79011037442 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_post_responses.go @@ -0,0 +1,365 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudPvminstancesPostReader is a Reader for the PcloudPvminstancesPost structure. +type PcloudPvminstancesPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudPvminstancesPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudPvminstancesPostOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 201: + result := NewPcloudPvminstancesPostCreated() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 202: + result := NewPcloudPvminstancesPostAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudPvminstancesPostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudPvminstancesPostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewPcloudPvminstancesPostConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudPvminstancesPostUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudPvminstancesPostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 504: + result := NewPcloudPvminstancesPostGatewayTimeout() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudPvminstancesPostOK creates a PcloudPvminstancesPostOK with default headers values +func NewPcloudPvminstancesPostOK() *PcloudPvminstancesPostOK { + return &PcloudPvminstancesPostOK{} +} + +/* PcloudPvminstancesPostOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudPvminstancesPostOK struct { + Payload models.PVMInstanceList +} + +func (o *PcloudPvminstancesPostOK) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances][%d] pcloudPvminstancesPostOK %+v", 200, o.Payload) +} +func (o *PcloudPvminstancesPostOK) GetPayload() models.PVMInstanceList { + return o.Payload +} + +func (o *PcloudPvminstancesPostOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesPostCreated creates a PcloudPvminstancesPostCreated with default headers values +func NewPcloudPvminstancesPostCreated() *PcloudPvminstancesPostCreated { + return &PcloudPvminstancesPostCreated{} +} + +/* PcloudPvminstancesPostCreated describes a response with status code 201, with default header values. + +Created +*/ +type PcloudPvminstancesPostCreated struct { + Payload models.PVMInstanceList +} + +func (o *PcloudPvminstancesPostCreated) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances][%d] pcloudPvminstancesPostCreated %+v", 201, o.Payload) +} +func (o *PcloudPvminstancesPostCreated) GetPayload() models.PVMInstanceList { + return o.Payload +} + +func (o *PcloudPvminstancesPostCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesPostAccepted creates a PcloudPvminstancesPostAccepted with default headers values +func NewPcloudPvminstancesPostAccepted() *PcloudPvminstancesPostAccepted { + return &PcloudPvminstancesPostAccepted{} +} + +/* PcloudPvminstancesPostAccepted describes a response with status code 202, with default header values. + +Accepted +*/ +type PcloudPvminstancesPostAccepted struct { + Payload models.PVMInstanceList +} + +func (o *PcloudPvminstancesPostAccepted) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances][%d] pcloudPvminstancesPostAccepted %+v", 202, o.Payload) +} +func (o *PcloudPvminstancesPostAccepted) GetPayload() models.PVMInstanceList { + return o.Payload +} + +func (o *PcloudPvminstancesPostAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesPostBadRequest creates a PcloudPvminstancesPostBadRequest with default headers values +func NewPcloudPvminstancesPostBadRequest() *PcloudPvminstancesPostBadRequest { + return &PcloudPvminstancesPostBadRequest{} +} + +/* PcloudPvminstancesPostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudPvminstancesPostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesPostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances][%d] pcloudPvminstancesPostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudPvminstancesPostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesPostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesPostUnauthorized creates a PcloudPvminstancesPostUnauthorized with default headers values +func NewPcloudPvminstancesPostUnauthorized() *PcloudPvminstancesPostUnauthorized { + return &PcloudPvminstancesPostUnauthorized{} +} + +/* PcloudPvminstancesPostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudPvminstancesPostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesPostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances][%d] pcloudPvminstancesPostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudPvminstancesPostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesPostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesPostConflict creates a PcloudPvminstancesPostConflict with default headers values +func NewPcloudPvminstancesPostConflict() *PcloudPvminstancesPostConflict { + return &PcloudPvminstancesPostConflict{} +} + +/* PcloudPvminstancesPostConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type PcloudPvminstancesPostConflict struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesPostConflict) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances][%d] pcloudPvminstancesPostConflict %+v", 409, o.Payload) +} +func (o *PcloudPvminstancesPostConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesPostConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesPostUnprocessableEntity creates a PcloudPvminstancesPostUnprocessableEntity with default headers values +func NewPcloudPvminstancesPostUnprocessableEntity() *PcloudPvminstancesPostUnprocessableEntity { + return &PcloudPvminstancesPostUnprocessableEntity{} +} + +/* PcloudPvminstancesPostUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudPvminstancesPostUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesPostUnprocessableEntity) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances][%d] pcloudPvminstancesPostUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudPvminstancesPostUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesPostUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesPostInternalServerError creates a PcloudPvminstancesPostInternalServerError with default headers values +func NewPcloudPvminstancesPostInternalServerError() *PcloudPvminstancesPostInternalServerError { + return &PcloudPvminstancesPostInternalServerError{} +} + +/* PcloudPvminstancesPostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudPvminstancesPostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesPostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances][%d] pcloudPvminstancesPostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudPvminstancesPostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesPostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesPostGatewayTimeout creates a PcloudPvminstancesPostGatewayTimeout with default headers values +func NewPcloudPvminstancesPostGatewayTimeout() *PcloudPvminstancesPostGatewayTimeout { + return &PcloudPvminstancesPostGatewayTimeout{} +} + +/* PcloudPvminstancesPostGatewayTimeout describes a response with status code 504, with default header values. + +Gateway Timeout. Request is still processing and taking longer than expected. +*/ +type PcloudPvminstancesPostGatewayTimeout struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesPostGatewayTimeout) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances][%d] pcloudPvminstancesPostGatewayTimeout %+v", 504, o.Payload) +} +func (o *PcloudPvminstancesPostGatewayTimeout) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesPostGatewayTimeout) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_put_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_put_parameters.go new file mode 100644 index 00000000000..48b71a21d9e --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_put_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudPvminstancesPutParams creates a new PcloudPvminstancesPutParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudPvminstancesPutParams() *PcloudPvminstancesPutParams { + return &PcloudPvminstancesPutParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudPvminstancesPutParamsWithTimeout creates a new PcloudPvminstancesPutParams object +// with the ability to set a timeout on a request. +func NewPcloudPvminstancesPutParamsWithTimeout(timeout time.Duration) *PcloudPvminstancesPutParams { + return &PcloudPvminstancesPutParams{ + timeout: timeout, + } +} + +// NewPcloudPvminstancesPutParamsWithContext creates a new PcloudPvminstancesPutParams object +// with the ability to set a context for a request. +func NewPcloudPvminstancesPutParamsWithContext(ctx context.Context) *PcloudPvminstancesPutParams { + return &PcloudPvminstancesPutParams{ + Context: ctx, + } +} + +// NewPcloudPvminstancesPutParamsWithHTTPClient creates a new PcloudPvminstancesPutParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudPvminstancesPutParamsWithHTTPClient(client *http.Client) *PcloudPvminstancesPutParams { + return &PcloudPvminstancesPutParams{ + HTTPClient: client, + } +} + +/* PcloudPvminstancesPutParams contains all the parameters to send to the API endpoint + for the pcloud pvminstances put operation. + + Typically these are written to a http.Request. +*/ +type PcloudPvminstancesPutParams struct { + + /* Body. + + Parameters to update a PCloud PVM Instance + */ + Body *models.PVMInstanceUpdate + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* PvmInstanceID. + + PCloud PVM Instance ID + */ + PvmInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud pvminstances put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesPutParams) WithDefaults() *PcloudPvminstancesPutParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud pvminstances put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesPutParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud pvminstances put params +func (o *PcloudPvminstancesPutParams) WithTimeout(timeout time.Duration) *PcloudPvminstancesPutParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud pvminstances put params +func (o *PcloudPvminstancesPutParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud pvminstances put params +func (o *PcloudPvminstancesPutParams) WithContext(ctx context.Context) *PcloudPvminstancesPutParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud pvminstances put params +func (o *PcloudPvminstancesPutParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud pvminstances put params +func (o *PcloudPvminstancesPutParams) WithHTTPClient(client *http.Client) *PcloudPvminstancesPutParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud pvminstances put params +func (o *PcloudPvminstancesPutParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud pvminstances put params +func (o *PcloudPvminstancesPutParams) WithBody(body *models.PVMInstanceUpdate) *PcloudPvminstancesPutParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud pvminstances put params +func (o *PcloudPvminstancesPutParams) SetBody(body *models.PVMInstanceUpdate) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud pvminstances put params +func (o *PcloudPvminstancesPutParams) WithCloudInstanceID(cloudInstanceID string) *PcloudPvminstancesPutParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud pvminstances put params +func (o *PcloudPvminstancesPutParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithPvmInstanceID adds the pvmInstanceID to the pcloud pvminstances put params +func (o *PcloudPvminstancesPutParams) WithPvmInstanceID(pvmInstanceID string) *PcloudPvminstancesPutParams { + o.SetPvmInstanceID(pvmInstanceID) + return o +} + +// SetPvmInstanceID adds the pvmInstanceId to the pcloud pvminstances put params +func (o *PcloudPvminstancesPutParams) SetPvmInstanceID(pvmInstanceID string) { + o.PvmInstanceID = pvmInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudPvminstancesPutParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param pvm_instance_id + if err := r.SetPathParam("pvm_instance_id", o.PvmInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_put_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_put_responses.go new file mode 100644 index 00000000000..c88a794f302 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_put_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudPvminstancesPutReader is a Reader for the PcloudPvminstancesPut structure. +type PcloudPvminstancesPutReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudPvminstancesPutReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 202: + result := NewPcloudPvminstancesPutAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudPvminstancesPutBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudPvminstancesPutUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudPvminstancesPutUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudPvminstancesPutInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudPvminstancesPutAccepted creates a PcloudPvminstancesPutAccepted with default headers values +func NewPcloudPvminstancesPutAccepted() *PcloudPvminstancesPutAccepted { + return &PcloudPvminstancesPutAccepted{} +} + +/* PcloudPvminstancesPutAccepted describes a response with status code 202, with default header values. + +Accepted (this is a long running operation) +*/ +type PcloudPvminstancesPutAccepted struct { + Payload *models.PVMInstanceUpdateResponse +} + +func (o *PcloudPvminstancesPutAccepted) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}][%d] pcloudPvminstancesPutAccepted %+v", 202, o.Payload) +} +func (o *PcloudPvminstancesPutAccepted) GetPayload() *models.PVMInstanceUpdateResponse { + return o.Payload +} + +func (o *PcloudPvminstancesPutAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.PVMInstanceUpdateResponse) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesPutBadRequest creates a PcloudPvminstancesPutBadRequest with default headers values +func NewPcloudPvminstancesPutBadRequest() *PcloudPvminstancesPutBadRequest { + return &PcloudPvminstancesPutBadRequest{} +} + +/* PcloudPvminstancesPutBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudPvminstancesPutBadRequest struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesPutBadRequest) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}][%d] pcloudPvminstancesPutBadRequest %+v", 400, o.Payload) +} +func (o *PcloudPvminstancesPutBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesPutBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesPutUnauthorized creates a PcloudPvminstancesPutUnauthorized with default headers values +func NewPcloudPvminstancesPutUnauthorized() *PcloudPvminstancesPutUnauthorized { + return &PcloudPvminstancesPutUnauthorized{} +} + +/* PcloudPvminstancesPutUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudPvminstancesPutUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesPutUnauthorized) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}][%d] pcloudPvminstancesPutUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudPvminstancesPutUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesPutUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesPutUnprocessableEntity creates a PcloudPvminstancesPutUnprocessableEntity with default headers values +func NewPcloudPvminstancesPutUnprocessableEntity() *PcloudPvminstancesPutUnprocessableEntity { + return &PcloudPvminstancesPutUnprocessableEntity{} +} + +/* PcloudPvminstancesPutUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudPvminstancesPutUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesPutUnprocessableEntity) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}][%d] pcloudPvminstancesPutUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudPvminstancesPutUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesPutUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesPutInternalServerError creates a PcloudPvminstancesPutInternalServerError with default headers values +func NewPcloudPvminstancesPutInternalServerError() *PcloudPvminstancesPutInternalServerError { + return &PcloudPvminstancesPutInternalServerError{} +} + +/* PcloudPvminstancesPutInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudPvminstancesPutInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesPutInternalServerError) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}][%d] pcloudPvminstancesPutInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudPvminstancesPutInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesPutInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_snapshots_getall_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_snapshots_getall_parameters.go new file mode 100644 index 00000000000..6441ed24abd --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_snapshots_getall_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudPvminstancesSnapshotsGetallParams creates a new PcloudPvminstancesSnapshotsGetallParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudPvminstancesSnapshotsGetallParams() *PcloudPvminstancesSnapshotsGetallParams { + return &PcloudPvminstancesSnapshotsGetallParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudPvminstancesSnapshotsGetallParamsWithTimeout creates a new PcloudPvminstancesSnapshotsGetallParams object +// with the ability to set a timeout on a request. +func NewPcloudPvminstancesSnapshotsGetallParamsWithTimeout(timeout time.Duration) *PcloudPvminstancesSnapshotsGetallParams { + return &PcloudPvminstancesSnapshotsGetallParams{ + timeout: timeout, + } +} + +// NewPcloudPvminstancesSnapshotsGetallParamsWithContext creates a new PcloudPvminstancesSnapshotsGetallParams object +// with the ability to set a context for a request. +func NewPcloudPvminstancesSnapshotsGetallParamsWithContext(ctx context.Context) *PcloudPvminstancesSnapshotsGetallParams { + return &PcloudPvminstancesSnapshotsGetallParams{ + Context: ctx, + } +} + +// NewPcloudPvminstancesSnapshotsGetallParamsWithHTTPClient creates a new PcloudPvminstancesSnapshotsGetallParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudPvminstancesSnapshotsGetallParamsWithHTTPClient(client *http.Client) *PcloudPvminstancesSnapshotsGetallParams { + return &PcloudPvminstancesSnapshotsGetallParams{ + HTTPClient: client, + } +} + +/* PcloudPvminstancesSnapshotsGetallParams contains all the parameters to send to the API endpoint + for the pcloud pvminstances snapshots getall operation. + + Typically these are written to a http.Request. +*/ +type PcloudPvminstancesSnapshotsGetallParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* PvmInstanceID. + + PCloud PVM Instance ID + */ + PvmInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud pvminstances snapshots getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesSnapshotsGetallParams) WithDefaults() *PcloudPvminstancesSnapshotsGetallParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud pvminstances snapshots getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesSnapshotsGetallParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud pvminstances snapshots getall params +func (o *PcloudPvminstancesSnapshotsGetallParams) WithTimeout(timeout time.Duration) *PcloudPvminstancesSnapshotsGetallParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud pvminstances snapshots getall params +func (o *PcloudPvminstancesSnapshotsGetallParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud pvminstances snapshots getall params +func (o *PcloudPvminstancesSnapshotsGetallParams) WithContext(ctx context.Context) *PcloudPvminstancesSnapshotsGetallParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud pvminstances snapshots getall params +func (o *PcloudPvminstancesSnapshotsGetallParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud pvminstances snapshots getall params +func (o *PcloudPvminstancesSnapshotsGetallParams) WithHTTPClient(client *http.Client) *PcloudPvminstancesSnapshotsGetallParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud pvminstances snapshots getall params +func (o *PcloudPvminstancesSnapshotsGetallParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud pvminstances snapshots getall params +func (o *PcloudPvminstancesSnapshotsGetallParams) WithCloudInstanceID(cloudInstanceID string) *PcloudPvminstancesSnapshotsGetallParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud pvminstances snapshots getall params +func (o *PcloudPvminstancesSnapshotsGetallParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithPvmInstanceID adds the pvmInstanceID to the pcloud pvminstances snapshots getall params +func (o *PcloudPvminstancesSnapshotsGetallParams) WithPvmInstanceID(pvmInstanceID string) *PcloudPvminstancesSnapshotsGetallParams { + o.SetPvmInstanceID(pvmInstanceID) + return o +} + +// SetPvmInstanceID adds the pvmInstanceId to the pcloud pvminstances snapshots getall params +func (o *PcloudPvminstancesSnapshotsGetallParams) SetPvmInstanceID(pvmInstanceID string) { + o.PvmInstanceID = pvmInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudPvminstancesSnapshotsGetallParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param pvm_instance_id + if err := r.SetPathParam("pvm_instance_id", o.PvmInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_snapshots_getall_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_snapshots_getall_responses.go new file mode 100644 index 00000000000..9b257b3e2b7 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_snapshots_getall_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudPvminstancesSnapshotsGetallReader is a Reader for the PcloudPvminstancesSnapshotsGetall structure. +type PcloudPvminstancesSnapshotsGetallReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudPvminstancesSnapshotsGetallReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudPvminstancesSnapshotsGetallOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudPvminstancesSnapshotsGetallBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudPvminstancesSnapshotsGetallUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudPvminstancesSnapshotsGetallNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudPvminstancesSnapshotsGetallInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudPvminstancesSnapshotsGetallOK creates a PcloudPvminstancesSnapshotsGetallOK with default headers values +func NewPcloudPvminstancesSnapshotsGetallOK() *PcloudPvminstancesSnapshotsGetallOK { + return &PcloudPvminstancesSnapshotsGetallOK{} +} + +/* PcloudPvminstancesSnapshotsGetallOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudPvminstancesSnapshotsGetallOK struct { + Payload *models.Snapshots +} + +func (o *PcloudPvminstancesSnapshotsGetallOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/snapshots][%d] pcloudPvminstancesSnapshotsGetallOK %+v", 200, o.Payload) +} +func (o *PcloudPvminstancesSnapshotsGetallOK) GetPayload() *models.Snapshots { + return o.Payload +} + +func (o *PcloudPvminstancesSnapshotsGetallOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Snapshots) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesSnapshotsGetallBadRequest creates a PcloudPvminstancesSnapshotsGetallBadRequest with default headers values +func NewPcloudPvminstancesSnapshotsGetallBadRequest() *PcloudPvminstancesSnapshotsGetallBadRequest { + return &PcloudPvminstancesSnapshotsGetallBadRequest{} +} + +/* PcloudPvminstancesSnapshotsGetallBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudPvminstancesSnapshotsGetallBadRequest struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesSnapshotsGetallBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/snapshots][%d] pcloudPvminstancesSnapshotsGetallBadRequest %+v", 400, o.Payload) +} +func (o *PcloudPvminstancesSnapshotsGetallBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesSnapshotsGetallBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesSnapshotsGetallUnauthorized creates a PcloudPvminstancesSnapshotsGetallUnauthorized with default headers values +func NewPcloudPvminstancesSnapshotsGetallUnauthorized() *PcloudPvminstancesSnapshotsGetallUnauthorized { + return &PcloudPvminstancesSnapshotsGetallUnauthorized{} +} + +/* PcloudPvminstancesSnapshotsGetallUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudPvminstancesSnapshotsGetallUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesSnapshotsGetallUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/snapshots][%d] pcloudPvminstancesSnapshotsGetallUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudPvminstancesSnapshotsGetallUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesSnapshotsGetallUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesSnapshotsGetallNotFound creates a PcloudPvminstancesSnapshotsGetallNotFound with default headers values +func NewPcloudPvminstancesSnapshotsGetallNotFound() *PcloudPvminstancesSnapshotsGetallNotFound { + return &PcloudPvminstancesSnapshotsGetallNotFound{} +} + +/* PcloudPvminstancesSnapshotsGetallNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudPvminstancesSnapshotsGetallNotFound struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesSnapshotsGetallNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/snapshots][%d] pcloudPvminstancesSnapshotsGetallNotFound %+v", 404, o.Payload) +} +func (o *PcloudPvminstancesSnapshotsGetallNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesSnapshotsGetallNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesSnapshotsGetallInternalServerError creates a PcloudPvminstancesSnapshotsGetallInternalServerError with default headers values +func NewPcloudPvminstancesSnapshotsGetallInternalServerError() *PcloudPvminstancesSnapshotsGetallInternalServerError { + return &PcloudPvminstancesSnapshotsGetallInternalServerError{} +} + +/* PcloudPvminstancesSnapshotsGetallInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudPvminstancesSnapshotsGetallInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesSnapshotsGetallInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/snapshots][%d] pcloudPvminstancesSnapshotsGetallInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudPvminstancesSnapshotsGetallInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesSnapshotsGetallInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_snapshots_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_snapshots_post_parameters.go new file mode 100644 index 00000000000..551a20e44af --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_snapshots_post_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudPvminstancesSnapshotsPostParams creates a new PcloudPvminstancesSnapshotsPostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudPvminstancesSnapshotsPostParams() *PcloudPvminstancesSnapshotsPostParams { + return &PcloudPvminstancesSnapshotsPostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudPvminstancesSnapshotsPostParamsWithTimeout creates a new PcloudPvminstancesSnapshotsPostParams object +// with the ability to set a timeout on a request. +func NewPcloudPvminstancesSnapshotsPostParamsWithTimeout(timeout time.Duration) *PcloudPvminstancesSnapshotsPostParams { + return &PcloudPvminstancesSnapshotsPostParams{ + timeout: timeout, + } +} + +// NewPcloudPvminstancesSnapshotsPostParamsWithContext creates a new PcloudPvminstancesSnapshotsPostParams object +// with the ability to set a context for a request. +func NewPcloudPvminstancesSnapshotsPostParamsWithContext(ctx context.Context) *PcloudPvminstancesSnapshotsPostParams { + return &PcloudPvminstancesSnapshotsPostParams{ + Context: ctx, + } +} + +// NewPcloudPvminstancesSnapshotsPostParamsWithHTTPClient creates a new PcloudPvminstancesSnapshotsPostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudPvminstancesSnapshotsPostParamsWithHTTPClient(client *http.Client) *PcloudPvminstancesSnapshotsPostParams { + return &PcloudPvminstancesSnapshotsPostParams{ + HTTPClient: client, + } +} + +/* PcloudPvminstancesSnapshotsPostParams contains all the parameters to send to the API endpoint + for the pcloud pvminstances snapshots post operation. + + Typically these are written to a http.Request. +*/ +type PcloudPvminstancesSnapshotsPostParams struct { + + /* Body. + + PVM Instance snapshot create parameters + */ + Body *models.SnapshotCreate + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* PvmInstanceID. + + PCloud PVM Instance ID + */ + PvmInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud pvminstances snapshots post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesSnapshotsPostParams) WithDefaults() *PcloudPvminstancesSnapshotsPostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud pvminstances snapshots post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesSnapshotsPostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud pvminstances snapshots post params +func (o *PcloudPvminstancesSnapshotsPostParams) WithTimeout(timeout time.Duration) *PcloudPvminstancesSnapshotsPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud pvminstances snapshots post params +func (o *PcloudPvminstancesSnapshotsPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud pvminstances snapshots post params +func (o *PcloudPvminstancesSnapshotsPostParams) WithContext(ctx context.Context) *PcloudPvminstancesSnapshotsPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud pvminstances snapshots post params +func (o *PcloudPvminstancesSnapshotsPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud pvminstances snapshots post params +func (o *PcloudPvminstancesSnapshotsPostParams) WithHTTPClient(client *http.Client) *PcloudPvminstancesSnapshotsPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud pvminstances snapshots post params +func (o *PcloudPvminstancesSnapshotsPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud pvminstances snapshots post params +func (o *PcloudPvminstancesSnapshotsPostParams) WithBody(body *models.SnapshotCreate) *PcloudPvminstancesSnapshotsPostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud pvminstances snapshots post params +func (o *PcloudPvminstancesSnapshotsPostParams) SetBody(body *models.SnapshotCreate) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud pvminstances snapshots post params +func (o *PcloudPvminstancesSnapshotsPostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudPvminstancesSnapshotsPostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud pvminstances snapshots post params +func (o *PcloudPvminstancesSnapshotsPostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithPvmInstanceID adds the pvmInstanceID to the pcloud pvminstances snapshots post params +func (o *PcloudPvminstancesSnapshotsPostParams) WithPvmInstanceID(pvmInstanceID string) *PcloudPvminstancesSnapshotsPostParams { + o.SetPvmInstanceID(pvmInstanceID) + return o +} + +// SetPvmInstanceID adds the pvmInstanceId to the pcloud pvminstances snapshots post params +func (o *PcloudPvminstancesSnapshotsPostParams) SetPvmInstanceID(pvmInstanceID string) { + o.PvmInstanceID = pvmInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudPvminstancesSnapshotsPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param pvm_instance_id + if err := r.SetPathParam("pvm_instance_id", o.PvmInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_snapshots_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_snapshots_post_responses.go new file mode 100644 index 00000000000..a1f957222e6 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_snapshots_post_responses.go @@ -0,0 +1,257 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudPvminstancesSnapshotsPostReader is a Reader for the PcloudPvminstancesSnapshotsPost structure. +type PcloudPvminstancesSnapshotsPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudPvminstancesSnapshotsPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 202: + result := NewPcloudPvminstancesSnapshotsPostAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudPvminstancesSnapshotsPostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudPvminstancesSnapshotsPostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudPvminstancesSnapshotsPostNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewPcloudPvminstancesSnapshotsPostConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudPvminstancesSnapshotsPostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudPvminstancesSnapshotsPostAccepted creates a PcloudPvminstancesSnapshotsPostAccepted with default headers values +func NewPcloudPvminstancesSnapshotsPostAccepted() *PcloudPvminstancesSnapshotsPostAccepted { + return &PcloudPvminstancesSnapshotsPostAccepted{} +} + +/* PcloudPvminstancesSnapshotsPostAccepted describes a response with status code 202, with default header values. + +Accepted +*/ +type PcloudPvminstancesSnapshotsPostAccepted struct { + Payload *models.SnapshotCreateResponse +} + +func (o *PcloudPvminstancesSnapshotsPostAccepted) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/snapshots][%d] pcloudPvminstancesSnapshotsPostAccepted %+v", 202, o.Payload) +} +func (o *PcloudPvminstancesSnapshotsPostAccepted) GetPayload() *models.SnapshotCreateResponse { + return o.Payload +} + +func (o *PcloudPvminstancesSnapshotsPostAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.SnapshotCreateResponse) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesSnapshotsPostBadRequest creates a PcloudPvminstancesSnapshotsPostBadRequest with default headers values +func NewPcloudPvminstancesSnapshotsPostBadRequest() *PcloudPvminstancesSnapshotsPostBadRequest { + return &PcloudPvminstancesSnapshotsPostBadRequest{} +} + +/* PcloudPvminstancesSnapshotsPostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudPvminstancesSnapshotsPostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesSnapshotsPostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/snapshots][%d] pcloudPvminstancesSnapshotsPostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudPvminstancesSnapshotsPostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesSnapshotsPostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesSnapshotsPostUnauthorized creates a PcloudPvminstancesSnapshotsPostUnauthorized with default headers values +func NewPcloudPvminstancesSnapshotsPostUnauthorized() *PcloudPvminstancesSnapshotsPostUnauthorized { + return &PcloudPvminstancesSnapshotsPostUnauthorized{} +} + +/* PcloudPvminstancesSnapshotsPostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudPvminstancesSnapshotsPostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesSnapshotsPostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/snapshots][%d] pcloudPvminstancesSnapshotsPostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudPvminstancesSnapshotsPostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesSnapshotsPostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesSnapshotsPostNotFound creates a PcloudPvminstancesSnapshotsPostNotFound with default headers values +func NewPcloudPvminstancesSnapshotsPostNotFound() *PcloudPvminstancesSnapshotsPostNotFound { + return &PcloudPvminstancesSnapshotsPostNotFound{} +} + +/* PcloudPvminstancesSnapshotsPostNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudPvminstancesSnapshotsPostNotFound struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesSnapshotsPostNotFound) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/snapshots][%d] pcloudPvminstancesSnapshotsPostNotFound %+v", 404, o.Payload) +} +func (o *PcloudPvminstancesSnapshotsPostNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesSnapshotsPostNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesSnapshotsPostConflict creates a PcloudPvminstancesSnapshotsPostConflict with default headers values +func NewPcloudPvminstancesSnapshotsPostConflict() *PcloudPvminstancesSnapshotsPostConflict { + return &PcloudPvminstancesSnapshotsPostConflict{} +} + +/* PcloudPvminstancesSnapshotsPostConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type PcloudPvminstancesSnapshotsPostConflict struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesSnapshotsPostConflict) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/snapshots][%d] pcloudPvminstancesSnapshotsPostConflict %+v", 409, o.Payload) +} +func (o *PcloudPvminstancesSnapshotsPostConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesSnapshotsPostConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesSnapshotsPostInternalServerError creates a PcloudPvminstancesSnapshotsPostInternalServerError with default headers values +func NewPcloudPvminstancesSnapshotsPostInternalServerError() *PcloudPvminstancesSnapshotsPostInternalServerError { + return &PcloudPvminstancesSnapshotsPostInternalServerError{} +} + +/* PcloudPvminstancesSnapshotsPostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudPvminstancesSnapshotsPostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesSnapshotsPostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/snapshots][%d] pcloudPvminstancesSnapshotsPostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudPvminstancesSnapshotsPostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesSnapshotsPostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_snapshots_restore_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_snapshots_restore_post_parameters.go new file mode 100644 index 00000000000..9a56a1f7a5b --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_snapshots_restore_post_parameters.go @@ -0,0 +1,251 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudPvminstancesSnapshotsRestorePostParams creates a new PcloudPvminstancesSnapshotsRestorePostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudPvminstancesSnapshotsRestorePostParams() *PcloudPvminstancesSnapshotsRestorePostParams { + return &PcloudPvminstancesSnapshotsRestorePostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudPvminstancesSnapshotsRestorePostParamsWithTimeout creates a new PcloudPvminstancesSnapshotsRestorePostParams object +// with the ability to set a timeout on a request. +func NewPcloudPvminstancesSnapshotsRestorePostParamsWithTimeout(timeout time.Duration) *PcloudPvminstancesSnapshotsRestorePostParams { + return &PcloudPvminstancesSnapshotsRestorePostParams{ + timeout: timeout, + } +} + +// NewPcloudPvminstancesSnapshotsRestorePostParamsWithContext creates a new PcloudPvminstancesSnapshotsRestorePostParams object +// with the ability to set a context for a request. +func NewPcloudPvminstancesSnapshotsRestorePostParamsWithContext(ctx context.Context) *PcloudPvminstancesSnapshotsRestorePostParams { + return &PcloudPvminstancesSnapshotsRestorePostParams{ + Context: ctx, + } +} + +// NewPcloudPvminstancesSnapshotsRestorePostParamsWithHTTPClient creates a new PcloudPvminstancesSnapshotsRestorePostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudPvminstancesSnapshotsRestorePostParamsWithHTTPClient(client *http.Client) *PcloudPvminstancesSnapshotsRestorePostParams { + return &PcloudPvminstancesSnapshotsRestorePostParams{ + HTTPClient: client, + } +} + +/* PcloudPvminstancesSnapshotsRestorePostParams contains all the parameters to send to the API endpoint + for the pcloud pvminstances snapshots restore post operation. + + Typically these are written to a http.Request. +*/ +type PcloudPvminstancesSnapshotsRestorePostParams struct { + + /* Body. + + PVM Instance snapshot restore parameters + */ + Body *models.SnapshotRestore + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* PvmInstanceID. + + PCloud PVM Instance ID + */ + PvmInstanceID string + + /* RestoreFailAction. + + Action to take on a failed snapshot restore + */ + RestoreFailAction *string + + /* SnapshotID. + + PVM Instance snapshot id + */ + SnapshotID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud pvminstances snapshots restore post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesSnapshotsRestorePostParams) WithDefaults() *PcloudPvminstancesSnapshotsRestorePostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud pvminstances snapshots restore post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesSnapshotsRestorePostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud pvminstances snapshots restore post params +func (o *PcloudPvminstancesSnapshotsRestorePostParams) WithTimeout(timeout time.Duration) *PcloudPvminstancesSnapshotsRestorePostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud pvminstances snapshots restore post params +func (o *PcloudPvminstancesSnapshotsRestorePostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud pvminstances snapshots restore post params +func (o *PcloudPvminstancesSnapshotsRestorePostParams) WithContext(ctx context.Context) *PcloudPvminstancesSnapshotsRestorePostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud pvminstances snapshots restore post params +func (o *PcloudPvminstancesSnapshotsRestorePostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud pvminstances snapshots restore post params +func (o *PcloudPvminstancesSnapshotsRestorePostParams) WithHTTPClient(client *http.Client) *PcloudPvminstancesSnapshotsRestorePostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud pvminstances snapshots restore post params +func (o *PcloudPvminstancesSnapshotsRestorePostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud pvminstances snapshots restore post params +func (o *PcloudPvminstancesSnapshotsRestorePostParams) WithBody(body *models.SnapshotRestore) *PcloudPvminstancesSnapshotsRestorePostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud pvminstances snapshots restore post params +func (o *PcloudPvminstancesSnapshotsRestorePostParams) SetBody(body *models.SnapshotRestore) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud pvminstances snapshots restore post params +func (o *PcloudPvminstancesSnapshotsRestorePostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudPvminstancesSnapshotsRestorePostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud pvminstances snapshots restore post params +func (o *PcloudPvminstancesSnapshotsRestorePostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithPvmInstanceID adds the pvmInstanceID to the pcloud pvminstances snapshots restore post params +func (o *PcloudPvminstancesSnapshotsRestorePostParams) WithPvmInstanceID(pvmInstanceID string) *PcloudPvminstancesSnapshotsRestorePostParams { + o.SetPvmInstanceID(pvmInstanceID) + return o +} + +// SetPvmInstanceID adds the pvmInstanceId to the pcloud pvminstances snapshots restore post params +func (o *PcloudPvminstancesSnapshotsRestorePostParams) SetPvmInstanceID(pvmInstanceID string) { + o.PvmInstanceID = pvmInstanceID +} + +// WithRestoreFailAction adds the restoreFailAction to the pcloud pvminstances snapshots restore post params +func (o *PcloudPvminstancesSnapshotsRestorePostParams) WithRestoreFailAction(restoreFailAction *string) *PcloudPvminstancesSnapshotsRestorePostParams { + o.SetRestoreFailAction(restoreFailAction) + return o +} + +// SetRestoreFailAction adds the restoreFailAction to the pcloud pvminstances snapshots restore post params +func (o *PcloudPvminstancesSnapshotsRestorePostParams) SetRestoreFailAction(restoreFailAction *string) { + o.RestoreFailAction = restoreFailAction +} + +// WithSnapshotID adds the snapshotID to the pcloud pvminstances snapshots restore post params +func (o *PcloudPvminstancesSnapshotsRestorePostParams) WithSnapshotID(snapshotID string) *PcloudPvminstancesSnapshotsRestorePostParams { + o.SetSnapshotID(snapshotID) + return o +} + +// SetSnapshotID adds the snapshotId to the pcloud pvminstances snapshots restore post params +func (o *PcloudPvminstancesSnapshotsRestorePostParams) SetSnapshotID(snapshotID string) { + o.SnapshotID = snapshotID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudPvminstancesSnapshotsRestorePostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param pvm_instance_id + if err := r.SetPathParam("pvm_instance_id", o.PvmInstanceID); err != nil { + return err + } + + if o.RestoreFailAction != nil { + + // query param restore_fail_action + var qrRestoreFailAction string + + if o.RestoreFailAction != nil { + qrRestoreFailAction = *o.RestoreFailAction + } + qRestoreFailAction := qrRestoreFailAction + if qRestoreFailAction != "" { + + if err := r.SetQueryParam("restore_fail_action", qRestoreFailAction); err != nil { + return err + } + } + } + + // path param snapshot_id + if err := r.SetPathParam("snapshot_id", o.SnapshotID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_snapshots_restore_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_snapshots_restore_post_responses.go new file mode 100644 index 00000000000..5dbfbac8bbf --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_pvminstances_snapshots_restore_post_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudPvminstancesSnapshotsRestorePostReader is a Reader for the PcloudPvminstancesSnapshotsRestorePost structure. +type PcloudPvminstancesSnapshotsRestorePostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudPvminstancesSnapshotsRestorePostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 202: + result := NewPcloudPvminstancesSnapshotsRestorePostAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudPvminstancesSnapshotsRestorePostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudPvminstancesSnapshotsRestorePostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewPcloudPvminstancesSnapshotsRestorePostConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudPvminstancesSnapshotsRestorePostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudPvminstancesSnapshotsRestorePostAccepted creates a PcloudPvminstancesSnapshotsRestorePostAccepted with default headers values +func NewPcloudPvminstancesSnapshotsRestorePostAccepted() *PcloudPvminstancesSnapshotsRestorePostAccepted { + return &PcloudPvminstancesSnapshotsRestorePostAccepted{} +} + +/* PcloudPvminstancesSnapshotsRestorePostAccepted describes a response with status code 202, with default header values. + +Accepted +*/ +type PcloudPvminstancesSnapshotsRestorePostAccepted struct { + Payload *models.Snapshot +} + +func (o *PcloudPvminstancesSnapshotsRestorePostAccepted) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/snapshots/{snapshot_id}/restore][%d] pcloudPvminstancesSnapshotsRestorePostAccepted %+v", 202, o.Payload) +} +func (o *PcloudPvminstancesSnapshotsRestorePostAccepted) GetPayload() *models.Snapshot { + return o.Payload +} + +func (o *PcloudPvminstancesSnapshotsRestorePostAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Snapshot) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesSnapshotsRestorePostBadRequest creates a PcloudPvminstancesSnapshotsRestorePostBadRequest with default headers values +func NewPcloudPvminstancesSnapshotsRestorePostBadRequest() *PcloudPvminstancesSnapshotsRestorePostBadRequest { + return &PcloudPvminstancesSnapshotsRestorePostBadRequest{} +} + +/* PcloudPvminstancesSnapshotsRestorePostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudPvminstancesSnapshotsRestorePostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesSnapshotsRestorePostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/snapshots/{snapshot_id}/restore][%d] pcloudPvminstancesSnapshotsRestorePostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudPvminstancesSnapshotsRestorePostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesSnapshotsRestorePostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesSnapshotsRestorePostUnauthorized creates a PcloudPvminstancesSnapshotsRestorePostUnauthorized with default headers values +func NewPcloudPvminstancesSnapshotsRestorePostUnauthorized() *PcloudPvminstancesSnapshotsRestorePostUnauthorized { + return &PcloudPvminstancesSnapshotsRestorePostUnauthorized{} +} + +/* PcloudPvminstancesSnapshotsRestorePostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudPvminstancesSnapshotsRestorePostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesSnapshotsRestorePostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/snapshots/{snapshot_id}/restore][%d] pcloudPvminstancesSnapshotsRestorePostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudPvminstancesSnapshotsRestorePostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesSnapshotsRestorePostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesSnapshotsRestorePostConflict creates a PcloudPvminstancesSnapshotsRestorePostConflict with default headers values +func NewPcloudPvminstancesSnapshotsRestorePostConflict() *PcloudPvminstancesSnapshotsRestorePostConflict { + return &PcloudPvminstancesSnapshotsRestorePostConflict{} +} + +/* PcloudPvminstancesSnapshotsRestorePostConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type PcloudPvminstancesSnapshotsRestorePostConflict struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesSnapshotsRestorePostConflict) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/snapshots/{snapshot_id}/restore][%d] pcloudPvminstancesSnapshotsRestorePostConflict %+v", 409, o.Payload) +} +func (o *PcloudPvminstancesSnapshotsRestorePostConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesSnapshotsRestorePostConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesSnapshotsRestorePostInternalServerError creates a PcloudPvminstancesSnapshotsRestorePostInternalServerError with default headers values +func NewPcloudPvminstancesSnapshotsRestorePostInternalServerError() *PcloudPvminstancesSnapshotsRestorePostInternalServerError { + return &PcloudPvminstancesSnapshotsRestorePostInternalServerError{} +} + +/* PcloudPvminstancesSnapshotsRestorePostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudPvminstancesSnapshotsRestorePostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesSnapshotsRestorePostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/snapshots/{snapshot_id}/restore][%d] pcloudPvminstancesSnapshotsRestorePostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudPvminstancesSnapshotsRestorePostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesSnapshotsRestorePostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_v2_pvminstances_capture_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_v2_pvminstances_capture_get_parameters.go new file mode 100644 index 00000000000..8519057ed01 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_v2_pvminstances_capture_get_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudV2PvminstancesCaptureGetParams creates a new PcloudV2PvminstancesCaptureGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudV2PvminstancesCaptureGetParams() *PcloudV2PvminstancesCaptureGetParams { + return &PcloudV2PvminstancesCaptureGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudV2PvminstancesCaptureGetParamsWithTimeout creates a new PcloudV2PvminstancesCaptureGetParams object +// with the ability to set a timeout on a request. +func NewPcloudV2PvminstancesCaptureGetParamsWithTimeout(timeout time.Duration) *PcloudV2PvminstancesCaptureGetParams { + return &PcloudV2PvminstancesCaptureGetParams{ + timeout: timeout, + } +} + +// NewPcloudV2PvminstancesCaptureGetParamsWithContext creates a new PcloudV2PvminstancesCaptureGetParams object +// with the ability to set a context for a request. +func NewPcloudV2PvminstancesCaptureGetParamsWithContext(ctx context.Context) *PcloudV2PvminstancesCaptureGetParams { + return &PcloudV2PvminstancesCaptureGetParams{ + Context: ctx, + } +} + +// NewPcloudV2PvminstancesCaptureGetParamsWithHTTPClient creates a new PcloudV2PvminstancesCaptureGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudV2PvminstancesCaptureGetParamsWithHTTPClient(client *http.Client) *PcloudV2PvminstancesCaptureGetParams { + return &PcloudV2PvminstancesCaptureGetParams{ + HTTPClient: client, + } +} + +/* PcloudV2PvminstancesCaptureGetParams contains all the parameters to send to the API endpoint + for the pcloud v2 pvminstances capture get operation. + + Typically these are written to a http.Request. +*/ +type PcloudV2PvminstancesCaptureGetParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* PvmInstanceID. + + PCloud PVM Instance ID + */ + PvmInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud v2 pvminstances capture get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV2PvminstancesCaptureGetParams) WithDefaults() *PcloudV2PvminstancesCaptureGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud v2 pvminstances capture get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV2PvminstancesCaptureGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud v2 pvminstances capture get params +func (o *PcloudV2PvminstancesCaptureGetParams) WithTimeout(timeout time.Duration) *PcloudV2PvminstancesCaptureGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud v2 pvminstances capture get params +func (o *PcloudV2PvminstancesCaptureGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud v2 pvminstances capture get params +func (o *PcloudV2PvminstancesCaptureGetParams) WithContext(ctx context.Context) *PcloudV2PvminstancesCaptureGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud v2 pvminstances capture get params +func (o *PcloudV2PvminstancesCaptureGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud v2 pvminstances capture get params +func (o *PcloudV2PvminstancesCaptureGetParams) WithHTTPClient(client *http.Client) *PcloudV2PvminstancesCaptureGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud v2 pvminstances capture get params +func (o *PcloudV2PvminstancesCaptureGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud v2 pvminstances capture get params +func (o *PcloudV2PvminstancesCaptureGetParams) WithCloudInstanceID(cloudInstanceID string) *PcloudV2PvminstancesCaptureGetParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud v2 pvminstances capture get params +func (o *PcloudV2PvminstancesCaptureGetParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithPvmInstanceID adds the pvmInstanceID to the pcloud v2 pvminstances capture get params +func (o *PcloudV2PvminstancesCaptureGetParams) WithPvmInstanceID(pvmInstanceID string) *PcloudV2PvminstancesCaptureGetParams { + o.SetPvmInstanceID(pvmInstanceID) + return o +} + +// SetPvmInstanceID adds the pvmInstanceId to the pcloud v2 pvminstances capture get params +func (o *PcloudV2PvminstancesCaptureGetParams) SetPvmInstanceID(pvmInstanceID string) { + o.PvmInstanceID = pvmInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudV2PvminstancesCaptureGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param pvm_instance_id + if err := r.SetPathParam("pvm_instance_id", o.PvmInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_v2_pvminstances_capture_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_v2_pvminstances_capture_get_responses.go new file mode 100644 index 00000000000..d53cfa0b720 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_v2_pvminstances_capture_get_responses.go @@ -0,0 +1,181 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudV2PvminstancesCaptureGetReader is a Reader for the PcloudV2PvminstancesCaptureGet structure. +type PcloudV2PvminstancesCaptureGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudV2PvminstancesCaptureGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudV2PvminstancesCaptureGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewPcloudV2PvminstancesCaptureGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudV2PvminstancesCaptureGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudV2PvminstancesCaptureGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudV2PvminstancesCaptureGetOK creates a PcloudV2PvminstancesCaptureGetOK with default headers values +func NewPcloudV2PvminstancesCaptureGetOK() *PcloudV2PvminstancesCaptureGetOK { + return &PcloudV2PvminstancesCaptureGetOK{} +} + +/* PcloudV2PvminstancesCaptureGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudV2PvminstancesCaptureGetOK struct { + Payload *models.Job +} + +func (o *PcloudV2PvminstancesCaptureGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v2/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/capture][%d] pcloudV2PvminstancesCaptureGetOK %+v", 200, o.Payload) +} +func (o *PcloudV2PvminstancesCaptureGetOK) GetPayload() *models.Job { + return o.Payload +} + +func (o *PcloudV2PvminstancesCaptureGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Job) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2PvminstancesCaptureGetUnauthorized creates a PcloudV2PvminstancesCaptureGetUnauthorized with default headers values +func NewPcloudV2PvminstancesCaptureGetUnauthorized() *PcloudV2PvminstancesCaptureGetUnauthorized { + return &PcloudV2PvminstancesCaptureGetUnauthorized{} +} + +/* PcloudV2PvminstancesCaptureGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudV2PvminstancesCaptureGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudV2PvminstancesCaptureGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v2/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/capture][%d] pcloudV2PvminstancesCaptureGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudV2PvminstancesCaptureGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2PvminstancesCaptureGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2PvminstancesCaptureGetNotFound creates a PcloudV2PvminstancesCaptureGetNotFound with default headers values +func NewPcloudV2PvminstancesCaptureGetNotFound() *PcloudV2PvminstancesCaptureGetNotFound { + return &PcloudV2PvminstancesCaptureGetNotFound{} +} + +/* PcloudV2PvminstancesCaptureGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudV2PvminstancesCaptureGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudV2PvminstancesCaptureGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v2/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/capture][%d] pcloudV2PvminstancesCaptureGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudV2PvminstancesCaptureGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2PvminstancesCaptureGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2PvminstancesCaptureGetInternalServerError creates a PcloudV2PvminstancesCaptureGetInternalServerError with default headers values +func NewPcloudV2PvminstancesCaptureGetInternalServerError() *PcloudV2PvminstancesCaptureGetInternalServerError { + return &PcloudV2PvminstancesCaptureGetInternalServerError{} +} + +/* PcloudV2PvminstancesCaptureGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudV2PvminstancesCaptureGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudV2PvminstancesCaptureGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v2/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/capture][%d] pcloudV2PvminstancesCaptureGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudV2PvminstancesCaptureGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2PvminstancesCaptureGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_v2_pvminstances_capture_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_v2_pvminstances_capture_post_parameters.go new file mode 100644 index 00000000000..2a09a266f53 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_v2_pvminstances_capture_post_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudV2PvminstancesCapturePostParams creates a new PcloudV2PvminstancesCapturePostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudV2PvminstancesCapturePostParams() *PcloudV2PvminstancesCapturePostParams { + return &PcloudV2PvminstancesCapturePostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudV2PvminstancesCapturePostParamsWithTimeout creates a new PcloudV2PvminstancesCapturePostParams object +// with the ability to set a timeout on a request. +func NewPcloudV2PvminstancesCapturePostParamsWithTimeout(timeout time.Duration) *PcloudV2PvminstancesCapturePostParams { + return &PcloudV2PvminstancesCapturePostParams{ + timeout: timeout, + } +} + +// NewPcloudV2PvminstancesCapturePostParamsWithContext creates a new PcloudV2PvminstancesCapturePostParams object +// with the ability to set a context for a request. +func NewPcloudV2PvminstancesCapturePostParamsWithContext(ctx context.Context) *PcloudV2PvminstancesCapturePostParams { + return &PcloudV2PvminstancesCapturePostParams{ + Context: ctx, + } +} + +// NewPcloudV2PvminstancesCapturePostParamsWithHTTPClient creates a new PcloudV2PvminstancesCapturePostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudV2PvminstancesCapturePostParamsWithHTTPClient(client *http.Client) *PcloudV2PvminstancesCapturePostParams { + return &PcloudV2PvminstancesCapturePostParams{ + HTTPClient: client, + } +} + +/* PcloudV2PvminstancesCapturePostParams contains all the parameters to send to the API endpoint + for the pcloud v2 pvminstances capture post operation. + + Typically these are written to a http.Request. +*/ +type PcloudV2PvminstancesCapturePostParams struct { + + /* Body. + + Parameters for the capture + */ + Body *models.PVMInstanceCapture + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* PvmInstanceID. + + PCloud PVM Instance ID + */ + PvmInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud v2 pvminstances capture post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV2PvminstancesCapturePostParams) WithDefaults() *PcloudV2PvminstancesCapturePostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud v2 pvminstances capture post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV2PvminstancesCapturePostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud v2 pvminstances capture post params +func (o *PcloudV2PvminstancesCapturePostParams) WithTimeout(timeout time.Duration) *PcloudV2PvminstancesCapturePostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud v2 pvminstances capture post params +func (o *PcloudV2PvminstancesCapturePostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud v2 pvminstances capture post params +func (o *PcloudV2PvminstancesCapturePostParams) WithContext(ctx context.Context) *PcloudV2PvminstancesCapturePostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud v2 pvminstances capture post params +func (o *PcloudV2PvminstancesCapturePostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud v2 pvminstances capture post params +func (o *PcloudV2PvminstancesCapturePostParams) WithHTTPClient(client *http.Client) *PcloudV2PvminstancesCapturePostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud v2 pvminstances capture post params +func (o *PcloudV2PvminstancesCapturePostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud v2 pvminstances capture post params +func (o *PcloudV2PvminstancesCapturePostParams) WithBody(body *models.PVMInstanceCapture) *PcloudV2PvminstancesCapturePostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud v2 pvminstances capture post params +func (o *PcloudV2PvminstancesCapturePostParams) SetBody(body *models.PVMInstanceCapture) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud v2 pvminstances capture post params +func (o *PcloudV2PvminstancesCapturePostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudV2PvminstancesCapturePostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud v2 pvminstances capture post params +func (o *PcloudV2PvminstancesCapturePostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithPvmInstanceID adds the pvmInstanceID to the pcloud v2 pvminstances capture post params +func (o *PcloudV2PvminstancesCapturePostParams) WithPvmInstanceID(pvmInstanceID string) *PcloudV2PvminstancesCapturePostParams { + o.SetPvmInstanceID(pvmInstanceID) + return o +} + +// SetPvmInstanceID adds the pvmInstanceId to the pcloud v2 pvminstances capture post params +func (o *PcloudV2PvminstancesCapturePostParams) SetPvmInstanceID(pvmInstanceID string) { + o.PvmInstanceID = pvmInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudV2PvminstancesCapturePostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param pvm_instance_id + if err := r.SetPathParam("pvm_instance_id", o.PvmInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_v2_pvminstances_capture_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_v2_pvminstances_capture_post_responses.go new file mode 100644 index 00000000000..787b81faa37 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances/pcloud_v2_pvminstances_capture_post_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_p_vm_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudV2PvminstancesCapturePostReader is a Reader for the PcloudV2PvminstancesCapturePost structure. +type PcloudV2PvminstancesCapturePostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudV2PvminstancesCapturePostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 202: + result := NewPcloudV2PvminstancesCapturePostAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudV2PvminstancesCapturePostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudV2PvminstancesCapturePostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudV2PvminstancesCapturePostNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewPcloudV2PvminstancesCapturePostConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudV2PvminstancesCapturePostUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudV2PvminstancesCapturePostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudV2PvminstancesCapturePostAccepted creates a PcloudV2PvminstancesCapturePostAccepted with default headers values +func NewPcloudV2PvminstancesCapturePostAccepted() *PcloudV2PvminstancesCapturePostAccepted { + return &PcloudV2PvminstancesCapturePostAccepted{} +} + +/* PcloudV2PvminstancesCapturePostAccepted describes a response with status code 202, with default header values. + +Accepted, pvm-instance capture successfully added to the jobs queue +*/ +type PcloudV2PvminstancesCapturePostAccepted struct { + Payload *models.JobReference +} + +func (o *PcloudV2PvminstancesCapturePostAccepted) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/capture][%d] pcloudV2PvminstancesCapturePostAccepted %+v", 202, o.Payload) +} +func (o *PcloudV2PvminstancesCapturePostAccepted) GetPayload() *models.JobReference { + return o.Payload +} + +func (o *PcloudV2PvminstancesCapturePostAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.JobReference) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2PvminstancesCapturePostBadRequest creates a PcloudV2PvminstancesCapturePostBadRequest with default headers values +func NewPcloudV2PvminstancesCapturePostBadRequest() *PcloudV2PvminstancesCapturePostBadRequest { + return &PcloudV2PvminstancesCapturePostBadRequest{} +} + +/* PcloudV2PvminstancesCapturePostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudV2PvminstancesCapturePostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudV2PvminstancesCapturePostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/capture][%d] pcloudV2PvminstancesCapturePostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudV2PvminstancesCapturePostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2PvminstancesCapturePostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2PvminstancesCapturePostUnauthorized creates a PcloudV2PvminstancesCapturePostUnauthorized with default headers values +func NewPcloudV2PvminstancesCapturePostUnauthorized() *PcloudV2PvminstancesCapturePostUnauthorized { + return &PcloudV2PvminstancesCapturePostUnauthorized{} +} + +/* PcloudV2PvminstancesCapturePostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudV2PvminstancesCapturePostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudV2PvminstancesCapturePostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/capture][%d] pcloudV2PvminstancesCapturePostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudV2PvminstancesCapturePostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2PvminstancesCapturePostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2PvminstancesCapturePostNotFound creates a PcloudV2PvminstancesCapturePostNotFound with default headers values +func NewPcloudV2PvminstancesCapturePostNotFound() *PcloudV2PvminstancesCapturePostNotFound { + return &PcloudV2PvminstancesCapturePostNotFound{} +} + +/* PcloudV2PvminstancesCapturePostNotFound describes a response with status code 404, with default header values. + +pvm instance id not found +*/ +type PcloudV2PvminstancesCapturePostNotFound struct { + Payload *models.Error +} + +func (o *PcloudV2PvminstancesCapturePostNotFound) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/capture][%d] pcloudV2PvminstancesCapturePostNotFound %+v", 404, o.Payload) +} +func (o *PcloudV2PvminstancesCapturePostNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2PvminstancesCapturePostNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2PvminstancesCapturePostConflict creates a PcloudV2PvminstancesCapturePostConflict with default headers values +func NewPcloudV2PvminstancesCapturePostConflict() *PcloudV2PvminstancesCapturePostConflict { + return &PcloudV2PvminstancesCapturePostConflict{} +} + +/* PcloudV2PvminstancesCapturePostConflict describes a response with status code 409, with default header values. + +Conflict, a conflict has prevented adding the pvm-instance capture job +*/ +type PcloudV2PvminstancesCapturePostConflict struct { + Payload *models.Error +} + +func (o *PcloudV2PvminstancesCapturePostConflict) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/capture][%d] pcloudV2PvminstancesCapturePostConflict %+v", 409, o.Payload) +} +func (o *PcloudV2PvminstancesCapturePostConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2PvminstancesCapturePostConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2PvminstancesCapturePostUnprocessableEntity creates a PcloudV2PvminstancesCapturePostUnprocessableEntity with default headers values +func NewPcloudV2PvminstancesCapturePostUnprocessableEntity() *PcloudV2PvminstancesCapturePostUnprocessableEntity { + return &PcloudV2PvminstancesCapturePostUnprocessableEntity{} +} + +/* PcloudV2PvminstancesCapturePostUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudV2PvminstancesCapturePostUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudV2PvminstancesCapturePostUnprocessableEntity) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/capture][%d] pcloudV2PvminstancesCapturePostUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudV2PvminstancesCapturePostUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2PvminstancesCapturePostUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2PvminstancesCapturePostInternalServerError creates a PcloudV2PvminstancesCapturePostInternalServerError with default headers values +func NewPcloudV2PvminstancesCapturePostInternalServerError() *PcloudV2PvminstancesCapturePostInternalServerError { + return &PcloudV2PvminstancesCapturePostInternalServerError{} +} + +/* PcloudV2PvminstancesCapturePostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudV2PvminstancesCapturePostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudV2PvminstancesCapturePostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/capture][%d] pcloudV2PvminstancesCapturePostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudV2PvminstancesCapturePostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2PvminstancesCapturePostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/p_cloud_placement_groups_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/p_cloud_placement_groups_client.go new file mode 100644 index 00000000000..85828def897 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/p_cloud_placement_groups_client.go @@ -0,0 +1,285 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_placement_groups + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new p cloud placement groups API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for p cloud placement groups API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + PcloudPlacementgroupsDelete(params *PcloudPlacementgroupsDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPlacementgroupsDeleteOK, error) + + PcloudPlacementgroupsGet(params *PcloudPlacementgroupsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPlacementgroupsGetOK, error) + + PcloudPlacementgroupsGetall(params *PcloudPlacementgroupsGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPlacementgroupsGetallOK, error) + + PcloudPlacementgroupsMembersDelete(params *PcloudPlacementgroupsMembersDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPlacementgroupsMembersDeleteOK, error) + + PcloudPlacementgroupsMembersPost(params *PcloudPlacementgroupsMembersPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPlacementgroupsMembersPostOK, error) + + PcloudPlacementgroupsPost(params *PcloudPlacementgroupsPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPlacementgroupsPostOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + PcloudPlacementgroupsDelete deletes server placement group +*/ +func (a *Client) PcloudPlacementgroupsDelete(params *PcloudPlacementgroupsDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPlacementgroupsDeleteOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudPlacementgroupsDeleteParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.placementgroups.delete", + Method: "DELETE", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups/{placement_group_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudPlacementgroupsDeleteReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudPlacementgroupsDeleteOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.placementgroups.delete: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudPlacementgroupsGet gets server placement group detail +*/ +func (a *Client) PcloudPlacementgroupsGet(params *PcloudPlacementgroupsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPlacementgroupsGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudPlacementgroupsGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.placementgroups.get", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups/{placement_group_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudPlacementgroupsGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudPlacementgroupsGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.placementgroups.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudPlacementgroupsGetall gets all server placement groups +*/ +func (a *Client) PcloudPlacementgroupsGetall(params *PcloudPlacementgroupsGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPlacementgroupsGetallOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudPlacementgroupsGetallParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.placementgroups.getall", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudPlacementgroupsGetallReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudPlacementgroupsGetallOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.placementgroups.getall: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudPlacementgroupsMembersDelete removes server from placement group +*/ +func (a *Client) PcloudPlacementgroupsMembersDelete(params *PcloudPlacementgroupsMembersDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPlacementgroupsMembersDeleteOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudPlacementgroupsMembersDeleteParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.placementgroups.members.delete", + Method: "DELETE", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups/{placement_group_id}/members", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudPlacementgroupsMembersDeleteReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudPlacementgroupsMembersDeleteOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.placementgroups.members.delete: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudPlacementgroupsMembersPost adds server to placement group +*/ +func (a *Client) PcloudPlacementgroupsMembersPost(params *PcloudPlacementgroupsMembersPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPlacementgroupsMembersPostOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudPlacementgroupsMembersPostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.placementgroups.members.post", + Method: "POST", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups/{placement_group_id}/members", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudPlacementgroupsMembersPostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudPlacementgroupsMembersPostOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.placementgroups.members.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudPlacementgroupsPost creates a new server placement group +*/ +func (a *Client) PcloudPlacementgroupsPost(params *PcloudPlacementgroupsPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPlacementgroupsPostOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudPlacementgroupsPostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.placementgroups.post", + Method: "POST", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudPlacementgroupsPostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudPlacementgroupsPostOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.placementgroups.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_delete_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_delete_parameters.go new file mode 100644 index 00000000000..a81176ab48f --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_delete_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_placement_groups + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudPlacementgroupsDeleteParams creates a new PcloudPlacementgroupsDeleteParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudPlacementgroupsDeleteParams() *PcloudPlacementgroupsDeleteParams { + return &PcloudPlacementgroupsDeleteParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudPlacementgroupsDeleteParamsWithTimeout creates a new PcloudPlacementgroupsDeleteParams object +// with the ability to set a timeout on a request. +func NewPcloudPlacementgroupsDeleteParamsWithTimeout(timeout time.Duration) *PcloudPlacementgroupsDeleteParams { + return &PcloudPlacementgroupsDeleteParams{ + timeout: timeout, + } +} + +// NewPcloudPlacementgroupsDeleteParamsWithContext creates a new PcloudPlacementgroupsDeleteParams object +// with the ability to set a context for a request. +func NewPcloudPlacementgroupsDeleteParamsWithContext(ctx context.Context) *PcloudPlacementgroupsDeleteParams { + return &PcloudPlacementgroupsDeleteParams{ + Context: ctx, + } +} + +// NewPcloudPlacementgroupsDeleteParamsWithHTTPClient creates a new PcloudPlacementgroupsDeleteParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudPlacementgroupsDeleteParamsWithHTTPClient(client *http.Client) *PcloudPlacementgroupsDeleteParams { + return &PcloudPlacementgroupsDeleteParams{ + HTTPClient: client, + } +} + +/* PcloudPlacementgroupsDeleteParams contains all the parameters to send to the API endpoint + for the pcloud placementgroups delete operation. + + Typically these are written to a http.Request. +*/ +type PcloudPlacementgroupsDeleteParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* PlacementGroupID. + + Placement Group ID + */ + PlacementGroupID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud placementgroups delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPlacementgroupsDeleteParams) WithDefaults() *PcloudPlacementgroupsDeleteParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud placementgroups delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPlacementgroupsDeleteParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud placementgroups delete params +func (o *PcloudPlacementgroupsDeleteParams) WithTimeout(timeout time.Duration) *PcloudPlacementgroupsDeleteParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud placementgroups delete params +func (o *PcloudPlacementgroupsDeleteParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud placementgroups delete params +func (o *PcloudPlacementgroupsDeleteParams) WithContext(ctx context.Context) *PcloudPlacementgroupsDeleteParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud placementgroups delete params +func (o *PcloudPlacementgroupsDeleteParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud placementgroups delete params +func (o *PcloudPlacementgroupsDeleteParams) WithHTTPClient(client *http.Client) *PcloudPlacementgroupsDeleteParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud placementgroups delete params +func (o *PcloudPlacementgroupsDeleteParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud placementgroups delete params +func (o *PcloudPlacementgroupsDeleteParams) WithCloudInstanceID(cloudInstanceID string) *PcloudPlacementgroupsDeleteParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud placementgroups delete params +func (o *PcloudPlacementgroupsDeleteParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithPlacementGroupID adds the placementGroupID to the pcloud placementgroups delete params +func (o *PcloudPlacementgroupsDeleteParams) WithPlacementGroupID(placementGroupID string) *PcloudPlacementgroupsDeleteParams { + o.SetPlacementGroupID(placementGroupID) + return o +} + +// SetPlacementGroupID adds the placementGroupId to the pcloud placementgroups delete params +func (o *PcloudPlacementgroupsDeleteParams) SetPlacementGroupID(placementGroupID string) { + o.PlacementGroupID = placementGroupID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudPlacementgroupsDeleteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param placement_group_id + if err := r.SetPathParam("placement_group_id", o.PlacementGroupID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_delete_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_delete_responses.go new file mode 100644 index 00000000000..7052f606440 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_delete_responses.go @@ -0,0 +1,179 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_placement_groups + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudPlacementgroupsDeleteReader is a Reader for the PcloudPlacementgroupsDelete structure. +type PcloudPlacementgroupsDeleteReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudPlacementgroupsDeleteReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudPlacementgroupsDeleteOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudPlacementgroupsDeleteBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudPlacementgroupsDeleteNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudPlacementgroupsDeleteInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudPlacementgroupsDeleteOK creates a PcloudPlacementgroupsDeleteOK with default headers values +func NewPcloudPlacementgroupsDeleteOK() *PcloudPlacementgroupsDeleteOK { + return &PcloudPlacementgroupsDeleteOK{} +} + +/* PcloudPlacementgroupsDeleteOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudPlacementgroupsDeleteOK struct { + Payload models.Object +} + +func (o *PcloudPlacementgroupsDeleteOK) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups/{placement_group_id}][%d] pcloudPlacementgroupsDeleteOK %+v", 200, o.Payload) +} +func (o *PcloudPlacementgroupsDeleteOK) GetPayload() models.Object { + return o.Payload +} + +func (o *PcloudPlacementgroupsDeleteOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPlacementgroupsDeleteBadRequest creates a PcloudPlacementgroupsDeleteBadRequest with default headers values +func NewPcloudPlacementgroupsDeleteBadRequest() *PcloudPlacementgroupsDeleteBadRequest { + return &PcloudPlacementgroupsDeleteBadRequest{} +} + +/* PcloudPlacementgroupsDeleteBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudPlacementgroupsDeleteBadRequest struct { + Payload *models.Error +} + +func (o *PcloudPlacementgroupsDeleteBadRequest) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups/{placement_group_id}][%d] pcloudPlacementgroupsDeleteBadRequest %+v", 400, o.Payload) +} +func (o *PcloudPlacementgroupsDeleteBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPlacementgroupsDeleteBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPlacementgroupsDeleteNotFound creates a PcloudPlacementgroupsDeleteNotFound with default headers values +func NewPcloudPlacementgroupsDeleteNotFound() *PcloudPlacementgroupsDeleteNotFound { + return &PcloudPlacementgroupsDeleteNotFound{} +} + +/* PcloudPlacementgroupsDeleteNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudPlacementgroupsDeleteNotFound struct { + Payload *models.Error +} + +func (o *PcloudPlacementgroupsDeleteNotFound) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups/{placement_group_id}][%d] pcloudPlacementgroupsDeleteNotFound %+v", 404, o.Payload) +} +func (o *PcloudPlacementgroupsDeleteNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPlacementgroupsDeleteNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPlacementgroupsDeleteInternalServerError creates a PcloudPlacementgroupsDeleteInternalServerError with default headers values +func NewPcloudPlacementgroupsDeleteInternalServerError() *PcloudPlacementgroupsDeleteInternalServerError { + return &PcloudPlacementgroupsDeleteInternalServerError{} +} + +/* PcloudPlacementgroupsDeleteInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudPlacementgroupsDeleteInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudPlacementgroupsDeleteInternalServerError) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups/{placement_group_id}][%d] pcloudPlacementgroupsDeleteInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudPlacementgroupsDeleteInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPlacementgroupsDeleteInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_get_parameters.go new file mode 100644 index 00000000000..7c9106fc5c8 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_get_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_placement_groups + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudPlacementgroupsGetParams creates a new PcloudPlacementgroupsGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudPlacementgroupsGetParams() *PcloudPlacementgroupsGetParams { + return &PcloudPlacementgroupsGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudPlacementgroupsGetParamsWithTimeout creates a new PcloudPlacementgroupsGetParams object +// with the ability to set a timeout on a request. +func NewPcloudPlacementgroupsGetParamsWithTimeout(timeout time.Duration) *PcloudPlacementgroupsGetParams { + return &PcloudPlacementgroupsGetParams{ + timeout: timeout, + } +} + +// NewPcloudPlacementgroupsGetParamsWithContext creates a new PcloudPlacementgroupsGetParams object +// with the ability to set a context for a request. +func NewPcloudPlacementgroupsGetParamsWithContext(ctx context.Context) *PcloudPlacementgroupsGetParams { + return &PcloudPlacementgroupsGetParams{ + Context: ctx, + } +} + +// NewPcloudPlacementgroupsGetParamsWithHTTPClient creates a new PcloudPlacementgroupsGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudPlacementgroupsGetParamsWithHTTPClient(client *http.Client) *PcloudPlacementgroupsGetParams { + return &PcloudPlacementgroupsGetParams{ + HTTPClient: client, + } +} + +/* PcloudPlacementgroupsGetParams contains all the parameters to send to the API endpoint + for the pcloud placementgroups get operation. + + Typically these are written to a http.Request. +*/ +type PcloudPlacementgroupsGetParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* PlacementGroupID. + + Placement Group ID + */ + PlacementGroupID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud placementgroups get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPlacementgroupsGetParams) WithDefaults() *PcloudPlacementgroupsGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud placementgroups get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPlacementgroupsGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud placementgroups get params +func (o *PcloudPlacementgroupsGetParams) WithTimeout(timeout time.Duration) *PcloudPlacementgroupsGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud placementgroups get params +func (o *PcloudPlacementgroupsGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud placementgroups get params +func (o *PcloudPlacementgroupsGetParams) WithContext(ctx context.Context) *PcloudPlacementgroupsGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud placementgroups get params +func (o *PcloudPlacementgroupsGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud placementgroups get params +func (o *PcloudPlacementgroupsGetParams) WithHTTPClient(client *http.Client) *PcloudPlacementgroupsGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud placementgroups get params +func (o *PcloudPlacementgroupsGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud placementgroups get params +func (o *PcloudPlacementgroupsGetParams) WithCloudInstanceID(cloudInstanceID string) *PcloudPlacementgroupsGetParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud placementgroups get params +func (o *PcloudPlacementgroupsGetParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithPlacementGroupID adds the placementGroupID to the pcloud placementgroups get params +func (o *PcloudPlacementgroupsGetParams) WithPlacementGroupID(placementGroupID string) *PcloudPlacementgroupsGetParams { + o.SetPlacementGroupID(placementGroupID) + return o +} + +// SetPlacementGroupID adds the placementGroupId to the pcloud placementgroups get params +func (o *PcloudPlacementgroupsGetParams) SetPlacementGroupID(placementGroupID string) { + o.PlacementGroupID = placementGroupID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudPlacementgroupsGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param placement_group_id + if err := r.SetPathParam("placement_group_id", o.PlacementGroupID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_get_responses.go new file mode 100644 index 00000000000..8a3a7acf9b9 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_get_responses.go @@ -0,0 +1,181 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_placement_groups + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudPlacementgroupsGetReader is a Reader for the PcloudPlacementgroupsGet structure. +type PcloudPlacementgroupsGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudPlacementgroupsGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudPlacementgroupsGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudPlacementgroupsGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudPlacementgroupsGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudPlacementgroupsGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudPlacementgroupsGetOK creates a PcloudPlacementgroupsGetOK with default headers values +func NewPcloudPlacementgroupsGetOK() *PcloudPlacementgroupsGetOK { + return &PcloudPlacementgroupsGetOK{} +} + +/* PcloudPlacementgroupsGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudPlacementgroupsGetOK struct { + Payload *models.PlacementGroup +} + +func (o *PcloudPlacementgroupsGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups/{placement_group_id}][%d] pcloudPlacementgroupsGetOK %+v", 200, o.Payload) +} +func (o *PcloudPlacementgroupsGetOK) GetPayload() *models.PlacementGroup { + return o.Payload +} + +func (o *PcloudPlacementgroupsGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.PlacementGroup) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPlacementgroupsGetBadRequest creates a PcloudPlacementgroupsGetBadRequest with default headers values +func NewPcloudPlacementgroupsGetBadRequest() *PcloudPlacementgroupsGetBadRequest { + return &PcloudPlacementgroupsGetBadRequest{} +} + +/* PcloudPlacementgroupsGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudPlacementgroupsGetBadRequest struct { + Payload *models.Error +} + +func (o *PcloudPlacementgroupsGetBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups/{placement_group_id}][%d] pcloudPlacementgroupsGetBadRequest %+v", 400, o.Payload) +} +func (o *PcloudPlacementgroupsGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPlacementgroupsGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPlacementgroupsGetNotFound creates a PcloudPlacementgroupsGetNotFound with default headers values +func NewPcloudPlacementgroupsGetNotFound() *PcloudPlacementgroupsGetNotFound { + return &PcloudPlacementgroupsGetNotFound{} +} + +/* PcloudPlacementgroupsGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudPlacementgroupsGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudPlacementgroupsGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups/{placement_group_id}][%d] pcloudPlacementgroupsGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudPlacementgroupsGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPlacementgroupsGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPlacementgroupsGetInternalServerError creates a PcloudPlacementgroupsGetInternalServerError with default headers values +func NewPcloudPlacementgroupsGetInternalServerError() *PcloudPlacementgroupsGetInternalServerError { + return &PcloudPlacementgroupsGetInternalServerError{} +} + +/* PcloudPlacementgroupsGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudPlacementgroupsGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudPlacementgroupsGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups/{placement_group_id}][%d] pcloudPlacementgroupsGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudPlacementgroupsGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPlacementgroupsGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_getall_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_getall_parameters.go new file mode 100644 index 00000000000..07366c2d8b1 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_getall_parameters.go @@ -0,0 +1,149 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_placement_groups + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudPlacementgroupsGetallParams creates a new PcloudPlacementgroupsGetallParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudPlacementgroupsGetallParams() *PcloudPlacementgroupsGetallParams { + return &PcloudPlacementgroupsGetallParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudPlacementgroupsGetallParamsWithTimeout creates a new PcloudPlacementgroupsGetallParams object +// with the ability to set a timeout on a request. +func NewPcloudPlacementgroupsGetallParamsWithTimeout(timeout time.Duration) *PcloudPlacementgroupsGetallParams { + return &PcloudPlacementgroupsGetallParams{ + timeout: timeout, + } +} + +// NewPcloudPlacementgroupsGetallParamsWithContext creates a new PcloudPlacementgroupsGetallParams object +// with the ability to set a context for a request. +func NewPcloudPlacementgroupsGetallParamsWithContext(ctx context.Context) *PcloudPlacementgroupsGetallParams { + return &PcloudPlacementgroupsGetallParams{ + Context: ctx, + } +} + +// NewPcloudPlacementgroupsGetallParamsWithHTTPClient creates a new PcloudPlacementgroupsGetallParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudPlacementgroupsGetallParamsWithHTTPClient(client *http.Client) *PcloudPlacementgroupsGetallParams { + return &PcloudPlacementgroupsGetallParams{ + HTTPClient: client, + } +} + +/* PcloudPlacementgroupsGetallParams contains all the parameters to send to the API endpoint + for the pcloud placementgroups getall operation. + + Typically these are written to a http.Request. +*/ +type PcloudPlacementgroupsGetallParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud placementgroups getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPlacementgroupsGetallParams) WithDefaults() *PcloudPlacementgroupsGetallParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud placementgroups getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPlacementgroupsGetallParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud placementgroups getall params +func (o *PcloudPlacementgroupsGetallParams) WithTimeout(timeout time.Duration) *PcloudPlacementgroupsGetallParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud placementgroups getall params +func (o *PcloudPlacementgroupsGetallParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud placementgroups getall params +func (o *PcloudPlacementgroupsGetallParams) WithContext(ctx context.Context) *PcloudPlacementgroupsGetallParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud placementgroups getall params +func (o *PcloudPlacementgroupsGetallParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud placementgroups getall params +func (o *PcloudPlacementgroupsGetallParams) WithHTTPClient(client *http.Client) *PcloudPlacementgroupsGetallParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud placementgroups getall params +func (o *PcloudPlacementgroupsGetallParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud placementgroups getall params +func (o *PcloudPlacementgroupsGetallParams) WithCloudInstanceID(cloudInstanceID string) *PcloudPlacementgroupsGetallParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud placementgroups getall params +func (o *PcloudPlacementgroupsGetallParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudPlacementgroupsGetallParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_getall_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_getall_responses.go new file mode 100644 index 00000000000..7263ac5fa8e --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_getall_responses.go @@ -0,0 +1,181 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_placement_groups + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudPlacementgroupsGetallReader is a Reader for the PcloudPlacementgroupsGetall structure. +type PcloudPlacementgroupsGetallReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudPlacementgroupsGetallReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudPlacementgroupsGetallOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudPlacementgroupsGetallBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudPlacementgroupsGetallUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudPlacementgroupsGetallInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudPlacementgroupsGetallOK creates a PcloudPlacementgroupsGetallOK with default headers values +func NewPcloudPlacementgroupsGetallOK() *PcloudPlacementgroupsGetallOK { + return &PcloudPlacementgroupsGetallOK{} +} + +/* PcloudPlacementgroupsGetallOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudPlacementgroupsGetallOK struct { + Payload *models.PlacementGroups +} + +func (o *PcloudPlacementgroupsGetallOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups][%d] pcloudPlacementgroupsGetallOK %+v", 200, o.Payload) +} +func (o *PcloudPlacementgroupsGetallOK) GetPayload() *models.PlacementGroups { + return o.Payload +} + +func (o *PcloudPlacementgroupsGetallOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.PlacementGroups) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPlacementgroupsGetallBadRequest creates a PcloudPlacementgroupsGetallBadRequest with default headers values +func NewPcloudPlacementgroupsGetallBadRequest() *PcloudPlacementgroupsGetallBadRequest { + return &PcloudPlacementgroupsGetallBadRequest{} +} + +/* PcloudPlacementgroupsGetallBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudPlacementgroupsGetallBadRequest struct { + Payload *models.Error +} + +func (o *PcloudPlacementgroupsGetallBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups][%d] pcloudPlacementgroupsGetallBadRequest %+v", 400, o.Payload) +} +func (o *PcloudPlacementgroupsGetallBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPlacementgroupsGetallBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPlacementgroupsGetallUnauthorized creates a PcloudPlacementgroupsGetallUnauthorized with default headers values +func NewPcloudPlacementgroupsGetallUnauthorized() *PcloudPlacementgroupsGetallUnauthorized { + return &PcloudPlacementgroupsGetallUnauthorized{} +} + +/* PcloudPlacementgroupsGetallUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudPlacementgroupsGetallUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudPlacementgroupsGetallUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups][%d] pcloudPlacementgroupsGetallUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudPlacementgroupsGetallUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPlacementgroupsGetallUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPlacementgroupsGetallInternalServerError creates a PcloudPlacementgroupsGetallInternalServerError with default headers values +func NewPcloudPlacementgroupsGetallInternalServerError() *PcloudPlacementgroupsGetallInternalServerError { + return &PcloudPlacementgroupsGetallInternalServerError{} +} + +/* PcloudPlacementgroupsGetallInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudPlacementgroupsGetallInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudPlacementgroupsGetallInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups][%d] pcloudPlacementgroupsGetallInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudPlacementgroupsGetallInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPlacementgroupsGetallInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_members_delete_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_members_delete_parameters.go new file mode 100644 index 00000000000..c860277a23c --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_members_delete_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_placement_groups + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudPlacementgroupsMembersDeleteParams creates a new PcloudPlacementgroupsMembersDeleteParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudPlacementgroupsMembersDeleteParams() *PcloudPlacementgroupsMembersDeleteParams { + return &PcloudPlacementgroupsMembersDeleteParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudPlacementgroupsMembersDeleteParamsWithTimeout creates a new PcloudPlacementgroupsMembersDeleteParams object +// with the ability to set a timeout on a request. +func NewPcloudPlacementgroupsMembersDeleteParamsWithTimeout(timeout time.Duration) *PcloudPlacementgroupsMembersDeleteParams { + return &PcloudPlacementgroupsMembersDeleteParams{ + timeout: timeout, + } +} + +// NewPcloudPlacementgroupsMembersDeleteParamsWithContext creates a new PcloudPlacementgroupsMembersDeleteParams object +// with the ability to set a context for a request. +func NewPcloudPlacementgroupsMembersDeleteParamsWithContext(ctx context.Context) *PcloudPlacementgroupsMembersDeleteParams { + return &PcloudPlacementgroupsMembersDeleteParams{ + Context: ctx, + } +} + +// NewPcloudPlacementgroupsMembersDeleteParamsWithHTTPClient creates a new PcloudPlacementgroupsMembersDeleteParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudPlacementgroupsMembersDeleteParamsWithHTTPClient(client *http.Client) *PcloudPlacementgroupsMembersDeleteParams { + return &PcloudPlacementgroupsMembersDeleteParams{ + HTTPClient: client, + } +} + +/* PcloudPlacementgroupsMembersDeleteParams contains all the parameters to send to the API endpoint + for the pcloud placementgroups members delete operation. + + Typically these are written to a http.Request. +*/ +type PcloudPlacementgroupsMembersDeleteParams struct { + + /* Body. + + Parameters for removing a Server in a Placement Group + */ + Body *models.PlacementGroupServer + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* PlacementGroupID. + + Placement Group ID + */ + PlacementGroupID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud placementgroups members delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPlacementgroupsMembersDeleteParams) WithDefaults() *PcloudPlacementgroupsMembersDeleteParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud placementgroups members delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPlacementgroupsMembersDeleteParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud placementgroups members delete params +func (o *PcloudPlacementgroupsMembersDeleteParams) WithTimeout(timeout time.Duration) *PcloudPlacementgroupsMembersDeleteParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud placementgroups members delete params +func (o *PcloudPlacementgroupsMembersDeleteParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud placementgroups members delete params +func (o *PcloudPlacementgroupsMembersDeleteParams) WithContext(ctx context.Context) *PcloudPlacementgroupsMembersDeleteParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud placementgroups members delete params +func (o *PcloudPlacementgroupsMembersDeleteParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud placementgroups members delete params +func (o *PcloudPlacementgroupsMembersDeleteParams) WithHTTPClient(client *http.Client) *PcloudPlacementgroupsMembersDeleteParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud placementgroups members delete params +func (o *PcloudPlacementgroupsMembersDeleteParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud placementgroups members delete params +func (o *PcloudPlacementgroupsMembersDeleteParams) WithBody(body *models.PlacementGroupServer) *PcloudPlacementgroupsMembersDeleteParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud placementgroups members delete params +func (o *PcloudPlacementgroupsMembersDeleteParams) SetBody(body *models.PlacementGroupServer) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud placementgroups members delete params +func (o *PcloudPlacementgroupsMembersDeleteParams) WithCloudInstanceID(cloudInstanceID string) *PcloudPlacementgroupsMembersDeleteParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud placementgroups members delete params +func (o *PcloudPlacementgroupsMembersDeleteParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithPlacementGroupID adds the placementGroupID to the pcloud placementgroups members delete params +func (o *PcloudPlacementgroupsMembersDeleteParams) WithPlacementGroupID(placementGroupID string) *PcloudPlacementgroupsMembersDeleteParams { + o.SetPlacementGroupID(placementGroupID) + return o +} + +// SetPlacementGroupID adds the placementGroupId to the pcloud placementgroups members delete params +func (o *PcloudPlacementgroupsMembersDeleteParams) SetPlacementGroupID(placementGroupID string) { + o.PlacementGroupID = placementGroupID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudPlacementgroupsMembersDeleteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param placement_group_id + if err := r.SetPathParam("placement_group_id", o.PlacementGroupID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_members_delete_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_members_delete_responses.go new file mode 100644 index 00000000000..513178760f2 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_members_delete_responses.go @@ -0,0 +1,257 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_placement_groups + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudPlacementgroupsMembersDeleteReader is a Reader for the PcloudPlacementgroupsMembersDelete structure. +type PcloudPlacementgroupsMembersDeleteReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudPlacementgroupsMembersDeleteReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudPlacementgroupsMembersDeleteOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudPlacementgroupsMembersDeleteBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudPlacementgroupsMembersDeleteNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewPcloudPlacementgroupsMembersDeleteConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudPlacementgroupsMembersDeleteUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudPlacementgroupsMembersDeleteInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudPlacementgroupsMembersDeleteOK creates a PcloudPlacementgroupsMembersDeleteOK with default headers values +func NewPcloudPlacementgroupsMembersDeleteOK() *PcloudPlacementgroupsMembersDeleteOK { + return &PcloudPlacementgroupsMembersDeleteOK{} +} + +/* PcloudPlacementgroupsMembersDeleteOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudPlacementgroupsMembersDeleteOK struct { + Payload *models.PlacementGroup +} + +func (o *PcloudPlacementgroupsMembersDeleteOK) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups/{placement_group_id}/members][%d] pcloudPlacementgroupsMembersDeleteOK %+v", 200, o.Payload) +} +func (o *PcloudPlacementgroupsMembersDeleteOK) GetPayload() *models.PlacementGroup { + return o.Payload +} + +func (o *PcloudPlacementgroupsMembersDeleteOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.PlacementGroup) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPlacementgroupsMembersDeleteBadRequest creates a PcloudPlacementgroupsMembersDeleteBadRequest with default headers values +func NewPcloudPlacementgroupsMembersDeleteBadRequest() *PcloudPlacementgroupsMembersDeleteBadRequest { + return &PcloudPlacementgroupsMembersDeleteBadRequest{} +} + +/* PcloudPlacementgroupsMembersDeleteBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudPlacementgroupsMembersDeleteBadRequest struct { + Payload *models.Error +} + +func (o *PcloudPlacementgroupsMembersDeleteBadRequest) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups/{placement_group_id}/members][%d] pcloudPlacementgroupsMembersDeleteBadRequest %+v", 400, o.Payload) +} +func (o *PcloudPlacementgroupsMembersDeleteBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPlacementgroupsMembersDeleteBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPlacementgroupsMembersDeleteNotFound creates a PcloudPlacementgroupsMembersDeleteNotFound with default headers values +func NewPcloudPlacementgroupsMembersDeleteNotFound() *PcloudPlacementgroupsMembersDeleteNotFound { + return &PcloudPlacementgroupsMembersDeleteNotFound{} +} + +/* PcloudPlacementgroupsMembersDeleteNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudPlacementgroupsMembersDeleteNotFound struct { + Payload *models.Error +} + +func (o *PcloudPlacementgroupsMembersDeleteNotFound) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups/{placement_group_id}/members][%d] pcloudPlacementgroupsMembersDeleteNotFound %+v", 404, o.Payload) +} +func (o *PcloudPlacementgroupsMembersDeleteNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPlacementgroupsMembersDeleteNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPlacementgroupsMembersDeleteConflict creates a PcloudPlacementgroupsMembersDeleteConflict with default headers values +func NewPcloudPlacementgroupsMembersDeleteConflict() *PcloudPlacementgroupsMembersDeleteConflict { + return &PcloudPlacementgroupsMembersDeleteConflict{} +} + +/* PcloudPlacementgroupsMembersDeleteConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type PcloudPlacementgroupsMembersDeleteConflict struct { + Payload *models.Error +} + +func (o *PcloudPlacementgroupsMembersDeleteConflict) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups/{placement_group_id}/members][%d] pcloudPlacementgroupsMembersDeleteConflict %+v", 409, o.Payload) +} +func (o *PcloudPlacementgroupsMembersDeleteConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPlacementgroupsMembersDeleteConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPlacementgroupsMembersDeleteUnprocessableEntity creates a PcloudPlacementgroupsMembersDeleteUnprocessableEntity with default headers values +func NewPcloudPlacementgroupsMembersDeleteUnprocessableEntity() *PcloudPlacementgroupsMembersDeleteUnprocessableEntity { + return &PcloudPlacementgroupsMembersDeleteUnprocessableEntity{} +} + +/* PcloudPlacementgroupsMembersDeleteUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudPlacementgroupsMembersDeleteUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudPlacementgroupsMembersDeleteUnprocessableEntity) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups/{placement_group_id}/members][%d] pcloudPlacementgroupsMembersDeleteUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudPlacementgroupsMembersDeleteUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPlacementgroupsMembersDeleteUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPlacementgroupsMembersDeleteInternalServerError creates a PcloudPlacementgroupsMembersDeleteInternalServerError with default headers values +func NewPcloudPlacementgroupsMembersDeleteInternalServerError() *PcloudPlacementgroupsMembersDeleteInternalServerError { + return &PcloudPlacementgroupsMembersDeleteInternalServerError{} +} + +/* PcloudPlacementgroupsMembersDeleteInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudPlacementgroupsMembersDeleteInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudPlacementgroupsMembersDeleteInternalServerError) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups/{placement_group_id}/members][%d] pcloudPlacementgroupsMembersDeleteInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudPlacementgroupsMembersDeleteInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPlacementgroupsMembersDeleteInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_members_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_members_post_parameters.go new file mode 100644 index 00000000000..8f9106c1834 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_members_post_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_placement_groups + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudPlacementgroupsMembersPostParams creates a new PcloudPlacementgroupsMembersPostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudPlacementgroupsMembersPostParams() *PcloudPlacementgroupsMembersPostParams { + return &PcloudPlacementgroupsMembersPostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudPlacementgroupsMembersPostParamsWithTimeout creates a new PcloudPlacementgroupsMembersPostParams object +// with the ability to set a timeout on a request. +func NewPcloudPlacementgroupsMembersPostParamsWithTimeout(timeout time.Duration) *PcloudPlacementgroupsMembersPostParams { + return &PcloudPlacementgroupsMembersPostParams{ + timeout: timeout, + } +} + +// NewPcloudPlacementgroupsMembersPostParamsWithContext creates a new PcloudPlacementgroupsMembersPostParams object +// with the ability to set a context for a request. +func NewPcloudPlacementgroupsMembersPostParamsWithContext(ctx context.Context) *PcloudPlacementgroupsMembersPostParams { + return &PcloudPlacementgroupsMembersPostParams{ + Context: ctx, + } +} + +// NewPcloudPlacementgroupsMembersPostParamsWithHTTPClient creates a new PcloudPlacementgroupsMembersPostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudPlacementgroupsMembersPostParamsWithHTTPClient(client *http.Client) *PcloudPlacementgroupsMembersPostParams { + return &PcloudPlacementgroupsMembersPostParams{ + HTTPClient: client, + } +} + +/* PcloudPlacementgroupsMembersPostParams contains all the parameters to send to the API endpoint + for the pcloud placementgroups members post operation. + + Typically these are written to a http.Request. +*/ +type PcloudPlacementgroupsMembersPostParams struct { + + /* Body. + + Parameters for adding a server to a Server Placement Group + */ + Body *models.PlacementGroupServer + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* PlacementGroupID. + + Placement Group ID + */ + PlacementGroupID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud placementgroups members post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPlacementgroupsMembersPostParams) WithDefaults() *PcloudPlacementgroupsMembersPostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud placementgroups members post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPlacementgroupsMembersPostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud placementgroups members post params +func (o *PcloudPlacementgroupsMembersPostParams) WithTimeout(timeout time.Duration) *PcloudPlacementgroupsMembersPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud placementgroups members post params +func (o *PcloudPlacementgroupsMembersPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud placementgroups members post params +func (o *PcloudPlacementgroupsMembersPostParams) WithContext(ctx context.Context) *PcloudPlacementgroupsMembersPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud placementgroups members post params +func (o *PcloudPlacementgroupsMembersPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud placementgroups members post params +func (o *PcloudPlacementgroupsMembersPostParams) WithHTTPClient(client *http.Client) *PcloudPlacementgroupsMembersPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud placementgroups members post params +func (o *PcloudPlacementgroupsMembersPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud placementgroups members post params +func (o *PcloudPlacementgroupsMembersPostParams) WithBody(body *models.PlacementGroupServer) *PcloudPlacementgroupsMembersPostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud placementgroups members post params +func (o *PcloudPlacementgroupsMembersPostParams) SetBody(body *models.PlacementGroupServer) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud placementgroups members post params +func (o *PcloudPlacementgroupsMembersPostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudPlacementgroupsMembersPostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud placementgroups members post params +func (o *PcloudPlacementgroupsMembersPostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithPlacementGroupID adds the placementGroupID to the pcloud placementgroups members post params +func (o *PcloudPlacementgroupsMembersPostParams) WithPlacementGroupID(placementGroupID string) *PcloudPlacementgroupsMembersPostParams { + o.SetPlacementGroupID(placementGroupID) + return o +} + +// SetPlacementGroupID adds the placementGroupId to the pcloud placementgroups members post params +func (o *PcloudPlacementgroupsMembersPostParams) SetPlacementGroupID(placementGroupID string) { + o.PlacementGroupID = placementGroupID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudPlacementgroupsMembersPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param placement_group_id + if err := r.SetPathParam("placement_group_id", o.PlacementGroupID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_members_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_members_post_responses.go new file mode 100644 index 00000000000..c7d53f939b8 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_members_post_responses.go @@ -0,0 +1,257 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_placement_groups + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudPlacementgroupsMembersPostReader is a Reader for the PcloudPlacementgroupsMembersPost structure. +type PcloudPlacementgroupsMembersPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudPlacementgroupsMembersPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudPlacementgroupsMembersPostOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudPlacementgroupsMembersPostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudPlacementgroupsMembersPostNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewPcloudPlacementgroupsMembersPostConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudPlacementgroupsMembersPostUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudPlacementgroupsMembersPostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudPlacementgroupsMembersPostOK creates a PcloudPlacementgroupsMembersPostOK with default headers values +func NewPcloudPlacementgroupsMembersPostOK() *PcloudPlacementgroupsMembersPostOK { + return &PcloudPlacementgroupsMembersPostOK{} +} + +/* PcloudPlacementgroupsMembersPostOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudPlacementgroupsMembersPostOK struct { + Payload *models.PlacementGroup +} + +func (o *PcloudPlacementgroupsMembersPostOK) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups/{placement_group_id}/members][%d] pcloudPlacementgroupsMembersPostOK %+v", 200, o.Payload) +} +func (o *PcloudPlacementgroupsMembersPostOK) GetPayload() *models.PlacementGroup { + return o.Payload +} + +func (o *PcloudPlacementgroupsMembersPostOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.PlacementGroup) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPlacementgroupsMembersPostBadRequest creates a PcloudPlacementgroupsMembersPostBadRequest with default headers values +func NewPcloudPlacementgroupsMembersPostBadRequest() *PcloudPlacementgroupsMembersPostBadRequest { + return &PcloudPlacementgroupsMembersPostBadRequest{} +} + +/* PcloudPlacementgroupsMembersPostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudPlacementgroupsMembersPostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudPlacementgroupsMembersPostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups/{placement_group_id}/members][%d] pcloudPlacementgroupsMembersPostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudPlacementgroupsMembersPostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPlacementgroupsMembersPostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPlacementgroupsMembersPostNotFound creates a PcloudPlacementgroupsMembersPostNotFound with default headers values +func NewPcloudPlacementgroupsMembersPostNotFound() *PcloudPlacementgroupsMembersPostNotFound { + return &PcloudPlacementgroupsMembersPostNotFound{} +} + +/* PcloudPlacementgroupsMembersPostNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudPlacementgroupsMembersPostNotFound struct { + Payload *models.Error +} + +func (o *PcloudPlacementgroupsMembersPostNotFound) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups/{placement_group_id}/members][%d] pcloudPlacementgroupsMembersPostNotFound %+v", 404, o.Payload) +} +func (o *PcloudPlacementgroupsMembersPostNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPlacementgroupsMembersPostNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPlacementgroupsMembersPostConflict creates a PcloudPlacementgroupsMembersPostConflict with default headers values +func NewPcloudPlacementgroupsMembersPostConflict() *PcloudPlacementgroupsMembersPostConflict { + return &PcloudPlacementgroupsMembersPostConflict{} +} + +/* PcloudPlacementgroupsMembersPostConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type PcloudPlacementgroupsMembersPostConflict struct { + Payload *models.Error +} + +func (o *PcloudPlacementgroupsMembersPostConflict) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups/{placement_group_id}/members][%d] pcloudPlacementgroupsMembersPostConflict %+v", 409, o.Payload) +} +func (o *PcloudPlacementgroupsMembersPostConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPlacementgroupsMembersPostConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPlacementgroupsMembersPostUnprocessableEntity creates a PcloudPlacementgroupsMembersPostUnprocessableEntity with default headers values +func NewPcloudPlacementgroupsMembersPostUnprocessableEntity() *PcloudPlacementgroupsMembersPostUnprocessableEntity { + return &PcloudPlacementgroupsMembersPostUnprocessableEntity{} +} + +/* PcloudPlacementgroupsMembersPostUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudPlacementgroupsMembersPostUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudPlacementgroupsMembersPostUnprocessableEntity) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups/{placement_group_id}/members][%d] pcloudPlacementgroupsMembersPostUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudPlacementgroupsMembersPostUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPlacementgroupsMembersPostUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPlacementgroupsMembersPostInternalServerError creates a PcloudPlacementgroupsMembersPostInternalServerError with default headers values +func NewPcloudPlacementgroupsMembersPostInternalServerError() *PcloudPlacementgroupsMembersPostInternalServerError { + return &PcloudPlacementgroupsMembersPostInternalServerError{} +} + +/* PcloudPlacementgroupsMembersPostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudPlacementgroupsMembersPostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudPlacementgroupsMembersPostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups/{placement_group_id}/members][%d] pcloudPlacementgroupsMembersPostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudPlacementgroupsMembersPostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPlacementgroupsMembersPostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_post_parameters.go new file mode 100644 index 00000000000..2bb2348af3a --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_post_parameters.go @@ -0,0 +1,173 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_placement_groups + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudPlacementgroupsPostParams creates a new PcloudPlacementgroupsPostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudPlacementgroupsPostParams() *PcloudPlacementgroupsPostParams { + return &PcloudPlacementgroupsPostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudPlacementgroupsPostParamsWithTimeout creates a new PcloudPlacementgroupsPostParams object +// with the ability to set a timeout on a request. +func NewPcloudPlacementgroupsPostParamsWithTimeout(timeout time.Duration) *PcloudPlacementgroupsPostParams { + return &PcloudPlacementgroupsPostParams{ + timeout: timeout, + } +} + +// NewPcloudPlacementgroupsPostParamsWithContext creates a new PcloudPlacementgroupsPostParams object +// with the ability to set a context for a request. +func NewPcloudPlacementgroupsPostParamsWithContext(ctx context.Context) *PcloudPlacementgroupsPostParams { + return &PcloudPlacementgroupsPostParams{ + Context: ctx, + } +} + +// NewPcloudPlacementgroupsPostParamsWithHTTPClient creates a new PcloudPlacementgroupsPostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudPlacementgroupsPostParamsWithHTTPClient(client *http.Client) *PcloudPlacementgroupsPostParams { + return &PcloudPlacementgroupsPostParams{ + HTTPClient: client, + } +} + +/* PcloudPlacementgroupsPostParams contains all the parameters to send to the API endpoint + for the pcloud placementgroups post operation. + + Typically these are written to a http.Request. +*/ +type PcloudPlacementgroupsPostParams struct { + + /* Body. + + Parameters for the creation of a new Server Placement Group + */ + Body *models.PlacementGroupCreate + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud placementgroups post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPlacementgroupsPostParams) WithDefaults() *PcloudPlacementgroupsPostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud placementgroups post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPlacementgroupsPostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud placementgroups post params +func (o *PcloudPlacementgroupsPostParams) WithTimeout(timeout time.Duration) *PcloudPlacementgroupsPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud placementgroups post params +func (o *PcloudPlacementgroupsPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud placementgroups post params +func (o *PcloudPlacementgroupsPostParams) WithContext(ctx context.Context) *PcloudPlacementgroupsPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud placementgroups post params +func (o *PcloudPlacementgroupsPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud placementgroups post params +func (o *PcloudPlacementgroupsPostParams) WithHTTPClient(client *http.Client) *PcloudPlacementgroupsPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud placementgroups post params +func (o *PcloudPlacementgroupsPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud placementgroups post params +func (o *PcloudPlacementgroupsPostParams) WithBody(body *models.PlacementGroupCreate) *PcloudPlacementgroupsPostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud placementgroups post params +func (o *PcloudPlacementgroupsPostParams) SetBody(body *models.PlacementGroupCreate) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud placementgroups post params +func (o *PcloudPlacementgroupsPostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudPlacementgroupsPostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud placementgroups post params +func (o *PcloudPlacementgroupsPostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudPlacementgroupsPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_post_responses.go new file mode 100644 index 00000000000..448359f1992 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups/pcloud_placementgroups_post_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_placement_groups + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudPlacementgroupsPostReader is a Reader for the PcloudPlacementgroupsPost structure. +type PcloudPlacementgroupsPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudPlacementgroupsPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudPlacementgroupsPostOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudPlacementgroupsPostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewPcloudPlacementgroupsPostConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudPlacementgroupsPostUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudPlacementgroupsPostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudPlacementgroupsPostOK creates a PcloudPlacementgroupsPostOK with default headers values +func NewPcloudPlacementgroupsPostOK() *PcloudPlacementgroupsPostOK { + return &PcloudPlacementgroupsPostOK{} +} + +/* PcloudPlacementgroupsPostOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudPlacementgroupsPostOK struct { + Payload *models.PlacementGroup +} + +func (o *PcloudPlacementgroupsPostOK) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups][%d] pcloudPlacementgroupsPostOK %+v", 200, o.Payload) +} +func (o *PcloudPlacementgroupsPostOK) GetPayload() *models.PlacementGroup { + return o.Payload +} + +func (o *PcloudPlacementgroupsPostOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.PlacementGroup) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPlacementgroupsPostBadRequest creates a PcloudPlacementgroupsPostBadRequest with default headers values +func NewPcloudPlacementgroupsPostBadRequest() *PcloudPlacementgroupsPostBadRequest { + return &PcloudPlacementgroupsPostBadRequest{} +} + +/* PcloudPlacementgroupsPostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudPlacementgroupsPostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudPlacementgroupsPostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups][%d] pcloudPlacementgroupsPostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudPlacementgroupsPostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPlacementgroupsPostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPlacementgroupsPostConflict creates a PcloudPlacementgroupsPostConflict with default headers values +func NewPcloudPlacementgroupsPostConflict() *PcloudPlacementgroupsPostConflict { + return &PcloudPlacementgroupsPostConflict{} +} + +/* PcloudPlacementgroupsPostConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type PcloudPlacementgroupsPostConflict struct { + Payload *models.Error +} + +func (o *PcloudPlacementgroupsPostConflict) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups][%d] pcloudPlacementgroupsPostConflict %+v", 409, o.Payload) +} +func (o *PcloudPlacementgroupsPostConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPlacementgroupsPostConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPlacementgroupsPostUnprocessableEntity creates a PcloudPlacementgroupsPostUnprocessableEntity with default headers values +func NewPcloudPlacementgroupsPostUnprocessableEntity() *PcloudPlacementgroupsPostUnprocessableEntity { + return &PcloudPlacementgroupsPostUnprocessableEntity{} +} + +/* PcloudPlacementgroupsPostUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudPlacementgroupsPostUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudPlacementgroupsPostUnprocessableEntity) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups][%d] pcloudPlacementgroupsPostUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudPlacementgroupsPostUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPlacementgroupsPostUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPlacementgroupsPostInternalServerError creates a PcloudPlacementgroupsPostInternalServerError with default headers values +func NewPcloudPlacementgroupsPostInternalServerError() *PcloudPlacementgroupsPostInternalServerError { + return &PcloudPlacementgroupsPostInternalServerError{} +} + +/* PcloudPlacementgroupsPostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudPlacementgroupsPostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudPlacementgroupsPostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/placement-groups][%d] pcloudPlacementgroupsPostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudPlacementgroupsPostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPlacementgroupsPostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_s_a_p/p_cloudsap_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_s_a_p/p_cloudsap_client.go new file mode 100644 index 00000000000..0504c37c91e --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_s_a_p/p_cloudsap_client.go @@ -0,0 +1,165 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_s_a_p + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new p cloud s a p API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for p cloud s a p API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + PcloudSapGet(params *PcloudSapGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudSapGetOK, error) + + PcloudSapGetall(params *PcloudSapGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudSapGetallOK, error) + + PcloudSapPost(params *PcloudSapPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudSapPostOK, *PcloudSapPostCreated, *PcloudSapPostAccepted, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + PcloudSapGet gets the information on an s a p profile +*/ +func (a *Client) PcloudSapGet(params *PcloudSapGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudSapGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudSapGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.sap.get", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/sap/{sap_profile_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudSapGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudSapGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.sap.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudSapGetall gets list of s a p profiles +*/ +func (a *Client) PcloudSapGetall(params *PcloudSapGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudSapGetallOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudSapGetallParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.sap.getall", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/sap", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudSapGetallReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudSapGetallOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.sap.getall: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudSapPost creates a new s a p p VM instance +*/ +func (a *Client) PcloudSapPost(params *PcloudSapPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudSapPostOK, *PcloudSapPostCreated, *PcloudSapPostAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudSapPostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.sap.post", + Method: "POST", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/sap", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudSapPostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, nil, nil, err + } + switch value := result.(type) { + case *PcloudSapPostOK: + return value, nil, nil, nil + case *PcloudSapPostCreated: + return nil, value, nil, nil + case *PcloudSapPostAccepted: + return nil, nil, value, nil + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for p_cloud_s_a_p: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_s_a_p/pcloud_sap_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_s_a_p/pcloud_sap_get_parameters.go new file mode 100644 index 00000000000..76081ddb140 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_s_a_p/pcloud_sap_get_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_s_a_p + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudSapGetParams creates a new PcloudSapGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudSapGetParams() *PcloudSapGetParams { + return &PcloudSapGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudSapGetParamsWithTimeout creates a new PcloudSapGetParams object +// with the ability to set a timeout on a request. +func NewPcloudSapGetParamsWithTimeout(timeout time.Duration) *PcloudSapGetParams { + return &PcloudSapGetParams{ + timeout: timeout, + } +} + +// NewPcloudSapGetParamsWithContext creates a new PcloudSapGetParams object +// with the ability to set a context for a request. +func NewPcloudSapGetParamsWithContext(ctx context.Context) *PcloudSapGetParams { + return &PcloudSapGetParams{ + Context: ctx, + } +} + +// NewPcloudSapGetParamsWithHTTPClient creates a new PcloudSapGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudSapGetParamsWithHTTPClient(client *http.Client) *PcloudSapGetParams { + return &PcloudSapGetParams{ + HTTPClient: client, + } +} + +/* PcloudSapGetParams contains all the parameters to send to the API endpoint + for the pcloud sap get operation. + + Typically these are written to a http.Request. +*/ +type PcloudSapGetParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* SapProfileID. + + SAP Profile ID + */ + SapProfileID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud sap get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudSapGetParams) WithDefaults() *PcloudSapGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud sap get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudSapGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud sap get params +func (o *PcloudSapGetParams) WithTimeout(timeout time.Duration) *PcloudSapGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud sap get params +func (o *PcloudSapGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud sap get params +func (o *PcloudSapGetParams) WithContext(ctx context.Context) *PcloudSapGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud sap get params +func (o *PcloudSapGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud sap get params +func (o *PcloudSapGetParams) WithHTTPClient(client *http.Client) *PcloudSapGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud sap get params +func (o *PcloudSapGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud sap get params +func (o *PcloudSapGetParams) WithCloudInstanceID(cloudInstanceID string) *PcloudSapGetParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud sap get params +func (o *PcloudSapGetParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithSapProfileID adds the sapProfileID to the pcloud sap get params +func (o *PcloudSapGetParams) WithSapProfileID(sapProfileID string) *PcloudSapGetParams { + o.SetSapProfileID(sapProfileID) + return o +} + +// SetSapProfileID adds the sapProfileId to the pcloud sap get params +func (o *PcloudSapGetParams) SetSapProfileID(sapProfileID string) { + o.SapProfileID = sapProfileID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudSapGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param sap_profile_id + if err := r.SetPathParam("sap_profile_id", o.SapProfileID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_s_a_p/pcloud_sap_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_s_a_p/pcloud_sap_get_responses.go new file mode 100644 index 00000000000..395448fd440 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_s_a_p/pcloud_sap_get_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_s_a_p + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudSapGetReader is a Reader for the PcloudSapGet structure. +type PcloudSapGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudSapGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudSapGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudSapGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudSapGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudSapGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudSapGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudSapGetOK creates a PcloudSapGetOK with default headers values +func NewPcloudSapGetOK() *PcloudSapGetOK { + return &PcloudSapGetOK{} +} + +/* PcloudSapGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudSapGetOK struct { + Payload *models.SAPProfile +} + +func (o *PcloudSapGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/sap/{sap_profile_id}][%d] pcloudSapGetOK %+v", 200, o.Payload) +} +func (o *PcloudSapGetOK) GetPayload() *models.SAPProfile { + return o.Payload +} + +func (o *PcloudSapGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.SAPProfile) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudSapGetBadRequest creates a PcloudSapGetBadRequest with default headers values +func NewPcloudSapGetBadRequest() *PcloudSapGetBadRequest { + return &PcloudSapGetBadRequest{} +} + +/* PcloudSapGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudSapGetBadRequest struct { + Payload *models.Error +} + +func (o *PcloudSapGetBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/sap/{sap_profile_id}][%d] pcloudSapGetBadRequest %+v", 400, o.Payload) +} +func (o *PcloudSapGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudSapGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudSapGetUnauthorized creates a PcloudSapGetUnauthorized with default headers values +func NewPcloudSapGetUnauthorized() *PcloudSapGetUnauthorized { + return &PcloudSapGetUnauthorized{} +} + +/* PcloudSapGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudSapGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudSapGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/sap/{sap_profile_id}][%d] pcloudSapGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudSapGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudSapGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudSapGetNotFound creates a PcloudSapGetNotFound with default headers values +func NewPcloudSapGetNotFound() *PcloudSapGetNotFound { + return &PcloudSapGetNotFound{} +} + +/* PcloudSapGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudSapGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudSapGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/sap/{sap_profile_id}][%d] pcloudSapGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudSapGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudSapGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudSapGetInternalServerError creates a PcloudSapGetInternalServerError with default headers values +func NewPcloudSapGetInternalServerError() *PcloudSapGetInternalServerError { + return &PcloudSapGetInternalServerError{} +} + +/* PcloudSapGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudSapGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudSapGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/sap/{sap_profile_id}][%d] pcloudSapGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudSapGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudSapGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_s_a_p/pcloud_sap_getall_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_s_a_p/pcloud_sap_getall_parameters.go new file mode 100644 index 00000000000..725a1afc583 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_s_a_p/pcloud_sap_getall_parameters.go @@ -0,0 +1,149 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_s_a_p + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudSapGetallParams creates a new PcloudSapGetallParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudSapGetallParams() *PcloudSapGetallParams { + return &PcloudSapGetallParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudSapGetallParamsWithTimeout creates a new PcloudSapGetallParams object +// with the ability to set a timeout on a request. +func NewPcloudSapGetallParamsWithTimeout(timeout time.Duration) *PcloudSapGetallParams { + return &PcloudSapGetallParams{ + timeout: timeout, + } +} + +// NewPcloudSapGetallParamsWithContext creates a new PcloudSapGetallParams object +// with the ability to set a context for a request. +func NewPcloudSapGetallParamsWithContext(ctx context.Context) *PcloudSapGetallParams { + return &PcloudSapGetallParams{ + Context: ctx, + } +} + +// NewPcloudSapGetallParamsWithHTTPClient creates a new PcloudSapGetallParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudSapGetallParamsWithHTTPClient(client *http.Client) *PcloudSapGetallParams { + return &PcloudSapGetallParams{ + HTTPClient: client, + } +} + +/* PcloudSapGetallParams contains all the parameters to send to the API endpoint + for the pcloud sap getall operation. + + Typically these are written to a http.Request. +*/ +type PcloudSapGetallParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud sap getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudSapGetallParams) WithDefaults() *PcloudSapGetallParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud sap getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudSapGetallParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud sap getall params +func (o *PcloudSapGetallParams) WithTimeout(timeout time.Duration) *PcloudSapGetallParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud sap getall params +func (o *PcloudSapGetallParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud sap getall params +func (o *PcloudSapGetallParams) WithContext(ctx context.Context) *PcloudSapGetallParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud sap getall params +func (o *PcloudSapGetallParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud sap getall params +func (o *PcloudSapGetallParams) WithHTTPClient(client *http.Client) *PcloudSapGetallParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud sap getall params +func (o *PcloudSapGetallParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud sap getall params +func (o *PcloudSapGetallParams) WithCloudInstanceID(cloudInstanceID string) *PcloudSapGetallParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud sap getall params +func (o *PcloudSapGetallParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudSapGetallParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_s_a_p/pcloud_sap_getall_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_s_a_p/pcloud_sap_getall_responses.go new file mode 100644 index 00000000000..97b35e04c1a --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_s_a_p/pcloud_sap_getall_responses.go @@ -0,0 +1,181 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_s_a_p + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudSapGetallReader is a Reader for the PcloudSapGetall structure. +type PcloudSapGetallReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudSapGetallReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudSapGetallOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudSapGetallBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudSapGetallUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudSapGetallInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudSapGetallOK creates a PcloudSapGetallOK with default headers values +func NewPcloudSapGetallOK() *PcloudSapGetallOK { + return &PcloudSapGetallOK{} +} + +/* PcloudSapGetallOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudSapGetallOK struct { + Payload *models.SAPProfiles +} + +func (o *PcloudSapGetallOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/sap][%d] pcloudSapGetallOK %+v", 200, o.Payload) +} +func (o *PcloudSapGetallOK) GetPayload() *models.SAPProfiles { + return o.Payload +} + +func (o *PcloudSapGetallOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.SAPProfiles) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudSapGetallBadRequest creates a PcloudSapGetallBadRequest with default headers values +func NewPcloudSapGetallBadRequest() *PcloudSapGetallBadRequest { + return &PcloudSapGetallBadRequest{} +} + +/* PcloudSapGetallBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudSapGetallBadRequest struct { + Payload *models.Error +} + +func (o *PcloudSapGetallBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/sap][%d] pcloudSapGetallBadRequest %+v", 400, o.Payload) +} +func (o *PcloudSapGetallBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudSapGetallBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudSapGetallUnauthorized creates a PcloudSapGetallUnauthorized with default headers values +func NewPcloudSapGetallUnauthorized() *PcloudSapGetallUnauthorized { + return &PcloudSapGetallUnauthorized{} +} + +/* PcloudSapGetallUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudSapGetallUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudSapGetallUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/sap][%d] pcloudSapGetallUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudSapGetallUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudSapGetallUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudSapGetallInternalServerError creates a PcloudSapGetallInternalServerError with default headers values +func NewPcloudSapGetallInternalServerError() *PcloudSapGetallInternalServerError { + return &PcloudSapGetallInternalServerError{} +} + +/* PcloudSapGetallInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudSapGetallInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudSapGetallInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/sap][%d] pcloudSapGetallInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudSapGetallInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudSapGetallInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_s_a_p/pcloud_sap_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_s_a_p/pcloud_sap_post_parameters.go new file mode 100644 index 00000000000..1b8ad094aa3 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_s_a_p/pcloud_sap_post_parameters.go @@ -0,0 +1,173 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_s_a_p + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudSapPostParams creates a new PcloudSapPostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudSapPostParams() *PcloudSapPostParams { + return &PcloudSapPostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudSapPostParamsWithTimeout creates a new PcloudSapPostParams object +// with the ability to set a timeout on a request. +func NewPcloudSapPostParamsWithTimeout(timeout time.Duration) *PcloudSapPostParams { + return &PcloudSapPostParams{ + timeout: timeout, + } +} + +// NewPcloudSapPostParamsWithContext creates a new PcloudSapPostParams object +// with the ability to set a context for a request. +func NewPcloudSapPostParamsWithContext(ctx context.Context) *PcloudSapPostParams { + return &PcloudSapPostParams{ + Context: ctx, + } +} + +// NewPcloudSapPostParamsWithHTTPClient creates a new PcloudSapPostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudSapPostParamsWithHTTPClient(client *http.Client) *PcloudSapPostParams { + return &PcloudSapPostParams{ + HTTPClient: client, + } +} + +/* PcloudSapPostParams contains all the parameters to send to the API endpoint + for the pcloud sap post operation. + + Typically these are written to a http.Request. +*/ +type PcloudSapPostParams struct { + + /* Body. + + Parameters for the creation of a new SAP PVM Instance + */ + Body *models.SAPCreate + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud sap post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudSapPostParams) WithDefaults() *PcloudSapPostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud sap post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudSapPostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud sap post params +func (o *PcloudSapPostParams) WithTimeout(timeout time.Duration) *PcloudSapPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud sap post params +func (o *PcloudSapPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud sap post params +func (o *PcloudSapPostParams) WithContext(ctx context.Context) *PcloudSapPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud sap post params +func (o *PcloudSapPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud sap post params +func (o *PcloudSapPostParams) WithHTTPClient(client *http.Client) *PcloudSapPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud sap post params +func (o *PcloudSapPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud sap post params +func (o *PcloudSapPostParams) WithBody(body *models.SAPCreate) *PcloudSapPostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud sap post params +func (o *PcloudSapPostParams) SetBody(body *models.SAPCreate) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud sap post params +func (o *PcloudSapPostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudSapPostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud sap post params +func (o *PcloudSapPostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudSapPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_s_a_p/pcloud_sap_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_s_a_p/pcloud_sap_post_responses.go new file mode 100644 index 00000000000..802291ee218 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_s_a_p/pcloud_sap_post_responses.go @@ -0,0 +1,327 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_s_a_p + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudSapPostReader is a Reader for the PcloudSapPost structure. +type PcloudSapPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudSapPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudSapPostOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 201: + result := NewPcloudSapPostCreated() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 202: + result := NewPcloudSapPostAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudSapPostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudSapPostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewPcloudSapPostConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudSapPostUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudSapPostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudSapPostOK creates a PcloudSapPostOK with default headers values +func NewPcloudSapPostOK() *PcloudSapPostOK { + return &PcloudSapPostOK{} +} + +/* PcloudSapPostOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudSapPostOK struct { + Payload models.PVMInstanceList +} + +func (o *PcloudSapPostOK) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/sap][%d] pcloudSapPostOK %+v", 200, o.Payload) +} +func (o *PcloudSapPostOK) GetPayload() models.PVMInstanceList { + return o.Payload +} + +func (o *PcloudSapPostOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudSapPostCreated creates a PcloudSapPostCreated with default headers values +func NewPcloudSapPostCreated() *PcloudSapPostCreated { + return &PcloudSapPostCreated{} +} + +/* PcloudSapPostCreated describes a response with status code 201, with default header values. + +Created +*/ +type PcloudSapPostCreated struct { + Payload models.PVMInstanceList +} + +func (o *PcloudSapPostCreated) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/sap][%d] pcloudSapPostCreated %+v", 201, o.Payload) +} +func (o *PcloudSapPostCreated) GetPayload() models.PVMInstanceList { + return o.Payload +} + +func (o *PcloudSapPostCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudSapPostAccepted creates a PcloudSapPostAccepted with default headers values +func NewPcloudSapPostAccepted() *PcloudSapPostAccepted { + return &PcloudSapPostAccepted{} +} + +/* PcloudSapPostAccepted describes a response with status code 202, with default header values. + +Accepted +*/ +type PcloudSapPostAccepted struct { + Payload models.PVMInstanceList +} + +func (o *PcloudSapPostAccepted) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/sap][%d] pcloudSapPostAccepted %+v", 202, o.Payload) +} +func (o *PcloudSapPostAccepted) GetPayload() models.PVMInstanceList { + return o.Payload +} + +func (o *PcloudSapPostAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudSapPostBadRequest creates a PcloudSapPostBadRequest with default headers values +func NewPcloudSapPostBadRequest() *PcloudSapPostBadRequest { + return &PcloudSapPostBadRequest{} +} + +/* PcloudSapPostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudSapPostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudSapPostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/sap][%d] pcloudSapPostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudSapPostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudSapPostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudSapPostUnauthorized creates a PcloudSapPostUnauthorized with default headers values +func NewPcloudSapPostUnauthorized() *PcloudSapPostUnauthorized { + return &PcloudSapPostUnauthorized{} +} + +/* PcloudSapPostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudSapPostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudSapPostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/sap][%d] pcloudSapPostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudSapPostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudSapPostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudSapPostConflict creates a PcloudSapPostConflict with default headers values +func NewPcloudSapPostConflict() *PcloudSapPostConflict { + return &PcloudSapPostConflict{} +} + +/* PcloudSapPostConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type PcloudSapPostConflict struct { + Payload *models.Error +} + +func (o *PcloudSapPostConflict) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/sap][%d] pcloudSapPostConflict %+v", 409, o.Payload) +} +func (o *PcloudSapPostConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudSapPostConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudSapPostUnprocessableEntity creates a PcloudSapPostUnprocessableEntity with default headers values +func NewPcloudSapPostUnprocessableEntity() *PcloudSapPostUnprocessableEntity { + return &PcloudSapPostUnprocessableEntity{} +} + +/* PcloudSapPostUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudSapPostUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudSapPostUnprocessableEntity) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/sap][%d] pcloudSapPostUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudSapPostUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudSapPostUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudSapPostInternalServerError creates a PcloudSapPostInternalServerError with default headers values +func NewPcloudSapPostInternalServerError() *PcloudSapPostInternalServerError { + return &PcloudSapPostInternalServerError{} +} + +/* PcloudSapPostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudSapPostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudSapPostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/sap][%d] pcloudSapPostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudSapPostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudSapPostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_service_d_h_c_p/p_cloud_servicedhcp_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_service_d_h_c_p/p_cloud_servicedhcp_client.go new file mode 100644 index 00000000000..ddf143b6cfb --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_service_d_h_c_p/p_cloud_servicedhcp_client.go @@ -0,0 +1,203 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_service_d_h_c_p + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new p cloud service d h c p API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for p cloud service d h c p API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + PcloudDhcpDelete(params *PcloudDhcpDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudDhcpDeleteAccepted, error) + + PcloudDhcpGet(params *PcloudDhcpGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudDhcpGetOK, error) + + PcloudDhcpGetall(params *PcloudDhcpGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudDhcpGetallOK, error) + + PcloudDhcpPost(params *PcloudDhcpPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudDhcpPostAccepted, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + PcloudDhcpDelete deletes d h c p server open shift internal use only +*/ +func (a *Client) PcloudDhcpDelete(params *PcloudDhcpDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudDhcpDeleteAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudDhcpDeleteParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.dhcp.delete", + Method: "DELETE", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/services/dhcp/{dhcp_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudDhcpDeleteReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudDhcpDeleteAccepted) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.dhcp.delete: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudDhcpGet gets d h c p server information open shift internal use only +*/ +func (a *Client) PcloudDhcpGet(params *PcloudDhcpGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudDhcpGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudDhcpGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.dhcp.get", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/services/dhcp/{dhcp_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudDhcpGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudDhcpGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.dhcp.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudDhcpGetall gets all d h c p servers information open shift internal use only +*/ +func (a *Client) PcloudDhcpGetall(params *PcloudDhcpGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudDhcpGetallOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudDhcpGetallParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.dhcp.getall", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/services/dhcp", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudDhcpGetallReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudDhcpGetallOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.dhcp.getall: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudDhcpPost creates a d h c p server open shift internal use only +*/ +func (a *Client) PcloudDhcpPost(params *PcloudDhcpPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudDhcpPostAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudDhcpPostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.dhcp.post", + Method: "POST", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/services/dhcp", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudDhcpPostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudDhcpPostAccepted) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.dhcp.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_service_d_h_c_p/pcloud_dhcp_delete_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_service_d_h_c_p/pcloud_dhcp_delete_parameters.go new file mode 100644 index 00000000000..3869c75667f --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_service_d_h_c_p/pcloud_dhcp_delete_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_service_d_h_c_p + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudDhcpDeleteParams creates a new PcloudDhcpDeleteParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudDhcpDeleteParams() *PcloudDhcpDeleteParams { + return &PcloudDhcpDeleteParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudDhcpDeleteParamsWithTimeout creates a new PcloudDhcpDeleteParams object +// with the ability to set a timeout on a request. +func NewPcloudDhcpDeleteParamsWithTimeout(timeout time.Duration) *PcloudDhcpDeleteParams { + return &PcloudDhcpDeleteParams{ + timeout: timeout, + } +} + +// NewPcloudDhcpDeleteParamsWithContext creates a new PcloudDhcpDeleteParams object +// with the ability to set a context for a request. +func NewPcloudDhcpDeleteParamsWithContext(ctx context.Context) *PcloudDhcpDeleteParams { + return &PcloudDhcpDeleteParams{ + Context: ctx, + } +} + +// NewPcloudDhcpDeleteParamsWithHTTPClient creates a new PcloudDhcpDeleteParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudDhcpDeleteParamsWithHTTPClient(client *http.Client) *PcloudDhcpDeleteParams { + return &PcloudDhcpDeleteParams{ + HTTPClient: client, + } +} + +/* PcloudDhcpDeleteParams contains all the parameters to send to the API endpoint + for the pcloud dhcp delete operation. + + Typically these are written to a http.Request. +*/ +type PcloudDhcpDeleteParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* DhcpID. + + The ID of the DHCP Server + */ + DhcpID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud dhcp delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudDhcpDeleteParams) WithDefaults() *PcloudDhcpDeleteParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud dhcp delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudDhcpDeleteParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud dhcp delete params +func (o *PcloudDhcpDeleteParams) WithTimeout(timeout time.Duration) *PcloudDhcpDeleteParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud dhcp delete params +func (o *PcloudDhcpDeleteParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud dhcp delete params +func (o *PcloudDhcpDeleteParams) WithContext(ctx context.Context) *PcloudDhcpDeleteParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud dhcp delete params +func (o *PcloudDhcpDeleteParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud dhcp delete params +func (o *PcloudDhcpDeleteParams) WithHTTPClient(client *http.Client) *PcloudDhcpDeleteParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud dhcp delete params +func (o *PcloudDhcpDeleteParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud dhcp delete params +func (o *PcloudDhcpDeleteParams) WithCloudInstanceID(cloudInstanceID string) *PcloudDhcpDeleteParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud dhcp delete params +func (o *PcloudDhcpDeleteParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithDhcpID adds the dhcpID to the pcloud dhcp delete params +func (o *PcloudDhcpDeleteParams) WithDhcpID(dhcpID string) *PcloudDhcpDeleteParams { + o.SetDhcpID(dhcpID) + return o +} + +// SetDhcpID adds the dhcpId to the pcloud dhcp delete params +func (o *PcloudDhcpDeleteParams) SetDhcpID(dhcpID string) { + o.DhcpID = dhcpID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudDhcpDeleteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param dhcp_id + if err := r.SetPathParam("dhcp_id", o.DhcpID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_service_d_h_c_p/pcloud_dhcp_delete_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_service_d_h_c_p/pcloud_dhcp_delete_responses.go new file mode 100644 index 00000000000..f108dadaa2d --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_service_d_h_c_p/pcloud_dhcp_delete_responses.go @@ -0,0 +1,217 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_service_d_h_c_p + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudDhcpDeleteReader is a Reader for the PcloudDhcpDelete structure. +type PcloudDhcpDeleteReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudDhcpDeleteReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 202: + result := NewPcloudDhcpDeleteAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudDhcpDeleteBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewPcloudDhcpDeleteForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudDhcpDeleteNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudDhcpDeleteInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudDhcpDeleteAccepted creates a PcloudDhcpDeleteAccepted with default headers values +func NewPcloudDhcpDeleteAccepted() *PcloudDhcpDeleteAccepted { + return &PcloudDhcpDeleteAccepted{} +} + +/* PcloudDhcpDeleteAccepted describes a response with status code 202, with default header values. + +OK +*/ +type PcloudDhcpDeleteAccepted struct { + Payload models.Object +} + +func (o *PcloudDhcpDeleteAccepted) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/services/dhcp/{dhcp_id}][%d] pcloudDhcpDeleteAccepted %+v", 202, o.Payload) +} +func (o *PcloudDhcpDeleteAccepted) GetPayload() models.Object { + return o.Payload +} + +func (o *PcloudDhcpDeleteAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudDhcpDeleteBadRequest creates a PcloudDhcpDeleteBadRequest with default headers values +func NewPcloudDhcpDeleteBadRequest() *PcloudDhcpDeleteBadRequest { + return &PcloudDhcpDeleteBadRequest{} +} + +/* PcloudDhcpDeleteBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudDhcpDeleteBadRequest struct { + Payload *models.Error +} + +func (o *PcloudDhcpDeleteBadRequest) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/services/dhcp/{dhcp_id}][%d] pcloudDhcpDeleteBadRequest %+v", 400, o.Payload) +} +func (o *PcloudDhcpDeleteBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudDhcpDeleteBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudDhcpDeleteForbidden creates a PcloudDhcpDeleteForbidden with default headers values +func NewPcloudDhcpDeleteForbidden() *PcloudDhcpDeleteForbidden { + return &PcloudDhcpDeleteForbidden{} +} + +/* PcloudDhcpDeleteForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type PcloudDhcpDeleteForbidden struct { + Payload *models.Error +} + +func (o *PcloudDhcpDeleteForbidden) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/services/dhcp/{dhcp_id}][%d] pcloudDhcpDeleteForbidden %+v", 403, o.Payload) +} +func (o *PcloudDhcpDeleteForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudDhcpDeleteForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudDhcpDeleteNotFound creates a PcloudDhcpDeleteNotFound with default headers values +func NewPcloudDhcpDeleteNotFound() *PcloudDhcpDeleteNotFound { + return &PcloudDhcpDeleteNotFound{} +} + +/* PcloudDhcpDeleteNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudDhcpDeleteNotFound struct { + Payload *models.Error +} + +func (o *PcloudDhcpDeleteNotFound) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/services/dhcp/{dhcp_id}][%d] pcloudDhcpDeleteNotFound %+v", 404, o.Payload) +} +func (o *PcloudDhcpDeleteNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudDhcpDeleteNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudDhcpDeleteInternalServerError creates a PcloudDhcpDeleteInternalServerError with default headers values +func NewPcloudDhcpDeleteInternalServerError() *PcloudDhcpDeleteInternalServerError { + return &PcloudDhcpDeleteInternalServerError{} +} + +/* PcloudDhcpDeleteInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudDhcpDeleteInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudDhcpDeleteInternalServerError) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/services/dhcp/{dhcp_id}][%d] pcloudDhcpDeleteInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudDhcpDeleteInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudDhcpDeleteInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_service_d_h_c_p/pcloud_dhcp_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_service_d_h_c_p/pcloud_dhcp_get_parameters.go new file mode 100644 index 00000000000..341c63d4778 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_service_d_h_c_p/pcloud_dhcp_get_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_service_d_h_c_p + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudDhcpGetParams creates a new PcloudDhcpGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudDhcpGetParams() *PcloudDhcpGetParams { + return &PcloudDhcpGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudDhcpGetParamsWithTimeout creates a new PcloudDhcpGetParams object +// with the ability to set a timeout on a request. +func NewPcloudDhcpGetParamsWithTimeout(timeout time.Duration) *PcloudDhcpGetParams { + return &PcloudDhcpGetParams{ + timeout: timeout, + } +} + +// NewPcloudDhcpGetParamsWithContext creates a new PcloudDhcpGetParams object +// with the ability to set a context for a request. +func NewPcloudDhcpGetParamsWithContext(ctx context.Context) *PcloudDhcpGetParams { + return &PcloudDhcpGetParams{ + Context: ctx, + } +} + +// NewPcloudDhcpGetParamsWithHTTPClient creates a new PcloudDhcpGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudDhcpGetParamsWithHTTPClient(client *http.Client) *PcloudDhcpGetParams { + return &PcloudDhcpGetParams{ + HTTPClient: client, + } +} + +/* PcloudDhcpGetParams contains all the parameters to send to the API endpoint + for the pcloud dhcp get operation. + + Typically these are written to a http.Request. +*/ +type PcloudDhcpGetParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* DhcpID. + + The ID of the DHCP Server + */ + DhcpID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud dhcp get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudDhcpGetParams) WithDefaults() *PcloudDhcpGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud dhcp get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudDhcpGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud dhcp get params +func (o *PcloudDhcpGetParams) WithTimeout(timeout time.Duration) *PcloudDhcpGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud dhcp get params +func (o *PcloudDhcpGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud dhcp get params +func (o *PcloudDhcpGetParams) WithContext(ctx context.Context) *PcloudDhcpGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud dhcp get params +func (o *PcloudDhcpGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud dhcp get params +func (o *PcloudDhcpGetParams) WithHTTPClient(client *http.Client) *PcloudDhcpGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud dhcp get params +func (o *PcloudDhcpGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud dhcp get params +func (o *PcloudDhcpGetParams) WithCloudInstanceID(cloudInstanceID string) *PcloudDhcpGetParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud dhcp get params +func (o *PcloudDhcpGetParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithDhcpID adds the dhcpID to the pcloud dhcp get params +func (o *PcloudDhcpGetParams) WithDhcpID(dhcpID string) *PcloudDhcpGetParams { + o.SetDhcpID(dhcpID) + return o +} + +// SetDhcpID adds the dhcpId to the pcloud dhcp get params +func (o *PcloudDhcpGetParams) SetDhcpID(dhcpID string) { + o.DhcpID = dhcpID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudDhcpGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param dhcp_id + if err := r.SetPathParam("dhcp_id", o.DhcpID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_service_d_h_c_p/pcloud_dhcp_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_service_d_h_c_p/pcloud_dhcp_get_responses.go new file mode 100644 index 00000000000..533dd79a841 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_service_d_h_c_p/pcloud_dhcp_get_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_service_d_h_c_p + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudDhcpGetReader is a Reader for the PcloudDhcpGet structure. +type PcloudDhcpGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudDhcpGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudDhcpGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudDhcpGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewPcloudDhcpGetForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudDhcpGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudDhcpGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudDhcpGetOK creates a PcloudDhcpGetOK with default headers values +func NewPcloudDhcpGetOK() *PcloudDhcpGetOK { + return &PcloudDhcpGetOK{} +} + +/* PcloudDhcpGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudDhcpGetOK struct { + Payload *models.DHCPServerDetail +} + +func (o *PcloudDhcpGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/services/dhcp/{dhcp_id}][%d] pcloudDhcpGetOK %+v", 200, o.Payload) +} +func (o *PcloudDhcpGetOK) GetPayload() *models.DHCPServerDetail { + return o.Payload +} + +func (o *PcloudDhcpGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.DHCPServerDetail) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudDhcpGetBadRequest creates a PcloudDhcpGetBadRequest with default headers values +func NewPcloudDhcpGetBadRequest() *PcloudDhcpGetBadRequest { + return &PcloudDhcpGetBadRequest{} +} + +/* PcloudDhcpGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudDhcpGetBadRequest struct { + Payload *models.Error +} + +func (o *PcloudDhcpGetBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/services/dhcp/{dhcp_id}][%d] pcloudDhcpGetBadRequest %+v", 400, o.Payload) +} +func (o *PcloudDhcpGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudDhcpGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudDhcpGetForbidden creates a PcloudDhcpGetForbidden with default headers values +func NewPcloudDhcpGetForbidden() *PcloudDhcpGetForbidden { + return &PcloudDhcpGetForbidden{} +} + +/* PcloudDhcpGetForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type PcloudDhcpGetForbidden struct { + Payload *models.Error +} + +func (o *PcloudDhcpGetForbidden) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/services/dhcp/{dhcp_id}][%d] pcloudDhcpGetForbidden %+v", 403, o.Payload) +} +func (o *PcloudDhcpGetForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudDhcpGetForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudDhcpGetNotFound creates a PcloudDhcpGetNotFound with default headers values +func NewPcloudDhcpGetNotFound() *PcloudDhcpGetNotFound { + return &PcloudDhcpGetNotFound{} +} + +/* PcloudDhcpGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudDhcpGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudDhcpGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/services/dhcp/{dhcp_id}][%d] pcloudDhcpGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudDhcpGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudDhcpGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudDhcpGetInternalServerError creates a PcloudDhcpGetInternalServerError with default headers values +func NewPcloudDhcpGetInternalServerError() *PcloudDhcpGetInternalServerError { + return &PcloudDhcpGetInternalServerError{} +} + +/* PcloudDhcpGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudDhcpGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudDhcpGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/services/dhcp/{dhcp_id}][%d] pcloudDhcpGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudDhcpGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudDhcpGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_service_d_h_c_p/pcloud_dhcp_getall_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_service_d_h_c_p/pcloud_dhcp_getall_parameters.go new file mode 100644 index 00000000000..52bbb8487b0 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_service_d_h_c_p/pcloud_dhcp_getall_parameters.go @@ -0,0 +1,149 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_service_d_h_c_p + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudDhcpGetallParams creates a new PcloudDhcpGetallParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudDhcpGetallParams() *PcloudDhcpGetallParams { + return &PcloudDhcpGetallParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudDhcpGetallParamsWithTimeout creates a new PcloudDhcpGetallParams object +// with the ability to set a timeout on a request. +func NewPcloudDhcpGetallParamsWithTimeout(timeout time.Duration) *PcloudDhcpGetallParams { + return &PcloudDhcpGetallParams{ + timeout: timeout, + } +} + +// NewPcloudDhcpGetallParamsWithContext creates a new PcloudDhcpGetallParams object +// with the ability to set a context for a request. +func NewPcloudDhcpGetallParamsWithContext(ctx context.Context) *PcloudDhcpGetallParams { + return &PcloudDhcpGetallParams{ + Context: ctx, + } +} + +// NewPcloudDhcpGetallParamsWithHTTPClient creates a new PcloudDhcpGetallParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudDhcpGetallParamsWithHTTPClient(client *http.Client) *PcloudDhcpGetallParams { + return &PcloudDhcpGetallParams{ + HTTPClient: client, + } +} + +/* PcloudDhcpGetallParams contains all the parameters to send to the API endpoint + for the pcloud dhcp getall operation. + + Typically these are written to a http.Request. +*/ +type PcloudDhcpGetallParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud dhcp getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudDhcpGetallParams) WithDefaults() *PcloudDhcpGetallParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud dhcp getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudDhcpGetallParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud dhcp getall params +func (o *PcloudDhcpGetallParams) WithTimeout(timeout time.Duration) *PcloudDhcpGetallParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud dhcp getall params +func (o *PcloudDhcpGetallParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud dhcp getall params +func (o *PcloudDhcpGetallParams) WithContext(ctx context.Context) *PcloudDhcpGetallParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud dhcp getall params +func (o *PcloudDhcpGetallParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud dhcp getall params +func (o *PcloudDhcpGetallParams) WithHTTPClient(client *http.Client) *PcloudDhcpGetallParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud dhcp getall params +func (o *PcloudDhcpGetallParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud dhcp getall params +func (o *PcloudDhcpGetallParams) WithCloudInstanceID(cloudInstanceID string) *PcloudDhcpGetallParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud dhcp getall params +func (o *PcloudDhcpGetallParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudDhcpGetallParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_service_d_h_c_p/pcloud_dhcp_getall_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_service_d_h_c_p/pcloud_dhcp_getall_responses.go new file mode 100644 index 00000000000..3aeb4415c33 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_service_d_h_c_p/pcloud_dhcp_getall_responses.go @@ -0,0 +1,141 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_service_d_h_c_p + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudDhcpGetallReader is a Reader for the PcloudDhcpGetall structure. +type PcloudDhcpGetallReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudDhcpGetallReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudDhcpGetallOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 403: + result := NewPcloudDhcpGetallForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudDhcpGetallInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudDhcpGetallOK creates a PcloudDhcpGetallOK with default headers values +func NewPcloudDhcpGetallOK() *PcloudDhcpGetallOK { + return &PcloudDhcpGetallOK{} +} + +/* PcloudDhcpGetallOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudDhcpGetallOK struct { + Payload models.DHCPServers +} + +func (o *PcloudDhcpGetallOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/services/dhcp][%d] pcloudDhcpGetallOK %+v", 200, o.Payload) +} +func (o *PcloudDhcpGetallOK) GetPayload() models.DHCPServers { + return o.Payload +} + +func (o *PcloudDhcpGetallOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudDhcpGetallForbidden creates a PcloudDhcpGetallForbidden with default headers values +func NewPcloudDhcpGetallForbidden() *PcloudDhcpGetallForbidden { + return &PcloudDhcpGetallForbidden{} +} + +/* PcloudDhcpGetallForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type PcloudDhcpGetallForbidden struct { + Payload *models.Error +} + +func (o *PcloudDhcpGetallForbidden) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/services/dhcp][%d] pcloudDhcpGetallForbidden %+v", 403, o.Payload) +} +func (o *PcloudDhcpGetallForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudDhcpGetallForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudDhcpGetallInternalServerError creates a PcloudDhcpGetallInternalServerError with default headers values +func NewPcloudDhcpGetallInternalServerError() *PcloudDhcpGetallInternalServerError { + return &PcloudDhcpGetallInternalServerError{} +} + +/* PcloudDhcpGetallInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudDhcpGetallInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudDhcpGetallInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/services/dhcp][%d] pcloudDhcpGetallInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudDhcpGetallInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudDhcpGetallInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_service_d_h_c_p/pcloud_dhcp_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_service_d_h_c_p/pcloud_dhcp_post_parameters.go new file mode 100644 index 00000000000..d16312a19b3 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_service_d_h_c_p/pcloud_dhcp_post_parameters.go @@ -0,0 +1,173 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_service_d_h_c_p + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudDhcpPostParams creates a new PcloudDhcpPostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudDhcpPostParams() *PcloudDhcpPostParams { + return &PcloudDhcpPostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudDhcpPostParamsWithTimeout creates a new PcloudDhcpPostParams object +// with the ability to set a timeout on a request. +func NewPcloudDhcpPostParamsWithTimeout(timeout time.Duration) *PcloudDhcpPostParams { + return &PcloudDhcpPostParams{ + timeout: timeout, + } +} + +// NewPcloudDhcpPostParamsWithContext creates a new PcloudDhcpPostParams object +// with the ability to set a context for a request. +func NewPcloudDhcpPostParamsWithContext(ctx context.Context) *PcloudDhcpPostParams { + return &PcloudDhcpPostParams{ + Context: ctx, + } +} + +// NewPcloudDhcpPostParamsWithHTTPClient creates a new PcloudDhcpPostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudDhcpPostParamsWithHTTPClient(client *http.Client) *PcloudDhcpPostParams { + return &PcloudDhcpPostParams{ + HTTPClient: client, + } +} + +/* PcloudDhcpPostParams contains all the parameters to send to the API endpoint + for the pcloud dhcp post operation. + + Typically these are written to a http.Request. +*/ +type PcloudDhcpPostParams struct { + + /* Body. + + Parameters used during creation of DHCP service + */ + Body *models.DHCPServerCreate + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud dhcp post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudDhcpPostParams) WithDefaults() *PcloudDhcpPostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud dhcp post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudDhcpPostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud dhcp post params +func (o *PcloudDhcpPostParams) WithTimeout(timeout time.Duration) *PcloudDhcpPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud dhcp post params +func (o *PcloudDhcpPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud dhcp post params +func (o *PcloudDhcpPostParams) WithContext(ctx context.Context) *PcloudDhcpPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud dhcp post params +func (o *PcloudDhcpPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud dhcp post params +func (o *PcloudDhcpPostParams) WithHTTPClient(client *http.Client) *PcloudDhcpPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud dhcp post params +func (o *PcloudDhcpPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud dhcp post params +func (o *PcloudDhcpPostParams) WithBody(body *models.DHCPServerCreate) *PcloudDhcpPostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud dhcp post params +func (o *PcloudDhcpPostParams) SetBody(body *models.DHCPServerCreate) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud dhcp post params +func (o *PcloudDhcpPostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudDhcpPostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud dhcp post params +func (o *PcloudDhcpPostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudDhcpPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_service_d_h_c_p/pcloud_dhcp_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_service_d_h_c_p/pcloud_dhcp_post_responses.go new file mode 100644 index 00000000000..7b5b6850820 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_service_d_h_c_p/pcloud_dhcp_post_responses.go @@ -0,0 +1,181 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_service_d_h_c_p + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudDhcpPostReader is a Reader for the PcloudDhcpPost structure. +type PcloudDhcpPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudDhcpPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 202: + result := NewPcloudDhcpPostAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudDhcpPostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewPcloudDhcpPostForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudDhcpPostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudDhcpPostAccepted creates a PcloudDhcpPostAccepted with default headers values +func NewPcloudDhcpPostAccepted() *PcloudDhcpPostAccepted { + return &PcloudDhcpPostAccepted{} +} + +/* PcloudDhcpPostAccepted describes a response with status code 202, with default header values. + +OK +*/ +type PcloudDhcpPostAccepted struct { + Payload *models.DHCPServer +} + +func (o *PcloudDhcpPostAccepted) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/services/dhcp][%d] pcloudDhcpPostAccepted %+v", 202, o.Payload) +} +func (o *PcloudDhcpPostAccepted) GetPayload() *models.DHCPServer { + return o.Payload +} + +func (o *PcloudDhcpPostAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.DHCPServer) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudDhcpPostBadRequest creates a PcloudDhcpPostBadRequest with default headers values +func NewPcloudDhcpPostBadRequest() *PcloudDhcpPostBadRequest { + return &PcloudDhcpPostBadRequest{} +} + +/* PcloudDhcpPostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudDhcpPostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudDhcpPostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/services/dhcp][%d] pcloudDhcpPostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudDhcpPostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudDhcpPostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudDhcpPostForbidden creates a PcloudDhcpPostForbidden with default headers values +func NewPcloudDhcpPostForbidden() *PcloudDhcpPostForbidden { + return &PcloudDhcpPostForbidden{} +} + +/* PcloudDhcpPostForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type PcloudDhcpPostForbidden struct { + Payload *models.Error +} + +func (o *PcloudDhcpPostForbidden) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/services/dhcp][%d] pcloudDhcpPostForbidden %+v", 403, o.Payload) +} +func (o *PcloudDhcpPostForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudDhcpPostForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudDhcpPostInternalServerError creates a PcloudDhcpPostInternalServerError with default headers values +func NewPcloudDhcpPostInternalServerError() *PcloudDhcpPostInternalServerError { + return &PcloudDhcpPostInternalServerError{} +} + +/* PcloudDhcpPostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudDhcpPostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudDhcpPostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/services/dhcp][%d] pcloudDhcpPostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudDhcpPostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudDhcpPostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_snapshots/p_cloud_snapshots_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_snapshots/p_cloud_snapshots_client.go new file mode 100644 index 00000000000..173f444230b --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_snapshots/p_cloud_snapshots_client.go @@ -0,0 +1,203 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_snapshots + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new p cloud snapshots API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for p cloud snapshots API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + PcloudCloudinstancesSnapshotsDelete(params *PcloudCloudinstancesSnapshotsDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesSnapshotsDeleteAccepted, error) + + PcloudCloudinstancesSnapshotsGet(params *PcloudCloudinstancesSnapshotsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesSnapshotsGetOK, error) + + PcloudCloudinstancesSnapshotsGetall(params *PcloudCloudinstancesSnapshotsGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesSnapshotsGetallOK, error) + + PcloudCloudinstancesSnapshotsPut(params *PcloudCloudinstancesSnapshotsPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesSnapshotsPutOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + PcloudCloudinstancesSnapshotsDelete deletes a p VM instance snapshot of a cloud instance +*/ +func (a *Client) PcloudCloudinstancesSnapshotsDelete(params *PcloudCloudinstancesSnapshotsDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesSnapshotsDeleteAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudinstancesSnapshotsDeleteParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.cloudinstances.snapshots.delete", + Method: "DELETE", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/snapshots/{snapshot_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudinstancesSnapshotsDeleteReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudCloudinstancesSnapshotsDeleteAccepted) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.cloudinstances.snapshots.delete: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudCloudinstancesSnapshotsGet gets the detail of a snapshot +*/ +func (a *Client) PcloudCloudinstancesSnapshotsGet(params *PcloudCloudinstancesSnapshotsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesSnapshotsGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudinstancesSnapshotsGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.cloudinstances.snapshots.get", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/snapshots/{snapshot_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudinstancesSnapshotsGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudCloudinstancesSnapshotsGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.cloudinstances.snapshots.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudCloudinstancesSnapshotsGetall lists all p VM instance snapshots for this cloud instance +*/ +func (a *Client) PcloudCloudinstancesSnapshotsGetall(params *PcloudCloudinstancesSnapshotsGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesSnapshotsGetallOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudinstancesSnapshotsGetallParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.cloudinstances.snapshots.getall", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/snapshots", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudinstancesSnapshotsGetallReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudCloudinstancesSnapshotsGetallOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.cloudinstances.snapshots.getall: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudCloudinstancesSnapshotsPut updates a p VM instance snapshot +*/ +func (a *Client) PcloudCloudinstancesSnapshotsPut(params *PcloudCloudinstancesSnapshotsPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesSnapshotsPutOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudinstancesSnapshotsPutParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.cloudinstances.snapshots.put", + Method: "PUT", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/snapshots/{snapshot_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudinstancesSnapshotsPutReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudCloudinstancesSnapshotsPutOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.cloudinstances.snapshots.put: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_delete_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_delete_parameters.go new file mode 100644 index 00000000000..ce1013739d7 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_delete_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_snapshots + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudCloudinstancesSnapshotsDeleteParams creates a new PcloudCloudinstancesSnapshotsDeleteParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudCloudinstancesSnapshotsDeleteParams() *PcloudCloudinstancesSnapshotsDeleteParams { + return &PcloudCloudinstancesSnapshotsDeleteParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudinstancesSnapshotsDeleteParamsWithTimeout creates a new PcloudCloudinstancesSnapshotsDeleteParams object +// with the ability to set a timeout on a request. +func NewPcloudCloudinstancesSnapshotsDeleteParamsWithTimeout(timeout time.Duration) *PcloudCloudinstancesSnapshotsDeleteParams { + return &PcloudCloudinstancesSnapshotsDeleteParams{ + timeout: timeout, + } +} + +// NewPcloudCloudinstancesSnapshotsDeleteParamsWithContext creates a new PcloudCloudinstancesSnapshotsDeleteParams object +// with the ability to set a context for a request. +func NewPcloudCloudinstancesSnapshotsDeleteParamsWithContext(ctx context.Context) *PcloudCloudinstancesSnapshotsDeleteParams { + return &PcloudCloudinstancesSnapshotsDeleteParams{ + Context: ctx, + } +} + +// NewPcloudCloudinstancesSnapshotsDeleteParamsWithHTTPClient creates a new PcloudCloudinstancesSnapshotsDeleteParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudCloudinstancesSnapshotsDeleteParamsWithHTTPClient(client *http.Client) *PcloudCloudinstancesSnapshotsDeleteParams { + return &PcloudCloudinstancesSnapshotsDeleteParams{ + HTTPClient: client, + } +} + +/* PcloudCloudinstancesSnapshotsDeleteParams contains all the parameters to send to the API endpoint + for the pcloud cloudinstances snapshots delete operation. + + Typically these are written to a http.Request. +*/ +type PcloudCloudinstancesSnapshotsDeleteParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* SnapshotID. + + PVM Instance snapshot id + */ + SnapshotID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud cloudinstances snapshots delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesSnapshotsDeleteParams) WithDefaults() *PcloudCloudinstancesSnapshotsDeleteParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud cloudinstances snapshots delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesSnapshotsDeleteParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud cloudinstances snapshots delete params +func (o *PcloudCloudinstancesSnapshotsDeleteParams) WithTimeout(timeout time.Duration) *PcloudCloudinstancesSnapshotsDeleteParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudinstances snapshots delete params +func (o *PcloudCloudinstancesSnapshotsDeleteParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudinstances snapshots delete params +func (o *PcloudCloudinstancesSnapshotsDeleteParams) WithContext(ctx context.Context) *PcloudCloudinstancesSnapshotsDeleteParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudinstances snapshots delete params +func (o *PcloudCloudinstancesSnapshotsDeleteParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudinstances snapshots delete params +func (o *PcloudCloudinstancesSnapshotsDeleteParams) WithHTTPClient(client *http.Client) *PcloudCloudinstancesSnapshotsDeleteParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudinstances snapshots delete params +func (o *PcloudCloudinstancesSnapshotsDeleteParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudinstances snapshots delete params +func (o *PcloudCloudinstancesSnapshotsDeleteParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudinstancesSnapshotsDeleteParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudinstances snapshots delete params +func (o *PcloudCloudinstancesSnapshotsDeleteParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithSnapshotID adds the snapshotID to the pcloud cloudinstances snapshots delete params +func (o *PcloudCloudinstancesSnapshotsDeleteParams) WithSnapshotID(snapshotID string) *PcloudCloudinstancesSnapshotsDeleteParams { + o.SetSnapshotID(snapshotID) + return o +} + +// SetSnapshotID adds the snapshotId to the pcloud cloudinstances snapshots delete params +func (o *PcloudCloudinstancesSnapshotsDeleteParams) SetSnapshotID(snapshotID string) { + o.SnapshotID = snapshotID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudinstancesSnapshotsDeleteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param snapshot_id + if err := r.SetPathParam("snapshot_id", o.SnapshotID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_delete_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_delete_responses.go new file mode 100644 index 00000000000..db473201767 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_delete_responses.go @@ -0,0 +1,255 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_snapshots + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudinstancesSnapshotsDeleteReader is a Reader for the PcloudCloudinstancesSnapshotsDelete structure. +type PcloudCloudinstancesSnapshotsDeleteReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudinstancesSnapshotsDeleteReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 202: + result := NewPcloudCloudinstancesSnapshotsDeleteAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudCloudinstancesSnapshotsDeleteBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudCloudinstancesSnapshotsDeleteUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudCloudinstancesSnapshotsDeleteNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 410: + result := NewPcloudCloudinstancesSnapshotsDeleteGone() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudCloudinstancesSnapshotsDeleteInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudCloudinstancesSnapshotsDeleteAccepted creates a PcloudCloudinstancesSnapshotsDeleteAccepted with default headers values +func NewPcloudCloudinstancesSnapshotsDeleteAccepted() *PcloudCloudinstancesSnapshotsDeleteAccepted { + return &PcloudCloudinstancesSnapshotsDeleteAccepted{} +} + +/* PcloudCloudinstancesSnapshotsDeleteAccepted describes a response with status code 202, with default header values. + +Accepted +*/ +type PcloudCloudinstancesSnapshotsDeleteAccepted struct { + Payload models.Object +} + +func (o *PcloudCloudinstancesSnapshotsDeleteAccepted) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/snapshots/{snapshot_id}][%d] pcloudCloudinstancesSnapshotsDeleteAccepted %+v", 202, o.Payload) +} +func (o *PcloudCloudinstancesSnapshotsDeleteAccepted) GetPayload() models.Object { + return o.Payload +} + +func (o *PcloudCloudinstancesSnapshotsDeleteAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesSnapshotsDeleteBadRequest creates a PcloudCloudinstancesSnapshotsDeleteBadRequest with default headers values +func NewPcloudCloudinstancesSnapshotsDeleteBadRequest() *PcloudCloudinstancesSnapshotsDeleteBadRequest { + return &PcloudCloudinstancesSnapshotsDeleteBadRequest{} +} + +/* PcloudCloudinstancesSnapshotsDeleteBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudCloudinstancesSnapshotsDeleteBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesSnapshotsDeleteBadRequest) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/snapshots/{snapshot_id}][%d] pcloudCloudinstancesSnapshotsDeleteBadRequest %+v", 400, o.Payload) +} +func (o *PcloudCloudinstancesSnapshotsDeleteBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesSnapshotsDeleteBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesSnapshotsDeleteUnauthorized creates a PcloudCloudinstancesSnapshotsDeleteUnauthorized with default headers values +func NewPcloudCloudinstancesSnapshotsDeleteUnauthorized() *PcloudCloudinstancesSnapshotsDeleteUnauthorized { + return &PcloudCloudinstancesSnapshotsDeleteUnauthorized{} +} + +/* PcloudCloudinstancesSnapshotsDeleteUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudCloudinstancesSnapshotsDeleteUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesSnapshotsDeleteUnauthorized) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/snapshots/{snapshot_id}][%d] pcloudCloudinstancesSnapshotsDeleteUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudCloudinstancesSnapshotsDeleteUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesSnapshotsDeleteUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesSnapshotsDeleteNotFound creates a PcloudCloudinstancesSnapshotsDeleteNotFound with default headers values +func NewPcloudCloudinstancesSnapshotsDeleteNotFound() *PcloudCloudinstancesSnapshotsDeleteNotFound { + return &PcloudCloudinstancesSnapshotsDeleteNotFound{} +} + +/* PcloudCloudinstancesSnapshotsDeleteNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudCloudinstancesSnapshotsDeleteNotFound struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesSnapshotsDeleteNotFound) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/snapshots/{snapshot_id}][%d] pcloudCloudinstancesSnapshotsDeleteNotFound %+v", 404, o.Payload) +} +func (o *PcloudCloudinstancesSnapshotsDeleteNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesSnapshotsDeleteNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesSnapshotsDeleteGone creates a PcloudCloudinstancesSnapshotsDeleteGone with default headers values +func NewPcloudCloudinstancesSnapshotsDeleteGone() *PcloudCloudinstancesSnapshotsDeleteGone { + return &PcloudCloudinstancesSnapshotsDeleteGone{} +} + +/* PcloudCloudinstancesSnapshotsDeleteGone describes a response with status code 410, with default header values. + +Gone +*/ +type PcloudCloudinstancesSnapshotsDeleteGone struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesSnapshotsDeleteGone) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/snapshots/{snapshot_id}][%d] pcloudCloudinstancesSnapshotsDeleteGone %+v", 410, o.Payload) +} +func (o *PcloudCloudinstancesSnapshotsDeleteGone) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesSnapshotsDeleteGone) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesSnapshotsDeleteInternalServerError creates a PcloudCloudinstancesSnapshotsDeleteInternalServerError with default headers values +func NewPcloudCloudinstancesSnapshotsDeleteInternalServerError() *PcloudCloudinstancesSnapshotsDeleteInternalServerError { + return &PcloudCloudinstancesSnapshotsDeleteInternalServerError{} +} + +/* PcloudCloudinstancesSnapshotsDeleteInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudCloudinstancesSnapshotsDeleteInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesSnapshotsDeleteInternalServerError) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/snapshots/{snapshot_id}][%d] pcloudCloudinstancesSnapshotsDeleteInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudCloudinstancesSnapshotsDeleteInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesSnapshotsDeleteInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_get_parameters.go new file mode 100644 index 00000000000..58857dc0eb0 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_get_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_snapshots + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudCloudinstancesSnapshotsGetParams creates a new PcloudCloudinstancesSnapshotsGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudCloudinstancesSnapshotsGetParams() *PcloudCloudinstancesSnapshotsGetParams { + return &PcloudCloudinstancesSnapshotsGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudinstancesSnapshotsGetParamsWithTimeout creates a new PcloudCloudinstancesSnapshotsGetParams object +// with the ability to set a timeout on a request. +func NewPcloudCloudinstancesSnapshotsGetParamsWithTimeout(timeout time.Duration) *PcloudCloudinstancesSnapshotsGetParams { + return &PcloudCloudinstancesSnapshotsGetParams{ + timeout: timeout, + } +} + +// NewPcloudCloudinstancesSnapshotsGetParamsWithContext creates a new PcloudCloudinstancesSnapshotsGetParams object +// with the ability to set a context for a request. +func NewPcloudCloudinstancesSnapshotsGetParamsWithContext(ctx context.Context) *PcloudCloudinstancesSnapshotsGetParams { + return &PcloudCloudinstancesSnapshotsGetParams{ + Context: ctx, + } +} + +// NewPcloudCloudinstancesSnapshotsGetParamsWithHTTPClient creates a new PcloudCloudinstancesSnapshotsGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudCloudinstancesSnapshotsGetParamsWithHTTPClient(client *http.Client) *PcloudCloudinstancesSnapshotsGetParams { + return &PcloudCloudinstancesSnapshotsGetParams{ + HTTPClient: client, + } +} + +/* PcloudCloudinstancesSnapshotsGetParams contains all the parameters to send to the API endpoint + for the pcloud cloudinstances snapshots get operation. + + Typically these are written to a http.Request. +*/ +type PcloudCloudinstancesSnapshotsGetParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* SnapshotID. + + PVM Instance snapshot id + */ + SnapshotID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud cloudinstances snapshots get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesSnapshotsGetParams) WithDefaults() *PcloudCloudinstancesSnapshotsGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud cloudinstances snapshots get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesSnapshotsGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud cloudinstances snapshots get params +func (o *PcloudCloudinstancesSnapshotsGetParams) WithTimeout(timeout time.Duration) *PcloudCloudinstancesSnapshotsGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudinstances snapshots get params +func (o *PcloudCloudinstancesSnapshotsGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudinstances snapshots get params +func (o *PcloudCloudinstancesSnapshotsGetParams) WithContext(ctx context.Context) *PcloudCloudinstancesSnapshotsGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudinstances snapshots get params +func (o *PcloudCloudinstancesSnapshotsGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudinstances snapshots get params +func (o *PcloudCloudinstancesSnapshotsGetParams) WithHTTPClient(client *http.Client) *PcloudCloudinstancesSnapshotsGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudinstances snapshots get params +func (o *PcloudCloudinstancesSnapshotsGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudinstances snapshots get params +func (o *PcloudCloudinstancesSnapshotsGetParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudinstancesSnapshotsGetParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudinstances snapshots get params +func (o *PcloudCloudinstancesSnapshotsGetParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithSnapshotID adds the snapshotID to the pcloud cloudinstances snapshots get params +func (o *PcloudCloudinstancesSnapshotsGetParams) WithSnapshotID(snapshotID string) *PcloudCloudinstancesSnapshotsGetParams { + o.SetSnapshotID(snapshotID) + return o +} + +// SetSnapshotID adds the snapshotId to the pcloud cloudinstances snapshots get params +func (o *PcloudCloudinstancesSnapshotsGetParams) SetSnapshotID(snapshotID string) { + o.SnapshotID = snapshotID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudinstancesSnapshotsGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param snapshot_id + if err := r.SetPathParam("snapshot_id", o.SnapshotID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_get_responses.go new file mode 100644 index 00000000000..44ebe00012a --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_get_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_snapshots + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudinstancesSnapshotsGetReader is a Reader for the PcloudCloudinstancesSnapshotsGet structure. +type PcloudCloudinstancesSnapshotsGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudinstancesSnapshotsGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudCloudinstancesSnapshotsGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudCloudinstancesSnapshotsGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudCloudinstancesSnapshotsGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudCloudinstancesSnapshotsGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudCloudinstancesSnapshotsGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudCloudinstancesSnapshotsGetOK creates a PcloudCloudinstancesSnapshotsGetOK with default headers values +func NewPcloudCloudinstancesSnapshotsGetOK() *PcloudCloudinstancesSnapshotsGetOK { + return &PcloudCloudinstancesSnapshotsGetOK{} +} + +/* PcloudCloudinstancesSnapshotsGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudCloudinstancesSnapshotsGetOK struct { + Payload *models.Snapshot +} + +func (o *PcloudCloudinstancesSnapshotsGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/snapshots/{snapshot_id}][%d] pcloudCloudinstancesSnapshotsGetOK %+v", 200, o.Payload) +} +func (o *PcloudCloudinstancesSnapshotsGetOK) GetPayload() *models.Snapshot { + return o.Payload +} + +func (o *PcloudCloudinstancesSnapshotsGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Snapshot) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesSnapshotsGetBadRequest creates a PcloudCloudinstancesSnapshotsGetBadRequest with default headers values +func NewPcloudCloudinstancesSnapshotsGetBadRequest() *PcloudCloudinstancesSnapshotsGetBadRequest { + return &PcloudCloudinstancesSnapshotsGetBadRequest{} +} + +/* PcloudCloudinstancesSnapshotsGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudCloudinstancesSnapshotsGetBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesSnapshotsGetBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/snapshots/{snapshot_id}][%d] pcloudCloudinstancesSnapshotsGetBadRequest %+v", 400, o.Payload) +} +func (o *PcloudCloudinstancesSnapshotsGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesSnapshotsGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesSnapshotsGetUnauthorized creates a PcloudCloudinstancesSnapshotsGetUnauthorized with default headers values +func NewPcloudCloudinstancesSnapshotsGetUnauthorized() *PcloudCloudinstancesSnapshotsGetUnauthorized { + return &PcloudCloudinstancesSnapshotsGetUnauthorized{} +} + +/* PcloudCloudinstancesSnapshotsGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudCloudinstancesSnapshotsGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesSnapshotsGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/snapshots/{snapshot_id}][%d] pcloudCloudinstancesSnapshotsGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudCloudinstancesSnapshotsGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesSnapshotsGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesSnapshotsGetNotFound creates a PcloudCloudinstancesSnapshotsGetNotFound with default headers values +func NewPcloudCloudinstancesSnapshotsGetNotFound() *PcloudCloudinstancesSnapshotsGetNotFound { + return &PcloudCloudinstancesSnapshotsGetNotFound{} +} + +/* PcloudCloudinstancesSnapshotsGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudCloudinstancesSnapshotsGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesSnapshotsGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/snapshots/{snapshot_id}][%d] pcloudCloudinstancesSnapshotsGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudCloudinstancesSnapshotsGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesSnapshotsGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesSnapshotsGetInternalServerError creates a PcloudCloudinstancesSnapshotsGetInternalServerError with default headers values +func NewPcloudCloudinstancesSnapshotsGetInternalServerError() *PcloudCloudinstancesSnapshotsGetInternalServerError { + return &PcloudCloudinstancesSnapshotsGetInternalServerError{} +} + +/* PcloudCloudinstancesSnapshotsGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudCloudinstancesSnapshotsGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesSnapshotsGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/snapshots/{snapshot_id}][%d] pcloudCloudinstancesSnapshotsGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudCloudinstancesSnapshotsGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesSnapshotsGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_getall_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_getall_parameters.go new file mode 100644 index 00000000000..281b70623c3 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_getall_parameters.go @@ -0,0 +1,149 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_snapshots + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudCloudinstancesSnapshotsGetallParams creates a new PcloudCloudinstancesSnapshotsGetallParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudCloudinstancesSnapshotsGetallParams() *PcloudCloudinstancesSnapshotsGetallParams { + return &PcloudCloudinstancesSnapshotsGetallParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudinstancesSnapshotsGetallParamsWithTimeout creates a new PcloudCloudinstancesSnapshotsGetallParams object +// with the ability to set a timeout on a request. +func NewPcloudCloudinstancesSnapshotsGetallParamsWithTimeout(timeout time.Duration) *PcloudCloudinstancesSnapshotsGetallParams { + return &PcloudCloudinstancesSnapshotsGetallParams{ + timeout: timeout, + } +} + +// NewPcloudCloudinstancesSnapshotsGetallParamsWithContext creates a new PcloudCloudinstancesSnapshotsGetallParams object +// with the ability to set a context for a request. +func NewPcloudCloudinstancesSnapshotsGetallParamsWithContext(ctx context.Context) *PcloudCloudinstancesSnapshotsGetallParams { + return &PcloudCloudinstancesSnapshotsGetallParams{ + Context: ctx, + } +} + +// NewPcloudCloudinstancesSnapshotsGetallParamsWithHTTPClient creates a new PcloudCloudinstancesSnapshotsGetallParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudCloudinstancesSnapshotsGetallParamsWithHTTPClient(client *http.Client) *PcloudCloudinstancesSnapshotsGetallParams { + return &PcloudCloudinstancesSnapshotsGetallParams{ + HTTPClient: client, + } +} + +/* PcloudCloudinstancesSnapshotsGetallParams contains all the parameters to send to the API endpoint + for the pcloud cloudinstances snapshots getall operation. + + Typically these are written to a http.Request. +*/ +type PcloudCloudinstancesSnapshotsGetallParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud cloudinstances snapshots getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesSnapshotsGetallParams) WithDefaults() *PcloudCloudinstancesSnapshotsGetallParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud cloudinstances snapshots getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesSnapshotsGetallParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud cloudinstances snapshots getall params +func (o *PcloudCloudinstancesSnapshotsGetallParams) WithTimeout(timeout time.Duration) *PcloudCloudinstancesSnapshotsGetallParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudinstances snapshots getall params +func (o *PcloudCloudinstancesSnapshotsGetallParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudinstances snapshots getall params +func (o *PcloudCloudinstancesSnapshotsGetallParams) WithContext(ctx context.Context) *PcloudCloudinstancesSnapshotsGetallParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudinstances snapshots getall params +func (o *PcloudCloudinstancesSnapshotsGetallParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudinstances snapshots getall params +func (o *PcloudCloudinstancesSnapshotsGetallParams) WithHTTPClient(client *http.Client) *PcloudCloudinstancesSnapshotsGetallParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudinstances snapshots getall params +func (o *PcloudCloudinstancesSnapshotsGetallParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudinstances snapshots getall params +func (o *PcloudCloudinstancesSnapshotsGetallParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudinstancesSnapshotsGetallParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudinstances snapshots getall params +func (o *PcloudCloudinstancesSnapshotsGetallParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudinstancesSnapshotsGetallParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_getall_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_getall_responses.go new file mode 100644 index 00000000000..c4dee1b560f --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_getall_responses.go @@ -0,0 +1,181 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_snapshots + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudinstancesSnapshotsGetallReader is a Reader for the PcloudCloudinstancesSnapshotsGetall structure. +type PcloudCloudinstancesSnapshotsGetallReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudinstancesSnapshotsGetallReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudCloudinstancesSnapshotsGetallOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudCloudinstancesSnapshotsGetallBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudCloudinstancesSnapshotsGetallUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudCloudinstancesSnapshotsGetallInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudCloudinstancesSnapshotsGetallOK creates a PcloudCloudinstancesSnapshotsGetallOK with default headers values +func NewPcloudCloudinstancesSnapshotsGetallOK() *PcloudCloudinstancesSnapshotsGetallOK { + return &PcloudCloudinstancesSnapshotsGetallOK{} +} + +/* PcloudCloudinstancesSnapshotsGetallOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudCloudinstancesSnapshotsGetallOK struct { + Payload *models.Snapshots +} + +func (o *PcloudCloudinstancesSnapshotsGetallOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/snapshots][%d] pcloudCloudinstancesSnapshotsGetallOK %+v", 200, o.Payload) +} +func (o *PcloudCloudinstancesSnapshotsGetallOK) GetPayload() *models.Snapshots { + return o.Payload +} + +func (o *PcloudCloudinstancesSnapshotsGetallOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Snapshots) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesSnapshotsGetallBadRequest creates a PcloudCloudinstancesSnapshotsGetallBadRequest with default headers values +func NewPcloudCloudinstancesSnapshotsGetallBadRequest() *PcloudCloudinstancesSnapshotsGetallBadRequest { + return &PcloudCloudinstancesSnapshotsGetallBadRequest{} +} + +/* PcloudCloudinstancesSnapshotsGetallBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudCloudinstancesSnapshotsGetallBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesSnapshotsGetallBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/snapshots][%d] pcloudCloudinstancesSnapshotsGetallBadRequest %+v", 400, o.Payload) +} +func (o *PcloudCloudinstancesSnapshotsGetallBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesSnapshotsGetallBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesSnapshotsGetallUnauthorized creates a PcloudCloudinstancesSnapshotsGetallUnauthorized with default headers values +func NewPcloudCloudinstancesSnapshotsGetallUnauthorized() *PcloudCloudinstancesSnapshotsGetallUnauthorized { + return &PcloudCloudinstancesSnapshotsGetallUnauthorized{} +} + +/* PcloudCloudinstancesSnapshotsGetallUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudCloudinstancesSnapshotsGetallUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesSnapshotsGetallUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/snapshots][%d] pcloudCloudinstancesSnapshotsGetallUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudCloudinstancesSnapshotsGetallUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesSnapshotsGetallUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesSnapshotsGetallInternalServerError creates a PcloudCloudinstancesSnapshotsGetallInternalServerError with default headers values +func NewPcloudCloudinstancesSnapshotsGetallInternalServerError() *PcloudCloudinstancesSnapshotsGetallInternalServerError { + return &PcloudCloudinstancesSnapshotsGetallInternalServerError{} +} + +/* PcloudCloudinstancesSnapshotsGetallInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudCloudinstancesSnapshotsGetallInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesSnapshotsGetallInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/snapshots][%d] pcloudCloudinstancesSnapshotsGetallInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudCloudinstancesSnapshotsGetallInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesSnapshotsGetallInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_put_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_put_parameters.go new file mode 100644 index 00000000000..268a2dfe269 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_put_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_snapshots + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudCloudinstancesSnapshotsPutParams creates a new PcloudCloudinstancesSnapshotsPutParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudCloudinstancesSnapshotsPutParams() *PcloudCloudinstancesSnapshotsPutParams { + return &PcloudCloudinstancesSnapshotsPutParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudinstancesSnapshotsPutParamsWithTimeout creates a new PcloudCloudinstancesSnapshotsPutParams object +// with the ability to set a timeout on a request. +func NewPcloudCloudinstancesSnapshotsPutParamsWithTimeout(timeout time.Duration) *PcloudCloudinstancesSnapshotsPutParams { + return &PcloudCloudinstancesSnapshotsPutParams{ + timeout: timeout, + } +} + +// NewPcloudCloudinstancesSnapshotsPutParamsWithContext creates a new PcloudCloudinstancesSnapshotsPutParams object +// with the ability to set a context for a request. +func NewPcloudCloudinstancesSnapshotsPutParamsWithContext(ctx context.Context) *PcloudCloudinstancesSnapshotsPutParams { + return &PcloudCloudinstancesSnapshotsPutParams{ + Context: ctx, + } +} + +// NewPcloudCloudinstancesSnapshotsPutParamsWithHTTPClient creates a new PcloudCloudinstancesSnapshotsPutParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudCloudinstancesSnapshotsPutParamsWithHTTPClient(client *http.Client) *PcloudCloudinstancesSnapshotsPutParams { + return &PcloudCloudinstancesSnapshotsPutParams{ + HTTPClient: client, + } +} + +/* PcloudCloudinstancesSnapshotsPutParams contains all the parameters to send to the API endpoint + for the pcloud cloudinstances snapshots put operation. + + Typically these are written to a http.Request. +*/ +type PcloudCloudinstancesSnapshotsPutParams struct { + + /* Body. + + Parameters for the update of a PVM instance snapshot + */ + Body *models.SnapshotUpdate + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* SnapshotID. + + PVM Instance snapshot id + */ + SnapshotID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud cloudinstances snapshots put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesSnapshotsPutParams) WithDefaults() *PcloudCloudinstancesSnapshotsPutParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud cloudinstances snapshots put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesSnapshotsPutParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud cloudinstances snapshots put params +func (o *PcloudCloudinstancesSnapshotsPutParams) WithTimeout(timeout time.Duration) *PcloudCloudinstancesSnapshotsPutParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudinstances snapshots put params +func (o *PcloudCloudinstancesSnapshotsPutParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudinstances snapshots put params +func (o *PcloudCloudinstancesSnapshotsPutParams) WithContext(ctx context.Context) *PcloudCloudinstancesSnapshotsPutParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudinstances snapshots put params +func (o *PcloudCloudinstancesSnapshotsPutParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudinstances snapshots put params +func (o *PcloudCloudinstancesSnapshotsPutParams) WithHTTPClient(client *http.Client) *PcloudCloudinstancesSnapshotsPutParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudinstances snapshots put params +func (o *PcloudCloudinstancesSnapshotsPutParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud cloudinstances snapshots put params +func (o *PcloudCloudinstancesSnapshotsPutParams) WithBody(body *models.SnapshotUpdate) *PcloudCloudinstancesSnapshotsPutParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud cloudinstances snapshots put params +func (o *PcloudCloudinstancesSnapshotsPutParams) SetBody(body *models.SnapshotUpdate) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudinstances snapshots put params +func (o *PcloudCloudinstancesSnapshotsPutParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudinstancesSnapshotsPutParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudinstances snapshots put params +func (o *PcloudCloudinstancesSnapshotsPutParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithSnapshotID adds the snapshotID to the pcloud cloudinstances snapshots put params +func (o *PcloudCloudinstancesSnapshotsPutParams) WithSnapshotID(snapshotID string) *PcloudCloudinstancesSnapshotsPutParams { + o.SetSnapshotID(snapshotID) + return o +} + +// SetSnapshotID adds the snapshotId to the pcloud cloudinstances snapshots put params +func (o *PcloudCloudinstancesSnapshotsPutParams) SetSnapshotID(snapshotID string) { + o.SnapshotID = snapshotID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudinstancesSnapshotsPutParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param snapshot_id + if err := r.SetPathParam("snapshot_id", o.SnapshotID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_put_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_put_responses.go new file mode 100644 index 00000000000..5dd9d99fac8 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_put_responses.go @@ -0,0 +1,217 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_snapshots + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudinstancesSnapshotsPutReader is a Reader for the PcloudCloudinstancesSnapshotsPut structure. +type PcloudCloudinstancesSnapshotsPutReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudinstancesSnapshotsPutReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudCloudinstancesSnapshotsPutOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudCloudinstancesSnapshotsPutBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudCloudinstancesSnapshotsPutUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudCloudinstancesSnapshotsPutNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudCloudinstancesSnapshotsPutInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudCloudinstancesSnapshotsPutOK creates a PcloudCloudinstancesSnapshotsPutOK with default headers values +func NewPcloudCloudinstancesSnapshotsPutOK() *PcloudCloudinstancesSnapshotsPutOK { + return &PcloudCloudinstancesSnapshotsPutOK{} +} + +/* PcloudCloudinstancesSnapshotsPutOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudCloudinstancesSnapshotsPutOK struct { + Payload models.Object +} + +func (o *PcloudCloudinstancesSnapshotsPutOK) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/snapshots/{snapshot_id}][%d] pcloudCloudinstancesSnapshotsPutOK %+v", 200, o.Payload) +} +func (o *PcloudCloudinstancesSnapshotsPutOK) GetPayload() models.Object { + return o.Payload +} + +func (o *PcloudCloudinstancesSnapshotsPutOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesSnapshotsPutBadRequest creates a PcloudCloudinstancesSnapshotsPutBadRequest with default headers values +func NewPcloudCloudinstancesSnapshotsPutBadRequest() *PcloudCloudinstancesSnapshotsPutBadRequest { + return &PcloudCloudinstancesSnapshotsPutBadRequest{} +} + +/* PcloudCloudinstancesSnapshotsPutBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudCloudinstancesSnapshotsPutBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesSnapshotsPutBadRequest) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/snapshots/{snapshot_id}][%d] pcloudCloudinstancesSnapshotsPutBadRequest %+v", 400, o.Payload) +} +func (o *PcloudCloudinstancesSnapshotsPutBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesSnapshotsPutBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesSnapshotsPutUnauthorized creates a PcloudCloudinstancesSnapshotsPutUnauthorized with default headers values +func NewPcloudCloudinstancesSnapshotsPutUnauthorized() *PcloudCloudinstancesSnapshotsPutUnauthorized { + return &PcloudCloudinstancesSnapshotsPutUnauthorized{} +} + +/* PcloudCloudinstancesSnapshotsPutUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudCloudinstancesSnapshotsPutUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesSnapshotsPutUnauthorized) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/snapshots/{snapshot_id}][%d] pcloudCloudinstancesSnapshotsPutUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudCloudinstancesSnapshotsPutUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesSnapshotsPutUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesSnapshotsPutNotFound creates a PcloudCloudinstancesSnapshotsPutNotFound with default headers values +func NewPcloudCloudinstancesSnapshotsPutNotFound() *PcloudCloudinstancesSnapshotsPutNotFound { + return &PcloudCloudinstancesSnapshotsPutNotFound{} +} + +/* PcloudCloudinstancesSnapshotsPutNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudCloudinstancesSnapshotsPutNotFound struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesSnapshotsPutNotFound) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/snapshots/{snapshot_id}][%d] pcloudCloudinstancesSnapshotsPutNotFound %+v", 404, o.Payload) +} +func (o *PcloudCloudinstancesSnapshotsPutNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesSnapshotsPutNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesSnapshotsPutInternalServerError creates a PcloudCloudinstancesSnapshotsPutInternalServerError with default headers values +func NewPcloudCloudinstancesSnapshotsPutInternalServerError() *PcloudCloudinstancesSnapshotsPutInternalServerError { + return &PcloudCloudinstancesSnapshotsPutInternalServerError{} +} + +/* PcloudCloudinstancesSnapshotsPutInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudCloudinstancesSnapshotsPutInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesSnapshotsPutInternalServerError) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/snapshots/{snapshot_id}][%d] pcloudCloudinstancesSnapshotsPutInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudCloudinstancesSnapshotsPutInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesSnapshotsPutInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_storage_capacity/p_cloud_storage_capacity_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_storage_capacity/p_cloud_storage_capacity_client.go new file mode 100644 index 00000000000..061b527297d --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_storage_capacity/p_cloud_storage_capacity_client.go @@ -0,0 +1,203 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_storage_capacity + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new p cloud storage capacity API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for p cloud storage capacity API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + PcloudStoragecapacityPoolsGet(params *PcloudStoragecapacityPoolsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudStoragecapacityPoolsGetOK, error) + + PcloudStoragecapacityPoolsGetall(params *PcloudStoragecapacityPoolsGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudStoragecapacityPoolsGetallOK, error) + + PcloudStoragecapacityTypesGet(params *PcloudStoragecapacityTypesGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudStoragecapacityTypesGetOK, error) + + PcloudStoragecapacityTypesGetall(params *PcloudStoragecapacityTypesGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudStoragecapacityTypesGetallOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + PcloudStoragecapacityPoolsGet storages capacity for a storage pool in a region +*/ +func (a *Client) PcloudStoragecapacityPoolsGet(params *PcloudStoragecapacityPoolsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudStoragecapacityPoolsGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudStoragecapacityPoolsGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.storagecapacity.pools.get", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/storage-capacity/storage-pools/{storage_pool_name}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudStoragecapacityPoolsGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudStoragecapacityPoolsGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.storagecapacity.pools.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudStoragecapacityPoolsGetall storages capacity for all available storage pools in a region +*/ +func (a *Client) PcloudStoragecapacityPoolsGetall(params *PcloudStoragecapacityPoolsGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudStoragecapacityPoolsGetallOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudStoragecapacityPoolsGetallParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.storagecapacity.pools.getall", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/storage-capacity/storage-pools", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudStoragecapacityPoolsGetallReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudStoragecapacityPoolsGetallOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.storagecapacity.pools.getall: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudStoragecapacityTypesGet storages capacity for a storage type in a region +*/ +func (a *Client) PcloudStoragecapacityTypesGet(params *PcloudStoragecapacityTypesGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudStoragecapacityTypesGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudStoragecapacityTypesGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.storagecapacity.types.get", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/storage-capacity/storage-types/{storage_type_name}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudStoragecapacityTypesGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudStoragecapacityTypesGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.storagecapacity.types.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudStoragecapacityTypesGetall storages capacity for all available storage types in a region +*/ +func (a *Client) PcloudStoragecapacityTypesGetall(params *PcloudStoragecapacityTypesGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudStoragecapacityTypesGetallOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudStoragecapacityTypesGetallParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.storagecapacity.types.getall", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/storage-capacity/storage-types", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudStoragecapacityTypesGetallReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudStoragecapacityTypesGetallOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.storagecapacity.types.getall: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_storage_capacity/pcloud_storagecapacity_pools_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_storage_capacity/pcloud_storagecapacity_pools_get_parameters.go new file mode 100644 index 00000000000..c2d5df80832 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_storage_capacity/pcloud_storagecapacity_pools_get_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_storage_capacity + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudStoragecapacityPoolsGetParams creates a new PcloudStoragecapacityPoolsGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudStoragecapacityPoolsGetParams() *PcloudStoragecapacityPoolsGetParams { + return &PcloudStoragecapacityPoolsGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudStoragecapacityPoolsGetParamsWithTimeout creates a new PcloudStoragecapacityPoolsGetParams object +// with the ability to set a timeout on a request. +func NewPcloudStoragecapacityPoolsGetParamsWithTimeout(timeout time.Duration) *PcloudStoragecapacityPoolsGetParams { + return &PcloudStoragecapacityPoolsGetParams{ + timeout: timeout, + } +} + +// NewPcloudStoragecapacityPoolsGetParamsWithContext creates a new PcloudStoragecapacityPoolsGetParams object +// with the ability to set a context for a request. +func NewPcloudStoragecapacityPoolsGetParamsWithContext(ctx context.Context) *PcloudStoragecapacityPoolsGetParams { + return &PcloudStoragecapacityPoolsGetParams{ + Context: ctx, + } +} + +// NewPcloudStoragecapacityPoolsGetParamsWithHTTPClient creates a new PcloudStoragecapacityPoolsGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudStoragecapacityPoolsGetParamsWithHTTPClient(client *http.Client) *PcloudStoragecapacityPoolsGetParams { + return &PcloudStoragecapacityPoolsGetParams{ + HTTPClient: client, + } +} + +/* PcloudStoragecapacityPoolsGetParams contains all the parameters to send to the API endpoint + for the pcloud storagecapacity pools get operation. + + Typically these are written to a http.Request. +*/ +type PcloudStoragecapacityPoolsGetParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* StoragePoolName. + + Storage pool name + */ + StoragePoolName string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud storagecapacity pools get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudStoragecapacityPoolsGetParams) WithDefaults() *PcloudStoragecapacityPoolsGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud storagecapacity pools get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudStoragecapacityPoolsGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud storagecapacity pools get params +func (o *PcloudStoragecapacityPoolsGetParams) WithTimeout(timeout time.Duration) *PcloudStoragecapacityPoolsGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud storagecapacity pools get params +func (o *PcloudStoragecapacityPoolsGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud storagecapacity pools get params +func (o *PcloudStoragecapacityPoolsGetParams) WithContext(ctx context.Context) *PcloudStoragecapacityPoolsGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud storagecapacity pools get params +func (o *PcloudStoragecapacityPoolsGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud storagecapacity pools get params +func (o *PcloudStoragecapacityPoolsGetParams) WithHTTPClient(client *http.Client) *PcloudStoragecapacityPoolsGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud storagecapacity pools get params +func (o *PcloudStoragecapacityPoolsGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud storagecapacity pools get params +func (o *PcloudStoragecapacityPoolsGetParams) WithCloudInstanceID(cloudInstanceID string) *PcloudStoragecapacityPoolsGetParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud storagecapacity pools get params +func (o *PcloudStoragecapacityPoolsGetParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithStoragePoolName adds the storagePoolName to the pcloud storagecapacity pools get params +func (o *PcloudStoragecapacityPoolsGetParams) WithStoragePoolName(storagePoolName string) *PcloudStoragecapacityPoolsGetParams { + o.SetStoragePoolName(storagePoolName) + return o +} + +// SetStoragePoolName adds the storagePoolName to the pcloud storagecapacity pools get params +func (o *PcloudStoragecapacityPoolsGetParams) SetStoragePoolName(storagePoolName string) { + o.StoragePoolName = storagePoolName +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudStoragecapacityPoolsGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param storage_pool_name + if err := r.SetPathParam("storage_pool_name", o.StoragePoolName); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_storage_capacity/pcloud_storagecapacity_pools_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_storage_capacity/pcloud_storagecapacity_pools_get_responses.go new file mode 100644 index 00000000000..d6abdcf9b65 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_storage_capacity/pcloud_storagecapacity_pools_get_responses.go @@ -0,0 +1,181 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_storage_capacity + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudStoragecapacityPoolsGetReader is a Reader for the PcloudStoragecapacityPoolsGet structure. +type PcloudStoragecapacityPoolsGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudStoragecapacityPoolsGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudStoragecapacityPoolsGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewPcloudStoragecapacityPoolsGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudStoragecapacityPoolsGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudStoragecapacityPoolsGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudStoragecapacityPoolsGetOK creates a PcloudStoragecapacityPoolsGetOK with default headers values +func NewPcloudStoragecapacityPoolsGetOK() *PcloudStoragecapacityPoolsGetOK { + return &PcloudStoragecapacityPoolsGetOK{} +} + +/* PcloudStoragecapacityPoolsGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudStoragecapacityPoolsGetOK struct { + Payload *models.StoragePoolCapacity +} + +func (o *PcloudStoragecapacityPoolsGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/storage-capacity/storage-pools/{storage_pool_name}][%d] pcloudStoragecapacityPoolsGetOK %+v", 200, o.Payload) +} +func (o *PcloudStoragecapacityPoolsGetOK) GetPayload() *models.StoragePoolCapacity { + return o.Payload +} + +func (o *PcloudStoragecapacityPoolsGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.StoragePoolCapacity) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudStoragecapacityPoolsGetUnauthorized creates a PcloudStoragecapacityPoolsGetUnauthorized with default headers values +func NewPcloudStoragecapacityPoolsGetUnauthorized() *PcloudStoragecapacityPoolsGetUnauthorized { + return &PcloudStoragecapacityPoolsGetUnauthorized{} +} + +/* PcloudStoragecapacityPoolsGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudStoragecapacityPoolsGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudStoragecapacityPoolsGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/storage-capacity/storage-pools/{storage_pool_name}][%d] pcloudStoragecapacityPoolsGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudStoragecapacityPoolsGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudStoragecapacityPoolsGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudStoragecapacityPoolsGetNotFound creates a PcloudStoragecapacityPoolsGetNotFound with default headers values +func NewPcloudStoragecapacityPoolsGetNotFound() *PcloudStoragecapacityPoolsGetNotFound { + return &PcloudStoragecapacityPoolsGetNotFound{} +} + +/* PcloudStoragecapacityPoolsGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudStoragecapacityPoolsGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudStoragecapacityPoolsGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/storage-capacity/storage-pools/{storage_pool_name}][%d] pcloudStoragecapacityPoolsGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudStoragecapacityPoolsGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudStoragecapacityPoolsGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudStoragecapacityPoolsGetInternalServerError creates a PcloudStoragecapacityPoolsGetInternalServerError with default headers values +func NewPcloudStoragecapacityPoolsGetInternalServerError() *PcloudStoragecapacityPoolsGetInternalServerError { + return &PcloudStoragecapacityPoolsGetInternalServerError{} +} + +/* PcloudStoragecapacityPoolsGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudStoragecapacityPoolsGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudStoragecapacityPoolsGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/storage-capacity/storage-pools/{storage_pool_name}][%d] pcloudStoragecapacityPoolsGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudStoragecapacityPoolsGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudStoragecapacityPoolsGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_storage_capacity/pcloud_storagecapacity_pools_getall_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_storage_capacity/pcloud_storagecapacity_pools_getall_parameters.go new file mode 100644 index 00000000000..e955e007b4b --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_storage_capacity/pcloud_storagecapacity_pools_getall_parameters.go @@ -0,0 +1,149 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_storage_capacity + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudStoragecapacityPoolsGetallParams creates a new PcloudStoragecapacityPoolsGetallParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudStoragecapacityPoolsGetallParams() *PcloudStoragecapacityPoolsGetallParams { + return &PcloudStoragecapacityPoolsGetallParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudStoragecapacityPoolsGetallParamsWithTimeout creates a new PcloudStoragecapacityPoolsGetallParams object +// with the ability to set a timeout on a request. +func NewPcloudStoragecapacityPoolsGetallParamsWithTimeout(timeout time.Duration) *PcloudStoragecapacityPoolsGetallParams { + return &PcloudStoragecapacityPoolsGetallParams{ + timeout: timeout, + } +} + +// NewPcloudStoragecapacityPoolsGetallParamsWithContext creates a new PcloudStoragecapacityPoolsGetallParams object +// with the ability to set a context for a request. +func NewPcloudStoragecapacityPoolsGetallParamsWithContext(ctx context.Context) *PcloudStoragecapacityPoolsGetallParams { + return &PcloudStoragecapacityPoolsGetallParams{ + Context: ctx, + } +} + +// NewPcloudStoragecapacityPoolsGetallParamsWithHTTPClient creates a new PcloudStoragecapacityPoolsGetallParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudStoragecapacityPoolsGetallParamsWithHTTPClient(client *http.Client) *PcloudStoragecapacityPoolsGetallParams { + return &PcloudStoragecapacityPoolsGetallParams{ + HTTPClient: client, + } +} + +/* PcloudStoragecapacityPoolsGetallParams contains all the parameters to send to the API endpoint + for the pcloud storagecapacity pools getall operation. + + Typically these are written to a http.Request. +*/ +type PcloudStoragecapacityPoolsGetallParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud storagecapacity pools getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudStoragecapacityPoolsGetallParams) WithDefaults() *PcloudStoragecapacityPoolsGetallParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud storagecapacity pools getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudStoragecapacityPoolsGetallParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud storagecapacity pools getall params +func (o *PcloudStoragecapacityPoolsGetallParams) WithTimeout(timeout time.Duration) *PcloudStoragecapacityPoolsGetallParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud storagecapacity pools getall params +func (o *PcloudStoragecapacityPoolsGetallParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud storagecapacity pools getall params +func (o *PcloudStoragecapacityPoolsGetallParams) WithContext(ctx context.Context) *PcloudStoragecapacityPoolsGetallParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud storagecapacity pools getall params +func (o *PcloudStoragecapacityPoolsGetallParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud storagecapacity pools getall params +func (o *PcloudStoragecapacityPoolsGetallParams) WithHTTPClient(client *http.Client) *PcloudStoragecapacityPoolsGetallParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud storagecapacity pools getall params +func (o *PcloudStoragecapacityPoolsGetallParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud storagecapacity pools getall params +func (o *PcloudStoragecapacityPoolsGetallParams) WithCloudInstanceID(cloudInstanceID string) *PcloudStoragecapacityPoolsGetallParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud storagecapacity pools getall params +func (o *PcloudStoragecapacityPoolsGetallParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudStoragecapacityPoolsGetallParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_storage_capacity/pcloud_storagecapacity_pools_getall_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_storage_capacity/pcloud_storagecapacity_pools_getall_responses.go new file mode 100644 index 00000000000..6aa16ffe92c --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_storage_capacity/pcloud_storagecapacity_pools_getall_responses.go @@ -0,0 +1,143 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_storage_capacity + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudStoragecapacityPoolsGetallReader is a Reader for the PcloudStoragecapacityPoolsGetall structure. +type PcloudStoragecapacityPoolsGetallReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudStoragecapacityPoolsGetallReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudStoragecapacityPoolsGetallOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewPcloudStoragecapacityPoolsGetallUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudStoragecapacityPoolsGetallInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudStoragecapacityPoolsGetallOK creates a PcloudStoragecapacityPoolsGetallOK with default headers values +func NewPcloudStoragecapacityPoolsGetallOK() *PcloudStoragecapacityPoolsGetallOK { + return &PcloudStoragecapacityPoolsGetallOK{} +} + +/* PcloudStoragecapacityPoolsGetallOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudStoragecapacityPoolsGetallOK struct { + Payload *models.StoragePoolsCapacity +} + +func (o *PcloudStoragecapacityPoolsGetallOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/storage-capacity/storage-pools][%d] pcloudStoragecapacityPoolsGetallOK %+v", 200, o.Payload) +} +func (o *PcloudStoragecapacityPoolsGetallOK) GetPayload() *models.StoragePoolsCapacity { + return o.Payload +} + +func (o *PcloudStoragecapacityPoolsGetallOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.StoragePoolsCapacity) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudStoragecapacityPoolsGetallUnauthorized creates a PcloudStoragecapacityPoolsGetallUnauthorized with default headers values +func NewPcloudStoragecapacityPoolsGetallUnauthorized() *PcloudStoragecapacityPoolsGetallUnauthorized { + return &PcloudStoragecapacityPoolsGetallUnauthorized{} +} + +/* PcloudStoragecapacityPoolsGetallUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudStoragecapacityPoolsGetallUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudStoragecapacityPoolsGetallUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/storage-capacity/storage-pools][%d] pcloudStoragecapacityPoolsGetallUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudStoragecapacityPoolsGetallUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudStoragecapacityPoolsGetallUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudStoragecapacityPoolsGetallInternalServerError creates a PcloudStoragecapacityPoolsGetallInternalServerError with default headers values +func NewPcloudStoragecapacityPoolsGetallInternalServerError() *PcloudStoragecapacityPoolsGetallInternalServerError { + return &PcloudStoragecapacityPoolsGetallInternalServerError{} +} + +/* PcloudStoragecapacityPoolsGetallInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudStoragecapacityPoolsGetallInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudStoragecapacityPoolsGetallInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/storage-capacity/storage-pools][%d] pcloudStoragecapacityPoolsGetallInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudStoragecapacityPoolsGetallInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudStoragecapacityPoolsGetallInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_storage_capacity/pcloud_storagecapacity_types_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_storage_capacity/pcloud_storagecapacity_types_get_parameters.go new file mode 100644 index 00000000000..51f3bb9b40d --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_storage_capacity/pcloud_storagecapacity_types_get_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_storage_capacity + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudStoragecapacityTypesGetParams creates a new PcloudStoragecapacityTypesGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudStoragecapacityTypesGetParams() *PcloudStoragecapacityTypesGetParams { + return &PcloudStoragecapacityTypesGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudStoragecapacityTypesGetParamsWithTimeout creates a new PcloudStoragecapacityTypesGetParams object +// with the ability to set a timeout on a request. +func NewPcloudStoragecapacityTypesGetParamsWithTimeout(timeout time.Duration) *PcloudStoragecapacityTypesGetParams { + return &PcloudStoragecapacityTypesGetParams{ + timeout: timeout, + } +} + +// NewPcloudStoragecapacityTypesGetParamsWithContext creates a new PcloudStoragecapacityTypesGetParams object +// with the ability to set a context for a request. +func NewPcloudStoragecapacityTypesGetParamsWithContext(ctx context.Context) *PcloudStoragecapacityTypesGetParams { + return &PcloudStoragecapacityTypesGetParams{ + Context: ctx, + } +} + +// NewPcloudStoragecapacityTypesGetParamsWithHTTPClient creates a new PcloudStoragecapacityTypesGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudStoragecapacityTypesGetParamsWithHTTPClient(client *http.Client) *PcloudStoragecapacityTypesGetParams { + return &PcloudStoragecapacityTypesGetParams{ + HTTPClient: client, + } +} + +/* PcloudStoragecapacityTypesGetParams contains all the parameters to send to the API endpoint + for the pcloud storagecapacity types get operation. + + Typically these are written to a http.Request. +*/ +type PcloudStoragecapacityTypesGetParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* StorageTypeName. + + Storage type name + */ + StorageTypeName string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud storagecapacity types get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudStoragecapacityTypesGetParams) WithDefaults() *PcloudStoragecapacityTypesGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud storagecapacity types get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudStoragecapacityTypesGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud storagecapacity types get params +func (o *PcloudStoragecapacityTypesGetParams) WithTimeout(timeout time.Duration) *PcloudStoragecapacityTypesGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud storagecapacity types get params +func (o *PcloudStoragecapacityTypesGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud storagecapacity types get params +func (o *PcloudStoragecapacityTypesGetParams) WithContext(ctx context.Context) *PcloudStoragecapacityTypesGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud storagecapacity types get params +func (o *PcloudStoragecapacityTypesGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud storagecapacity types get params +func (o *PcloudStoragecapacityTypesGetParams) WithHTTPClient(client *http.Client) *PcloudStoragecapacityTypesGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud storagecapacity types get params +func (o *PcloudStoragecapacityTypesGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud storagecapacity types get params +func (o *PcloudStoragecapacityTypesGetParams) WithCloudInstanceID(cloudInstanceID string) *PcloudStoragecapacityTypesGetParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud storagecapacity types get params +func (o *PcloudStoragecapacityTypesGetParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithStorageTypeName adds the storageTypeName to the pcloud storagecapacity types get params +func (o *PcloudStoragecapacityTypesGetParams) WithStorageTypeName(storageTypeName string) *PcloudStoragecapacityTypesGetParams { + o.SetStorageTypeName(storageTypeName) + return o +} + +// SetStorageTypeName adds the storageTypeName to the pcloud storagecapacity types get params +func (o *PcloudStoragecapacityTypesGetParams) SetStorageTypeName(storageTypeName string) { + o.StorageTypeName = storageTypeName +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudStoragecapacityTypesGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param storage_type_name + if err := r.SetPathParam("storage_type_name", o.StorageTypeName); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_storage_capacity/pcloud_storagecapacity_types_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_storage_capacity/pcloud_storagecapacity_types_get_responses.go new file mode 100644 index 00000000000..3623f47c005 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_storage_capacity/pcloud_storagecapacity_types_get_responses.go @@ -0,0 +1,181 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_storage_capacity + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudStoragecapacityTypesGetReader is a Reader for the PcloudStoragecapacityTypesGet structure. +type PcloudStoragecapacityTypesGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudStoragecapacityTypesGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudStoragecapacityTypesGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewPcloudStoragecapacityTypesGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudStoragecapacityTypesGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudStoragecapacityTypesGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudStoragecapacityTypesGetOK creates a PcloudStoragecapacityTypesGetOK with default headers values +func NewPcloudStoragecapacityTypesGetOK() *PcloudStoragecapacityTypesGetOK { + return &PcloudStoragecapacityTypesGetOK{} +} + +/* PcloudStoragecapacityTypesGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudStoragecapacityTypesGetOK struct { + Payload *models.StorageTypeCapacity +} + +func (o *PcloudStoragecapacityTypesGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/storage-capacity/storage-types/{storage_type_name}][%d] pcloudStoragecapacityTypesGetOK %+v", 200, o.Payload) +} +func (o *PcloudStoragecapacityTypesGetOK) GetPayload() *models.StorageTypeCapacity { + return o.Payload +} + +func (o *PcloudStoragecapacityTypesGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.StorageTypeCapacity) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudStoragecapacityTypesGetUnauthorized creates a PcloudStoragecapacityTypesGetUnauthorized with default headers values +func NewPcloudStoragecapacityTypesGetUnauthorized() *PcloudStoragecapacityTypesGetUnauthorized { + return &PcloudStoragecapacityTypesGetUnauthorized{} +} + +/* PcloudStoragecapacityTypesGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudStoragecapacityTypesGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudStoragecapacityTypesGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/storage-capacity/storage-types/{storage_type_name}][%d] pcloudStoragecapacityTypesGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudStoragecapacityTypesGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudStoragecapacityTypesGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudStoragecapacityTypesGetNotFound creates a PcloudStoragecapacityTypesGetNotFound with default headers values +func NewPcloudStoragecapacityTypesGetNotFound() *PcloudStoragecapacityTypesGetNotFound { + return &PcloudStoragecapacityTypesGetNotFound{} +} + +/* PcloudStoragecapacityTypesGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudStoragecapacityTypesGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudStoragecapacityTypesGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/storage-capacity/storage-types/{storage_type_name}][%d] pcloudStoragecapacityTypesGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudStoragecapacityTypesGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudStoragecapacityTypesGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudStoragecapacityTypesGetInternalServerError creates a PcloudStoragecapacityTypesGetInternalServerError with default headers values +func NewPcloudStoragecapacityTypesGetInternalServerError() *PcloudStoragecapacityTypesGetInternalServerError { + return &PcloudStoragecapacityTypesGetInternalServerError{} +} + +/* PcloudStoragecapacityTypesGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudStoragecapacityTypesGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudStoragecapacityTypesGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/storage-capacity/storage-types/{storage_type_name}][%d] pcloudStoragecapacityTypesGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudStoragecapacityTypesGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudStoragecapacityTypesGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_storage_capacity/pcloud_storagecapacity_types_getall_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_storage_capacity/pcloud_storagecapacity_types_getall_parameters.go new file mode 100644 index 00000000000..50519ea2e9a --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_storage_capacity/pcloud_storagecapacity_types_getall_parameters.go @@ -0,0 +1,149 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_storage_capacity + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudStoragecapacityTypesGetallParams creates a new PcloudStoragecapacityTypesGetallParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudStoragecapacityTypesGetallParams() *PcloudStoragecapacityTypesGetallParams { + return &PcloudStoragecapacityTypesGetallParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudStoragecapacityTypesGetallParamsWithTimeout creates a new PcloudStoragecapacityTypesGetallParams object +// with the ability to set a timeout on a request. +func NewPcloudStoragecapacityTypesGetallParamsWithTimeout(timeout time.Duration) *PcloudStoragecapacityTypesGetallParams { + return &PcloudStoragecapacityTypesGetallParams{ + timeout: timeout, + } +} + +// NewPcloudStoragecapacityTypesGetallParamsWithContext creates a new PcloudStoragecapacityTypesGetallParams object +// with the ability to set a context for a request. +func NewPcloudStoragecapacityTypesGetallParamsWithContext(ctx context.Context) *PcloudStoragecapacityTypesGetallParams { + return &PcloudStoragecapacityTypesGetallParams{ + Context: ctx, + } +} + +// NewPcloudStoragecapacityTypesGetallParamsWithHTTPClient creates a new PcloudStoragecapacityTypesGetallParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudStoragecapacityTypesGetallParamsWithHTTPClient(client *http.Client) *PcloudStoragecapacityTypesGetallParams { + return &PcloudStoragecapacityTypesGetallParams{ + HTTPClient: client, + } +} + +/* PcloudStoragecapacityTypesGetallParams contains all the parameters to send to the API endpoint + for the pcloud storagecapacity types getall operation. + + Typically these are written to a http.Request. +*/ +type PcloudStoragecapacityTypesGetallParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud storagecapacity types getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudStoragecapacityTypesGetallParams) WithDefaults() *PcloudStoragecapacityTypesGetallParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud storagecapacity types getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudStoragecapacityTypesGetallParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud storagecapacity types getall params +func (o *PcloudStoragecapacityTypesGetallParams) WithTimeout(timeout time.Duration) *PcloudStoragecapacityTypesGetallParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud storagecapacity types getall params +func (o *PcloudStoragecapacityTypesGetallParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud storagecapacity types getall params +func (o *PcloudStoragecapacityTypesGetallParams) WithContext(ctx context.Context) *PcloudStoragecapacityTypesGetallParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud storagecapacity types getall params +func (o *PcloudStoragecapacityTypesGetallParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud storagecapacity types getall params +func (o *PcloudStoragecapacityTypesGetallParams) WithHTTPClient(client *http.Client) *PcloudStoragecapacityTypesGetallParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud storagecapacity types getall params +func (o *PcloudStoragecapacityTypesGetallParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud storagecapacity types getall params +func (o *PcloudStoragecapacityTypesGetallParams) WithCloudInstanceID(cloudInstanceID string) *PcloudStoragecapacityTypesGetallParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud storagecapacity types getall params +func (o *PcloudStoragecapacityTypesGetallParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudStoragecapacityTypesGetallParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_storage_capacity/pcloud_storagecapacity_types_getall_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_storage_capacity/pcloud_storagecapacity_types_getall_responses.go new file mode 100644 index 00000000000..97595cd310d --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_storage_capacity/pcloud_storagecapacity_types_getall_responses.go @@ -0,0 +1,143 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_storage_capacity + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudStoragecapacityTypesGetallReader is a Reader for the PcloudStoragecapacityTypesGetall structure. +type PcloudStoragecapacityTypesGetallReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudStoragecapacityTypesGetallReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudStoragecapacityTypesGetallOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewPcloudStoragecapacityTypesGetallUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudStoragecapacityTypesGetallInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudStoragecapacityTypesGetallOK creates a PcloudStoragecapacityTypesGetallOK with default headers values +func NewPcloudStoragecapacityTypesGetallOK() *PcloudStoragecapacityTypesGetallOK { + return &PcloudStoragecapacityTypesGetallOK{} +} + +/* PcloudStoragecapacityTypesGetallOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudStoragecapacityTypesGetallOK struct { + Payload *models.StorageTypesCapacity +} + +func (o *PcloudStoragecapacityTypesGetallOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/storage-capacity/storage-types][%d] pcloudStoragecapacityTypesGetallOK %+v", 200, o.Payload) +} +func (o *PcloudStoragecapacityTypesGetallOK) GetPayload() *models.StorageTypesCapacity { + return o.Payload +} + +func (o *PcloudStoragecapacityTypesGetallOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.StorageTypesCapacity) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudStoragecapacityTypesGetallUnauthorized creates a PcloudStoragecapacityTypesGetallUnauthorized with default headers values +func NewPcloudStoragecapacityTypesGetallUnauthorized() *PcloudStoragecapacityTypesGetallUnauthorized { + return &PcloudStoragecapacityTypesGetallUnauthorized{} +} + +/* PcloudStoragecapacityTypesGetallUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudStoragecapacityTypesGetallUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudStoragecapacityTypesGetallUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/storage-capacity/storage-types][%d] pcloudStoragecapacityTypesGetallUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudStoragecapacityTypesGetallUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudStoragecapacityTypesGetallUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudStoragecapacityTypesGetallInternalServerError creates a PcloudStoragecapacityTypesGetallInternalServerError with default headers values +func NewPcloudStoragecapacityTypesGetallInternalServerError() *PcloudStoragecapacityTypesGetallInternalServerError { + return &PcloudStoragecapacityTypesGetallInternalServerError{} +} + +/* PcloudStoragecapacityTypesGetallInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudStoragecapacityTypesGetallInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudStoragecapacityTypesGetallInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/storage-capacity/storage-types][%d] pcloudStoragecapacityTypesGetallInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudStoragecapacityTypesGetallInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudStoragecapacityTypesGetallInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_system_pools/p_cloud_system_pools_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_system_pools/p_cloud_system_pools_client.go new file mode 100644 index 00000000000..a94da9c21e4 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_system_pools/p_cloud_system_pools_client.go @@ -0,0 +1,80 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_system_pools + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new p cloud system pools API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for p cloud system pools API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + PcloudSystempoolsGet(params *PcloudSystempoolsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudSystempoolsGetOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + PcloudSystempoolsGet lists of available system pools within a particular data center +*/ +func (a *Client) PcloudSystempoolsGet(params *PcloudSystempoolsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudSystempoolsGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudSystempoolsGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.systempools.get", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/system-pools", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudSystempoolsGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudSystempoolsGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.systempools.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_system_pools/pcloud_systempools_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_system_pools/pcloud_systempools_get_parameters.go new file mode 100644 index 00000000000..a727b64e5b0 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_system_pools/pcloud_systempools_get_parameters.go @@ -0,0 +1,149 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_system_pools + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudSystempoolsGetParams creates a new PcloudSystempoolsGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudSystempoolsGetParams() *PcloudSystempoolsGetParams { + return &PcloudSystempoolsGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudSystempoolsGetParamsWithTimeout creates a new PcloudSystempoolsGetParams object +// with the ability to set a timeout on a request. +func NewPcloudSystempoolsGetParamsWithTimeout(timeout time.Duration) *PcloudSystempoolsGetParams { + return &PcloudSystempoolsGetParams{ + timeout: timeout, + } +} + +// NewPcloudSystempoolsGetParamsWithContext creates a new PcloudSystempoolsGetParams object +// with the ability to set a context for a request. +func NewPcloudSystempoolsGetParamsWithContext(ctx context.Context) *PcloudSystempoolsGetParams { + return &PcloudSystempoolsGetParams{ + Context: ctx, + } +} + +// NewPcloudSystempoolsGetParamsWithHTTPClient creates a new PcloudSystempoolsGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudSystempoolsGetParamsWithHTTPClient(client *http.Client) *PcloudSystempoolsGetParams { + return &PcloudSystempoolsGetParams{ + HTTPClient: client, + } +} + +/* PcloudSystempoolsGetParams contains all the parameters to send to the API endpoint + for the pcloud systempools get operation. + + Typically these are written to a http.Request. +*/ +type PcloudSystempoolsGetParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud systempools get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudSystempoolsGetParams) WithDefaults() *PcloudSystempoolsGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud systempools get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudSystempoolsGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud systempools get params +func (o *PcloudSystempoolsGetParams) WithTimeout(timeout time.Duration) *PcloudSystempoolsGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud systempools get params +func (o *PcloudSystempoolsGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud systempools get params +func (o *PcloudSystempoolsGetParams) WithContext(ctx context.Context) *PcloudSystempoolsGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud systempools get params +func (o *PcloudSystempoolsGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud systempools get params +func (o *PcloudSystempoolsGetParams) WithHTTPClient(client *http.Client) *PcloudSystempoolsGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud systempools get params +func (o *PcloudSystempoolsGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud systempools get params +func (o *PcloudSystempoolsGetParams) WithCloudInstanceID(cloudInstanceID string) *PcloudSystempoolsGetParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud systempools get params +func (o *PcloudSystempoolsGetParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudSystempoolsGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_system_pools/pcloud_systempools_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_system_pools/pcloud_systempools_get_responses.go new file mode 100644 index 00000000000..78089d7a0f4 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_system_pools/pcloud_systempools_get_responses.go @@ -0,0 +1,141 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_system_pools + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudSystempoolsGetReader is a Reader for the PcloudSystempoolsGet structure. +type PcloudSystempoolsGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudSystempoolsGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudSystempoolsGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewPcloudSystempoolsGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudSystempoolsGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudSystempoolsGetOK creates a PcloudSystempoolsGetOK with default headers values +func NewPcloudSystempoolsGetOK() *PcloudSystempoolsGetOK { + return &PcloudSystempoolsGetOK{} +} + +/* PcloudSystempoolsGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudSystempoolsGetOK struct { + Payload models.SystemPools +} + +func (o *PcloudSystempoolsGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/system-pools][%d] pcloudSystempoolsGetOK %+v", 200, o.Payload) +} +func (o *PcloudSystempoolsGetOK) GetPayload() models.SystemPools { + return o.Payload +} + +func (o *PcloudSystempoolsGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudSystempoolsGetUnauthorized creates a PcloudSystempoolsGetUnauthorized with default headers values +func NewPcloudSystempoolsGetUnauthorized() *PcloudSystempoolsGetUnauthorized { + return &PcloudSystempoolsGetUnauthorized{} +} + +/* PcloudSystempoolsGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudSystempoolsGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudSystempoolsGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/system-pools][%d] pcloudSystempoolsGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudSystempoolsGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudSystempoolsGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudSystempoolsGetInternalServerError creates a PcloudSystempoolsGetInternalServerError with default headers values +func NewPcloudSystempoolsGetInternalServerError() *PcloudSystempoolsGetInternalServerError { + return &PcloudSystempoolsGetInternalServerError{} +} + +/* PcloudSystempoolsGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudSystempoolsGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudSystempoolsGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/system-pools][%d] pcloudSystempoolsGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudSystempoolsGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudSystempoolsGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tasks/p_cloud_tasks_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tasks/p_cloud_tasks_client.go new file mode 100644 index 00000000000..22d71e5ec92 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tasks/p_cloud_tasks_client.go @@ -0,0 +1,121 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_tasks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new p cloud tasks API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for p cloud tasks API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + PcloudTasksDelete(params *PcloudTasksDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudTasksDeleteOK, error) + + PcloudTasksGet(params *PcloudTasksGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudTasksGetOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + PcloudTasksDelete deletes a task +*/ +func (a *Client) PcloudTasksDelete(params *PcloudTasksDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudTasksDeleteOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudTasksDeleteParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.tasks.delete", + Method: "DELETE", + PathPattern: "/pcloud/v1/tasks/{task_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudTasksDeleteReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudTasksDeleteOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.tasks.delete: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudTasksGet gets a task +*/ +func (a *Client) PcloudTasksGet(params *PcloudTasksGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudTasksGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudTasksGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.tasks.get", + Method: "GET", + PathPattern: "/pcloud/v1/tasks/{task_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudTasksGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudTasksGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.tasks.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tasks/pcloud_tasks_delete_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tasks/pcloud_tasks_delete_parameters.go new file mode 100644 index 00000000000..641d712bc8a --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tasks/pcloud_tasks_delete_parameters.go @@ -0,0 +1,149 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_tasks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudTasksDeleteParams creates a new PcloudTasksDeleteParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudTasksDeleteParams() *PcloudTasksDeleteParams { + return &PcloudTasksDeleteParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudTasksDeleteParamsWithTimeout creates a new PcloudTasksDeleteParams object +// with the ability to set a timeout on a request. +func NewPcloudTasksDeleteParamsWithTimeout(timeout time.Duration) *PcloudTasksDeleteParams { + return &PcloudTasksDeleteParams{ + timeout: timeout, + } +} + +// NewPcloudTasksDeleteParamsWithContext creates a new PcloudTasksDeleteParams object +// with the ability to set a context for a request. +func NewPcloudTasksDeleteParamsWithContext(ctx context.Context) *PcloudTasksDeleteParams { + return &PcloudTasksDeleteParams{ + Context: ctx, + } +} + +// NewPcloudTasksDeleteParamsWithHTTPClient creates a new PcloudTasksDeleteParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudTasksDeleteParamsWithHTTPClient(client *http.Client) *PcloudTasksDeleteParams { + return &PcloudTasksDeleteParams{ + HTTPClient: client, + } +} + +/* PcloudTasksDeleteParams contains all the parameters to send to the API endpoint + for the pcloud tasks delete operation. + + Typically these are written to a http.Request. +*/ +type PcloudTasksDeleteParams struct { + + /* TaskID. + + PCloud Task ID + */ + TaskID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud tasks delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudTasksDeleteParams) WithDefaults() *PcloudTasksDeleteParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud tasks delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudTasksDeleteParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud tasks delete params +func (o *PcloudTasksDeleteParams) WithTimeout(timeout time.Duration) *PcloudTasksDeleteParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud tasks delete params +func (o *PcloudTasksDeleteParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud tasks delete params +func (o *PcloudTasksDeleteParams) WithContext(ctx context.Context) *PcloudTasksDeleteParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud tasks delete params +func (o *PcloudTasksDeleteParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud tasks delete params +func (o *PcloudTasksDeleteParams) WithHTTPClient(client *http.Client) *PcloudTasksDeleteParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud tasks delete params +func (o *PcloudTasksDeleteParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithTaskID adds the taskID to the pcloud tasks delete params +func (o *PcloudTasksDeleteParams) WithTaskID(taskID string) *PcloudTasksDeleteParams { + o.SetTaskID(taskID) + return o +} + +// SetTaskID adds the taskId to the pcloud tasks delete params +func (o *PcloudTasksDeleteParams) SetTaskID(taskID string) { + o.TaskID = taskID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudTasksDeleteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param task_id + if err := r.SetPathParam("task_id", o.TaskID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tasks/pcloud_tasks_delete_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tasks/pcloud_tasks_delete_responses.go new file mode 100644 index 00000000000..63e82c88155 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tasks/pcloud_tasks_delete_responses.go @@ -0,0 +1,255 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_tasks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudTasksDeleteReader is a Reader for the PcloudTasksDelete structure. +type PcloudTasksDeleteReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudTasksDeleteReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudTasksDeleteOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudTasksDeleteBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudTasksDeleteUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudTasksDeleteNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 410: + result := NewPcloudTasksDeleteGone() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudTasksDeleteInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudTasksDeleteOK creates a PcloudTasksDeleteOK with default headers values +func NewPcloudTasksDeleteOK() *PcloudTasksDeleteOK { + return &PcloudTasksDeleteOK{} +} + +/* PcloudTasksDeleteOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudTasksDeleteOK struct { + Payload models.Object +} + +func (o *PcloudTasksDeleteOK) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/tasks/{task_id}][%d] pcloudTasksDeleteOK %+v", 200, o.Payload) +} +func (o *PcloudTasksDeleteOK) GetPayload() models.Object { + return o.Payload +} + +func (o *PcloudTasksDeleteOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTasksDeleteBadRequest creates a PcloudTasksDeleteBadRequest with default headers values +func NewPcloudTasksDeleteBadRequest() *PcloudTasksDeleteBadRequest { + return &PcloudTasksDeleteBadRequest{} +} + +/* PcloudTasksDeleteBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudTasksDeleteBadRequest struct { + Payload *models.Error +} + +func (o *PcloudTasksDeleteBadRequest) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/tasks/{task_id}][%d] pcloudTasksDeleteBadRequest %+v", 400, o.Payload) +} +func (o *PcloudTasksDeleteBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTasksDeleteBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTasksDeleteUnauthorized creates a PcloudTasksDeleteUnauthorized with default headers values +func NewPcloudTasksDeleteUnauthorized() *PcloudTasksDeleteUnauthorized { + return &PcloudTasksDeleteUnauthorized{} +} + +/* PcloudTasksDeleteUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudTasksDeleteUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudTasksDeleteUnauthorized) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/tasks/{task_id}][%d] pcloudTasksDeleteUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudTasksDeleteUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTasksDeleteUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTasksDeleteNotFound creates a PcloudTasksDeleteNotFound with default headers values +func NewPcloudTasksDeleteNotFound() *PcloudTasksDeleteNotFound { + return &PcloudTasksDeleteNotFound{} +} + +/* PcloudTasksDeleteNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudTasksDeleteNotFound struct { + Payload *models.Error +} + +func (o *PcloudTasksDeleteNotFound) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/tasks/{task_id}][%d] pcloudTasksDeleteNotFound %+v", 404, o.Payload) +} +func (o *PcloudTasksDeleteNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTasksDeleteNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTasksDeleteGone creates a PcloudTasksDeleteGone with default headers values +func NewPcloudTasksDeleteGone() *PcloudTasksDeleteGone { + return &PcloudTasksDeleteGone{} +} + +/* PcloudTasksDeleteGone describes a response with status code 410, with default header values. + +Gone +*/ +type PcloudTasksDeleteGone struct { + Payload *models.Error +} + +func (o *PcloudTasksDeleteGone) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/tasks/{task_id}][%d] pcloudTasksDeleteGone %+v", 410, o.Payload) +} +func (o *PcloudTasksDeleteGone) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTasksDeleteGone) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTasksDeleteInternalServerError creates a PcloudTasksDeleteInternalServerError with default headers values +func NewPcloudTasksDeleteInternalServerError() *PcloudTasksDeleteInternalServerError { + return &PcloudTasksDeleteInternalServerError{} +} + +/* PcloudTasksDeleteInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudTasksDeleteInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudTasksDeleteInternalServerError) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/tasks/{task_id}][%d] pcloudTasksDeleteInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudTasksDeleteInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTasksDeleteInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tasks/pcloud_tasks_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tasks/pcloud_tasks_get_parameters.go new file mode 100644 index 00000000000..756ff392bdb --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tasks/pcloud_tasks_get_parameters.go @@ -0,0 +1,149 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_tasks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudTasksGetParams creates a new PcloudTasksGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudTasksGetParams() *PcloudTasksGetParams { + return &PcloudTasksGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudTasksGetParamsWithTimeout creates a new PcloudTasksGetParams object +// with the ability to set a timeout on a request. +func NewPcloudTasksGetParamsWithTimeout(timeout time.Duration) *PcloudTasksGetParams { + return &PcloudTasksGetParams{ + timeout: timeout, + } +} + +// NewPcloudTasksGetParamsWithContext creates a new PcloudTasksGetParams object +// with the ability to set a context for a request. +func NewPcloudTasksGetParamsWithContext(ctx context.Context) *PcloudTasksGetParams { + return &PcloudTasksGetParams{ + Context: ctx, + } +} + +// NewPcloudTasksGetParamsWithHTTPClient creates a new PcloudTasksGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudTasksGetParamsWithHTTPClient(client *http.Client) *PcloudTasksGetParams { + return &PcloudTasksGetParams{ + HTTPClient: client, + } +} + +/* PcloudTasksGetParams contains all the parameters to send to the API endpoint + for the pcloud tasks get operation. + + Typically these are written to a http.Request. +*/ +type PcloudTasksGetParams struct { + + /* TaskID. + + PCloud Task ID + */ + TaskID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud tasks get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudTasksGetParams) WithDefaults() *PcloudTasksGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud tasks get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudTasksGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud tasks get params +func (o *PcloudTasksGetParams) WithTimeout(timeout time.Duration) *PcloudTasksGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud tasks get params +func (o *PcloudTasksGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud tasks get params +func (o *PcloudTasksGetParams) WithContext(ctx context.Context) *PcloudTasksGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud tasks get params +func (o *PcloudTasksGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud tasks get params +func (o *PcloudTasksGetParams) WithHTTPClient(client *http.Client) *PcloudTasksGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud tasks get params +func (o *PcloudTasksGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithTaskID adds the taskID to the pcloud tasks get params +func (o *PcloudTasksGetParams) WithTaskID(taskID string) *PcloudTasksGetParams { + o.SetTaskID(taskID) + return o +} + +// SetTaskID adds the taskId to the pcloud tasks get params +func (o *PcloudTasksGetParams) SetTaskID(taskID string) { + o.TaskID = taskID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudTasksGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param task_id + if err := r.SetPathParam("task_id", o.TaskID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tasks/pcloud_tasks_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tasks/pcloud_tasks_get_responses.go new file mode 100644 index 00000000000..607e52aa97a --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tasks/pcloud_tasks_get_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_tasks + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudTasksGetReader is a Reader for the PcloudTasksGet structure. +type PcloudTasksGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudTasksGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudTasksGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudTasksGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudTasksGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudTasksGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudTasksGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudTasksGetOK creates a PcloudTasksGetOK with default headers values +func NewPcloudTasksGetOK() *PcloudTasksGetOK { + return &PcloudTasksGetOK{} +} + +/* PcloudTasksGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudTasksGetOK struct { + Payload *models.Task +} + +func (o *PcloudTasksGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/tasks/{task_id}][%d] pcloudTasksGetOK %+v", 200, o.Payload) +} +func (o *PcloudTasksGetOK) GetPayload() *models.Task { + return o.Payload +} + +func (o *PcloudTasksGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Task) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTasksGetBadRequest creates a PcloudTasksGetBadRequest with default headers values +func NewPcloudTasksGetBadRequest() *PcloudTasksGetBadRequest { + return &PcloudTasksGetBadRequest{} +} + +/* PcloudTasksGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudTasksGetBadRequest struct { + Payload *models.Error +} + +func (o *PcloudTasksGetBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/tasks/{task_id}][%d] pcloudTasksGetBadRequest %+v", 400, o.Payload) +} +func (o *PcloudTasksGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTasksGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTasksGetUnauthorized creates a PcloudTasksGetUnauthorized with default headers values +func NewPcloudTasksGetUnauthorized() *PcloudTasksGetUnauthorized { + return &PcloudTasksGetUnauthorized{} +} + +/* PcloudTasksGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudTasksGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudTasksGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/tasks/{task_id}][%d] pcloudTasksGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudTasksGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTasksGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTasksGetNotFound creates a PcloudTasksGetNotFound with default headers values +func NewPcloudTasksGetNotFound() *PcloudTasksGetNotFound { + return &PcloudTasksGetNotFound{} +} + +/* PcloudTasksGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudTasksGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudTasksGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/tasks/{task_id}][%d] pcloudTasksGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudTasksGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTasksGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTasksGetInternalServerError creates a PcloudTasksGetInternalServerError with default headers values +func NewPcloudTasksGetInternalServerError() *PcloudTasksGetInternalServerError { + return &PcloudTasksGetInternalServerError{} +} + +/* PcloudTasksGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudTasksGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudTasksGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/tasks/{task_id}][%d] pcloudTasksGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudTasksGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTasksGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants/p_cloud_tenants_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants/p_cloud_tenants_client.go new file mode 100644 index 00000000000..48cd87d9404 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants/p_cloud_tenants_client.go @@ -0,0 +1,121 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_tenants + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new p cloud tenants API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for p cloud tenants API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + PcloudTenantsGet(params *PcloudTenantsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudTenantsGetOK, error) + + PcloudTenantsPut(params *PcloudTenantsPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudTenantsPutOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + PcloudTenantsGet gets a tenant s current state information +*/ +func (a *Client) PcloudTenantsGet(params *PcloudTenantsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudTenantsGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudTenantsGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.tenants.get", + Method: "GET", + PathPattern: "/pcloud/v1/tenants/{tenant_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudTenantsGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudTenantsGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.tenants.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudTenantsPut updates a tenant +*/ +func (a *Client) PcloudTenantsPut(params *PcloudTenantsPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudTenantsPutOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudTenantsPutParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.tenants.put", + Method: "PUT", + PathPattern: "/pcloud/v1/tenants/{tenant_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudTenantsPutReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudTenantsPutOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.tenants.put: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants/pcloud_tenants_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants/pcloud_tenants_get_parameters.go new file mode 100644 index 00000000000..f6106baeb1c --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants/pcloud_tenants_get_parameters.go @@ -0,0 +1,149 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_tenants + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudTenantsGetParams creates a new PcloudTenantsGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudTenantsGetParams() *PcloudTenantsGetParams { + return &PcloudTenantsGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudTenantsGetParamsWithTimeout creates a new PcloudTenantsGetParams object +// with the ability to set a timeout on a request. +func NewPcloudTenantsGetParamsWithTimeout(timeout time.Duration) *PcloudTenantsGetParams { + return &PcloudTenantsGetParams{ + timeout: timeout, + } +} + +// NewPcloudTenantsGetParamsWithContext creates a new PcloudTenantsGetParams object +// with the ability to set a context for a request. +func NewPcloudTenantsGetParamsWithContext(ctx context.Context) *PcloudTenantsGetParams { + return &PcloudTenantsGetParams{ + Context: ctx, + } +} + +// NewPcloudTenantsGetParamsWithHTTPClient creates a new PcloudTenantsGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudTenantsGetParamsWithHTTPClient(client *http.Client) *PcloudTenantsGetParams { + return &PcloudTenantsGetParams{ + HTTPClient: client, + } +} + +/* PcloudTenantsGetParams contains all the parameters to send to the API endpoint + for the pcloud tenants get operation. + + Typically these are written to a http.Request. +*/ +type PcloudTenantsGetParams struct { + + /* TenantID. + + Tenant ID of a pcloud tenant + */ + TenantID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud tenants get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudTenantsGetParams) WithDefaults() *PcloudTenantsGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud tenants get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudTenantsGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud tenants get params +func (o *PcloudTenantsGetParams) WithTimeout(timeout time.Duration) *PcloudTenantsGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud tenants get params +func (o *PcloudTenantsGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud tenants get params +func (o *PcloudTenantsGetParams) WithContext(ctx context.Context) *PcloudTenantsGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud tenants get params +func (o *PcloudTenantsGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud tenants get params +func (o *PcloudTenantsGetParams) WithHTTPClient(client *http.Client) *PcloudTenantsGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud tenants get params +func (o *PcloudTenantsGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithTenantID adds the tenantID to the pcloud tenants get params +func (o *PcloudTenantsGetParams) WithTenantID(tenantID string) *PcloudTenantsGetParams { + o.SetTenantID(tenantID) + return o +} + +// SetTenantID adds the tenantId to the pcloud tenants get params +func (o *PcloudTenantsGetParams) SetTenantID(tenantID string) { + o.TenantID = tenantID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudTenantsGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param tenant_id + if err := r.SetPathParam("tenant_id", o.TenantID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants/pcloud_tenants_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants/pcloud_tenants_get_responses.go new file mode 100644 index 00000000000..a6ca2731433 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants/pcloud_tenants_get_responses.go @@ -0,0 +1,257 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_tenants + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudTenantsGetReader is a Reader for the PcloudTenantsGet structure. +type PcloudTenantsGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudTenantsGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudTenantsGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudTenantsGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudTenantsGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewPcloudTenantsGetForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudTenantsGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudTenantsGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudTenantsGetOK creates a PcloudTenantsGetOK with default headers values +func NewPcloudTenantsGetOK() *PcloudTenantsGetOK { + return &PcloudTenantsGetOK{} +} + +/* PcloudTenantsGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudTenantsGetOK struct { + Payload *models.Tenant +} + +func (o *PcloudTenantsGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/tenants/{tenant_id}][%d] pcloudTenantsGetOK %+v", 200, o.Payload) +} +func (o *PcloudTenantsGetOK) GetPayload() *models.Tenant { + return o.Payload +} + +func (o *PcloudTenantsGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Tenant) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTenantsGetBadRequest creates a PcloudTenantsGetBadRequest with default headers values +func NewPcloudTenantsGetBadRequest() *PcloudTenantsGetBadRequest { + return &PcloudTenantsGetBadRequest{} +} + +/* PcloudTenantsGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudTenantsGetBadRequest struct { + Payload *models.Error +} + +func (o *PcloudTenantsGetBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/tenants/{tenant_id}][%d] pcloudTenantsGetBadRequest %+v", 400, o.Payload) +} +func (o *PcloudTenantsGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTenantsGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTenantsGetUnauthorized creates a PcloudTenantsGetUnauthorized with default headers values +func NewPcloudTenantsGetUnauthorized() *PcloudTenantsGetUnauthorized { + return &PcloudTenantsGetUnauthorized{} +} + +/* PcloudTenantsGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudTenantsGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudTenantsGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/tenants/{tenant_id}][%d] pcloudTenantsGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudTenantsGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTenantsGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTenantsGetForbidden creates a PcloudTenantsGetForbidden with default headers values +func NewPcloudTenantsGetForbidden() *PcloudTenantsGetForbidden { + return &PcloudTenantsGetForbidden{} +} + +/* PcloudTenantsGetForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type PcloudTenantsGetForbidden struct { + Payload *models.Error +} + +func (o *PcloudTenantsGetForbidden) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/tenants/{tenant_id}][%d] pcloudTenantsGetForbidden %+v", 403, o.Payload) +} +func (o *PcloudTenantsGetForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTenantsGetForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTenantsGetNotFound creates a PcloudTenantsGetNotFound with default headers values +func NewPcloudTenantsGetNotFound() *PcloudTenantsGetNotFound { + return &PcloudTenantsGetNotFound{} +} + +/* PcloudTenantsGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudTenantsGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudTenantsGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/tenants/{tenant_id}][%d] pcloudTenantsGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudTenantsGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTenantsGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTenantsGetInternalServerError creates a PcloudTenantsGetInternalServerError with default headers values +func NewPcloudTenantsGetInternalServerError() *PcloudTenantsGetInternalServerError { + return &PcloudTenantsGetInternalServerError{} +} + +/* PcloudTenantsGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudTenantsGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudTenantsGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/tenants/{tenant_id}][%d] pcloudTenantsGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudTenantsGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTenantsGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants/pcloud_tenants_put_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants/pcloud_tenants_put_parameters.go new file mode 100644 index 00000000000..182262c5134 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants/pcloud_tenants_put_parameters.go @@ -0,0 +1,173 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_tenants + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudTenantsPutParams creates a new PcloudTenantsPutParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudTenantsPutParams() *PcloudTenantsPutParams { + return &PcloudTenantsPutParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudTenantsPutParamsWithTimeout creates a new PcloudTenantsPutParams object +// with the ability to set a timeout on a request. +func NewPcloudTenantsPutParamsWithTimeout(timeout time.Duration) *PcloudTenantsPutParams { + return &PcloudTenantsPutParams{ + timeout: timeout, + } +} + +// NewPcloudTenantsPutParamsWithContext creates a new PcloudTenantsPutParams object +// with the ability to set a context for a request. +func NewPcloudTenantsPutParamsWithContext(ctx context.Context) *PcloudTenantsPutParams { + return &PcloudTenantsPutParams{ + Context: ctx, + } +} + +// NewPcloudTenantsPutParamsWithHTTPClient creates a new PcloudTenantsPutParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudTenantsPutParamsWithHTTPClient(client *http.Client) *PcloudTenantsPutParams { + return &PcloudTenantsPutParams{ + HTTPClient: client, + } +} + +/* PcloudTenantsPutParams contains all the parameters to send to the API endpoint + for the pcloud tenants put operation. + + Typically these are written to a http.Request. +*/ +type PcloudTenantsPutParams struct { + + /* Body. + + Parameters for updating a Tenant + */ + Body *models.TenantUpdate + + /* TenantID. + + Tenant ID of a pcloud tenant + */ + TenantID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud tenants put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudTenantsPutParams) WithDefaults() *PcloudTenantsPutParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud tenants put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudTenantsPutParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud tenants put params +func (o *PcloudTenantsPutParams) WithTimeout(timeout time.Duration) *PcloudTenantsPutParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud tenants put params +func (o *PcloudTenantsPutParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud tenants put params +func (o *PcloudTenantsPutParams) WithContext(ctx context.Context) *PcloudTenantsPutParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud tenants put params +func (o *PcloudTenantsPutParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud tenants put params +func (o *PcloudTenantsPutParams) WithHTTPClient(client *http.Client) *PcloudTenantsPutParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud tenants put params +func (o *PcloudTenantsPutParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud tenants put params +func (o *PcloudTenantsPutParams) WithBody(body *models.TenantUpdate) *PcloudTenantsPutParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud tenants put params +func (o *PcloudTenantsPutParams) SetBody(body *models.TenantUpdate) { + o.Body = body +} + +// WithTenantID adds the tenantID to the pcloud tenants put params +func (o *PcloudTenantsPutParams) WithTenantID(tenantID string) *PcloudTenantsPutParams { + o.SetTenantID(tenantID) + return o +} + +// SetTenantID adds the tenantId to the pcloud tenants put params +func (o *PcloudTenantsPutParams) SetTenantID(tenantID string) { + o.TenantID = tenantID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudTenantsPutParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param tenant_id + if err := r.SetPathParam("tenant_id", o.TenantID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants/pcloud_tenants_put_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants/pcloud_tenants_put_responses.go new file mode 100644 index 00000000000..75fec044d2c --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants/pcloud_tenants_put_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_tenants + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudTenantsPutReader is a Reader for the PcloudTenantsPut structure. +type PcloudTenantsPutReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudTenantsPutReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudTenantsPutOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudTenantsPutBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudTenantsPutUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudTenantsPutUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudTenantsPutInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudTenantsPutOK creates a PcloudTenantsPutOK with default headers values +func NewPcloudTenantsPutOK() *PcloudTenantsPutOK { + return &PcloudTenantsPutOK{} +} + +/* PcloudTenantsPutOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudTenantsPutOK struct { + Payload *models.Tenant +} + +func (o *PcloudTenantsPutOK) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/tenants/{tenant_id}][%d] pcloudTenantsPutOK %+v", 200, o.Payload) +} +func (o *PcloudTenantsPutOK) GetPayload() *models.Tenant { + return o.Payload +} + +func (o *PcloudTenantsPutOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Tenant) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTenantsPutBadRequest creates a PcloudTenantsPutBadRequest with default headers values +func NewPcloudTenantsPutBadRequest() *PcloudTenantsPutBadRequest { + return &PcloudTenantsPutBadRequest{} +} + +/* PcloudTenantsPutBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudTenantsPutBadRequest struct { + Payload *models.Error +} + +func (o *PcloudTenantsPutBadRequest) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/tenants/{tenant_id}][%d] pcloudTenantsPutBadRequest %+v", 400, o.Payload) +} +func (o *PcloudTenantsPutBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTenantsPutBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTenantsPutUnauthorized creates a PcloudTenantsPutUnauthorized with default headers values +func NewPcloudTenantsPutUnauthorized() *PcloudTenantsPutUnauthorized { + return &PcloudTenantsPutUnauthorized{} +} + +/* PcloudTenantsPutUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudTenantsPutUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudTenantsPutUnauthorized) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/tenants/{tenant_id}][%d] pcloudTenantsPutUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudTenantsPutUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTenantsPutUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTenantsPutUnprocessableEntity creates a PcloudTenantsPutUnprocessableEntity with default headers values +func NewPcloudTenantsPutUnprocessableEntity() *PcloudTenantsPutUnprocessableEntity { + return &PcloudTenantsPutUnprocessableEntity{} +} + +/* PcloudTenantsPutUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudTenantsPutUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudTenantsPutUnprocessableEntity) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/tenants/{tenant_id}][%d] pcloudTenantsPutUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudTenantsPutUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTenantsPutUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTenantsPutInternalServerError creates a PcloudTenantsPutInternalServerError with default headers values +func NewPcloudTenantsPutInternalServerError() *PcloudTenantsPutInternalServerError { + return &PcloudTenantsPutInternalServerError{} +} + +/* PcloudTenantsPutInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudTenantsPutInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudTenantsPutInternalServerError) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/tenants/{tenant_id}][%d] pcloudTenantsPutInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudTenantsPutInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTenantsPutInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/p_cloud_tenants_ssh_keys_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/p_cloud_tenants_ssh_keys_client.go new file mode 100644 index 00000000000..d05737fe800 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/p_cloud_tenants_ssh_keys_client.go @@ -0,0 +1,245 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_tenants_ssh_keys + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new p cloud tenants ssh keys API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for p cloud tenants ssh keys API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + PcloudTenantsSshkeysDelete(params *PcloudTenantsSshkeysDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudTenantsSshkeysDeleteOK, error) + + PcloudTenantsSshkeysGet(params *PcloudTenantsSshkeysGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudTenantsSshkeysGetOK, error) + + PcloudTenantsSshkeysGetall(params *PcloudTenantsSshkeysGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudTenantsSshkeysGetallOK, error) + + PcloudTenantsSshkeysPost(params *PcloudTenantsSshkeysPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudTenantsSshkeysPostOK, *PcloudTenantsSshkeysPostCreated, error) + + PcloudTenantsSshkeysPut(params *PcloudTenantsSshkeysPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudTenantsSshkeysPutOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + PcloudTenantsSshkeysDelete deletes a tenant s SSH key +*/ +func (a *Client) PcloudTenantsSshkeysDelete(params *PcloudTenantsSshkeysDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudTenantsSshkeysDeleteOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudTenantsSshkeysDeleteParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.tenants.sshkeys.delete", + Method: "DELETE", + PathPattern: "/pcloud/v1/tenants/{tenant_id}/sshkeys/{sshkey_name}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudTenantsSshkeysDeleteReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudTenantsSshkeysDeleteOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.tenants.sshkeys.delete: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudTenantsSshkeysGet gets a tenant s SSH key by name +*/ +func (a *Client) PcloudTenantsSshkeysGet(params *PcloudTenantsSshkeysGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudTenantsSshkeysGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudTenantsSshkeysGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.tenants.sshkeys.get", + Method: "GET", + PathPattern: "/pcloud/v1/tenants/{tenant_id}/sshkeys/{sshkey_name}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudTenantsSshkeysGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudTenantsSshkeysGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.tenants.sshkeys.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudTenantsSshkeysGetall lists a tenant s SSH keys +*/ +func (a *Client) PcloudTenantsSshkeysGetall(params *PcloudTenantsSshkeysGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudTenantsSshkeysGetallOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudTenantsSshkeysGetallParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.tenants.sshkeys.getall", + Method: "GET", + PathPattern: "/pcloud/v1/tenants/{tenant_id}/sshkeys", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudTenantsSshkeysGetallReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudTenantsSshkeysGetallOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.tenants.sshkeys.getall: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudTenantsSshkeysPost adds a new SSH key to the tenant +*/ +func (a *Client) PcloudTenantsSshkeysPost(params *PcloudTenantsSshkeysPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudTenantsSshkeysPostOK, *PcloudTenantsSshkeysPostCreated, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudTenantsSshkeysPostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.tenants.sshkeys.post", + Method: "POST", + PathPattern: "/pcloud/v1/tenants/{tenant_id}/sshkeys", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudTenantsSshkeysPostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, nil, err + } + switch value := result.(type) { + case *PcloudTenantsSshkeysPostOK: + return value, nil, nil + case *PcloudTenantsSshkeysPostCreated: + return nil, value, nil + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for p_cloud_tenants_ssh_keys: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudTenantsSshkeysPut updates an SSH key +*/ +func (a *Client) PcloudTenantsSshkeysPut(params *PcloudTenantsSshkeysPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudTenantsSshkeysPutOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudTenantsSshkeysPutParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.tenants.sshkeys.put", + Method: "PUT", + PathPattern: "/pcloud/v1/tenants/{tenant_id}/sshkeys/{sshkey_name}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudTenantsSshkeysPutReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudTenantsSshkeysPutOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.tenants.sshkeys.put: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/pcloud_tenants_sshkeys_delete_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/pcloud_tenants_sshkeys_delete_parameters.go new file mode 100644 index 00000000000..0de6c32d747 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/pcloud_tenants_sshkeys_delete_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_tenants_ssh_keys + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudTenantsSshkeysDeleteParams creates a new PcloudTenantsSshkeysDeleteParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudTenantsSshkeysDeleteParams() *PcloudTenantsSshkeysDeleteParams { + return &PcloudTenantsSshkeysDeleteParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudTenantsSshkeysDeleteParamsWithTimeout creates a new PcloudTenantsSshkeysDeleteParams object +// with the ability to set a timeout on a request. +func NewPcloudTenantsSshkeysDeleteParamsWithTimeout(timeout time.Duration) *PcloudTenantsSshkeysDeleteParams { + return &PcloudTenantsSshkeysDeleteParams{ + timeout: timeout, + } +} + +// NewPcloudTenantsSshkeysDeleteParamsWithContext creates a new PcloudTenantsSshkeysDeleteParams object +// with the ability to set a context for a request. +func NewPcloudTenantsSshkeysDeleteParamsWithContext(ctx context.Context) *PcloudTenantsSshkeysDeleteParams { + return &PcloudTenantsSshkeysDeleteParams{ + Context: ctx, + } +} + +// NewPcloudTenantsSshkeysDeleteParamsWithHTTPClient creates a new PcloudTenantsSshkeysDeleteParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudTenantsSshkeysDeleteParamsWithHTTPClient(client *http.Client) *PcloudTenantsSshkeysDeleteParams { + return &PcloudTenantsSshkeysDeleteParams{ + HTTPClient: client, + } +} + +/* PcloudTenantsSshkeysDeleteParams contains all the parameters to send to the API endpoint + for the pcloud tenants sshkeys delete operation. + + Typically these are written to a http.Request. +*/ +type PcloudTenantsSshkeysDeleteParams struct { + + /* SshkeyName. + + SSH key name for a pcloud tenant + */ + SshkeyName string + + /* TenantID. + + Tenant ID of a pcloud tenant + */ + TenantID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud tenants sshkeys delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudTenantsSshkeysDeleteParams) WithDefaults() *PcloudTenantsSshkeysDeleteParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud tenants sshkeys delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudTenantsSshkeysDeleteParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud tenants sshkeys delete params +func (o *PcloudTenantsSshkeysDeleteParams) WithTimeout(timeout time.Duration) *PcloudTenantsSshkeysDeleteParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud tenants sshkeys delete params +func (o *PcloudTenantsSshkeysDeleteParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud tenants sshkeys delete params +func (o *PcloudTenantsSshkeysDeleteParams) WithContext(ctx context.Context) *PcloudTenantsSshkeysDeleteParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud tenants sshkeys delete params +func (o *PcloudTenantsSshkeysDeleteParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud tenants sshkeys delete params +func (o *PcloudTenantsSshkeysDeleteParams) WithHTTPClient(client *http.Client) *PcloudTenantsSshkeysDeleteParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud tenants sshkeys delete params +func (o *PcloudTenantsSshkeysDeleteParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithSshkeyName adds the sshkeyName to the pcloud tenants sshkeys delete params +func (o *PcloudTenantsSshkeysDeleteParams) WithSshkeyName(sshkeyName string) *PcloudTenantsSshkeysDeleteParams { + o.SetSshkeyName(sshkeyName) + return o +} + +// SetSshkeyName adds the sshkeyName to the pcloud tenants sshkeys delete params +func (o *PcloudTenantsSshkeysDeleteParams) SetSshkeyName(sshkeyName string) { + o.SshkeyName = sshkeyName +} + +// WithTenantID adds the tenantID to the pcloud tenants sshkeys delete params +func (o *PcloudTenantsSshkeysDeleteParams) WithTenantID(tenantID string) *PcloudTenantsSshkeysDeleteParams { + o.SetTenantID(tenantID) + return o +} + +// SetTenantID adds the tenantId to the pcloud tenants sshkeys delete params +func (o *PcloudTenantsSshkeysDeleteParams) SetTenantID(tenantID string) { + o.TenantID = tenantID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudTenantsSshkeysDeleteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param sshkey_name + if err := r.SetPathParam("sshkey_name", o.SshkeyName); err != nil { + return err + } + + // path param tenant_id + if err := r.SetPathParam("tenant_id", o.TenantID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/pcloud_tenants_sshkeys_delete_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/pcloud_tenants_sshkeys_delete_responses.go new file mode 100644 index 00000000000..2c0f8aa23d5 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/pcloud_tenants_sshkeys_delete_responses.go @@ -0,0 +1,217 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_tenants_ssh_keys + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudTenantsSshkeysDeleteReader is a Reader for the PcloudTenantsSshkeysDelete structure. +type PcloudTenantsSshkeysDeleteReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudTenantsSshkeysDeleteReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudTenantsSshkeysDeleteOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudTenantsSshkeysDeleteBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudTenantsSshkeysDeleteUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 410: + result := NewPcloudTenantsSshkeysDeleteGone() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudTenantsSshkeysDeleteInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudTenantsSshkeysDeleteOK creates a PcloudTenantsSshkeysDeleteOK with default headers values +func NewPcloudTenantsSshkeysDeleteOK() *PcloudTenantsSshkeysDeleteOK { + return &PcloudTenantsSshkeysDeleteOK{} +} + +/* PcloudTenantsSshkeysDeleteOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudTenantsSshkeysDeleteOK struct { + Payload models.Object +} + +func (o *PcloudTenantsSshkeysDeleteOK) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/tenants/{tenant_id}/sshkeys/{sshkey_name}][%d] pcloudTenantsSshkeysDeleteOK %+v", 200, o.Payload) +} +func (o *PcloudTenantsSshkeysDeleteOK) GetPayload() models.Object { + return o.Payload +} + +func (o *PcloudTenantsSshkeysDeleteOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTenantsSshkeysDeleteBadRequest creates a PcloudTenantsSshkeysDeleteBadRequest with default headers values +func NewPcloudTenantsSshkeysDeleteBadRequest() *PcloudTenantsSshkeysDeleteBadRequest { + return &PcloudTenantsSshkeysDeleteBadRequest{} +} + +/* PcloudTenantsSshkeysDeleteBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudTenantsSshkeysDeleteBadRequest struct { + Payload *models.Error +} + +func (o *PcloudTenantsSshkeysDeleteBadRequest) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/tenants/{tenant_id}/sshkeys/{sshkey_name}][%d] pcloudTenantsSshkeysDeleteBadRequest %+v", 400, o.Payload) +} +func (o *PcloudTenantsSshkeysDeleteBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTenantsSshkeysDeleteBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTenantsSshkeysDeleteUnauthorized creates a PcloudTenantsSshkeysDeleteUnauthorized with default headers values +func NewPcloudTenantsSshkeysDeleteUnauthorized() *PcloudTenantsSshkeysDeleteUnauthorized { + return &PcloudTenantsSshkeysDeleteUnauthorized{} +} + +/* PcloudTenantsSshkeysDeleteUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudTenantsSshkeysDeleteUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudTenantsSshkeysDeleteUnauthorized) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/tenants/{tenant_id}/sshkeys/{sshkey_name}][%d] pcloudTenantsSshkeysDeleteUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudTenantsSshkeysDeleteUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTenantsSshkeysDeleteUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTenantsSshkeysDeleteGone creates a PcloudTenantsSshkeysDeleteGone with default headers values +func NewPcloudTenantsSshkeysDeleteGone() *PcloudTenantsSshkeysDeleteGone { + return &PcloudTenantsSshkeysDeleteGone{} +} + +/* PcloudTenantsSshkeysDeleteGone describes a response with status code 410, with default header values. + +Gone +*/ +type PcloudTenantsSshkeysDeleteGone struct { + Payload *models.Error +} + +func (o *PcloudTenantsSshkeysDeleteGone) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/tenants/{tenant_id}/sshkeys/{sshkey_name}][%d] pcloudTenantsSshkeysDeleteGone %+v", 410, o.Payload) +} +func (o *PcloudTenantsSshkeysDeleteGone) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTenantsSshkeysDeleteGone) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTenantsSshkeysDeleteInternalServerError creates a PcloudTenantsSshkeysDeleteInternalServerError with default headers values +func NewPcloudTenantsSshkeysDeleteInternalServerError() *PcloudTenantsSshkeysDeleteInternalServerError { + return &PcloudTenantsSshkeysDeleteInternalServerError{} +} + +/* PcloudTenantsSshkeysDeleteInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudTenantsSshkeysDeleteInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudTenantsSshkeysDeleteInternalServerError) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/tenants/{tenant_id}/sshkeys/{sshkey_name}][%d] pcloudTenantsSshkeysDeleteInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudTenantsSshkeysDeleteInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTenantsSshkeysDeleteInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/pcloud_tenants_sshkeys_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/pcloud_tenants_sshkeys_get_parameters.go new file mode 100644 index 00000000000..574cc6ae919 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/pcloud_tenants_sshkeys_get_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_tenants_ssh_keys + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudTenantsSshkeysGetParams creates a new PcloudTenantsSshkeysGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudTenantsSshkeysGetParams() *PcloudTenantsSshkeysGetParams { + return &PcloudTenantsSshkeysGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudTenantsSshkeysGetParamsWithTimeout creates a new PcloudTenantsSshkeysGetParams object +// with the ability to set a timeout on a request. +func NewPcloudTenantsSshkeysGetParamsWithTimeout(timeout time.Duration) *PcloudTenantsSshkeysGetParams { + return &PcloudTenantsSshkeysGetParams{ + timeout: timeout, + } +} + +// NewPcloudTenantsSshkeysGetParamsWithContext creates a new PcloudTenantsSshkeysGetParams object +// with the ability to set a context for a request. +func NewPcloudTenantsSshkeysGetParamsWithContext(ctx context.Context) *PcloudTenantsSshkeysGetParams { + return &PcloudTenantsSshkeysGetParams{ + Context: ctx, + } +} + +// NewPcloudTenantsSshkeysGetParamsWithHTTPClient creates a new PcloudTenantsSshkeysGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudTenantsSshkeysGetParamsWithHTTPClient(client *http.Client) *PcloudTenantsSshkeysGetParams { + return &PcloudTenantsSshkeysGetParams{ + HTTPClient: client, + } +} + +/* PcloudTenantsSshkeysGetParams contains all the parameters to send to the API endpoint + for the pcloud tenants sshkeys get operation. + + Typically these are written to a http.Request. +*/ +type PcloudTenantsSshkeysGetParams struct { + + /* SshkeyName. + + SSH key name for a pcloud tenant + */ + SshkeyName string + + /* TenantID. + + Tenant ID of a pcloud tenant + */ + TenantID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud tenants sshkeys get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudTenantsSshkeysGetParams) WithDefaults() *PcloudTenantsSshkeysGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud tenants sshkeys get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudTenantsSshkeysGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud tenants sshkeys get params +func (o *PcloudTenantsSshkeysGetParams) WithTimeout(timeout time.Duration) *PcloudTenantsSshkeysGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud tenants sshkeys get params +func (o *PcloudTenantsSshkeysGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud tenants sshkeys get params +func (o *PcloudTenantsSshkeysGetParams) WithContext(ctx context.Context) *PcloudTenantsSshkeysGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud tenants sshkeys get params +func (o *PcloudTenantsSshkeysGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud tenants sshkeys get params +func (o *PcloudTenantsSshkeysGetParams) WithHTTPClient(client *http.Client) *PcloudTenantsSshkeysGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud tenants sshkeys get params +func (o *PcloudTenantsSshkeysGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithSshkeyName adds the sshkeyName to the pcloud tenants sshkeys get params +func (o *PcloudTenantsSshkeysGetParams) WithSshkeyName(sshkeyName string) *PcloudTenantsSshkeysGetParams { + o.SetSshkeyName(sshkeyName) + return o +} + +// SetSshkeyName adds the sshkeyName to the pcloud tenants sshkeys get params +func (o *PcloudTenantsSshkeysGetParams) SetSshkeyName(sshkeyName string) { + o.SshkeyName = sshkeyName +} + +// WithTenantID adds the tenantID to the pcloud tenants sshkeys get params +func (o *PcloudTenantsSshkeysGetParams) WithTenantID(tenantID string) *PcloudTenantsSshkeysGetParams { + o.SetTenantID(tenantID) + return o +} + +// SetTenantID adds the tenantId to the pcloud tenants sshkeys get params +func (o *PcloudTenantsSshkeysGetParams) SetTenantID(tenantID string) { + o.TenantID = tenantID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudTenantsSshkeysGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param sshkey_name + if err := r.SetPathParam("sshkey_name", o.SshkeyName); err != nil { + return err + } + + // path param tenant_id + if err := r.SetPathParam("tenant_id", o.TenantID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/pcloud_tenants_sshkeys_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/pcloud_tenants_sshkeys_get_responses.go new file mode 100644 index 00000000000..f49bad3c0df --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/pcloud_tenants_sshkeys_get_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_tenants_ssh_keys + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudTenantsSshkeysGetReader is a Reader for the PcloudTenantsSshkeysGet structure. +type PcloudTenantsSshkeysGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudTenantsSshkeysGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudTenantsSshkeysGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudTenantsSshkeysGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudTenantsSshkeysGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudTenantsSshkeysGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudTenantsSshkeysGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudTenantsSshkeysGetOK creates a PcloudTenantsSshkeysGetOK with default headers values +func NewPcloudTenantsSshkeysGetOK() *PcloudTenantsSshkeysGetOK { + return &PcloudTenantsSshkeysGetOK{} +} + +/* PcloudTenantsSshkeysGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudTenantsSshkeysGetOK struct { + Payload *models.SSHKey +} + +func (o *PcloudTenantsSshkeysGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/tenants/{tenant_id}/sshkeys/{sshkey_name}][%d] pcloudTenantsSshkeysGetOK %+v", 200, o.Payload) +} +func (o *PcloudTenantsSshkeysGetOK) GetPayload() *models.SSHKey { + return o.Payload +} + +func (o *PcloudTenantsSshkeysGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.SSHKey) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTenantsSshkeysGetBadRequest creates a PcloudTenantsSshkeysGetBadRequest with default headers values +func NewPcloudTenantsSshkeysGetBadRequest() *PcloudTenantsSshkeysGetBadRequest { + return &PcloudTenantsSshkeysGetBadRequest{} +} + +/* PcloudTenantsSshkeysGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudTenantsSshkeysGetBadRequest struct { + Payload *models.Error +} + +func (o *PcloudTenantsSshkeysGetBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/tenants/{tenant_id}/sshkeys/{sshkey_name}][%d] pcloudTenantsSshkeysGetBadRequest %+v", 400, o.Payload) +} +func (o *PcloudTenantsSshkeysGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTenantsSshkeysGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTenantsSshkeysGetUnauthorized creates a PcloudTenantsSshkeysGetUnauthorized with default headers values +func NewPcloudTenantsSshkeysGetUnauthorized() *PcloudTenantsSshkeysGetUnauthorized { + return &PcloudTenantsSshkeysGetUnauthorized{} +} + +/* PcloudTenantsSshkeysGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudTenantsSshkeysGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudTenantsSshkeysGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/tenants/{tenant_id}/sshkeys/{sshkey_name}][%d] pcloudTenantsSshkeysGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudTenantsSshkeysGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTenantsSshkeysGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTenantsSshkeysGetNotFound creates a PcloudTenantsSshkeysGetNotFound with default headers values +func NewPcloudTenantsSshkeysGetNotFound() *PcloudTenantsSshkeysGetNotFound { + return &PcloudTenantsSshkeysGetNotFound{} +} + +/* PcloudTenantsSshkeysGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudTenantsSshkeysGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudTenantsSshkeysGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/tenants/{tenant_id}/sshkeys/{sshkey_name}][%d] pcloudTenantsSshkeysGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudTenantsSshkeysGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTenantsSshkeysGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTenantsSshkeysGetInternalServerError creates a PcloudTenantsSshkeysGetInternalServerError with default headers values +func NewPcloudTenantsSshkeysGetInternalServerError() *PcloudTenantsSshkeysGetInternalServerError { + return &PcloudTenantsSshkeysGetInternalServerError{} +} + +/* PcloudTenantsSshkeysGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudTenantsSshkeysGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudTenantsSshkeysGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/tenants/{tenant_id}/sshkeys/{sshkey_name}][%d] pcloudTenantsSshkeysGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudTenantsSshkeysGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTenantsSshkeysGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/pcloud_tenants_sshkeys_getall_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/pcloud_tenants_sshkeys_getall_parameters.go new file mode 100644 index 00000000000..0e0e30b0411 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/pcloud_tenants_sshkeys_getall_parameters.go @@ -0,0 +1,149 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_tenants_ssh_keys + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudTenantsSshkeysGetallParams creates a new PcloudTenantsSshkeysGetallParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudTenantsSshkeysGetallParams() *PcloudTenantsSshkeysGetallParams { + return &PcloudTenantsSshkeysGetallParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudTenantsSshkeysGetallParamsWithTimeout creates a new PcloudTenantsSshkeysGetallParams object +// with the ability to set a timeout on a request. +func NewPcloudTenantsSshkeysGetallParamsWithTimeout(timeout time.Duration) *PcloudTenantsSshkeysGetallParams { + return &PcloudTenantsSshkeysGetallParams{ + timeout: timeout, + } +} + +// NewPcloudTenantsSshkeysGetallParamsWithContext creates a new PcloudTenantsSshkeysGetallParams object +// with the ability to set a context for a request. +func NewPcloudTenantsSshkeysGetallParamsWithContext(ctx context.Context) *PcloudTenantsSshkeysGetallParams { + return &PcloudTenantsSshkeysGetallParams{ + Context: ctx, + } +} + +// NewPcloudTenantsSshkeysGetallParamsWithHTTPClient creates a new PcloudTenantsSshkeysGetallParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudTenantsSshkeysGetallParamsWithHTTPClient(client *http.Client) *PcloudTenantsSshkeysGetallParams { + return &PcloudTenantsSshkeysGetallParams{ + HTTPClient: client, + } +} + +/* PcloudTenantsSshkeysGetallParams contains all the parameters to send to the API endpoint + for the pcloud tenants sshkeys getall operation. + + Typically these are written to a http.Request. +*/ +type PcloudTenantsSshkeysGetallParams struct { + + /* TenantID. + + Tenant ID of a pcloud tenant + */ + TenantID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud tenants sshkeys getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudTenantsSshkeysGetallParams) WithDefaults() *PcloudTenantsSshkeysGetallParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud tenants sshkeys getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudTenantsSshkeysGetallParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud tenants sshkeys getall params +func (o *PcloudTenantsSshkeysGetallParams) WithTimeout(timeout time.Duration) *PcloudTenantsSshkeysGetallParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud tenants sshkeys getall params +func (o *PcloudTenantsSshkeysGetallParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud tenants sshkeys getall params +func (o *PcloudTenantsSshkeysGetallParams) WithContext(ctx context.Context) *PcloudTenantsSshkeysGetallParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud tenants sshkeys getall params +func (o *PcloudTenantsSshkeysGetallParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud tenants sshkeys getall params +func (o *PcloudTenantsSshkeysGetallParams) WithHTTPClient(client *http.Client) *PcloudTenantsSshkeysGetallParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud tenants sshkeys getall params +func (o *PcloudTenantsSshkeysGetallParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithTenantID adds the tenantID to the pcloud tenants sshkeys getall params +func (o *PcloudTenantsSshkeysGetallParams) WithTenantID(tenantID string) *PcloudTenantsSshkeysGetallParams { + o.SetTenantID(tenantID) + return o +} + +// SetTenantID adds the tenantId to the pcloud tenants sshkeys getall params +func (o *PcloudTenantsSshkeysGetallParams) SetTenantID(tenantID string) { + o.TenantID = tenantID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudTenantsSshkeysGetallParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param tenant_id + if err := r.SetPathParam("tenant_id", o.TenantID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/pcloud_tenants_sshkeys_getall_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/pcloud_tenants_sshkeys_getall_responses.go new file mode 100644 index 00000000000..700ea0eb980 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/pcloud_tenants_sshkeys_getall_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_tenants_ssh_keys + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudTenantsSshkeysGetallReader is a Reader for the PcloudTenantsSshkeysGetall structure. +type PcloudTenantsSshkeysGetallReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudTenantsSshkeysGetallReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudTenantsSshkeysGetallOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudTenantsSshkeysGetallBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudTenantsSshkeysGetallUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudTenantsSshkeysGetallNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudTenantsSshkeysGetallInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudTenantsSshkeysGetallOK creates a PcloudTenantsSshkeysGetallOK with default headers values +func NewPcloudTenantsSshkeysGetallOK() *PcloudTenantsSshkeysGetallOK { + return &PcloudTenantsSshkeysGetallOK{} +} + +/* PcloudTenantsSshkeysGetallOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudTenantsSshkeysGetallOK struct { + Payload *models.SSHKeys +} + +func (o *PcloudTenantsSshkeysGetallOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/tenants/{tenant_id}/sshkeys][%d] pcloudTenantsSshkeysGetallOK %+v", 200, o.Payload) +} +func (o *PcloudTenantsSshkeysGetallOK) GetPayload() *models.SSHKeys { + return o.Payload +} + +func (o *PcloudTenantsSshkeysGetallOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.SSHKeys) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTenantsSshkeysGetallBadRequest creates a PcloudTenantsSshkeysGetallBadRequest with default headers values +func NewPcloudTenantsSshkeysGetallBadRequest() *PcloudTenantsSshkeysGetallBadRequest { + return &PcloudTenantsSshkeysGetallBadRequest{} +} + +/* PcloudTenantsSshkeysGetallBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudTenantsSshkeysGetallBadRequest struct { + Payload *models.Error +} + +func (o *PcloudTenantsSshkeysGetallBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/tenants/{tenant_id}/sshkeys][%d] pcloudTenantsSshkeysGetallBadRequest %+v", 400, o.Payload) +} +func (o *PcloudTenantsSshkeysGetallBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTenantsSshkeysGetallBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTenantsSshkeysGetallUnauthorized creates a PcloudTenantsSshkeysGetallUnauthorized with default headers values +func NewPcloudTenantsSshkeysGetallUnauthorized() *PcloudTenantsSshkeysGetallUnauthorized { + return &PcloudTenantsSshkeysGetallUnauthorized{} +} + +/* PcloudTenantsSshkeysGetallUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudTenantsSshkeysGetallUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudTenantsSshkeysGetallUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/tenants/{tenant_id}/sshkeys][%d] pcloudTenantsSshkeysGetallUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudTenantsSshkeysGetallUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTenantsSshkeysGetallUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTenantsSshkeysGetallNotFound creates a PcloudTenantsSshkeysGetallNotFound with default headers values +func NewPcloudTenantsSshkeysGetallNotFound() *PcloudTenantsSshkeysGetallNotFound { + return &PcloudTenantsSshkeysGetallNotFound{} +} + +/* PcloudTenantsSshkeysGetallNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudTenantsSshkeysGetallNotFound struct { + Payload *models.Error +} + +func (o *PcloudTenantsSshkeysGetallNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/tenants/{tenant_id}/sshkeys][%d] pcloudTenantsSshkeysGetallNotFound %+v", 404, o.Payload) +} +func (o *PcloudTenantsSshkeysGetallNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTenantsSshkeysGetallNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTenantsSshkeysGetallInternalServerError creates a PcloudTenantsSshkeysGetallInternalServerError with default headers values +func NewPcloudTenantsSshkeysGetallInternalServerError() *PcloudTenantsSshkeysGetallInternalServerError { + return &PcloudTenantsSshkeysGetallInternalServerError{} +} + +/* PcloudTenantsSshkeysGetallInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudTenantsSshkeysGetallInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudTenantsSshkeysGetallInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/tenants/{tenant_id}/sshkeys][%d] pcloudTenantsSshkeysGetallInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudTenantsSshkeysGetallInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTenantsSshkeysGetallInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/pcloud_tenants_sshkeys_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/pcloud_tenants_sshkeys_post_parameters.go new file mode 100644 index 00000000000..0f65423a5e5 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/pcloud_tenants_sshkeys_post_parameters.go @@ -0,0 +1,173 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_tenants_ssh_keys + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudTenantsSshkeysPostParams creates a new PcloudTenantsSshkeysPostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudTenantsSshkeysPostParams() *PcloudTenantsSshkeysPostParams { + return &PcloudTenantsSshkeysPostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudTenantsSshkeysPostParamsWithTimeout creates a new PcloudTenantsSshkeysPostParams object +// with the ability to set a timeout on a request. +func NewPcloudTenantsSshkeysPostParamsWithTimeout(timeout time.Duration) *PcloudTenantsSshkeysPostParams { + return &PcloudTenantsSshkeysPostParams{ + timeout: timeout, + } +} + +// NewPcloudTenantsSshkeysPostParamsWithContext creates a new PcloudTenantsSshkeysPostParams object +// with the ability to set a context for a request. +func NewPcloudTenantsSshkeysPostParamsWithContext(ctx context.Context) *PcloudTenantsSshkeysPostParams { + return &PcloudTenantsSshkeysPostParams{ + Context: ctx, + } +} + +// NewPcloudTenantsSshkeysPostParamsWithHTTPClient creates a new PcloudTenantsSshkeysPostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudTenantsSshkeysPostParamsWithHTTPClient(client *http.Client) *PcloudTenantsSshkeysPostParams { + return &PcloudTenantsSshkeysPostParams{ + HTTPClient: client, + } +} + +/* PcloudTenantsSshkeysPostParams contains all the parameters to send to the API endpoint + for the pcloud tenants sshkeys post operation. + + Typically these are written to a http.Request. +*/ +type PcloudTenantsSshkeysPostParams struct { + + /* Body. + + Parameters for the creation of a new SSH key + */ + Body *models.SSHKey + + /* TenantID. + + Tenant ID of a pcloud tenant + */ + TenantID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud tenants sshkeys post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudTenantsSshkeysPostParams) WithDefaults() *PcloudTenantsSshkeysPostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud tenants sshkeys post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudTenantsSshkeysPostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud tenants sshkeys post params +func (o *PcloudTenantsSshkeysPostParams) WithTimeout(timeout time.Duration) *PcloudTenantsSshkeysPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud tenants sshkeys post params +func (o *PcloudTenantsSshkeysPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud tenants sshkeys post params +func (o *PcloudTenantsSshkeysPostParams) WithContext(ctx context.Context) *PcloudTenantsSshkeysPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud tenants sshkeys post params +func (o *PcloudTenantsSshkeysPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud tenants sshkeys post params +func (o *PcloudTenantsSshkeysPostParams) WithHTTPClient(client *http.Client) *PcloudTenantsSshkeysPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud tenants sshkeys post params +func (o *PcloudTenantsSshkeysPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud tenants sshkeys post params +func (o *PcloudTenantsSshkeysPostParams) WithBody(body *models.SSHKey) *PcloudTenantsSshkeysPostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud tenants sshkeys post params +func (o *PcloudTenantsSshkeysPostParams) SetBody(body *models.SSHKey) { + o.Body = body +} + +// WithTenantID adds the tenantID to the pcloud tenants sshkeys post params +func (o *PcloudTenantsSshkeysPostParams) WithTenantID(tenantID string) *PcloudTenantsSshkeysPostParams { + o.SetTenantID(tenantID) + return o +} + +// SetTenantID adds the tenantId to the pcloud tenants sshkeys post params +func (o *PcloudTenantsSshkeysPostParams) SetTenantID(tenantID string) { + o.TenantID = tenantID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudTenantsSshkeysPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param tenant_id + if err := r.SetPathParam("tenant_id", o.TenantID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/pcloud_tenants_sshkeys_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/pcloud_tenants_sshkeys_post_responses.go new file mode 100644 index 00000000000..2717b7ea58b --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/pcloud_tenants_sshkeys_post_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_tenants_ssh_keys + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudTenantsSshkeysPostReader is a Reader for the PcloudTenantsSshkeysPost structure. +type PcloudTenantsSshkeysPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudTenantsSshkeysPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudTenantsSshkeysPostOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 201: + result := NewPcloudTenantsSshkeysPostCreated() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudTenantsSshkeysPostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudTenantsSshkeysPostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewPcloudTenantsSshkeysPostConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudTenantsSshkeysPostUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudTenantsSshkeysPostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudTenantsSshkeysPostOK creates a PcloudTenantsSshkeysPostOK with default headers values +func NewPcloudTenantsSshkeysPostOK() *PcloudTenantsSshkeysPostOK { + return &PcloudTenantsSshkeysPostOK{} +} + +/* PcloudTenantsSshkeysPostOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudTenantsSshkeysPostOK struct { + Payload *models.SSHKey +} + +func (o *PcloudTenantsSshkeysPostOK) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/tenants/{tenant_id}/sshkeys][%d] pcloudTenantsSshkeysPostOK %+v", 200, o.Payload) +} +func (o *PcloudTenantsSshkeysPostOK) GetPayload() *models.SSHKey { + return o.Payload +} + +func (o *PcloudTenantsSshkeysPostOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.SSHKey) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTenantsSshkeysPostCreated creates a PcloudTenantsSshkeysPostCreated with default headers values +func NewPcloudTenantsSshkeysPostCreated() *PcloudTenantsSshkeysPostCreated { + return &PcloudTenantsSshkeysPostCreated{} +} + +/* PcloudTenantsSshkeysPostCreated describes a response with status code 201, with default header values. + +Created +*/ +type PcloudTenantsSshkeysPostCreated struct { + Payload *models.SSHKey +} + +func (o *PcloudTenantsSshkeysPostCreated) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/tenants/{tenant_id}/sshkeys][%d] pcloudTenantsSshkeysPostCreated %+v", 201, o.Payload) +} +func (o *PcloudTenantsSshkeysPostCreated) GetPayload() *models.SSHKey { + return o.Payload +} + +func (o *PcloudTenantsSshkeysPostCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.SSHKey) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTenantsSshkeysPostBadRequest creates a PcloudTenantsSshkeysPostBadRequest with default headers values +func NewPcloudTenantsSshkeysPostBadRequest() *PcloudTenantsSshkeysPostBadRequest { + return &PcloudTenantsSshkeysPostBadRequest{} +} + +/* PcloudTenantsSshkeysPostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudTenantsSshkeysPostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudTenantsSshkeysPostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/tenants/{tenant_id}/sshkeys][%d] pcloudTenantsSshkeysPostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudTenantsSshkeysPostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTenantsSshkeysPostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTenantsSshkeysPostUnauthorized creates a PcloudTenantsSshkeysPostUnauthorized with default headers values +func NewPcloudTenantsSshkeysPostUnauthorized() *PcloudTenantsSshkeysPostUnauthorized { + return &PcloudTenantsSshkeysPostUnauthorized{} +} + +/* PcloudTenantsSshkeysPostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudTenantsSshkeysPostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudTenantsSshkeysPostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/tenants/{tenant_id}/sshkeys][%d] pcloudTenantsSshkeysPostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudTenantsSshkeysPostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTenantsSshkeysPostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTenantsSshkeysPostConflict creates a PcloudTenantsSshkeysPostConflict with default headers values +func NewPcloudTenantsSshkeysPostConflict() *PcloudTenantsSshkeysPostConflict { + return &PcloudTenantsSshkeysPostConflict{} +} + +/* PcloudTenantsSshkeysPostConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type PcloudTenantsSshkeysPostConflict struct { + Payload *models.Error +} + +func (o *PcloudTenantsSshkeysPostConflict) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/tenants/{tenant_id}/sshkeys][%d] pcloudTenantsSshkeysPostConflict %+v", 409, o.Payload) +} +func (o *PcloudTenantsSshkeysPostConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTenantsSshkeysPostConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTenantsSshkeysPostUnprocessableEntity creates a PcloudTenantsSshkeysPostUnprocessableEntity with default headers values +func NewPcloudTenantsSshkeysPostUnprocessableEntity() *PcloudTenantsSshkeysPostUnprocessableEntity { + return &PcloudTenantsSshkeysPostUnprocessableEntity{} +} + +/* PcloudTenantsSshkeysPostUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudTenantsSshkeysPostUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudTenantsSshkeysPostUnprocessableEntity) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/tenants/{tenant_id}/sshkeys][%d] pcloudTenantsSshkeysPostUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudTenantsSshkeysPostUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTenantsSshkeysPostUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTenantsSshkeysPostInternalServerError creates a PcloudTenantsSshkeysPostInternalServerError with default headers values +func NewPcloudTenantsSshkeysPostInternalServerError() *PcloudTenantsSshkeysPostInternalServerError { + return &PcloudTenantsSshkeysPostInternalServerError{} +} + +/* PcloudTenantsSshkeysPostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudTenantsSshkeysPostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudTenantsSshkeysPostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/tenants/{tenant_id}/sshkeys][%d] pcloudTenantsSshkeysPostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudTenantsSshkeysPostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTenantsSshkeysPostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/pcloud_tenants_sshkeys_put_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/pcloud_tenants_sshkeys_put_parameters.go new file mode 100644 index 00000000000..af532745052 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/pcloud_tenants_sshkeys_put_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_tenants_ssh_keys + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudTenantsSshkeysPutParams creates a new PcloudTenantsSshkeysPutParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudTenantsSshkeysPutParams() *PcloudTenantsSshkeysPutParams { + return &PcloudTenantsSshkeysPutParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudTenantsSshkeysPutParamsWithTimeout creates a new PcloudTenantsSshkeysPutParams object +// with the ability to set a timeout on a request. +func NewPcloudTenantsSshkeysPutParamsWithTimeout(timeout time.Duration) *PcloudTenantsSshkeysPutParams { + return &PcloudTenantsSshkeysPutParams{ + timeout: timeout, + } +} + +// NewPcloudTenantsSshkeysPutParamsWithContext creates a new PcloudTenantsSshkeysPutParams object +// with the ability to set a context for a request. +func NewPcloudTenantsSshkeysPutParamsWithContext(ctx context.Context) *PcloudTenantsSshkeysPutParams { + return &PcloudTenantsSshkeysPutParams{ + Context: ctx, + } +} + +// NewPcloudTenantsSshkeysPutParamsWithHTTPClient creates a new PcloudTenantsSshkeysPutParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudTenantsSshkeysPutParamsWithHTTPClient(client *http.Client) *PcloudTenantsSshkeysPutParams { + return &PcloudTenantsSshkeysPutParams{ + HTTPClient: client, + } +} + +/* PcloudTenantsSshkeysPutParams contains all the parameters to send to the API endpoint + for the pcloud tenants sshkeys put operation. + + Typically these are written to a http.Request. +*/ +type PcloudTenantsSshkeysPutParams struct { + + /* Body. + + Parameters for updating a Tenant's SSH Key + */ + Body *models.SSHKey + + /* SshkeyName. + + SSH key name for a pcloud tenant + */ + SshkeyName string + + /* TenantID. + + Tenant ID of a pcloud tenant + */ + TenantID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud tenants sshkeys put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudTenantsSshkeysPutParams) WithDefaults() *PcloudTenantsSshkeysPutParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud tenants sshkeys put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudTenantsSshkeysPutParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud tenants sshkeys put params +func (o *PcloudTenantsSshkeysPutParams) WithTimeout(timeout time.Duration) *PcloudTenantsSshkeysPutParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud tenants sshkeys put params +func (o *PcloudTenantsSshkeysPutParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud tenants sshkeys put params +func (o *PcloudTenantsSshkeysPutParams) WithContext(ctx context.Context) *PcloudTenantsSshkeysPutParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud tenants sshkeys put params +func (o *PcloudTenantsSshkeysPutParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud tenants sshkeys put params +func (o *PcloudTenantsSshkeysPutParams) WithHTTPClient(client *http.Client) *PcloudTenantsSshkeysPutParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud tenants sshkeys put params +func (o *PcloudTenantsSshkeysPutParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud tenants sshkeys put params +func (o *PcloudTenantsSshkeysPutParams) WithBody(body *models.SSHKey) *PcloudTenantsSshkeysPutParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud tenants sshkeys put params +func (o *PcloudTenantsSshkeysPutParams) SetBody(body *models.SSHKey) { + o.Body = body +} + +// WithSshkeyName adds the sshkeyName to the pcloud tenants sshkeys put params +func (o *PcloudTenantsSshkeysPutParams) WithSshkeyName(sshkeyName string) *PcloudTenantsSshkeysPutParams { + o.SetSshkeyName(sshkeyName) + return o +} + +// SetSshkeyName adds the sshkeyName to the pcloud tenants sshkeys put params +func (o *PcloudTenantsSshkeysPutParams) SetSshkeyName(sshkeyName string) { + o.SshkeyName = sshkeyName +} + +// WithTenantID adds the tenantID to the pcloud tenants sshkeys put params +func (o *PcloudTenantsSshkeysPutParams) WithTenantID(tenantID string) *PcloudTenantsSshkeysPutParams { + o.SetTenantID(tenantID) + return o +} + +// SetTenantID adds the tenantId to the pcloud tenants sshkeys put params +func (o *PcloudTenantsSshkeysPutParams) SetTenantID(tenantID string) { + o.TenantID = tenantID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudTenantsSshkeysPutParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param sshkey_name + if err := r.SetPathParam("sshkey_name", o.SshkeyName); err != nil { + return err + } + + // path param tenant_id + if err := r.SetPathParam("tenant_id", o.TenantID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/pcloud_tenants_sshkeys_put_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/pcloud_tenants_sshkeys_put_responses.go new file mode 100644 index 00000000000..5d091866f57 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys/pcloud_tenants_sshkeys_put_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_tenants_ssh_keys + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudTenantsSshkeysPutReader is a Reader for the PcloudTenantsSshkeysPut structure. +type PcloudTenantsSshkeysPutReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudTenantsSshkeysPutReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudTenantsSshkeysPutOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudTenantsSshkeysPutBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudTenantsSshkeysPutUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudTenantsSshkeysPutUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudTenantsSshkeysPutInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudTenantsSshkeysPutOK creates a PcloudTenantsSshkeysPutOK with default headers values +func NewPcloudTenantsSshkeysPutOK() *PcloudTenantsSshkeysPutOK { + return &PcloudTenantsSshkeysPutOK{} +} + +/* PcloudTenantsSshkeysPutOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudTenantsSshkeysPutOK struct { + Payload *models.SSHKey +} + +func (o *PcloudTenantsSshkeysPutOK) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/tenants/{tenant_id}/sshkeys/{sshkey_name}][%d] pcloudTenantsSshkeysPutOK %+v", 200, o.Payload) +} +func (o *PcloudTenantsSshkeysPutOK) GetPayload() *models.SSHKey { + return o.Payload +} + +func (o *PcloudTenantsSshkeysPutOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.SSHKey) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTenantsSshkeysPutBadRequest creates a PcloudTenantsSshkeysPutBadRequest with default headers values +func NewPcloudTenantsSshkeysPutBadRequest() *PcloudTenantsSshkeysPutBadRequest { + return &PcloudTenantsSshkeysPutBadRequest{} +} + +/* PcloudTenantsSshkeysPutBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudTenantsSshkeysPutBadRequest struct { + Payload *models.Error +} + +func (o *PcloudTenantsSshkeysPutBadRequest) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/tenants/{tenant_id}/sshkeys/{sshkey_name}][%d] pcloudTenantsSshkeysPutBadRequest %+v", 400, o.Payload) +} +func (o *PcloudTenantsSshkeysPutBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTenantsSshkeysPutBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTenantsSshkeysPutUnauthorized creates a PcloudTenantsSshkeysPutUnauthorized with default headers values +func NewPcloudTenantsSshkeysPutUnauthorized() *PcloudTenantsSshkeysPutUnauthorized { + return &PcloudTenantsSshkeysPutUnauthorized{} +} + +/* PcloudTenantsSshkeysPutUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudTenantsSshkeysPutUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudTenantsSshkeysPutUnauthorized) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/tenants/{tenant_id}/sshkeys/{sshkey_name}][%d] pcloudTenantsSshkeysPutUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudTenantsSshkeysPutUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTenantsSshkeysPutUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTenantsSshkeysPutUnprocessableEntity creates a PcloudTenantsSshkeysPutUnprocessableEntity with default headers values +func NewPcloudTenantsSshkeysPutUnprocessableEntity() *PcloudTenantsSshkeysPutUnprocessableEntity { + return &PcloudTenantsSshkeysPutUnprocessableEntity{} +} + +/* PcloudTenantsSshkeysPutUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudTenantsSshkeysPutUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudTenantsSshkeysPutUnprocessableEntity) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/tenants/{tenant_id}/sshkeys/{sshkey_name}][%d] pcloudTenantsSshkeysPutUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudTenantsSshkeysPutUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTenantsSshkeysPutUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudTenantsSshkeysPutInternalServerError creates a PcloudTenantsSshkeysPutInternalServerError with default headers values +func NewPcloudTenantsSshkeysPutInternalServerError() *PcloudTenantsSshkeysPutInternalServerError { + return &PcloudTenantsSshkeysPutInternalServerError{} +} + +/* PcloudTenantsSshkeysPutInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudTenantsSshkeysPutInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudTenantsSshkeysPutInternalServerError) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/tenants/{tenant_id}/sshkeys/{sshkey_name}][%d] pcloudTenantsSshkeysPutInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudTenantsSshkeysPutInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudTenantsSshkeysPutInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/p_cloudvpn_connections_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/p_cloudvpn_connections_client.go new file mode 100644 index 00000000000..95a58fbebb0 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/p_cloudvpn_connections_client.go @@ -0,0 +1,512 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new p cloud v p n connections API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for p cloud v p n connections API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + PcloudVpnconnectionsDelete(params *PcloudVpnconnectionsDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudVpnconnectionsDeleteAccepted, error) + + PcloudVpnconnectionsGet(params *PcloudVpnconnectionsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudVpnconnectionsGetOK, error) + + PcloudVpnconnectionsGetall(params *PcloudVpnconnectionsGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudVpnconnectionsGetallOK, error) + + PcloudVpnconnectionsNetworksDelete(params *PcloudVpnconnectionsNetworksDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudVpnconnectionsNetworksDeleteAccepted, error) + + PcloudVpnconnectionsNetworksGet(params *PcloudVpnconnectionsNetworksGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudVpnconnectionsNetworksGetOK, error) + + PcloudVpnconnectionsNetworksPut(params *PcloudVpnconnectionsNetworksPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudVpnconnectionsNetworksPutAccepted, error) + + PcloudVpnconnectionsPeersubnetsDelete(params *PcloudVpnconnectionsPeersubnetsDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudVpnconnectionsPeersubnetsDeleteOK, error) + + PcloudVpnconnectionsPeersubnetsGet(params *PcloudVpnconnectionsPeersubnetsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudVpnconnectionsPeersubnetsGetOK, error) + + PcloudVpnconnectionsPeersubnetsPut(params *PcloudVpnconnectionsPeersubnetsPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudVpnconnectionsPeersubnetsPutOK, error) + + PcloudVpnconnectionsPost(params *PcloudVpnconnectionsPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudVpnconnectionsPostAccepted, error) + + PcloudVpnconnectionsPut(params *PcloudVpnconnectionsPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudVpnconnectionsPutOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + PcloudVpnconnectionsDelete deletes v p n connection + + Delete VPN Connection (by its identifier) +*/ +func (a *Client) PcloudVpnconnectionsDelete(params *PcloudVpnconnectionsDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudVpnconnectionsDeleteAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudVpnconnectionsDeleteParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.vpnconnections.delete", + Method: "DELETE", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudVpnconnectionsDeleteReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudVpnconnectionsDeleteAccepted) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.vpnconnections.delete: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudVpnconnectionsGet gets v p n connection + + Get a VPN Connection +*/ +func (a *Client) PcloudVpnconnectionsGet(params *PcloudVpnconnectionsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudVpnconnectionsGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudVpnconnectionsGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.vpnconnections.get", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudVpnconnectionsGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudVpnconnectionsGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.vpnconnections.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudVpnconnectionsGetall gets all v p n connections + + Get all VPN Connections +*/ +func (a *Client) PcloudVpnconnectionsGetall(params *PcloudVpnconnectionsGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudVpnconnectionsGetallOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudVpnconnectionsGetallParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.vpnconnections.getall", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudVpnconnectionsGetallReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudVpnconnectionsGetallOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.vpnconnections.getall: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudVpnconnectionsNetworksDelete detaches network + + Detach network from a specific VPN Connection +*/ +func (a *Client) PcloudVpnconnectionsNetworksDelete(params *PcloudVpnconnectionsNetworksDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudVpnconnectionsNetworksDeleteAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudVpnconnectionsNetworksDeleteParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.vpnconnections.networks.delete", + Method: "DELETE", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/networks", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudVpnconnectionsNetworksDeleteReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudVpnconnectionsNetworksDeleteAccepted) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.vpnconnections.networks.delete: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudVpnconnectionsNetworksGet gets attached networks + + Get a list of network IDs attached to a VPN Connection +*/ +func (a *Client) PcloudVpnconnectionsNetworksGet(params *PcloudVpnconnectionsNetworksGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudVpnconnectionsNetworksGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudVpnconnectionsNetworksGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.vpnconnections.networks.get", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/networks", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudVpnconnectionsNetworksGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudVpnconnectionsNetworksGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.vpnconnections.networks.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudVpnconnectionsNetworksPut attaches network + + Attach a network to a VPN Connection +*/ +func (a *Client) PcloudVpnconnectionsNetworksPut(params *PcloudVpnconnectionsNetworksPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudVpnconnectionsNetworksPutAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudVpnconnectionsNetworksPutParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.vpnconnections.networks.put", + Method: "PUT", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/networks", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudVpnconnectionsNetworksPutReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudVpnconnectionsNetworksPutAccepted) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.vpnconnections.networks.put: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudVpnconnectionsPeersubnetsDelete detaches peer subnet + + Detach peer subnet from a VPN Connection +*/ +func (a *Client) PcloudVpnconnectionsPeersubnetsDelete(params *PcloudVpnconnectionsPeersubnetsDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudVpnconnectionsPeersubnetsDeleteOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudVpnconnectionsPeersubnetsDeleteParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.vpnconnections.peersubnets.delete", + Method: "DELETE", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/peer-subnets", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudVpnconnectionsPeersubnetsDeleteReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudVpnconnectionsPeersubnetsDeleteOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.vpnconnections.peersubnets.delete: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudVpnconnectionsPeersubnetsGet gets peer subnets + + Get a list of peer subnets attached to a specific VPN Connection +*/ +func (a *Client) PcloudVpnconnectionsPeersubnetsGet(params *PcloudVpnconnectionsPeersubnetsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudVpnconnectionsPeersubnetsGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudVpnconnectionsPeersubnetsGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.vpnconnections.peersubnets.get", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/peer-subnets", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudVpnconnectionsPeersubnetsGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudVpnconnectionsPeersubnetsGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.vpnconnections.peersubnets.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudVpnconnectionsPeersubnetsPut attaches peer subnet + + Attach peer subnet to a VPN Connection +*/ +func (a *Client) PcloudVpnconnectionsPeersubnetsPut(params *PcloudVpnconnectionsPeersubnetsPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudVpnconnectionsPeersubnetsPutOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudVpnconnectionsPeersubnetsPutParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.vpnconnections.peersubnets.put", + Method: "PUT", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/peer-subnets", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudVpnconnectionsPeersubnetsPutReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudVpnconnectionsPeersubnetsPutOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.vpnconnections.peersubnets.put: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudVpnconnectionsPost creates v p n connection + + Create a new VPN Connection +*/ +func (a *Client) PcloudVpnconnectionsPost(params *PcloudVpnconnectionsPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudVpnconnectionsPostAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudVpnconnectionsPostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.vpnconnections.post", + Method: "POST", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudVpnconnectionsPostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudVpnconnectionsPostAccepted) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.vpnconnections.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudVpnconnectionsPut updates v p n connection + + update a VPN Connection (by its identifier) +*/ +func (a *Client) PcloudVpnconnectionsPut(params *PcloudVpnconnectionsPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudVpnconnectionsPutOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudVpnconnectionsPutParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.vpnconnections.put", + Method: "PUT", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudVpnconnectionsPutReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudVpnconnectionsPutOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.vpnconnections.put: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_delete_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_delete_parameters.go new file mode 100644 index 00000000000..6bb03a9b94b --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_delete_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudVpnconnectionsDeleteParams creates a new PcloudVpnconnectionsDeleteParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudVpnconnectionsDeleteParams() *PcloudVpnconnectionsDeleteParams { + return &PcloudVpnconnectionsDeleteParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudVpnconnectionsDeleteParamsWithTimeout creates a new PcloudVpnconnectionsDeleteParams object +// with the ability to set a timeout on a request. +func NewPcloudVpnconnectionsDeleteParamsWithTimeout(timeout time.Duration) *PcloudVpnconnectionsDeleteParams { + return &PcloudVpnconnectionsDeleteParams{ + timeout: timeout, + } +} + +// NewPcloudVpnconnectionsDeleteParamsWithContext creates a new PcloudVpnconnectionsDeleteParams object +// with the ability to set a context for a request. +func NewPcloudVpnconnectionsDeleteParamsWithContext(ctx context.Context) *PcloudVpnconnectionsDeleteParams { + return &PcloudVpnconnectionsDeleteParams{ + Context: ctx, + } +} + +// NewPcloudVpnconnectionsDeleteParamsWithHTTPClient creates a new PcloudVpnconnectionsDeleteParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudVpnconnectionsDeleteParamsWithHTTPClient(client *http.Client) *PcloudVpnconnectionsDeleteParams { + return &PcloudVpnconnectionsDeleteParams{ + HTTPClient: client, + } +} + +/* PcloudVpnconnectionsDeleteParams contains all the parameters to send to the API endpoint + for the pcloud vpnconnections delete operation. + + Typically these are written to a http.Request. +*/ +type PcloudVpnconnectionsDeleteParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* VpnConnectionID. + + ID of a VPN connection + */ + VpnConnectionID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud vpnconnections delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudVpnconnectionsDeleteParams) WithDefaults() *PcloudVpnconnectionsDeleteParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud vpnconnections delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudVpnconnectionsDeleteParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud vpnconnections delete params +func (o *PcloudVpnconnectionsDeleteParams) WithTimeout(timeout time.Duration) *PcloudVpnconnectionsDeleteParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud vpnconnections delete params +func (o *PcloudVpnconnectionsDeleteParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud vpnconnections delete params +func (o *PcloudVpnconnectionsDeleteParams) WithContext(ctx context.Context) *PcloudVpnconnectionsDeleteParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud vpnconnections delete params +func (o *PcloudVpnconnectionsDeleteParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud vpnconnections delete params +func (o *PcloudVpnconnectionsDeleteParams) WithHTTPClient(client *http.Client) *PcloudVpnconnectionsDeleteParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud vpnconnections delete params +func (o *PcloudVpnconnectionsDeleteParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud vpnconnections delete params +func (o *PcloudVpnconnectionsDeleteParams) WithCloudInstanceID(cloudInstanceID string) *PcloudVpnconnectionsDeleteParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud vpnconnections delete params +func (o *PcloudVpnconnectionsDeleteParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithVpnConnectionID adds the vpnConnectionID to the pcloud vpnconnections delete params +func (o *PcloudVpnconnectionsDeleteParams) WithVpnConnectionID(vpnConnectionID string) *PcloudVpnconnectionsDeleteParams { + o.SetVpnConnectionID(vpnConnectionID) + return o +} + +// SetVpnConnectionID adds the vpnConnectionId to the pcloud vpnconnections delete params +func (o *PcloudVpnconnectionsDeleteParams) SetVpnConnectionID(vpnConnectionID string) { + o.VpnConnectionID = vpnConnectionID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudVpnconnectionsDeleteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param vpn_connection_id + if err := r.SetPathParam("vpn_connection_id", o.VpnConnectionID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_delete_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_delete_responses.go new file mode 100644 index 00000000000..cd546b15228 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_delete_responses.go @@ -0,0 +1,257 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudVpnconnectionsDeleteReader is a Reader for the PcloudVpnconnectionsDelete structure. +type PcloudVpnconnectionsDeleteReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudVpnconnectionsDeleteReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 202: + result := NewPcloudVpnconnectionsDeleteAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudVpnconnectionsDeleteBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudVpnconnectionsDeleteUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewPcloudVpnconnectionsDeleteForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudVpnconnectionsDeleteNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudVpnconnectionsDeleteInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudVpnconnectionsDeleteAccepted creates a PcloudVpnconnectionsDeleteAccepted with default headers values +func NewPcloudVpnconnectionsDeleteAccepted() *PcloudVpnconnectionsDeleteAccepted { + return &PcloudVpnconnectionsDeleteAccepted{} +} + +/* PcloudVpnconnectionsDeleteAccepted describes a response with status code 202, with default header values. + +Accepted +*/ +type PcloudVpnconnectionsDeleteAccepted struct { + Payload *models.JobReference +} + +func (o *PcloudVpnconnectionsDeleteAccepted) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}][%d] pcloudVpnconnectionsDeleteAccepted %+v", 202, o.Payload) +} +func (o *PcloudVpnconnectionsDeleteAccepted) GetPayload() *models.JobReference { + return o.Payload +} + +func (o *PcloudVpnconnectionsDeleteAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.JobReference) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsDeleteBadRequest creates a PcloudVpnconnectionsDeleteBadRequest with default headers values +func NewPcloudVpnconnectionsDeleteBadRequest() *PcloudVpnconnectionsDeleteBadRequest { + return &PcloudVpnconnectionsDeleteBadRequest{} +} + +/* PcloudVpnconnectionsDeleteBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudVpnconnectionsDeleteBadRequest struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsDeleteBadRequest) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}][%d] pcloudVpnconnectionsDeleteBadRequest %+v", 400, o.Payload) +} +func (o *PcloudVpnconnectionsDeleteBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsDeleteBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsDeleteUnauthorized creates a PcloudVpnconnectionsDeleteUnauthorized with default headers values +func NewPcloudVpnconnectionsDeleteUnauthorized() *PcloudVpnconnectionsDeleteUnauthorized { + return &PcloudVpnconnectionsDeleteUnauthorized{} +} + +/* PcloudVpnconnectionsDeleteUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudVpnconnectionsDeleteUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsDeleteUnauthorized) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}][%d] pcloudVpnconnectionsDeleteUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudVpnconnectionsDeleteUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsDeleteUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsDeleteForbidden creates a PcloudVpnconnectionsDeleteForbidden with default headers values +func NewPcloudVpnconnectionsDeleteForbidden() *PcloudVpnconnectionsDeleteForbidden { + return &PcloudVpnconnectionsDeleteForbidden{} +} + +/* PcloudVpnconnectionsDeleteForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type PcloudVpnconnectionsDeleteForbidden struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsDeleteForbidden) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}][%d] pcloudVpnconnectionsDeleteForbidden %+v", 403, o.Payload) +} +func (o *PcloudVpnconnectionsDeleteForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsDeleteForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsDeleteNotFound creates a PcloudVpnconnectionsDeleteNotFound with default headers values +func NewPcloudVpnconnectionsDeleteNotFound() *PcloudVpnconnectionsDeleteNotFound { + return &PcloudVpnconnectionsDeleteNotFound{} +} + +/* PcloudVpnconnectionsDeleteNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudVpnconnectionsDeleteNotFound struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsDeleteNotFound) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}][%d] pcloudVpnconnectionsDeleteNotFound %+v", 404, o.Payload) +} +func (o *PcloudVpnconnectionsDeleteNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsDeleteNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsDeleteInternalServerError creates a PcloudVpnconnectionsDeleteInternalServerError with default headers values +func NewPcloudVpnconnectionsDeleteInternalServerError() *PcloudVpnconnectionsDeleteInternalServerError { + return &PcloudVpnconnectionsDeleteInternalServerError{} +} + +/* PcloudVpnconnectionsDeleteInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudVpnconnectionsDeleteInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsDeleteInternalServerError) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}][%d] pcloudVpnconnectionsDeleteInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudVpnconnectionsDeleteInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsDeleteInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_get_parameters.go new file mode 100644 index 00000000000..9e34b4962b0 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_get_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudVpnconnectionsGetParams creates a new PcloudVpnconnectionsGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudVpnconnectionsGetParams() *PcloudVpnconnectionsGetParams { + return &PcloudVpnconnectionsGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudVpnconnectionsGetParamsWithTimeout creates a new PcloudVpnconnectionsGetParams object +// with the ability to set a timeout on a request. +func NewPcloudVpnconnectionsGetParamsWithTimeout(timeout time.Duration) *PcloudVpnconnectionsGetParams { + return &PcloudVpnconnectionsGetParams{ + timeout: timeout, + } +} + +// NewPcloudVpnconnectionsGetParamsWithContext creates a new PcloudVpnconnectionsGetParams object +// with the ability to set a context for a request. +func NewPcloudVpnconnectionsGetParamsWithContext(ctx context.Context) *PcloudVpnconnectionsGetParams { + return &PcloudVpnconnectionsGetParams{ + Context: ctx, + } +} + +// NewPcloudVpnconnectionsGetParamsWithHTTPClient creates a new PcloudVpnconnectionsGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudVpnconnectionsGetParamsWithHTTPClient(client *http.Client) *PcloudVpnconnectionsGetParams { + return &PcloudVpnconnectionsGetParams{ + HTTPClient: client, + } +} + +/* PcloudVpnconnectionsGetParams contains all the parameters to send to the API endpoint + for the pcloud vpnconnections get operation. + + Typically these are written to a http.Request. +*/ +type PcloudVpnconnectionsGetParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* VpnConnectionID. + + ID of a VPN connection + */ + VpnConnectionID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud vpnconnections get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudVpnconnectionsGetParams) WithDefaults() *PcloudVpnconnectionsGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud vpnconnections get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudVpnconnectionsGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud vpnconnections get params +func (o *PcloudVpnconnectionsGetParams) WithTimeout(timeout time.Duration) *PcloudVpnconnectionsGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud vpnconnections get params +func (o *PcloudVpnconnectionsGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud vpnconnections get params +func (o *PcloudVpnconnectionsGetParams) WithContext(ctx context.Context) *PcloudVpnconnectionsGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud vpnconnections get params +func (o *PcloudVpnconnectionsGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud vpnconnections get params +func (o *PcloudVpnconnectionsGetParams) WithHTTPClient(client *http.Client) *PcloudVpnconnectionsGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud vpnconnections get params +func (o *PcloudVpnconnectionsGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud vpnconnections get params +func (o *PcloudVpnconnectionsGetParams) WithCloudInstanceID(cloudInstanceID string) *PcloudVpnconnectionsGetParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud vpnconnections get params +func (o *PcloudVpnconnectionsGetParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithVpnConnectionID adds the vpnConnectionID to the pcloud vpnconnections get params +func (o *PcloudVpnconnectionsGetParams) WithVpnConnectionID(vpnConnectionID string) *PcloudVpnconnectionsGetParams { + o.SetVpnConnectionID(vpnConnectionID) + return o +} + +// SetVpnConnectionID adds the vpnConnectionId to the pcloud vpnconnections get params +func (o *PcloudVpnconnectionsGetParams) SetVpnConnectionID(vpnConnectionID string) { + o.VpnConnectionID = vpnConnectionID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudVpnconnectionsGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param vpn_connection_id + if err := r.SetPathParam("vpn_connection_id", o.VpnConnectionID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_get_responses.go new file mode 100644 index 00000000000..79413add9d7 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_get_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudVpnconnectionsGetReader is a Reader for the PcloudVpnconnectionsGet structure. +type PcloudVpnconnectionsGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudVpnconnectionsGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudVpnconnectionsGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudVpnconnectionsGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudVpnconnectionsGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewPcloudVpnconnectionsGetForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudVpnconnectionsGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudVpnconnectionsGetUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudVpnconnectionsGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudVpnconnectionsGetOK creates a PcloudVpnconnectionsGetOK with default headers values +func NewPcloudVpnconnectionsGetOK() *PcloudVpnconnectionsGetOK { + return &PcloudVpnconnectionsGetOK{} +} + +/* PcloudVpnconnectionsGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudVpnconnectionsGetOK struct { + Payload *models.VPNConnection +} + +func (o *PcloudVpnconnectionsGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}][%d] pcloudVpnconnectionsGetOK %+v", 200, o.Payload) +} +func (o *PcloudVpnconnectionsGetOK) GetPayload() *models.VPNConnection { + return o.Payload +} + +func (o *PcloudVpnconnectionsGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.VPNConnection) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsGetBadRequest creates a PcloudVpnconnectionsGetBadRequest with default headers values +func NewPcloudVpnconnectionsGetBadRequest() *PcloudVpnconnectionsGetBadRequest { + return &PcloudVpnconnectionsGetBadRequest{} +} + +/* PcloudVpnconnectionsGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudVpnconnectionsGetBadRequest struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsGetBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}][%d] pcloudVpnconnectionsGetBadRequest %+v", 400, o.Payload) +} +func (o *PcloudVpnconnectionsGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsGetUnauthorized creates a PcloudVpnconnectionsGetUnauthorized with default headers values +func NewPcloudVpnconnectionsGetUnauthorized() *PcloudVpnconnectionsGetUnauthorized { + return &PcloudVpnconnectionsGetUnauthorized{} +} + +/* PcloudVpnconnectionsGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudVpnconnectionsGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}][%d] pcloudVpnconnectionsGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudVpnconnectionsGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsGetForbidden creates a PcloudVpnconnectionsGetForbidden with default headers values +func NewPcloudVpnconnectionsGetForbidden() *PcloudVpnconnectionsGetForbidden { + return &PcloudVpnconnectionsGetForbidden{} +} + +/* PcloudVpnconnectionsGetForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type PcloudVpnconnectionsGetForbidden struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsGetForbidden) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}][%d] pcloudVpnconnectionsGetForbidden %+v", 403, o.Payload) +} +func (o *PcloudVpnconnectionsGetForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsGetForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsGetNotFound creates a PcloudVpnconnectionsGetNotFound with default headers values +func NewPcloudVpnconnectionsGetNotFound() *PcloudVpnconnectionsGetNotFound { + return &PcloudVpnconnectionsGetNotFound{} +} + +/* PcloudVpnconnectionsGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudVpnconnectionsGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}][%d] pcloudVpnconnectionsGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudVpnconnectionsGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsGetUnprocessableEntity creates a PcloudVpnconnectionsGetUnprocessableEntity with default headers values +func NewPcloudVpnconnectionsGetUnprocessableEntity() *PcloudVpnconnectionsGetUnprocessableEntity { + return &PcloudVpnconnectionsGetUnprocessableEntity{} +} + +/* PcloudVpnconnectionsGetUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudVpnconnectionsGetUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsGetUnprocessableEntity) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}][%d] pcloudVpnconnectionsGetUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudVpnconnectionsGetUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsGetUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsGetInternalServerError creates a PcloudVpnconnectionsGetInternalServerError with default headers values +func NewPcloudVpnconnectionsGetInternalServerError() *PcloudVpnconnectionsGetInternalServerError { + return &PcloudVpnconnectionsGetInternalServerError{} +} + +/* PcloudVpnconnectionsGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudVpnconnectionsGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}][%d] pcloudVpnconnectionsGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudVpnconnectionsGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_getall_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_getall_parameters.go new file mode 100644 index 00000000000..08d55e3aecd --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_getall_parameters.go @@ -0,0 +1,149 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudVpnconnectionsGetallParams creates a new PcloudVpnconnectionsGetallParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudVpnconnectionsGetallParams() *PcloudVpnconnectionsGetallParams { + return &PcloudVpnconnectionsGetallParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudVpnconnectionsGetallParamsWithTimeout creates a new PcloudVpnconnectionsGetallParams object +// with the ability to set a timeout on a request. +func NewPcloudVpnconnectionsGetallParamsWithTimeout(timeout time.Duration) *PcloudVpnconnectionsGetallParams { + return &PcloudVpnconnectionsGetallParams{ + timeout: timeout, + } +} + +// NewPcloudVpnconnectionsGetallParamsWithContext creates a new PcloudVpnconnectionsGetallParams object +// with the ability to set a context for a request. +func NewPcloudVpnconnectionsGetallParamsWithContext(ctx context.Context) *PcloudVpnconnectionsGetallParams { + return &PcloudVpnconnectionsGetallParams{ + Context: ctx, + } +} + +// NewPcloudVpnconnectionsGetallParamsWithHTTPClient creates a new PcloudVpnconnectionsGetallParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudVpnconnectionsGetallParamsWithHTTPClient(client *http.Client) *PcloudVpnconnectionsGetallParams { + return &PcloudVpnconnectionsGetallParams{ + HTTPClient: client, + } +} + +/* PcloudVpnconnectionsGetallParams contains all the parameters to send to the API endpoint + for the pcloud vpnconnections getall operation. + + Typically these are written to a http.Request. +*/ +type PcloudVpnconnectionsGetallParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud vpnconnections getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudVpnconnectionsGetallParams) WithDefaults() *PcloudVpnconnectionsGetallParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud vpnconnections getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudVpnconnectionsGetallParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud vpnconnections getall params +func (o *PcloudVpnconnectionsGetallParams) WithTimeout(timeout time.Duration) *PcloudVpnconnectionsGetallParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud vpnconnections getall params +func (o *PcloudVpnconnectionsGetallParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud vpnconnections getall params +func (o *PcloudVpnconnectionsGetallParams) WithContext(ctx context.Context) *PcloudVpnconnectionsGetallParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud vpnconnections getall params +func (o *PcloudVpnconnectionsGetallParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud vpnconnections getall params +func (o *PcloudVpnconnectionsGetallParams) WithHTTPClient(client *http.Client) *PcloudVpnconnectionsGetallParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud vpnconnections getall params +func (o *PcloudVpnconnectionsGetallParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud vpnconnections getall params +func (o *PcloudVpnconnectionsGetallParams) WithCloudInstanceID(cloudInstanceID string) *PcloudVpnconnectionsGetallParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud vpnconnections getall params +func (o *PcloudVpnconnectionsGetallParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudVpnconnectionsGetallParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_getall_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_getall_responses.go new file mode 100644 index 00000000000..487398c79ce --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_getall_responses.go @@ -0,0 +1,257 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudVpnconnectionsGetallReader is a Reader for the PcloudVpnconnectionsGetall structure. +type PcloudVpnconnectionsGetallReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudVpnconnectionsGetallReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudVpnconnectionsGetallOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudVpnconnectionsGetallBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudVpnconnectionsGetallUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewPcloudVpnconnectionsGetallForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudVpnconnectionsGetallNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudVpnconnectionsGetallInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudVpnconnectionsGetallOK creates a PcloudVpnconnectionsGetallOK with default headers values +func NewPcloudVpnconnectionsGetallOK() *PcloudVpnconnectionsGetallOK { + return &PcloudVpnconnectionsGetallOK{} +} + +/* PcloudVpnconnectionsGetallOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudVpnconnectionsGetallOK struct { + Payload *models.VPNConnections +} + +func (o *PcloudVpnconnectionsGetallOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections][%d] pcloudVpnconnectionsGetallOK %+v", 200, o.Payload) +} +func (o *PcloudVpnconnectionsGetallOK) GetPayload() *models.VPNConnections { + return o.Payload +} + +func (o *PcloudVpnconnectionsGetallOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.VPNConnections) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsGetallBadRequest creates a PcloudVpnconnectionsGetallBadRequest with default headers values +func NewPcloudVpnconnectionsGetallBadRequest() *PcloudVpnconnectionsGetallBadRequest { + return &PcloudVpnconnectionsGetallBadRequest{} +} + +/* PcloudVpnconnectionsGetallBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudVpnconnectionsGetallBadRequest struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsGetallBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections][%d] pcloudVpnconnectionsGetallBadRequest %+v", 400, o.Payload) +} +func (o *PcloudVpnconnectionsGetallBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsGetallBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsGetallUnauthorized creates a PcloudVpnconnectionsGetallUnauthorized with default headers values +func NewPcloudVpnconnectionsGetallUnauthorized() *PcloudVpnconnectionsGetallUnauthorized { + return &PcloudVpnconnectionsGetallUnauthorized{} +} + +/* PcloudVpnconnectionsGetallUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudVpnconnectionsGetallUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsGetallUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections][%d] pcloudVpnconnectionsGetallUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudVpnconnectionsGetallUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsGetallUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsGetallForbidden creates a PcloudVpnconnectionsGetallForbidden with default headers values +func NewPcloudVpnconnectionsGetallForbidden() *PcloudVpnconnectionsGetallForbidden { + return &PcloudVpnconnectionsGetallForbidden{} +} + +/* PcloudVpnconnectionsGetallForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type PcloudVpnconnectionsGetallForbidden struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsGetallForbidden) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections][%d] pcloudVpnconnectionsGetallForbidden %+v", 403, o.Payload) +} +func (o *PcloudVpnconnectionsGetallForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsGetallForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsGetallNotFound creates a PcloudVpnconnectionsGetallNotFound with default headers values +func NewPcloudVpnconnectionsGetallNotFound() *PcloudVpnconnectionsGetallNotFound { + return &PcloudVpnconnectionsGetallNotFound{} +} + +/* PcloudVpnconnectionsGetallNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudVpnconnectionsGetallNotFound struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsGetallNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections][%d] pcloudVpnconnectionsGetallNotFound %+v", 404, o.Payload) +} +func (o *PcloudVpnconnectionsGetallNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsGetallNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsGetallInternalServerError creates a PcloudVpnconnectionsGetallInternalServerError with default headers values +func NewPcloudVpnconnectionsGetallInternalServerError() *PcloudVpnconnectionsGetallInternalServerError { + return &PcloudVpnconnectionsGetallInternalServerError{} +} + +/* PcloudVpnconnectionsGetallInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudVpnconnectionsGetallInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsGetallInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections][%d] pcloudVpnconnectionsGetallInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudVpnconnectionsGetallInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsGetallInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_networks_delete_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_networks_delete_parameters.go new file mode 100644 index 00000000000..a7b4b14a236 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_networks_delete_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudVpnconnectionsNetworksDeleteParams creates a new PcloudVpnconnectionsNetworksDeleteParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudVpnconnectionsNetworksDeleteParams() *PcloudVpnconnectionsNetworksDeleteParams { + return &PcloudVpnconnectionsNetworksDeleteParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudVpnconnectionsNetworksDeleteParamsWithTimeout creates a new PcloudVpnconnectionsNetworksDeleteParams object +// with the ability to set a timeout on a request. +func NewPcloudVpnconnectionsNetworksDeleteParamsWithTimeout(timeout time.Duration) *PcloudVpnconnectionsNetworksDeleteParams { + return &PcloudVpnconnectionsNetworksDeleteParams{ + timeout: timeout, + } +} + +// NewPcloudVpnconnectionsNetworksDeleteParamsWithContext creates a new PcloudVpnconnectionsNetworksDeleteParams object +// with the ability to set a context for a request. +func NewPcloudVpnconnectionsNetworksDeleteParamsWithContext(ctx context.Context) *PcloudVpnconnectionsNetworksDeleteParams { + return &PcloudVpnconnectionsNetworksDeleteParams{ + Context: ctx, + } +} + +// NewPcloudVpnconnectionsNetworksDeleteParamsWithHTTPClient creates a new PcloudVpnconnectionsNetworksDeleteParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudVpnconnectionsNetworksDeleteParamsWithHTTPClient(client *http.Client) *PcloudVpnconnectionsNetworksDeleteParams { + return &PcloudVpnconnectionsNetworksDeleteParams{ + HTTPClient: client, + } +} + +/* PcloudVpnconnectionsNetworksDeleteParams contains all the parameters to send to the API endpoint + for the pcloud vpnconnections networks delete operation. + + Typically these are written to a http.Request. +*/ +type PcloudVpnconnectionsNetworksDeleteParams struct { + + /* Body. + + network to detach + */ + Body *models.NetworkID + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* VpnConnectionID. + + ID of a VPN connection + */ + VpnConnectionID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud vpnconnections networks delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudVpnconnectionsNetworksDeleteParams) WithDefaults() *PcloudVpnconnectionsNetworksDeleteParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud vpnconnections networks delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudVpnconnectionsNetworksDeleteParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud vpnconnections networks delete params +func (o *PcloudVpnconnectionsNetworksDeleteParams) WithTimeout(timeout time.Duration) *PcloudVpnconnectionsNetworksDeleteParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud vpnconnections networks delete params +func (o *PcloudVpnconnectionsNetworksDeleteParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud vpnconnections networks delete params +func (o *PcloudVpnconnectionsNetworksDeleteParams) WithContext(ctx context.Context) *PcloudVpnconnectionsNetworksDeleteParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud vpnconnections networks delete params +func (o *PcloudVpnconnectionsNetworksDeleteParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud vpnconnections networks delete params +func (o *PcloudVpnconnectionsNetworksDeleteParams) WithHTTPClient(client *http.Client) *PcloudVpnconnectionsNetworksDeleteParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud vpnconnections networks delete params +func (o *PcloudVpnconnectionsNetworksDeleteParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud vpnconnections networks delete params +func (o *PcloudVpnconnectionsNetworksDeleteParams) WithBody(body *models.NetworkID) *PcloudVpnconnectionsNetworksDeleteParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud vpnconnections networks delete params +func (o *PcloudVpnconnectionsNetworksDeleteParams) SetBody(body *models.NetworkID) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud vpnconnections networks delete params +func (o *PcloudVpnconnectionsNetworksDeleteParams) WithCloudInstanceID(cloudInstanceID string) *PcloudVpnconnectionsNetworksDeleteParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud vpnconnections networks delete params +func (o *PcloudVpnconnectionsNetworksDeleteParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithVpnConnectionID adds the vpnConnectionID to the pcloud vpnconnections networks delete params +func (o *PcloudVpnconnectionsNetworksDeleteParams) WithVpnConnectionID(vpnConnectionID string) *PcloudVpnconnectionsNetworksDeleteParams { + o.SetVpnConnectionID(vpnConnectionID) + return o +} + +// SetVpnConnectionID adds the vpnConnectionId to the pcloud vpnconnections networks delete params +func (o *PcloudVpnconnectionsNetworksDeleteParams) SetVpnConnectionID(vpnConnectionID string) { + o.VpnConnectionID = vpnConnectionID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudVpnconnectionsNetworksDeleteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param vpn_connection_id + if err := r.SetPathParam("vpn_connection_id", o.VpnConnectionID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_networks_delete_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_networks_delete_responses.go new file mode 100644 index 00000000000..4d2685a4b9d --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_networks_delete_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudVpnconnectionsNetworksDeleteReader is a Reader for the PcloudVpnconnectionsNetworksDelete structure. +type PcloudVpnconnectionsNetworksDeleteReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudVpnconnectionsNetworksDeleteReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 202: + result := NewPcloudVpnconnectionsNetworksDeleteAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudVpnconnectionsNetworksDeleteBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudVpnconnectionsNetworksDeleteUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewPcloudVpnconnectionsNetworksDeleteForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudVpnconnectionsNetworksDeleteNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudVpnconnectionsNetworksDeleteUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudVpnconnectionsNetworksDeleteInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudVpnconnectionsNetworksDeleteAccepted creates a PcloudVpnconnectionsNetworksDeleteAccepted with default headers values +func NewPcloudVpnconnectionsNetworksDeleteAccepted() *PcloudVpnconnectionsNetworksDeleteAccepted { + return &PcloudVpnconnectionsNetworksDeleteAccepted{} +} + +/* PcloudVpnconnectionsNetworksDeleteAccepted describes a response with status code 202, with default header values. + +Accepted +*/ +type PcloudVpnconnectionsNetworksDeleteAccepted struct { + Payload *models.JobReference +} + +func (o *PcloudVpnconnectionsNetworksDeleteAccepted) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/networks][%d] pcloudVpnconnectionsNetworksDeleteAccepted %+v", 202, o.Payload) +} +func (o *PcloudVpnconnectionsNetworksDeleteAccepted) GetPayload() *models.JobReference { + return o.Payload +} + +func (o *PcloudVpnconnectionsNetworksDeleteAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.JobReference) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsNetworksDeleteBadRequest creates a PcloudVpnconnectionsNetworksDeleteBadRequest with default headers values +func NewPcloudVpnconnectionsNetworksDeleteBadRequest() *PcloudVpnconnectionsNetworksDeleteBadRequest { + return &PcloudVpnconnectionsNetworksDeleteBadRequest{} +} + +/* PcloudVpnconnectionsNetworksDeleteBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudVpnconnectionsNetworksDeleteBadRequest struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsNetworksDeleteBadRequest) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/networks][%d] pcloudVpnconnectionsNetworksDeleteBadRequest %+v", 400, o.Payload) +} +func (o *PcloudVpnconnectionsNetworksDeleteBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsNetworksDeleteBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsNetworksDeleteUnauthorized creates a PcloudVpnconnectionsNetworksDeleteUnauthorized with default headers values +func NewPcloudVpnconnectionsNetworksDeleteUnauthorized() *PcloudVpnconnectionsNetworksDeleteUnauthorized { + return &PcloudVpnconnectionsNetworksDeleteUnauthorized{} +} + +/* PcloudVpnconnectionsNetworksDeleteUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudVpnconnectionsNetworksDeleteUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsNetworksDeleteUnauthorized) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/networks][%d] pcloudVpnconnectionsNetworksDeleteUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudVpnconnectionsNetworksDeleteUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsNetworksDeleteUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsNetworksDeleteForbidden creates a PcloudVpnconnectionsNetworksDeleteForbidden with default headers values +func NewPcloudVpnconnectionsNetworksDeleteForbidden() *PcloudVpnconnectionsNetworksDeleteForbidden { + return &PcloudVpnconnectionsNetworksDeleteForbidden{} +} + +/* PcloudVpnconnectionsNetworksDeleteForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type PcloudVpnconnectionsNetworksDeleteForbidden struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsNetworksDeleteForbidden) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/networks][%d] pcloudVpnconnectionsNetworksDeleteForbidden %+v", 403, o.Payload) +} +func (o *PcloudVpnconnectionsNetworksDeleteForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsNetworksDeleteForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsNetworksDeleteNotFound creates a PcloudVpnconnectionsNetworksDeleteNotFound with default headers values +func NewPcloudVpnconnectionsNetworksDeleteNotFound() *PcloudVpnconnectionsNetworksDeleteNotFound { + return &PcloudVpnconnectionsNetworksDeleteNotFound{} +} + +/* PcloudVpnconnectionsNetworksDeleteNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudVpnconnectionsNetworksDeleteNotFound struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsNetworksDeleteNotFound) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/networks][%d] pcloudVpnconnectionsNetworksDeleteNotFound %+v", 404, o.Payload) +} +func (o *PcloudVpnconnectionsNetworksDeleteNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsNetworksDeleteNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsNetworksDeleteUnprocessableEntity creates a PcloudVpnconnectionsNetworksDeleteUnprocessableEntity with default headers values +func NewPcloudVpnconnectionsNetworksDeleteUnprocessableEntity() *PcloudVpnconnectionsNetworksDeleteUnprocessableEntity { + return &PcloudVpnconnectionsNetworksDeleteUnprocessableEntity{} +} + +/* PcloudVpnconnectionsNetworksDeleteUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudVpnconnectionsNetworksDeleteUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsNetworksDeleteUnprocessableEntity) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/networks][%d] pcloudVpnconnectionsNetworksDeleteUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudVpnconnectionsNetworksDeleteUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsNetworksDeleteUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsNetworksDeleteInternalServerError creates a PcloudVpnconnectionsNetworksDeleteInternalServerError with default headers values +func NewPcloudVpnconnectionsNetworksDeleteInternalServerError() *PcloudVpnconnectionsNetworksDeleteInternalServerError { + return &PcloudVpnconnectionsNetworksDeleteInternalServerError{} +} + +/* PcloudVpnconnectionsNetworksDeleteInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudVpnconnectionsNetworksDeleteInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsNetworksDeleteInternalServerError) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/networks][%d] pcloudVpnconnectionsNetworksDeleteInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudVpnconnectionsNetworksDeleteInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsNetworksDeleteInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_networks_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_networks_get_parameters.go new file mode 100644 index 00000000000..a09738cfa28 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_networks_get_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudVpnconnectionsNetworksGetParams creates a new PcloudVpnconnectionsNetworksGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudVpnconnectionsNetworksGetParams() *PcloudVpnconnectionsNetworksGetParams { + return &PcloudVpnconnectionsNetworksGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudVpnconnectionsNetworksGetParamsWithTimeout creates a new PcloudVpnconnectionsNetworksGetParams object +// with the ability to set a timeout on a request. +func NewPcloudVpnconnectionsNetworksGetParamsWithTimeout(timeout time.Duration) *PcloudVpnconnectionsNetworksGetParams { + return &PcloudVpnconnectionsNetworksGetParams{ + timeout: timeout, + } +} + +// NewPcloudVpnconnectionsNetworksGetParamsWithContext creates a new PcloudVpnconnectionsNetworksGetParams object +// with the ability to set a context for a request. +func NewPcloudVpnconnectionsNetworksGetParamsWithContext(ctx context.Context) *PcloudVpnconnectionsNetworksGetParams { + return &PcloudVpnconnectionsNetworksGetParams{ + Context: ctx, + } +} + +// NewPcloudVpnconnectionsNetworksGetParamsWithHTTPClient creates a new PcloudVpnconnectionsNetworksGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudVpnconnectionsNetworksGetParamsWithHTTPClient(client *http.Client) *PcloudVpnconnectionsNetworksGetParams { + return &PcloudVpnconnectionsNetworksGetParams{ + HTTPClient: client, + } +} + +/* PcloudVpnconnectionsNetworksGetParams contains all the parameters to send to the API endpoint + for the pcloud vpnconnections networks get operation. + + Typically these are written to a http.Request. +*/ +type PcloudVpnconnectionsNetworksGetParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* VpnConnectionID. + + ID of a VPN connection + */ + VpnConnectionID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud vpnconnections networks get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudVpnconnectionsNetworksGetParams) WithDefaults() *PcloudVpnconnectionsNetworksGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud vpnconnections networks get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudVpnconnectionsNetworksGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud vpnconnections networks get params +func (o *PcloudVpnconnectionsNetworksGetParams) WithTimeout(timeout time.Duration) *PcloudVpnconnectionsNetworksGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud vpnconnections networks get params +func (o *PcloudVpnconnectionsNetworksGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud vpnconnections networks get params +func (o *PcloudVpnconnectionsNetworksGetParams) WithContext(ctx context.Context) *PcloudVpnconnectionsNetworksGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud vpnconnections networks get params +func (o *PcloudVpnconnectionsNetworksGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud vpnconnections networks get params +func (o *PcloudVpnconnectionsNetworksGetParams) WithHTTPClient(client *http.Client) *PcloudVpnconnectionsNetworksGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud vpnconnections networks get params +func (o *PcloudVpnconnectionsNetworksGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud vpnconnections networks get params +func (o *PcloudVpnconnectionsNetworksGetParams) WithCloudInstanceID(cloudInstanceID string) *PcloudVpnconnectionsNetworksGetParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud vpnconnections networks get params +func (o *PcloudVpnconnectionsNetworksGetParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithVpnConnectionID adds the vpnConnectionID to the pcloud vpnconnections networks get params +func (o *PcloudVpnconnectionsNetworksGetParams) WithVpnConnectionID(vpnConnectionID string) *PcloudVpnconnectionsNetworksGetParams { + o.SetVpnConnectionID(vpnConnectionID) + return o +} + +// SetVpnConnectionID adds the vpnConnectionId to the pcloud vpnconnections networks get params +func (o *PcloudVpnconnectionsNetworksGetParams) SetVpnConnectionID(vpnConnectionID string) { + o.VpnConnectionID = vpnConnectionID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudVpnconnectionsNetworksGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param vpn_connection_id + if err := r.SetPathParam("vpn_connection_id", o.VpnConnectionID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_networks_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_networks_get_responses.go new file mode 100644 index 00000000000..de86c27f685 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_networks_get_responses.go @@ -0,0 +1,257 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudVpnconnectionsNetworksGetReader is a Reader for the PcloudVpnconnectionsNetworksGet structure. +type PcloudVpnconnectionsNetworksGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudVpnconnectionsNetworksGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudVpnconnectionsNetworksGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudVpnconnectionsNetworksGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudVpnconnectionsNetworksGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewPcloudVpnconnectionsNetworksGetForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudVpnconnectionsNetworksGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudVpnconnectionsNetworksGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudVpnconnectionsNetworksGetOK creates a PcloudVpnconnectionsNetworksGetOK with default headers values +func NewPcloudVpnconnectionsNetworksGetOK() *PcloudVpnconnectionsNetworksGetOK { + return &PcloudVpnconnectionsNetworksGetOK{} +} + +/* PcloudVpnconnectionsNetworksGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudVpnconnectionsNetworksGetOK struct { + Payload *models.NetworkIDs +} + +func (o *PcloudVpnconnectionsNetworksGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/networks][%d] pcloudVpnconnectionsNetworksGetOK %+v", 200, o.Payload) +} +func (o *PcloudVpnconnectionsNetworksGetOK) GetPayload() *models.NetworkIDs { + return o.Payload +} + +func (o *PcloudVpnconnectionsNetworksGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.NetworkIDs) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsNetworksGetBadRequest creates a PcloudVpnconnectionsNetworksGetBadRequest with default headers values +func NewPcloudVpnconnectionsNetworksGetBadRequest() *PcloudVpnconnectionsNetworksGetBadRequest { + return &PcloudVpnconnectionsNetworksGetBadRequest{} +} + +/* PcloudVpnconnectionsNetworksGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudVpnconnectionsNetworksGetBadRequest struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsNetworksGetBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/networks][%d] pcloudVpnconnectionsNetworksGetBadRequest %+v", 400, o.Payload) +} +func (o *PcloudVpnconnectionsNetworksGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsNetworksGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsNetworksGetUnauthorized creates a PcloudVpnconnectionsNetworksGetUnauthorized with default headers values +func NewPcloudVpnconnectionsNetworksGetUnauthorized() *PcloudVpnconnectionsNetworksGetUnauthorized { + return &PcloudVpnconnectionsNetworksGetUnauthorized{} +} + +/* PcloudVpnconnectionsNetworksGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudVpnconnectionsNetworksGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsNetworksGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/networks][%d] pcloudVpnconnectionsNetworksGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudVpnconnectionsNetworksGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsNetworksGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsNetworksGetForbidden creates a PcloudVpnconnectionsNetworksGetForbidden with default headers values +func NewPcloudVpnconnectionsNetworksGetForbidden() *PcloudVpnconnectionsNetworksGetForbidden { + return &PcloudVpnconnectionsNetworksGetForbidden{} +} + +/* PcloudVpnconnectionsNetworksGetForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type PcloudVpnconnectionsNetworksGetForbidden struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsNetworksGetForbidden) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/networks][%d] pcloudVpnconnectionsNetworksGetForbidden %+v", 403, o.Payload) +} +func (o *PcloudVpnconnectionsNetworksGetForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsNetworksGetForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsNetworksGetNotFound creates a PcloudVpnconnectionsNetworksGetNotFound with default headers values +func NewPcloudVpnconnectionsNetworksGetNotFound() *PcloudVpnconnectionsNetworksGetNotFound { + return &PcloudVpnconnectionsNetworksGetNotFound{} +} + +/* PcloudVpnconnectionsNetworksGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudVpnconnectionsNetworksGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsNetworksGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/networks][%d] pcloudVpnconnectionsNetworksGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudVpnconnectionsNetworksGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsNetworksGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsNetworksGetInternalServerError creates a PcloudVpnconnectionsNetworksGetInternalServerError with default headers values +func NewPcloudVpnconnectionsNetworksGetInternalServerError() *PcloudVpnconnectionsNetworksGetInternalServerError { + return &PcloudVpnconnectionsNetworksGetInternalServerError{} +} + +/* PcloudVpnconnectionsNetworksGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudVpnconnectionsNetworksGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsNetworksGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/networks][%d] pcloudVpnconnectionsNetworksGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudVpnconnectionsNetworksGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsNetworksGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_networks_put_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_networks_put_parameters.go new file mode 100644 index 00000000000..1cd48aa1573 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_networks_put_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudVpnconnectionsNetworksPutParams creates a new PcloudVpnconnectionsNetworksPutParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudVpnconnectionsNetworksPutParams() *PcloudVpnconnectionsNetworksPutParams { + return &PcloudVpnconnectionsNetworksPutParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudVpnconnectionsNetworksPutParamsWithTimeout creates a new PcloudVpnconnectionsNetworksPutParams object +// with the ability to set a timeout on a request. +func NewPcloudVpnconnectionsNetworksPutParamsWithTimeout(timeout time.Duration) *PcloudVpnconnectionsNetworksPutParams { + return &PcloudVpnconnectionsNetworksPutParams{ + timeout: timeout, + } +} + +// NewPcloudVpnconnectionsNetworksPutParamsWithContext creates a new PcloudVpnconnectionsNetworksPutParams object +// with the ability to set a context for a request. +func NewPcloudVpnconnectionsNetworksPutParamsWithContext(ctx context.Context) *PcloudVpnconnectionsNetworksPutParams { + return &PcloudVpnconnectionsNetworksPutParams{ + Context: ctx, + } +} + +// NewPcloudVpnconnectionsNetworksPutParamsWithHTTPClient creates a new PcloudVpnconnectionsNetworksPutParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudVpnconnectionsNetworksPutParamsWithHTTPClient(client *http.Client) *PcloudVpnconnectionsNetworksPutParams { + return &PcloudVpnconnectionsNetworksPutParams{ + HTTPClient: client, + } +} + +/* PcloudVpnconnectionsNetworksPutParams contains all the parameters to send to the API endpoint + for the pcloud vpnconnections networks put operation. + + Typically these are written to a http.Request. +*/ +type PcloudVpnconnectionsNetworksPutParams struct { + + /* Body. + + network to attach + */ + Body *models.NetworkID + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* VpnConnectionID. + + ID of a VPN connection + */ + VpnConnectionID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud vpnconnections networks put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudVpnconnectionsNetworksPutParams) WithDefaults() *PcloudVpnconnectionsNetworksPutParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud vpnconnections networks put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudVpnconnectionsNetworksPutParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud vpnconnections networks put params +func (o *PcloudVpnconnectionsNetworksPutParams) WithTimeout(timeout time.Duration) *PcloudVpnconnectionsNetworksPutParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud vpnconnections networks put params +func (o *PcloudVpnconnectionsNetworksPutParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud vpnconnections networks put params +func (o *PcloudVpnconnectionsNetworksPutParams) WithContext(ctx context.Context) *PcloudVpnconnectionsNetworksPutParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud vpnconnections networks put params +func (o *PcloudVpnconnectionsNetworksPutParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud vpnconnections networks put params +func (o *PcloudVpnconnectionsNetworksPutParams) WithHTTPClient(client *http.Client) *PcloudVpnconnectionsNetworksPutParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud vpnconnections networks put params +func (o *PcloudVpnconnectionsNetworksPutParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud vpnconnections networks put params +func (o *PcloudVpnconnectionsNetworksPutParams) WithBody(body *models.NetworkID) *PcloudVpnconnectionsNetworksPutParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud vpnconnections networks put params +func (o *PcloudVpnconnectionsNetworksPutParams) SetBody(body *models.NetworkID) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud vpnconnections networks put params +func (o *PcloudVpnconnectionsNetworksPutParams) WithCloudInstanceID(cloudInstanceID string) *PcloudVpnconnectionsNetworksPutParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud vpnconnections networks put params +func (o *PcloudVpnconnectionsNetworksPutParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithVpnConnectionID adds the vpnConnectionID to the pcloud vpnconnections networks put params +func (o *PcloudVpnconnectionsNetworksPutParams) WithVpnConnectionID(vpnConnectionID string) *PcloudVpnconnectionsNetworksPutParams { + o.SetVpnConnectionID(vpnConnectionID) + return o +} + +// SetVpnConnectionID adds the vpnConnectionId to the pcloud vpnconnections networks put params +func (o *PcloudVpnconnectionsNetworksPutParams) SetVpnConnectionID(vpnConnectionID string) { + o.VpnConnectionID = vpnConnectionID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudVpnconnectionsNetworksPutParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param vpn_connection_id + if err := r.SetPathParam("vpn_connection_id", o.VpnConnectionID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_networks_put_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_networks_put_responses.go new file mode 100644 index 00000000000..4bcc8502d9b --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_networks_put_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudVpnconnectionsNetworksPutReader is a Reader for the PcloudVpnconnectionsNetworksPut structure. +type PcloudVpnconnectionsNetworksPutReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudVpnconnectionsNetworksPutReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 202: + result := NewPcloudVpnconnectionsNetworksPutAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudVpnconnectionsNetworksPutBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudVpnconnectionsNetworksPutUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewPcloudVpnconnectionsNetworksPutForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudVpnconnectionsNetworksPutNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudVpnconnectionsNetworksPutUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudVpnconnectionsNetworksPutInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudVpnconnectionsNetworksPutAccepted creates a PcloudVpnconnectionsNetworksPutAccepted with default headers values +func NewPcloudVpnconnectionsNetworksPutAccepted() *PcloudVpnconnectionsNetworksPutAccepted { + return &PcloudVpnconnectionsNetworksPutAccepted{} +} + +/* PcloudVpnconnectionsNetworksPutAccepted describes a response with status code 202, with default header values. + +Accepted +*/ +type PcloudVpnconnectionsNetworksPutAccepted struct { + Payload *models.JobReference +} + +func (o *PcloudVpnconnectionsNetworksPutAccepted) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/networks][%d] pcloudVpnconnectionsNetworksPutAccepted %+v", 202, o.Payload) +} +func (o *PcloudVpnconnectionsNetworksPutAccepted) GetPayload() *models.JobReference { + return o.Payload +} + +func (o *PcloudVpnconnectionsNetworksPutAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.JobReference) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsNetworksPutBadRequest creates a PcloudVpnconnectionsNetworksPutBadRequest with default headers values +func NewPcloudVpnconnectionsNetworksPutBadRequest() *PcloudVpnconnectionsNetworksPutBadRequest { + return &PcloudVpnconnectionsNetworksPutBadRequest{} +} + +/* PcloudVpnconnectionsNetworksPutBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudVpnconnectionsNetworksPutBadRequest struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsNetworksPutBadRequest) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/networks][%d] pcloudVpnconnectionsNetworksPutBadRequest %+v", 400, o.Payload) +} +func (o *PcloudVpnconnectionsNetworksPutBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsNetworksPutBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsNetworksPutUnauthorized creates a PcloudVpnconnectionsNetworksPutUnauthorized with default headers values +func NewPcloudVpnconnectionsNetworksPutUnauthorized() *PcloudVpnconnectionsNetworksPutUnauthorized { + return &PcloudVpnconnectionsNetworksPutUnauthorized{} +} + +/* PcloudVpnconnectionsNetworksPutUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudVpnconnectionsNetworksPutUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsNetworksPutUnauthorized) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/networks][%d] pcloudVpnconnectionsNetworksPutUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudVpnconnectionsNetworksPutUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsNetworksPutUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsNetworksPutForbidden creates a PcloudVpnconnectionsNetworksPutForbidden with default headers values +func NewPcloudVpnconnectionsNetworksPutForbidden() *PcloudVpnconnectionsNetworksPutForbidden { + return &PcloudVpnconnectionsNetworksPutForbidden{} +} + +/* PcloudVpnconnectionsNetworksPutForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type PcloudVpnconnectionsNetworksPutForbidden struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsNetworksPutForbidden) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/networks][%d] pcloudVpnconnectionsNetworksPutForbidden %+v", 403, o.Payload) +} +func (o *PcloudVpnconnectionsNetworksPutForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsNetworksPutForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsNetworksPutNotFound creates a PcloudVpnconnectionsNetworksPutNotFound with default headers values +func NewPcloudVpnconnectionsNetworksPutNotFound() *PcloudVpnconnectionsNetworksPutNotFound { + return &PcloudVpnconnectionsNetworksPutNotFound{} +} + +/* PcloudVpnconnectionsNetworksPutNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudVpnconnectionsNetworksPutNotFound struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsNetworksPutNotFound) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/networks][%d] pcloudVpnconnectionsNetworksPutNotFound %+v", 404, o.Payload) +} +func (o *PcloudVpnconnectionsNetworksPutNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsNetworksPutNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsNetworksPutUnprocessableEntity creates a PcloudVpnconnectionsNetworksPutUnprocessableEntity with default headers values +func NewPcloudVpnconnectionsNetworksPutUnprocessableEntity() *PcloudVpnconnectionsNetworksPutUnprocessableEntity { + return &PcloudVpnconnectionsNetworksPutUnprocessableEntity{} +} + +/* PcloudVpnconnectionsNetworksPutUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudVpnconnectionsNetworksPutUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsNetworksPutUnprocessableEntity) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/networks][%d] pcloudVpnconnectionsNetworksPutUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudVpnconnectionsNetworksPutUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsNetworksPutUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsNetworksPutInternalServerError creates a PcloudVpnconnectionsNetworksPutInternalServerError with default headers values +func NewPcloudVpnconnectionsNetworksPutInternalServerError() *PcloudVpnconnectionsNetworksPutInternalServerError { + return &PcloudVpnconnectionsNetworksPutInternalServerError{} +} + +/* PcloudVpnconnectionsNetworksPutInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudVpnconnectionsNetworksPutInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsNetworksPutInternalServerError) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/networks][%d] pcloudVpnconnectionsNetworksPutInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudVpnconnectionsNetworksPutInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsNetworksPutInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_peersubnets_delete_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_peersubnets_delete_parameters.go new file mode 100644 index 00000000000..5834aeab041 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_peersubnets_delete_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudVpnconnectionsPeersubnetsDeleteParams creates a new PcloudVpnconnectionsPeersubnetsDeleteParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudVpnconnectionsPeersubnetsDeleteParams() *PcloudVpnconnectionsPeersubnetsDeleteParams { + return &PcloudVpnconnectionsPeersubnetsDeleteParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudVpnconnectionsPeersubnetsDeleteParamsWithTimeout creates a new PcloudVpnconnectionsPeersubnetsDeleteParams object +// with the ability to set a timeout on a request. +func NewPcloudVpnconnectionsPeersubnetsDeleteParamsWithTimeout(timeout time.Duration) *PcloudVpnconnectionsPeersubnetsDeleteParams { + return &PcloudVpnconnectionsPeersubnetsDeleteParams{ + timeout: timeout, + } +} + +// NewPcloudVpnconnectionsPeersubnetsDeleteParamsWithContext creates a new PcloudVpnconnectionsPeersubnetsDeleteParams object +// with the ability to set a context for a request. +func NewPcloudVpnconnectionsPeersubnetsDeleteParamsWithContext(ctx context.Context) *PcloudVpnconnectionsPeersubnetsDeleteParams { + return &PcloudVpnconnectionsPeersubnetsDeleteParams{ + Context: ctx, + } +} + +// NewPcloudVpnconnectionsPeersubnetsDeleteParamsWithHTTPClient creates a new PcloudVpnconnectionsPeersubnetsDeleteParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudVpnconnectionsPeersubnetsDeleteParamsWithHTTPClient(client *http.Client) *PcloudVpnconnectionsPeersubnetsDeleteParams { + return &PcloudVpnconnectionsPeersubnetsDeleteParams{ + HTTPClient: client, + } +} + +/* PcloudVpnconnectionsPeersubnetsDeleteParams contains all the parameters to send to the API endpoint + for the pcloud vpnconnections peersubnets delete operation. + + Typically these are written to a http.Request. +*/ +type PcloudVpnconnectionsPeersubnetsDeleteParams struct { + + /* Body. + + Peer subnet to detach + */ + Body *models.PeerSubnetUpdate + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* VpnConnectionID. + + ID of a VPN connection + */ + VpnConnectionID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud vpnconnections peersubnets delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudVpnconnectionsPeersubnetsDeleteParams) WithDefaults() *PcloudVpnconnectionsPeersubnetsDeleteParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud vpnconnections peersubnets delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudVpnconnectionsPeersubnetsDeleteParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud vpnconnections peersubnets delete params +func (o *PcloudVpnconnectionsPeersubnetsDeleteParams) WithTimeout(timeout time.Duration) *PcloudVpnconnectionsPeersubnetsDeleteParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud vpnconnections peersubnets delete params +func (o *PcloudVpnconnectionsPeersubnetsDeleteParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud vpnconnections peersubnets delete params +func (o *PcloudVpnconnectionsPeersubnetsDeleteParams) WithContext(ctx context.Context) *PcloudVpnconnectionsPeersubnetsDeleteParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud vpnconnections peersubnets delete params +func (o *PcloudVpnconnectionsPeersubnetsDeleteParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud vpnconnections peersubnets delete params +func (o *PcloudVpnconnectionsPeersubnetsDeleteParams) WithHTTPClient(client *http.Client) *PcloudVpnconnectionsPeersubnetsDeleteParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud vpnconnections peersubnets delete params +func (o *PcloudVpnconnectionsPeersubnetsDeleteParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud vpnconnections peersubnets delete params +func (o *PcloudVpnconnectionsPeersubnetsDeleteParams) WithBody(body *models.PeerSubnetUpdate) *PcloudVpnconnectionsPeersubnetsDeleteParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud vpnconnections peersubnets delete params +func (o *PcloudVpnconnectionsPeersubnetsDeleteParams) SetBody(body *models.PeerSubnetUpdate) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud vpnconnections peersubnets delete params +func (o *PcloudVpnconnectionsPeersubnetsDeleteParams) WithCloudInstanceID(cloudInstanceID string) *PcloudVpnconnectionsPeersubnetsDeleteParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud vpnconnections peersubnets delete params +func (o *PcloudVpnconnectionsPeersubnetsDeleteParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithVpnConnectionID adds the vpnConnectionID to the pcloud vpnconnections peersubnets delete params +func (o *PcloudVpnconnectionsPeersubnetsDeleteParams) WithVpnConnectionID(vpnConnectionID string) *PcloudVpnconnectionsPeersubnetsDeleteParams { + o.SetVpnConnectionID(vpnConnectionID) + return o +} + +// SetVpnConnectionID adds the vpnConnectionId to the pcloud vpnconnections peersubnets delete params +func (o *PcloudVpnconnectionsPeersubnetsDeleteParams) SetVpnConnectionID(vpnConnectionID string) { + o.VpnConnectionID = vpnConnectionID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudVpnconnectionsPeersubnetsDeleteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param vpn_connection_id + if err := r.SetPathParam("vpn_connection_id", o.VpnConnectionID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_peersubnets_delete_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_peersubnets_delete_responses.go new file mode 100644 index 00000000000..5b6d05ba598 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_peersubnets_delete_responses.go @@ -0,0 +1,257 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudVpnconnectionsPeersubnetsDeleteReader is a Reader for the PcloudVpnconnectionsPeersubnetsDelete structure. +type PcloudVpnconnectionsPeersubnetsDeleteReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudVpnconnectionsPeersubnetsDeleteReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudVpnconnectionsPeersubnetsDeleteOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudVpnconnectionsPeersubnetsDeleteBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudVpnconnectionsPeersubnetsDeleteUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewPcloudVpnconnectionsPeersubnetsDeleteForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudVpnconnectionsPeersubnetsDeleteUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudVpnconnectionsPeersubnetsDeleteInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudVpnconnectionsPeersubnetsDeleteOK creates a PcloudVpnconnectionsPeersubnetsDeleteOK with default headers values +func NewPcloudVpnconnectionsPeersubnetsDeleteOK() *PcloudVpnconnectionsPeersubnetsDeleteOK { + return &PcloudVpnconnectionsPeersubnetsDeleteOK{} +} + +/* PcloudVpnconnectionsPeersubnetsDeleteOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudVpnconnectionsPeersubnetsDeleteOK struct { + Payload *models.PeerSubnets +} + +func (o *PcloudVpnconnectionsPeersubnetsDeleteOK) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/peer-subnets][%d] pcloudVpnconnectionsPeersubnetsDeleteOK %+v", 200, o.Payload) +} +func (o *PcloudVpnconnectionsPeersubnetsDeleteOK) GetPayload() *models.PeerSubnets { + return o.Payload +} + +func (o *PcloudVpnconnectionsPeersubnetsDeleteOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.PeerSubnets) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsPeersubnetsDeleteBadRequest creates a PcloudVpnconnectionsPeersubnetsDeleteBadRequest with default headers values +func NewPcloudVpnconnectionsPeersubnetsDeleteBadRequest() *PcloudVpnconnectionsPeersubnetsDeleteBadRequest { + return &PcloudVpnconnectionsPeersubnetsDeleteBadRequest{} +} + +/* PcloudVpnconnectionsPeersubnetsDeleteBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudVpnconnectionsPeersubnetsDeleteBadRequest struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsPeersubnetsDeleteBadRequest) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/peer-subnets][%d] pcloudVpnconnectionsPeersubnetsDeleteBadRequest %+v", 400, o.Payload) +} +func (o *PcloudVpnconnectionsPeersubnetsDeleteBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsPeersubnetsDeleteBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsPeersubnetsDeleteUnauthorized creates a PcloudVpnconnectionsPeersubnetsDeleteUnauthorized with default headers values +func NewPcloudVpnconnectionsPeersubnetsDeleteUnauthorized() *PcloudVpnconnectionsPeersubnetsDeleteUnauthorized { + return &PcloudVpnconnectionsPeersubnetsDeleteUnauthorized{} +} + +/* PcloudVpnconnectionsPeersubnetsDeleteUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudVpnconnectionsPeersubnetsDeleteUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsPeersubnetsDeleteUnauthorized) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/peer-subnets][%d] pcloudVpnconnectionsPeersubnetsDeleteUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudVpnconnectionsPeersubnetsDeleteUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsPeersubnetsDeleteUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsPeersubnetsDeleteForbidden creates a PcloudVpnconnectionsPeersubnetsDeleteForbidden with default headers values +func NewPcloudVpnconnectionsPeersubnetsDeleteForbidden() *PcloudVpnconnectionsPeersubnetsDeleteForbidden { + return &PcloudVpnconnectionsPeersubnetsDeleteForbidden{} +} + +/* PcloudVpnconnectionsPeersubnetsDeleteForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type PcloudVpnconnectionsPeersubnetsDeleteForbidden struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsPeersubnetsDeleteForbidden) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/peer-subnets][%d] pcloudVpnconnectionsPeersubnetsDeleteForbidden %+v", 403, o.Payload) +} +func (o *PcloudVpnconnectionsPeersubnetsDeleteForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsPeersubnetsDeleteForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsPeersubnetsDeleteUnprocessableEntity creates a PcloudVpnconnectionsPeersubnetsDeleteUnprocessableEntity with default headers values +func NewPcloudVpnconnectionsPeersubnetsDeleteUnprocessableEntity() *PcloudVpnconnectionsPeersubnetsDeleteUnprocessableEntity { + return &PcloudVpnconnectionsPeersubnetsDeleteUnprocessableEntity{} +} + +/* PcloudVpnconnectionsPeersubnetsDeleteUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudVpnconnectionsPeersubnetsDeleteUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsPeersubnetsDeleteUnprocessableEntity) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/peer-subnets][%d] pcloudVpnconnectionsPeersubnetsDeleteUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudVpnconnectionsPeersubnetsDeleteUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsPeersubnetsDeleteUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsPeersubnetsDeleteInternalServerError creates a PcloudVpnconnectionsPeersubnetsDeleteInternalServerError with default headers values +func NewPcloudVpnconnectionsPeersubnetsDeleteInternalServerError() *PcloudVpnconnectionsPeersubnetsDeleteInternalServerError { + return &PcloudVpnconnectionsPeersubnetsDeleteInternalServerError{} +} + +/* PcloudVpnconnectionsPeersubnetsDeleteInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudVpnconnectionsPeersubnetsDeleteInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsPeersubnetsDeleteInternalServerError) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/peer-subnets][%d] pcloudVpnconnectionsPeersubnetsDeleteInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudVpnconnectionsPeersubnetsDeleteInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsPeersubnetsDeleteInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_peersubnets_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_peersubnets_get_parameters.go new file mode 100644 index 00000000000..d17411fda91 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_peersubnets_get_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudVpnconnectionsPeersubnetsGetParams creates a new PcloudVpnconnectionsPeersubnetsGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudVpnconnectionsPeersubnetsGetParams() *PcloudVpnconnectionsPeersubnetsGetParams { + return &PcloudVpnconnectionsPeersubnetsGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudVpnconnectionsPeersubnetsGetParamsWithTimeout creates a new PcloudVpnconnectionsPeersubnetsGetParams object +// with the ability to set a timeout on a request. +func NewPcloudVpnconnectionsPeersubnetsGetParamsWithTimeout(timeout time.Duration) *PcloudVpnconnectionsPeersubnetsGetParams { + return &PcloudVpnconnectionsPeersubnetsGetParams{ + timeout: timeout, + } +} + +// NewPcloudVpnconnectionsPeersubnetsGetParamsWithContext creates a new PcloudVpnconnectionsPeersubnetsGetParams object +// with the ability to set a context for a request. +func NewPcloudVpnconnectionsPeersubnetsGetParamsWithContext(ctx context.Context) *PcloudVpnconnectionsPeersubnetsGetParams { + return &PcloudVpnconnectionsPeersubnetsGetParams{ + Context: ctx, + } +} + +// NewPcloudVpnconnectionsPeersubnetsGetParamsWithHTTPClient creates a new PcloudVpnconnectionsPeersubnetsGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudVpnconnectionsPeersubnetsGetParamsWithHTTPClient(client *http.Client) *PcloudVpnconnectionsPeersubnetsGetParams { + return &PcloudVpnconnectionsPeersubnetsGetParams{ + HTTPClient: client, + } +} + +/* PcloudVpnconnectionsPeersubnetsGetParams contains all the parameters to send to the API endpoint + for the pcloud vpnconnections peersubnets get operation. + + Typically these are written to a http.Request. +*/ +type PcloudVpnconnectionsPeersubnetsGetParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* VpnConnectionID. + + ID of a VPN connection + */ + VpnConnectionID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud vpnconnections peersubnets get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudVpnconnectionsPeersubnetsGetParams) WithDefaults() *PcloudVpnconnectionsPeersubnetsGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud vpnconnections peersubnets get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudVpnconnectionsPeersubnetsGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud vpnconnections peersubnets get params +func (o *PcloudVpnconnectionsPeersubnetsGetParams) WithTimeout(timeout time.Duration) *PcloudVpnconnectionsPeersubnetsGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud vpnconnections peersubnets get params +func (o *PcloudVpnconnectionsPeersubnetsGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud vpnconnections peersubnets get params +func (o *PcloudVpnconnectionsPeersubnetsGetParams) WithContext(ctx context.Context) *PcloudVpnconnectionsPeersubnetsGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud vpnconnections peersubnets get params +func (o *PcloudVpnconnectionsPeersubnetsGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud vpnconnections peersubnets get params +func (o *PcloudVpnconnectionsPeersubnetsGetParams) WithHTTPClient(client *http.Client) *PcloudVpnconnectionsPeersubnetsGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud vpnconnections peersubnets get params +func (o *PcloudVpnconnectionsPeersubnetsGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud vpnconnections peersubnets get params +func (o *PcloudVpnconnectionsPeersubnetsGetParams) WithCloudInstanceID(cloudInstanceID string) *PcloudVpnconnectionsPeersubnetsGetParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud vpnconnections peersubnets get params +func (o *PcloudVpnconnectionsPeersubnetsGetParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithVpnConnectionID adds the vpnConnectionID to the pcloud vpnconnections peersubnets get params +func (o *PcloudVpnconnectionsPeersubnetsGetParams) WithVpnConnectionID(vpnConnectionID string) *PcloudVpnconnectionsPeersubnetsGetParams { + o.SetVpnConnectionID(vpnConnectionID) + return o +} + +// SetVpnConnectionID adds the vpnConnectionId to the pcloud vpnconnections peersubnets get params +func (o *PcloudVpnconnectionsPeersubnetsGetParams) SetVpnConnectionID(vpnConnectionID string) { + o.VpnConnectionID = vpnConnectionID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudVpnconnectionsPeersubnetsGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param vpn_connection_id + if err := r.SetPathParam("vpn_connection_id", o.VpnConnectionID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_peersubnets_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_peersubnets_get_responses.go new file mode 100644 index 00000000000..6f9e64ef18f --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_peersubnets_get_responses.go @@ -0,0 +1,257 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudVpnconnectionsPeersubnetsGetReader is a Reader for the PcloudVpnconnectionsPeersubnetsGet structure. +type PcloudVpnconnectionsPeersubnetsGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudVpnconnectionsPeersubnetsGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudVpnconnectionsPeersubnetsGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudVpnconnectionsPeersubnetsGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudVpnconnectionsPeersubnetsGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewPcloudVpnconnectionsPeersubnetsGetForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudVpnconnectionsPeersubnetsGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudVpnconnectionsPeersubnetsGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudVpnconnectionsPeersubnetsGetOK creates a PcloudVpnconnectionsPeersubnetsGetOK with default headers values +func NewPcloudVpnconnectionsPeersubnetsGetOK() *PcloudVpnconnectionsPeersubnetsGetOK { + return &PcloudVpnconnectionsPeersubnetsGetOK{} +} + +/* PcloudVpnconnectionsPeersubnetsGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudVpnconnectionsPeersubnetsGetOK struct { + Payload *models.PeerSubnets +} + +func (o *PcloudVpnconnectionsPeersubnetsGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/peer-subnets][%d] pcloudVpnconnectionsPeersubnetsGetOK %+v", 200, o.Payload) +} +func (o *PcloudVpnconnectionsPeersubnetsGetOK) GetPayload() *models.PeerSubnets { + return o.Payload +} + +func (o *PcloudVpnconnectionsPeersubnetsGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.PeerSubnets) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsPeersubnetsGetBadRequest creates a PcloudVpnconnectionsPeersubnetsGetBadRequest with default headers values +func NewPcloudVpnconnectionsPeersubnetsGetBadRequest() *PcloudVpnconnectionsPeersubnetsGetBadRequest { + return &PcloudVpnconnectionsPeersubnetsGetBadRequest{} +} + +/* PcloudVpnconnectionsPeersubnetsGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudVpnconnectionsPeersubnetsGetBadRequest struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsPeersubnetsGetBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/peer-subnets][%d] pcloudVpnconnectionsPeersubnetsGetBadRequest %+v", 400, o.Payload) +} +func (o *PcloudVpnconnectionsPeersubnetsGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsPeersubnetsGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsPeersubnetsGetUnauthorized creates a PcloudVpnconnectionsPeersubnetsGetUnauthorized with default headers values +func NewPcloudVpnconnectionsPeersubnetsGetUnauthorized() *PcloudVpnconnectionsPeersubnetsGetUnauthorized { + return &PcloudVpnconnectionsPeersubnetsGetUnauthorized{} +} + +/* PcloudVpnconnectionsPeersubnetsGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudVpnconnectionsPeersubnetsGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsPeersubnetsGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/peer-subnets][%d] pcloudVpnconnectionsPeersubnetsGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudVpnconnectionsPeersubnetsGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsPeersubnetsGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsPeersubnetsGetForbidden creates a PcloudVpnconnectionsPeersubnetsGetForbidden with default headers values +func NewPcloudVpnconnectionsPeersubnetsGetForbidden() *PcloudVpnconnectionsPeersubnetsGetForbidden { + return &PcloudVpnconnectionsPeersubnetsGetForbidden{} +} + +/* PcloudVpnconnectionsPeersubnetsGetForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type PcloudVpnconnectionsPeersubnetsGetForbidden struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsPeersubnetsGetForbidden) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/peer-subnets][%d] pcloudVpnconnectionsPeersubnetsGetForbidden %+v", 403, o.Payload) +} +func (o *PcloudVpnconnectionsPeersubnetsGetForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsPeersubnetsGetForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsPeersubnetsGetNotFound creates a PcloudVpnconnectionsPeersubnetsGetNotFound with default headers values +func NewPcloudVpnconnectionsPeersubnetsGetNotFound() *PcloudVpnconnectionsPeersubnetsGetNotFound { + return &PcloudVpnconnectionsPeersubnetsGetNotFound{} +} + +/* PcloudVpnconnectionsPeersubnetsGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudVpnconnectionsPeersubnetsGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsPeersubnetsGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/peer-subnets][%d] pcloudVpnconnectionsPeersubnetsGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudVpnconnectionsPeersubnetsGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsPeersubnetsGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsPeersubnetsGetInternalServerError creates a PcloudVpnconnectionsPeersubnetsGetInternalServerError with default headers values +func NewPcloudVpnconnectionsPeersubnetsGetInternalServerError() *PcloudVpnconnectionsPeersubnetsGetInternalServerError { + return &PcloudVpnconnectionsPeersubnetsGetInternalServerError{} +} + +/* PcloudVpnconnectionsPeersubnetsGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudVpnconnectionsPeersubnetsGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsPeersubnetsGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/peer-subnets][%d] pcloudVpnconnectionsPeersubnetsGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudVpnconnectionsPeersubnetsGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsPeersubnetsGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_peersubnets_put_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_peersubnets_put_parameters.go new file mode 100644 index 00000000000..0f74fcc1555 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_peersubnets_put_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudVpnconnectionsPeersubnetsPutParams creates a new PcloudVpnconnectionsPeersubnetsPutParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudVpnconnectionsPeersubnetsPutParams() *PcloudVpnconnectionsPeersubnetsPutParams { + return &PcloudVpnconnectionsPeersubnetsPutParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudVpnconnectionsPeersubnetsPutParamsWithTimeout creates a new PcloudVpnconnectionsPeersubnetsPutParams object +// with the ability to set a timeout on a request. +func NewPcloudVpnconnectionsPeersubnetsPutParamsWithTimeout(timeout time.Duration) *PcloudVpnconnectionsPeersubnetsPutParams { + return &PcloudVpnconnectionsPeersubnetsPutParams{ + timeout: timeout, + } +} + +// NewPcloudVpnconnectionsPeersubnetsPutParamsWithContext creates a new PcloudVpnconnectionsPeersubnetsPutParams object +// with the ability to set a context for a request. +func NewPcloudVpnconnectionsPeersubnetsPutParamsWithContext(ctx context.Context) *PcloudVpnconnectionsPeersubnetsPutParams { + return &PcloudVpnconnectionsPeersubnetsPutParams{ + Context: ctx, + } +} + +// NewPcloudVpnconnectionsPeersubnetsPutParamsWithHTTPClient creates a new PcloudVpnconnectionsPeersubnetsPutParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudVpnconnectionsPeersubnetsPutParamsWithHTTPClient(client *http.Client) *PcloudVpnconnectionsPeersubnetsPutParams { + return &PcloudVpnconnectionsPeersubnetsPutParams{ + HTTPClient: client, + } +} + +/* PcloudVpnconnectionsPeersubnetsPutParams contains all the parameters to send to the API endpoint + for the pcloud vpnconnections peersubnets put operation. + + Typically these are written to a http.Request. +*/ +type PcloudVpnconnectionsPeersubnetsPutParams struct { + + /* Body. + + peer subnet to attach + */ + Body *models.PeerSubnetUpdate + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* VpnConnectionID. + + ID of a VPN connection + */ + VpnConnectionID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud vpnconnections peersubnets put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudVpnconnectionsPeersubnetsPutParams) WithDefaults() *PcloudVpnconnectionsPeersubnetsPutParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud vpnconnections peersubnets put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudVpnconnectionsPeersubnetsPutParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud vpnconnections peersubnets put params +func (o *PcloudVpnconnectionsPeersubnetsPutParams) WithTimeout(timeout time.Duration) *PcloudVpnconnectionsPeersubnetsPutParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud vpnconnections peersubnets put params +func (o *PcloudVpnconnectionsPeersubnetsPutParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud vpnconnections peersubnets put params +func (o *PcloudVpnconnectionsPeersubnetsPutParams) WithContext(ctx context.Context) *PcloudVpnconnectionsPeersubnetsPutParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud vpnconnections peersubnets put params +func (o *PcloudVpnconnectionsPeersubnetsPutParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud vpnconnections peersubnets put params +func (o *PcloudVpnconnectionsPeersubnetsPutParams) WithHTTPClient(client *http.Client) *PcloudVpnconnectionsPeersubnetsPutParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud vpnconnections peersubnets put params +func (o *PcloudVpnconnectionsPeersubnetsPutParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud vpnconnections peersubnets put params +func (o *PcloudVpnconnectionsPeersubnetsPutParams) WithBody(body *models.PeerSubnetUpdate) *PcloudVpnconnectionsPeersubnetsPutParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud vpnconnections peersubnets put params +func (o *PcloudVpnconnectionsPeersubnetsPutParams) SetBody(body *models.PeerSubnetUpdate) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud vpnconnections peersubnets put params +func (o *PcloudVpnconnectionsPeersubnetsPutParams) WithCloudInstanceID(cloudInstanceID string) *PcloudVpnconnectionsPeersubnetsPutParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud vpnconnections peersubnets put params +func (o *PcloudVpnconnectionsPeersubnetsPutParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithVpnConnectionID adds the vpnConnectionID to the pcloud vpnconnections peersubnets put params +func (o *PcloudVpnconnectionsPeersubnetsPutParams) WithVpnConnectionID(vpnConnectionID string) *PcloudVpnconnectionsPeersubnetsPutParams { + o.SetVpnConnectionID(vpnConnectionID) + return o +} + +// SetVpnConnectionID adds the vpnConnectionId to the pcloud vpnconnections peersubnets put params +func (o *PcloudVpnconnectionsPeersubnetsPutParams) SetVpnConnectionID(vpnConnectionID string) { + o.VpnConnectionID = vpnConnectionID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudVpnconnectionsPeersubnetsPutParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param vpn_connection_id + if err := r.SetPathParam("vpn_connection_id", o.VpnConnectionID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_peersubnets_put_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_peersubnets_put_responses.go new file mode 100644 index 00000000000..a9967c9a47c --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_peersubnets_put_responses.go @@ -0,0 +1,257 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudVpnconnectionsPeersubnetsPutReader is a Reader for the PcloudVpnconnectionsPeersubnetsPut structure. +type PcloudVpnconnectionsPeersubnetsPutReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudVpnconnectionsPeersubnetsPutReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudVpnconnectionsPeersubnetsPutOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudVpnconnectionsPeersubnetsPutBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudVpnconnectionsPeersubnetsPutUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewPcloudVpnconnectionsPeersubnetsPutForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudVpnconnectionsPeersubnetsPutUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudVpnconnectionsPeersubnetsPutInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudVpnconnectionsPeersubnetsPutOK creates a PcloudVpnconnectionsPeersubnetsPutOK with default headers values +func NewPcloudVpnconnectionsPeersubnetsPutOK() *PcloudVpnconnectionsPeersubnetsPutOK { + return &PcloudVpnconnectionsPeersubnetsPutOK{} +} + +/* PcloudVpnconnectionsPeersubnetsPutOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudVpnconnectionsPeersubnetsPutOK struct { + Payload *models.PeerSubnets +} + +func (o *PcloudVpnconnectionsPeersubnetsPutOK) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/peer-subnets][%d] pcloudVpnconnectionsPeersubnetsPutOK %+v", 200, o.Payload) +} +func (o *PcloudVpnconnectionsPeersubnetsPutOK) GetPayload() *models.PeerSubnets { + return o.Payload +} + +func (o *PcloudVpnconnectionsPeersubnetsPutOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.PeerSubnets) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsPeersubnetsPutBadRequest creates a PcloudVpnconnectionsPeersubnetsPutBadRequest with default headers values +func NewPcloudVpnconnectionsPeersubnetsPutBadRequest() *PcloudVpnconnectionsPeersubnetsPutBadRequest { + return &PcloudVpnconnectionsPeersubnetsPutBadRequest{} +} + +/* PcloudVpnconnectionsPeersubnetsPutBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudVpnconnectionsPeersubnetsPutBadRequest struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsPeersubnetsPutBadRequest) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/peer-subnets][%d] pcloudVpnconnectionsPeersubnetsPutBadRequest %+v", 400, o.Payload) +} +func (o *PcloudVpnconnectionsPeersubnetsPutBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsPeersubnetsPutBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsPeersubnetsPutUnauthorized creates a PcloudVpnconnectionsPeersubnetsPutUnauthorized with default headers values +func NewPcloudVpnconnectionsPeersubnetsPutUnauthorized() *PcloudVpnconnectionsPeersubnetsPutUnauthorized { + return &PcloudVpnconnectionsPeersubnetsPutUnauthorized{} +} + +/* PcloudVpnconnectionsPeersubnetsPutUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudVpnconnectionsPeersubnetsPutUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsPeersubnetsPutUnauthorized) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/peer-subnets][%d] pcloudVpnconnectionsPeersubnetsPutUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudVpnconnectionsPeersubnetsPutUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsPeersubnetsPutUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsPeersubnetsPutForbidden creates a PcloudVpnconnectionsPeersubnetsPutForbidden with default headers values +func NewPcloudVpnconnectionsPeersubnetsPutForbidden() *PcloudVpnconnectionsPeersubnetsPutForbidden { + return &PcloudVpnconnectionsPeersubnetsPutForbidden{} +} + +/* PcloudVpnconnectionsPeersubnetsPutForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type PcloudVpnconnectionsPeersubnetsPutForbidden struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsPeersubnetsPutForbidden) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/peer-subnets][%d] pcloudVpnconnectionsPeersubnetsPutForbidden %+v", 403, o.Payload) +} +func (o *PcloudVpnconnectionsPeersubnetsPutForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsPeersubnetsPutForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsPeersubnetsPutUnprocessableEntity creates a PcloudVpnconnectionsPeersubnetsPutUnprocessableEntity with default headers values +func NewPcloudVpnconnectionsPeersubnetsPutUnprocessableEntity() *PcloudVpnconnectionsPeersubnetsPutUnprocessableEntity { + return &PcloudVpnconnectionsPeersubnetsPutUnprocessableEntity{} +} + +/* PcloudVpnconnectionsPeersubnetsPutUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudVpnconnectionsPeersubnetsPutUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsPeersubnetsPutUnprocessableEntity) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/peer-subnets][%d] pcloudVpnconnectionsPeersubnetsPutUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudVpnconnectionsPeersubnetsPutUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsPeersubnetsPutUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsPeersubnetsPutInternalServerError creates a PcloudVpnconnectionsPeersubnetsPutInternalServerError with default headers values +func NewPcloudVpnconnectionsPeersubnetsPutInternalServerError() *PcloudVpnconnectionsPeersubnetsPutInternalServerError { + return &PcloudVpnconnectionsPeersubnetsPutInternalServerError{} +} + +/* PcloudVpnconnectionsPeersubnetsPutInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudVpnconnectionsPeersubnetsPutInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsPeersubnetsPutInternalServerError) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}/peer-subnets][%d] pcloudVpnconnectionsPeersubnetsPutInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudVpnconnectionsPeersubnetsPutInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsPeersubnetsPutInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_post_parameters.go new file mode 100644 index 00000000000..0c10162117b --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_post_parameters.go @@ -0,0 +1,173 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudVpnconnectionsPostParams creates a new PcloudVpnconnectionsPostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudVpnconnectionsPostParams() *PcloudVpnconnectionsPostParams { + return &PcloudVpnconnectionsPostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudVpnconnectionsPostParamsWithTimeout creates a new PcloudVpnconnectionsPostParams object +// with the ability to set a timeout on a request. +func NewPcloudVpnconnectionsPostParamsWithTimeout(timeout time.Duration) *PcloudVpnconnectionsPostParams { + return &PcloudVpnconnectionsPostParams{ + timeout: timeout, + } +} + +// NewPcloudVpnconnectionsPostParamsWithContext creates a new PcloudVpnconnectionsPostParams object +// with the ability to set a context for a request. +func NewPcloudVpnconnectionsPostParamsWithContext(ctx context.Context) *PcloudVpnconnectionsPostParams { + return &PcloudVpnconnectionsPostParams{ + Context: ctx, + } +} + +// NewPcloudVpnconnectionsPostParamsWithHTTPClient creates a new PcloudVpnconnectionsPostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudVpnconnectionsPostParamsWithHTTPClient(client *http.Client) *PcloudVpnconnectionsPostParams { + return &PcloudVpnconnectionsPostParams{ + HTTPClient: client, + } +} + +/* PcloudVpnconnectionsPostParams contains all the parameters to send to the API endpoint + for the pcloud vpnconnections post operation. + + Typically these are written to a http.Request. +*/ +type PcloudVpnconnectionsPostParams struct { + + /* Body. + + VPN Connection object used for creation + */ + Body *models.VPNConnectionCreate + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud vpnconnections post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudVpnconnectionsPostParams) WithDefaults() *PcloudVpnconnectionsPostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud vpnconnections post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudVpnconnectionsPostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud vpnconnections post params +func (o *PcloudVpnconnectionsPostParams) WithTimeout(timeout time.Duration) *PcloudVpnconnectionsPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud vpnconnections post params +func (o *PcloudVpnconnectionsPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud vpnconnections post params +func (o *PcloudVpnconnectionsPostParams) WithContext(ctx context.Context) *PcloudVpnconnectionsPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud vpnconnections post params +func (o *PcloudVpnconnectionsPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud vpnconnections post params +func (o *PcloudVpnconnectionsPostParams) WithHTTPClient(client *http.Client) *PcloudVpnconnectionsPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud vpnconnections post params +func (o *PcloudVpnconnectionsPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud vpnconnections post params +func (o *PcloudVpnconnectionsPostParams) WithBody(body *models.VPNConnectionCreate) *PcloudVpnconnectionsPostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud vpnconnections post params +func (o *PcloudVpnconnectionsPostParams) SetBody(body *models.VPNConnectionCreate) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud vpnconnections post params +func (o *PcloudVpnconnectionsPostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudVpnconnectionsPostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud vpnconnections post params +func (o *PcloudVpnconnectionsPostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudVpnconnectionsPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_post_responses.go new file mode 100644 index 00000000000..c4f1f0a6181 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_post_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudVpnconnectionsPostReader is a Reader for the PcloudVpnconnectionsPost structure. +type PcloudVpnconnectionsPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudVpnconnectionsPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 202: + result := NewPcloudVpnconnectionsPostAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudVpnconnectionsPostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudVpnconnectionsPostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewPcloudVpnconnectionsPostForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewPcloudVpnconnectionsPostConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudVpnconnectionsPostUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudVpnconnectionsPostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudVpnconnectionsPostAccepted creates a PcloudVpnconnectionsPostAccepted with default headers values +func NewPcloudVpnconnectionsPostAccepted() *PcloudVpnconnectionsPostAccepted { + return &PcloudVpnconnectionsPostAccepted{} +} + +/* PcloudVpnconnectionsPostAccepted describes a response with status code 202, with default header values. + +Accepted +*/ +type PcloudVpnconnectionsPostAccepted struct { + Payload *models.VPNConnectionCreateResponse +} + +func (o *PcloudVpnconnectionsPostAccepted) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections][%d] pcloudVpnconnectionsPostAccepted %+v", 202, o.Payload) +} +func (o *PcloudVpnconnectionsPostAccepted) GetPayload() *models.VPNConnectionCreateResponse { + return o.Payload +} + +func (o *PcloudVpnconnectionsPostAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.VPNConnectionCreateResponse) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsPostBadRequest creates a PcloudVpnconnectionsPostBadRequest with default headers values +func NewPcloudVpnconnectionsPostBadRequest() *PcloudVpnconnectionsPostBadRequest { + return &PcloudVpnconnectionsPostBadRequest{} +} + +/* PcloudVpnconnectionsPostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudVpnconnectionsPostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsPostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections][%d] pcloudVpnconnectionsPostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudVpnconnectionsPostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsPostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsPostUnauthorized creates a PcloudVpnconnectionsPostUnauthorized with default headers values +func NewPcloudVpnconnectionsPostUnauthorized() *PcloudVpnconnectionsPostUnauthorized { + return &PcloudVpnconnectionsPostUnauthorized{} +} + +/* PcloudVpnconnectionsPostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudVpnconnectionsPostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsPostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections][%d] pcloudVpnconnectionsPostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudVpnconnectionsPostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsPostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsPostForbidden creates a PcloudVpnconnectionsPostForbidden with default headers values +func NewPcloudVpnconnectionsPostForbidden() *PcloudVpnconnectionsPostForbidden { + return &PcloudVpnconnectionsPostForbidden{} +} + +/* PcloudVpnconnectionsPostForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type PcloudVpnconnectionsPostForbidden struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsPostForbidden) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections][%d] pcloudVpnconnectionsPostForbidden %+v", 403, o.Payload) +} +func (o *PcloudVpnconnectionsPostForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsPostForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsPostConflict creates a PcloudVpnconnectionsPostConflict with default headers values +func NewPcloudVpnconnectionsPostConflict() *PcloudVpnconnectionsPostConflict { + return &PcloudVpnconnectionsPostConflict{} +} + +/* PcloudVpnconnectionsPostConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type PcloudVpnconnectionsPostConflict struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsPostConflict) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections][%d] pcloudVpnconnectionsPostConflict %+v", 409, o.Payload) +} +func (o *PcloudVpnconnectionsPostConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsPostConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsPostUnprocessableEntity creates a PcloudVpnconnectionsPostUnprocessableEntity with default headers values +func NewPcloudVpnconnectionsPostUnprocessableEntity() *PcloudVpnconnectionsPostUnprocessableEntity { + return &PcloudVpnconnectionsPostUnprocessableEntity{} +} + +/* PcloudVpnconnectionsPostUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudVpnconnectionsPostUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsPostUnprocessableEntity) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections][%d] pcloudVpnconnectionsPostUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudVpnconnectionsPostUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsPostUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsPostInternalServerError creates a PcloudVpnconnectionsPostInternalServerError with default headers values +func NewPcloudVpnconnectionsPostInternalServerError() *PcloudVpnconnectionsPostInternalServerError { + return &PcloudVpnconnectionsPostInternalServerError{} +} + +/* PcloudVpnconnectionsPostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudVpnconnectionsPostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsPostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections][%d] pcloudVpnconnectionsPostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudVpnconnectionsPostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsPostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_put_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_put_parameters.go new file mode 100644 index 00000000000..5775cb00858 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_put_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudVpnconnectionsPutParams creates a new PcloudVpnconnectionsPutParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudVpnconnectionsPutParams() *PcloudVpnconnectionsPutParams { + return &PcloudVpnconnectionsPutParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudVpnconnectionsPutParamsWithTimeout creates a new PcloudVpnconnectionsPutParams object +// with the ability to set a timeout on a request. +func NewPcloudVpnconnectionsPutParamsWithTimeout(timeout time.Duration) *PcloudVpnconnectionsPutParams { + return &PcloudVpnconnectionsPutParams{ + timeout: timeout, + } +} + +// NewPcloudVpnconnectionsPutParamsWithContext creates a new PcloudVpnconnectionsPutParams object +// with the ability to set a context for a request. +func NewPcloudVpnconnectionsPutParamsWithContext(ctx context.Context) *PcloudVpnconnectionsPutParams { + return &PcloudVpnconnectionsPutParams{ + Context: ctx, + } +} + +// NewPcloudVpnconnectionsPutParamsWithHTTPClient creates a new PcloudVpnconnectionsPutParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudVpnconnectionsPutParamsWithHTTPClient(client *http.Client) *PcloudVpnconnectionsPutParams { + return &PcloudVpnconnectionsPutParams{ + HTTPClient: client, + } +} + +/* PcloudVpnconnectionsPutParams contains all the parameters to send to the API endpoint + for the pcloud vpnconnections put operation. + + Typically these are written to a http.Request. +*/ +type PcloudVpnconnectionsPutParams struct { + + /* Body. + + VPN Connection object used for update + */ + Body *models.VPNConnectionUpdate + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* VpnConnectionID. + + ID of a VPN connection + */ + VpnConnectionID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud vpnconnections put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudVpnconnectionsPutParams) WithDefaults() *PcloudVpnconnectionsPutParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud vpnconnections put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudVpnconnectionsPutParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud vpnconnections put params +func (o *PcloudVpnconnectionsPutParams) WithTimeout(timeout time.Duration) *PcloudVpnconnectionsPutParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud vpnconnections put params +func (o *PcloudVpnconnectionsPutParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud vpnconnections put params +func (o *PcloudVpnconnectionsPutParams) WithContext(ctx context.Context) *PcloudVpnconnectionsPutParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud vpnconnections put params +func (o *PcloudVpnconnectionsPutParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud vpnconnections put params +func (o *PcloudVpnconnectionsPutParams) WithHTTPClient(client *http.Client) *PcloudVpnconnectionsPutParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud vpnconnections put params +func (o *PcloudVpnconnectionsPutParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud vpnconnections put params +func (o *PcloudVpnconnectionsPutParams) WithBody(body *models.VPNConnectionUpdate) *PcloudVpnconnectionsPutParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud vpnconnections put params +func (o *PcloudVpnconnectionsPutParams) SetBody(body *models.VPNConnectionUpdate) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud vpnconnections put params +func (o *PcloudVpnconnectionsPutParams) WithCloudInstanceID(cloudInstanceID string) *PcloudVpnconnectionsPutParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud vpnconnections put params +func (o *PcloudVpnconnectionsPutParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithVpnConnectionID adds the vpnConnectionID to the pcloud vpnconnections put params +func (o *PcloudVpnconnectionsPutParams) WithVpnConnectionID(vpnConnectionID string) *PcloudVpnconnectionsPutParams { + o.SetVpnConnectionID(vpnConnectionID) + return o +} + +// SetVpnConnectionID adds the vpnConnectionId to the pcloud vpnconnections put params +func (o *PcloudVpnconnectionsPutParams) SetVpnConnectionID(vpnConnectionID string) { + o.VpnConnectionID = vpnConnectionID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudVpnconnectionsPutParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param vpn_connection_id + if err := r.SetPathParam("vpn_connection_id", o.VpnConnectionID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_put_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_put_responses.go new file mode 100644 index 00000000000..2e2026de05c --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections/pcloud_vpnconnections_put_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_connections + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudVpnconnectionsPutReader is a Reader for the PcloudVpnconnectionsPut structure. +type PcloudVpnconnectionsPutReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudVpnconnectionsPutReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudVpnconnectionsPutOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudVpnconnectionsPutBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudVpnconnectionsPutUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewPcloudVpnconnectionsPutForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudVpnconnectionsPutNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudVpnconnectionsPutUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudVpnconnectionsPutInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudVpnconnectionsPutOK creates a PcloudVpnconnectionsPutOK with default headers values +func NewPcloudVpnconnectionsPutOK() *PcloudVpnconnectionsPutOK { + return &PcloudVpnconnectionsPutOK{} +} + +/* PcloudVpnconnectionsPutOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudVpnconnectionsPutOK struct { + Payload *models.VPNConnection +} + +func (o *PcloudVpnconnectionsPutOK) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}][%d] pcloudVpnconnectionsPutOK %+v", 200, o.Payload) +} +func (o *PcloudVpnconnectionsPutOK) GetPayload() *models.VPNConnection { + return o.Payload +} + +func (o *PcloudVpnconnectionsPutOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.VPNConnection) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsPutBadRequest creates a PcloudVpnconnectionsPutBadRequest with default headers values +func NewPcloudVpnconnectionsPutBadRequest() *PcloudVpnconnectionsPutBadRequest { + return &PcloudVpnconnectionsPutBadRequest{} +} + +/* PcloudVpnconnectionsPutBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudVpnconnectionsPutBadRequest struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsPutBadRequest) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}][%d] pcloudVpnconnectionsPutBadRequest %+v", 400, o.Payload) +} +func (o *PcloudVpnconnectionsPutBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsPutBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsPutUnauthorized creates a PcloudVpnconnectionsPutUnauthorized with default headers values +func NewPcloudVpnconnectionsPutUnauthorized() *PcloudVpnconnectionsPutUnauthorized { + return &PcloudVpnconnectionsPutUnauthorized{} +} + +/* PcloudVpnconnectionsPutUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudVpnconnectionsPutUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsPutUnauthorized) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}][%d] pcloudVpnconnectionsPutUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudVpnconnectionsPutUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsPutUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsPutForbidden creates a PcloudVpnconnectionsPutForbidden with default headers values +func NewPcloudVpnconnectionsPutForbidden() *PcloudVpnconnectionsPutForbidden { + return &PcloudVpnconnectionsPutForbidden{} +} + +/* PcloudVpnconnectionsPutForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type PcloudVpnconnectionsPutForbidden struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsPutForbidden) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}][%d] pcloudVpnconnectionsPutForbidden %+v", 403, o.Payload) +} +func (o *PcloudVpnconnectionsPutForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsPutForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsPutNotFound creates a PcloudVpnconnectionsPutNotFound with default headers values +func NewPcloudVpnconnectionsPutNotFound() *PcloudVpnconnectionsPutNotFound { + return &PcloudVpnconnectionsPutNotFound{} +} + +/* PcloudVpnconnectionsPutNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudVpnconnectionsPutNotFound struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsPutNotFound) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}][%d] pcloudVpnconnectionsPutNotFound %+v", 404, o.Payload) +} +func (o *PcloudVpnconnectionsPutNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsPutNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsPutUnprocessableEntity creates a PcloudVpnconnectionsPutUnprocessableEntity with default headers values +func NewPcloudVpnconnectionsPutUnprocessableEntity() *PcloudVpnconnectionsPutUnprocessableEntity { + return &PcloudVpnconnectionsPutUnprocessableEntity{} +} + +/* PcloudVpnconnectionsPutUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudVpnconnectionsPutUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsPutUnprocessableEntity) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}][%d] pcloudVpnconnectionsPutUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudVpnconnectionsPutUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsPutUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVpnconnectionsPutInternalServerError creates a PcloudVpnconnectionsPutInternalServerError with default headers values +func NewPcloudVpnconnectionsPutInternalServerError() *PcloudVpnconnectionsPutInternalServerError { + return &PcloudVpnconnectionsPutInternalServerError{} +} + +/* PcloudVpnconnectionsPutInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudVpnconnectionsPutInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudVpnconnectionsPutInternalServerError) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/vpn-connections/{vpn_connection_id}][%d] pcloudVpnconnectionsPutInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudVpnconnectionsPutInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVpnconnectionsPutInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/p_cloudvpn_policies_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/p_cloudvpn_policies_client.go new file mode 100644 index 00000000000..677be4f2fbb --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/p_cloudvpn_policies_client.go @@ -0,0 +1,469 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_policies + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new p cloud v p n policies API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for p cloud v p n policies API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + PcloudIkepoliciesDelete(params *PcloudIkepoliciesDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudIkepoliciesDeleteOK, error) + + PcloudIkepoliciesGet(params *PcloudIkepoliciesGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudIkepoliciesGetOK, error) + + PcloudIkepoliciesGetall(params *PcloudIkepoliciesGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudIkepoliciesGetallOK, error) + + PcloudIkepoliciesPost(params *PcloudIkepoliciesPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudIkepoliciesPostOK, error) + + PcloudIkepoliciesPut(params *PcloudIkepoliciesPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudIkepoliciesPutOK, error) + + PcloudIpsecpoliciesDelete(params *PcloudIpsecpoliciesDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudIpsecpoliciesDeleteOK, error) + + PcloudIpsecpoliciesGet(params *PcloudIpsecpoliciesGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudIpsecpoliciesGetOK, error) + + PcloudIpsecpoliciesGetall(params *PcloudIpsecpoliciesGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudIpsecpoliciesGetallOK, error) + + PcloudIpsecpoliciesPost(params *PcloudIpsecpoliciesPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudIpsecpoliciesPostOK, error) + + PcloudIpsecpoliciesPut(params *PcloudIpsecpoliciesPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudIpsecpoliciesPutOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + PcloudIkepoliciesDelete deletes i k e policy + + Delete an IKE Policy (by its unique identifier) +*/ +func (a *Client) PcloudIkepoliciesDelete(params *PcloudIkepoliciesDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudIkepoliciesDeleteOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudIkepoliciesDeleteParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.ikepolicies.delete", + Method: "DELETE", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies/{ike_policy_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudIkepoliciesDeleteReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudIkepoliciesDeleteOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.ikepolicies.delete: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudIkepoliciesGet gets the specified i k e policy + + Get an IKE Policy (by its unique identifier) +*/ +func (a *Client) PcloudIkepoliciesGet(params *PcloudIkepoliciesGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudIkepoliciesGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudIkepoliciesGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.ikepolicies.get", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies/{ike_policy_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudIkepoliciesGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudIkepoliciesGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.ikepolicies.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudIkepoliciesGetall gets all i k e policies + + List all IKE Policies with all attributes +*/ +func (a *Client) PcloudIkepoliciesGetall(params *PcloudIkepoliciesGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudIkepoliciesGetallOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudIkepoliciesGetallParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.ikepolicies.getall", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudIkepoliciesGetallReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudIkepoliciesGetallOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.ikepolicies.getall: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudIkepoliciesPost adds i k e policy + + Add a new IKE Policy +*/ +func (a *Client) PcloudIkepoliciesPost(params *PcloudIkepoliciesPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudIkepoliciesPostOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudIkepoliciesPostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.ikepolicies.post", + Method: "POST", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudIkepoliciesPostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudIkepoliciesPostOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.ikepolicies.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudIkepoliciesPut updates i k e policy + + update an IKE Policy (by its unique identifier) +*/ +func (a *Client) PcloudIkepoliciesPut(params *PcloudIkepoliciesPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudIkepoliciesPutOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudIkepoliciesPutParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.ikepolicies.put", + Method: "PUT", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies/{ike_policy_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudIkepoliciesPutReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudIkepoliciesPutOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.ikepolicies.put: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudIpsecpoliciesDelete deletes IP sec policy + + Delete an IPSec Policy (by its unique identifier) +*/ +func (a *Client) PcloudIpsecpoliciesDelete(params *PcloudIpsecpoliciesDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudIpsecpoliciesDeleteOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudIpsecpoliciesDeleteParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.ipsecpolicies.delete", + Method: "DELETE", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies/{ipsec_policy_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudIpsecpoliciesDeleteReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudIpsecpoliciesDeleteOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.ipsecpolicies.delete: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudIpsecpoliciesGet gets the specified IP sec policy + + Get an IPSec Policy (by its unique identifier) +*/ +func (a *Client) PcloudIpsecpoliciesGet(params *PcloudIpsecpoliciesGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudIpsecpoliciesGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudIpsecpoliciesGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.ipsecpolicies.get", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies/{ipsec_policy_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudIpsecpoliciesGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudIpsecpoliciesGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.ipsecpolicies.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudIpsecpoliciesGetall gets all IP sec policies + + Get all IPSec Policies with all their attributes +*/ +func (a *Client) PcloudIpsecpoliciesGetall(params *PcloudIpsecpoliciesGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudIpsecpoliciesGetallOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudIpsecpoliciesGetallParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.ipsecpolicies.getall", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudIpsecpoliciesGetallReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudIpsecpoliciesGetallOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.ipsecpolicies.getall: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudIpsecpoliciesPost adds IP sec policy + + Add a new IPSec Policy +*/ +func (a *Client) PcloudIpsecpoliciesPost(params *PcloudIpsecpoliciesPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudIpsecpoliciesPostOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudIpsecpoliciesPostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.ipsecpolicies.post", + Method: "POST", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudIpsecpoliciesPostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudIpsecpoliciesPostOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.ipsecpolicies.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudIpsecpoliciesPut updates IP sec policy + + update an IPSec Policy +*/ +func (a *Client) PcloudIpsecpoliciesPut(params *PcloudIpsecpoliciesPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudIpsecpoliciesPutOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudIpsecpoliciesPutParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.ipsecpolicies.put", + Method: "PUT", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies/{ipsec_policy_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudIpsecpoliciesPutReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudIpsecpoliciesPutOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.ipsecpolicies.put: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ikepolicies_delete_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ikepolicies_delete_parameters.go new file mode 100644 index 00000000000..7463101da64 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ikepolicies_delete_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_policies + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudIkepoliciesDeleteParams creates a new PcloudIkepoliciesDeleteParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudIkepoliciesDeleteParams() *PcloudIkepoliciesDeleteParams { + return &PcloudIkepoliciesDeleteParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudIkepoliciesDeleteParamsWithTimeout creates a new PcloudIkepoliciesDeleteParams object +// with the ability to set a timeout on a request. +func NewPcloudIkepoliciesDeleteParamsWithTimeout(timeout time.Duration) *PcloudIkepoliciesDeleteParams { + return &PcloudIkepoliciesDeleteParams{ + timeout: timeout, + } +} + +// NewPcloudIkepoliciesDeleteParamsWithContext creates a new PcloudIkepoliciesDeleteParams object +// with the ability to set a context for a request. +func NewPcloudIkepoliciesDeleteParamsWithContext(ctx context.Context) *PcloudIkepoliciesDeleteParams { + return &PcloudIkepoliciesDeleteParams{ + Context: ctx, + } +} + +// NewPcloudIkepoliciesDeleteParamsWithHTTPClient creates a new PcloudIkepoliciesDeleteParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudIkepoliciesDeleteParamsWithHTTPClient(client *http.Client) *PcloudIkepoliciesDeleteParams { + return &PcloudIkepoliciesDeleteParams{ + HTTPClient: client, + } +} + +/* PcloudIkepoliciesDeleteParams contains all the parameters to send to the API endpoint + for the pcloud ikepolicies delete operation. + + Typically these are written to a http.Request. +*/ +type PcloudIkepoliciesDeleteParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* IkePolicyID. + + ID of a IKE Policy + */ + IkePolicyID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud ikepolicies delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudIkepoliciesDeleteParams) WithDefaults() *PcloudIkepoliciesDeleteParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud ikepolicies delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudIkepoliciesDeleteParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud ikepolicies delete params +func (o *PcloudIkepoliciesDeleteParams) WithTimeout(timeout time.Duration) *PcloudIkepoliciesDeleteParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud ikepolicies delete params +func (o *PcloudIkepoliciesDeleteParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud ikepolicies delete params +func (o *PcloudIkepoliciesDeleteParams) WithContext(ctx context.Context) *PcloudIkepoliciesDeleteParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud ikepolicies delete params +func (o *PcloudIkepoliciesDeleteParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud ikepolicies delete params +func (o *PcloudIkepoliciesDeleteParams) WithHTTPClient(client *http.Client) *PcloudIkepoliciesDeleteParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud ikepolicies delete params +func (o *PcloudIkepoliciesDeleteParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud ikepolicies delete params +func (o *PcloudIkepoliciesDeleteParams) WithCloudInstanceID(cloudInstanceID string) *PcloudIkepoliciesDeleteParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud ikepolicies delete params +func (o *PcloudIkepoliciesDeleteParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithIkePolicyID adds the ikePolicyID to the pcloud ikepolicies delete params +func (o *PcloudIkepoliciesDeleteParams) WithIkePolicyID(ikePolicyID string) *PcloudIkepoliciesDeleteParams { + o.SetIkePolicyID(ikePolicyID) + return o +} + +// SetIkePolicyID adds the ikePolicyId to the pcloud ikepolicies delete params +func (o *PcloudIkepoliciesDeleteParams) SetIkePolicyID(ikePolicyID string) { + o.IkePolicyID = ikePolicyID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudIkepoliciesDeleteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param ike_policy_id + if err := r.SetPathParam("ike_policy_id", o.IkePolicyID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ikepolicies_delete_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ikepolicies_delete_responses.go new file mode 100644 index 00000000000..6e717941063 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ikepolicies_delete_responses.go @@ -0,0 +1,255 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_policies + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudIkepoliciesDeleteReader is a Reader for the PcloudIkepoliciesDelete structure. +type PcloudIkepoliciesDeleteReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudIkepoliciesDeleteReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudIkepoliciesDeleteOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudIkepoliciesDeleteBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudIkepoliciesDeleteUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewPcloudIkepoliciesDeleteForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudIkepoliciesDeleteNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudIkepoliciesDeleteInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudIkepoliciesDeleteOK creates a PcloudIkepoliciesDeleteOK with default headers values +func NewPcloudIkepoliciesDeleteOK() *PcloudIkepoliciesDeleteOK { + return &PcloudIkepoliciesDeleteOK{} +} + +/* PcloudIkepoliciesDeleteOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudIkepoliciesDeleteOK struct { + Payload models.Object +} + +func (o *PcloudIkepoliciesDeleteOK) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies/{ike_policy_id}][%d] pcloudIkepoliciesDeleteOK %+v", 200, o.Payload) +} +func (o *PcloudIkepoliciesDeleteOK) GetPayload() models.Object { + return o.Payload +} + +func (o *PcloudIkepoliciesDeleteOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIkepoliciesDeleteBadRequest creates a PcloudIkepoliciesDeleteBadRequest with default headers values +func NewPcloudIkepoliciesDeleteBadRequest() *PcloudIkepoliciesDeleteBadRequest { + return &PcloudIkepoliciesDeleteBadRequest{} +} + +/* PcloudIkepoliciesDeleteBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudIkepoliciesDeleteBadRequest struct { + Payload *models.Error +} + +func (o *PcloudIkepoliciesDeleteBadRequest) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies/{ike_policy_id}][%d] pcloudIkepoliciesDeleteBadRequest %+v", 400, o.Payload) +} +func (o *PcloudIkepoliciesDeleteBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIkepoliciesDeleteBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIkepoliciesDeleteUnauthorized creates a PcloudIkepoliciesDeleteUnauthorized with default headers values +func NewPcloudIkepoliciesDeleteUnauthorized() *PcloudIkepoliciesDeleteUnauthorized { + return &PcloudIkepoliciesDeleteUnauthorized{} +} + +/* PcloudIkepoliciesDeleteUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudIkepoliciesDeleteUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudIkepoliciesDeleteUnauthorized) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies/{ike_policy_id}][%d] pcloudIkepoliciesDeleteUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudIkepoliciesDeleteUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIkepoliciesDeleteUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIkepoliciesDeleteForbidden creates a PcloudIkepoliciesDeleteForbidden with default headers values +func NewPcloudIkepoliciesDeleteForbidden() *PcloudIkepoliciesDeleteForbidden { + return &PcloudIkepoliciesDeleteForbidden{} +} + +/* PcloudIkepoliciesDeleteForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type PcloudIkepoliciesDeleteForbidden struct { + Payload *models.Error +} + +func (o *PcloudIkepoliciesDeleteForbidden) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies/{ike_policy_id}][%d] pcloudIkepoliciesDeleteForbidden %+v", 403, o.Payload) +} +func (o *PcloudIkepoliciesDeleteForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIkepoliciesDeleteForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIkepoliciesDeleteNotFound creates a PcloudIkepoliciesDeleteNotFound with default headers values +func NewPcloudIkepoliciesDeleteNotFound() *PcloudIkepoliciesDeleteNotFound { + return &PcloudIkepoliciesDeleteNotFound{} +} + +/* PcloudIkepoliciesDeleteNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudIkepoliciesDeleteNotFound struct { + Payload *models.Error +} + +func (o *PcloudIkepoliciesDeleteNotFound) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies/{ike_policy_id}][%d] pcloudIkepoliciesDeleteNotFound %+v", 404, o.Payload) +} +func (o *PcloudIkepoliciesDeleteNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIkepoliciesDeleteNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIkepoliciesDeleteInternalServerError creates a PcloudIkepoliciesDeleteInternalServerError with default headers values +func NewPcloudIkepoliciesDeleteInternalServerError() *PcloudIkepoliciesDeleteInternalServerError { + return &PcloudIkepoliciesDeleteInternalServerError{} +} + +/* PcloudIkepoliciesDeleteInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudIkepoliciesDeleteInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudIkepoliciesDeleteInternalServerError) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies/{ike_policy_id}][%d] pcloudIkepoliciesDeleteInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudIkepoliciesDeleteInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIkepoliciesDeleteInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ikepolicies_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ikepolicies_get_parameters.go new file mode 100644 index 00000000000..9a0318cff3d --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ikepolicies_get_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_policies + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudIkepoliciesGetParams creates a new PcloudIkepoliciesGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudIkepoliciesGetParams() *PcloudIkepoliciesGetParams { + return &PcloudIkepoliciesGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudIkepoliciesGetParamsWithTimeout creates a new PcloudIkepoliciesGetParams object +// with the ability to set a timeout on a request. +func NewPcloudIkepoliciesGetParamsWithTimeout(timeout time.Duration) *PcloudIkepoliciesGetParams { + return &PcloudIkepoliciesGetParams{ + timeout: timeout, + } +} + +// NewPcloudIkepoliciesGetParamsWithContext creates a new PcloudIkepoliciesGetParams object +// with the ability to set a context for a request. +func NewPcloudIkepoliciesGetParamsWithContext(ctx context.Context) *PcloudIkepoliciesGetParams { + return &PcloudIkepoliciesGetParams{ + Context: ctx, + } +} + +// NewPcloudIkepoliciesGetParamsWithHTTPClient creates a new PcloudIkepoliciesGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudIkepoliciesGetParamsWithHTTPClient(client *http.Client) *PcloudIkepoliciesGetParams { + return &PcloudIkepoliciesGetParams{ + HTTPClient: client, + } +} + +/* PcloudIkepoliciesGetParams contains all the parameters to send to the API endpoint + for the pcloud ikepolicies get operation. + + Typically these are written to a http.Request. +*/ +type PcloudIkepoliciesGetParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* IkePolicyID. + + ID of a IKE Policy + */ + IkePolicyID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud ikepolicies get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudIkepoliciesGetParams) WithDefaults() *PcloudIkepoliciesGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud ikepolicies get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudIkepoliciesGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud ikepolicies get params +func (o *PcloudIkepoliciesGetParams) WithTimeout(timeout time.Duration) *PcloudIkepoliciesGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud ikepolicies get params +func (o *PcloudIkepoliciesGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud ikepolicies get params +func (o *PcloudIkepoliciesGetParams) WithContext(ctx context.Context) *PcloudIkepoliciesGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud ikepolicies get params +func (o *PcloudIkepoliciesGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud ikepolicies get params +func (o *PcloudIkepoliciesGetParams) WithHTTPClient(client *http.Client) *PcloudIkepoliciesGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud ikepolicies get params +func (o *PcloudIkepoliciesGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud ikepolicies get params +func (o *PcloudIkepoliciesGetParams) WithCloudInstanceID(cloudInstanceID string) *PcloudIkepoliciesGetParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud ikepolicies get params +func (o *PcloudIkepoliciesGetParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithIkePolicyID adds the ikePolicyID to the pcloud ikepolicies get params +func (o *PcloudIkepoliciesGetParams) WithIkePolicyID(ikePolicyID string) *PcloudIkepoliciesGetParams { + o.SetIkePolicyID(ikePolicyID) + return o +} + +// SetIkePolicyID adds the ikePolicyId to the pcloud ikepolicies get params +func (o *PcloudIkepoliciesGetParams) SetIkePolicyID(ikePolicyID string) { + o.IkePolicyID = ikePolicyID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudIkepoliciesGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param ike_policy_id + if err := r.SetPathParam("ike_policy_id", o.IkePolicyID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ikepolicies_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ikepolicies_get_responses.go new file mode 100644 index 00000000000..d6d3b799c0f --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ikepolicies_get_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_policies + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudIkepoliciesGetReader is a Reader for the PcloudIkepoliciesGet structure. +type PcloudIkepoliciesGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudIkepoliciesGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudIkepoliciesGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudIkepoliciesGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudIkepoliciesGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewPcloudIkepoliciesGetForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudIkepoliciesGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudIkepoliciesGetUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudIkepoliciesGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudIkepoliciesGetOK creates a PcloudIkepoliciesGetOK with default headers values +func NewPcloudIkepoliciesGetOK() *PcloudIkepoliciesGetOK { + return &PcloudIkepoliciesGetOK{} +} + +/* PcloudIkepoliciesGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudIkepoliciesGetOK struct { + Payload *models.IKEPolicy +} + +func (o *PcloudIkepoliciesGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies/{ike_policy_id}][%d] pcloudIkepoliciesGetOK %+v", 200, o.Payload) +} +func (o *PcloudIkepoliciesGetOK) GetPayload() *models.IKEPolicy { + return o.Payload +} + +func (o *PcloudIkepoliciesGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.IKEPolicy) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIkepoliciesGetBadRequest creates a PcloudIkepoliciesGetBadRequest with default headers values +func NewPcloudIkepoliciesGetBadRequest() *PcloudIkepoliciesGetBadRequest { + return &PcloudIkepoliciesGetBadRequest{} +} + +/* PcloudIkepoliciesGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudIkepoliciesGetBadRequest struct { + Payload *models.Error +} + +func (o *PcloudIkepoliciesGetBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies/{ike_policy_id}][%d] pcloudIkepoliciesGetBadRequest %+v", 400, o.Payload) +} +func (o *PcloudIkepoliciesGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIkepoliciesGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIkepoliciesGetUnauthorized creates a PcloudIkepoliciesGetUnauthorized with default headers values +func NewPcloudIkepoliciesGetUnauthorized() *PcloudIkepoliciesGetUnauthorized { + return &PcloudIkepoliciesGetUnauthorized{} +} + +/* PcloudIkepoliciesGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudIkepoliciesGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudIkepoliciesGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies/{ike_policy_id}][%d] pcloudIkepoliciesGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudIkepoliciesGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIkepoliciesGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIkepoliciesGetForbidden creates a PcloudIkepoliciesGetForbidden with default headers values +func NewPcloudIkepoliciesGetForbidden() *PcloudIkepoliciesGetForbidden { + return &PcloudIkepoliciesGetForbidden{} +} + +/* PcloudIkepoliciesGetForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type PcloudIkepoliciesGetForbidden struct { + Payload *models.Error +} + +func (o *PcloudIkepoliciesGetForbidden) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies/{ike_policy_id}][%d] pcloudIkepoliciesGetForbidden %+v", 403, o.Payload) +} +func (o *PcloudIkepoliciesGetForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIkepoliciesGetForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIkepoliciesGetNotFound creates a PcloudIkepoliciesGetNotFound with default headers values +func NewPcloudIkepoliciesGetNotFound() *PcloudIkepoliciesGetNotFound { + return &PcloudIkepoliciesGetNotFound{} +} + +/* PcloudIkepoliciesGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudIkepoliciesGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudIkepoliciesGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies/{ike_policy_id}][%d] pcloudIkepoliciesGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudIkepoliciesGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIkepoliciesGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIkepoliciesGetUnprocessableEntity creates a PcloudIkepoliciesGetUnprocessableEntity with default headers values +func NewPcloudIkepoliciesGetUnprocessableEntity() *PcloudIkepoliciesGetUnprocessableEntity { + return &PcloudIkepoliciesGetUnprocessableEntity{} +} + +/* PcloudIkepoliciesGetUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudIkepoliciesGetUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudIkepoliciesGetUnprocessableEntity) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies/{ike_policy_id}][%d] pcloudIkepoliciesGetUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudIkepoliciesGetUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIkepoliciesGetUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIkepoliciesGetInternalServerError creates a PcloudIkepoliciesGetInternalServerError with default headers values +func NewPcloudIkepoliciesGetInternalServerError() *PcloudIkepoliciesGetInternalServerError { + return &PcloudIkepoliciesGetInternalServerError{} +} + +/* PcloudIkepoliciesGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudIkepoliciesGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudIkepoliciesGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies/{ike_policy_id}][%d] pcloudIkepoliciesGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudIkepoliciesGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIkepoliciesGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ikepolicies_getall_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ikepolicies_getall_parameters.go new file mode 100644 index 00000000000..c83d29a40df --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ikepolicies_getall_parameters.go @@ -0,0 +1,149 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_policies + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudIkepoliciesGetallParams creates a new PcloudIkepoliciesGetallParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudIkepoliciesGetallParams() *PcloudIkepoliciesGetallParams { + return &PcloudIkepoliciesGetallParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudIkepoliciesGetallParamsWithTimeout creates a new PcloudIkepoliciesGetallParams object +// with the ability to set a timeout on a request. +func NewPcloudIkepoliciesGetallParamsWithTimeout(timeout time.Duration) *PcloudIkepoliciesGetallParams { + return &PcloudIkepoliciesGetallParams{ + timeout: timeout, + } +} + +// NewPcloudIkepoliciesGetallParamsWithContext creates a new PcloudIkepoliciesGetallParams object +// with the ability to set a context for a request. +func NewPcloudIkepoliciesGetallParamsWithContext(ctx context.Context) *PcloudIkepoliciesGetallParams { + return &PcloudIkepoliciesGetallParams{ + Context: ctx, + } +} + +// NewPcloudIkepoliciesGetallParamsWithHTTPClient creates a new PcloudIkepoliciesGetallParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudIkepoliciesGetallParamsWithHTTPClient(client *http.Client) *PcloudIkepoliciesGetallParams { + return &PcloudIkepoliciesGetallParams{ + HTTPClient: client, + } +} + +/* PcloudIkepoliciesGetallParams contains all the parameters to send to the API endpoint + for the pcloud ikepolicies getall operation. + + Typically these are written to a http.Request. +*/ +type PcloudIkepoliciesGetallParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud ikepolicies getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudIkepoliciesGetallParams) WithDefaults() *PcloudIkepoliciesGetallParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud ikepolicies getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudIkepoliciesGetallParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud ikepolicies getall params +func (o *PcloudIkepoliciesGetallParams) WithTimeout(timeout time.Duration) *PcloudIkepoliciesGetallParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud ikepolicies getall params +func (o *PcloudIkepoliciesGetallParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud ikepolicies getall params +func (o *PcloudIkepoliciesGetallParams) WithContext(ctx context.Context) *PcloudIkepoliciesGetallParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud ikepolicies getall params +func (o *PcloudIkepoliciesGetallParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud ikepolicies getall params +func (o *PcloudIkepoliciesGetallParams) WithHTTPClient(client *http.Client) *PcloudIkepoliciesGetallParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud ikepolicies getall params +func (o *PcloudIkepoliciesGetallParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud ikepolicies getall params +func (o *PcloudIkepoliciesGetallParams) WithCloudInstanceID(cloudInstanceID string) *PcloudIkepoliciesGetallParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud ikepolicies getall params +func (o *PcloudIkepoliciesGetallParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudIkepoliciesGetallParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ikepolicies_getall_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ikepolicies_getall_responses.go new file mode 100644 index 00000000000..8286d8f0ba2 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ikepolicies_getall_responses.go @@ -0,0 +1,257 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_policies + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudIkepoliciesGetallReader is a Reader for the PcloudIkepoliciesGetall structure. +type PcloudIkepoliciesGetallReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudIkepoliciesGetallReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudIkepoliciesGetallOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudIkepoliciesGetallBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudIkepoliciesGetallUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewPcloudIkepoliciesGetallForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudIkepoliciesGetallNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudIkepoliciesGetallInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudIkepoliciesGetallOK creates a PcloudIkepoliciesGetallOK with default headers values +func NewPcloudIkepoliciesGetallOK() *PcloudIkepoliciesGetallOK { + return &PcloudIkepoliciesGetallOK{} +} + +/* PcloudIkepoliciesGetallOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudIkepoliciesGetallOK struct { + Payload *models.IKEPolicies +} + +func (o *PcloudIkepoliciesGetallOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies][%d] pcloudIkepoliciesGetallOK %+v", 200, o.Payload) +} +func (o *PcloudIkepoliciesGetallOK) GetPayload() *models.IKEPolicies { + return o.Payload +} + +func (o *PcloudIkepoliciesGetallOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.IKEPolicies) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIkepoliciesGetallBadRequest creates a PcloudIkepoliciesGetallBadRequest with default headers values +func NewPcloudIkepoliciesGetallBadRequest() *PcloudIkepoliciesGetallBadRequest { + return &PcloudIkepoliciesGetallBadRequest{} +} + +/* PcloudIkepoliciesGetallBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudIkepoliciesGetallBadRequest struct { + Payload *models.Error +} + +func (o *PcloudIkepoliciesGetallBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies][%d] pcloudIkepoliciesGetallBadRequest %+v", 400, o.Payload) +} +func (o *PcloudIkepoliciesGetallBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIkepoliciesGetallBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIkepoliciesGetallUnauthorized creates a PcloudIkepoliciesGetallUnauthorized with default headers values +func NewPcloudIkepoliciesGetallUnauthorized() *PcloudIkepoliciesGetallUnauthorized { + return &PcloudIkepoliciesGetallUnauthorized{} +} + +/* PcloudIkepoliciesGetallUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudIkepoliciesGetallUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudIkepoliciesGetallUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies][%d] pcloudIkepoliciesGetallUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudIkepoliciesGetallUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIkepoliciesGetallUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIkepoliciesGetallForbidden creates a PcloudIkepoliciesGetallForbidden with default headers values +func NewPcloudIkepoliciesGetallForbidden() *PcloudIkepoliciesGetallForbidden { + return &PcloudIkepoliciesGetallForbidden{} +} + +/* PcloudIkepoliciesGetallForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type PcloudIkepoliciesGetallForbidden struct { + Payload *models.Error +} + +func (o *PcloudIkepoliciesGetallForbidden) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies][%d] pcloudIkepoliciesGetallForbidden %+v", 403, o.Payload) +} +func (o *PcloudIkepoliciesGetallForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIkepoliciesGetallForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIkepoliciesGetallNotFound creates a PcloudIkepoliciesGetallNotFound with default headers values +func NewPcloudIkepoliciesGetallNotFound() *PcloudIkepoliciesGetallNotFound { + return &PcloudIkepoliciesGetallNotFound{} +} + +/* PcloudIkepoliciesGetallNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudIkepoliciesGetallNotFound struct { + Payload *models.Error +} + +func (o *PcloudIkepoliciesGetallNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies][%d] pcloudIkepoliciesGetallNotFound %+v", 404, o.Payload) +} +func (o *PcloudIkepoliciesGetallNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIkepoliciesGetallNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIkepoliciesGetallInternalServerError creates a PcloudIkepoliciesGetallInternalServerError with default headers values +func NewPcloudIkepoliciesGetallInternalServerError() *PcloudIkepoliciesGetallInternalServerError { + return &PcloudIkepoliciesGetallInternalServerError{} +} + +/* PcloudIkepoliciesGetallInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudIkepoliciesGetallInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudIkepoliciesGetallInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies][%d] pcloudIkepoliciesGetallInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudIkepoliciesGetallInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIkepoliciesGetallInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ikepolicies_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ikepolicies_post_parameters.go new file mode 100644 index 00000000000..57d82f091a6 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ikepolicies_post_parameters.go @@ -0,0 +1,173 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_policies + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudIkepoliciesPostParams creates a new PcloudIkepoliciesPostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudIkepoliciesPostParams() *PcloudIkepoliciesPostParams { + return &PcloudIkepoliciesPostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudIkepoliciesPostParamsWithTimeout creates a new PcloudIkepoliciesPostParams object +// with the ability to set a timeout on a request. +func NewPcloudIkepoliciesPostParamsWithTimeout(timeout time.Duration) *PcloudIkepoliciesPostParams { + return &PcloudIkepoliciesPostParams{ + timeout: timeout, + } +} + +// NewPcloudIkepoliciesPostParamsWithContext creates a new PcloudIkepoliciesPostParams object +// with the ability to set a context for a request. +func NewPcloudIkepoliciesPostParamsWithContext(ctx context.Context) *PcloudIkepoliciesPostParams { + return &PcloudIkepoliciesPostParams{ + Context: ctx, + } +} + +// NewPcloudIkepoliciesPostParamsWithHTTPClient creates a new PcloudIkepoliciesPostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudIkepoliciesPostParamsWithHTTPClient(client *http.Client) *PcloudIkepoliciesPostParams { + return &PcloudIkepoliciesPostParams{ + HTTPClient: client, + } +} + +/* PcloudIkepoliciesPostParams contains all the parameters to send to the API endpoint + for the pcloud ikepolicies post operation. + + Typically these are written to a http.Request. +*/ +type PcloudIkepoliciesPostParams struct { + + /* Body. + + Parameters for the creation of a new IKE Policy + */ + Body *models.IKEPolicyCreate + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud ikepolicies post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudIkepoliciesPostParams) WithDefaults() *PcloudIkepoliciesPostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud ikepolicies post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudIkepoliciesPostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud ikepolicies post params +func (o *PcloudIkepoliciesPostParams) WithTimeout(timeout time.Duration) *PcloudIkepoliciesPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud ikepolicies post params +func (o *PcloudIkepoliciesPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud ikepolicies post params +func (o *PcloudIkepoliciesPostParams) WithContext(ctx context.Context) *PcloudIkepoliciesPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud ikepolicies post params +func (o *PcloudIkepoliciesPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud ikepolicies post params +func (o *PcloudIkepoliciesPostParams) WithHTTPClient(client *http.Client) *PcloudIkepoliciesPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud ikepolicies post params +func (o *PcloudIkepoliciesPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud ikepolicies post params +func (o *PcloudIkepoliciesPostParams) WithBody(body *models.IKEPolicyCreate) *PcloudIkepoliciesPostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud ikepolicies post params +func (o *PcloudIkepoliciesPostParams) SetBody(body *models.IKEPolicyCreate) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud ikepolicies post params +func (o *PcloudIkepoliciesPostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudIkepoliciesPostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud ikepolicies post params +func (o *PcloudIkepoliciesPostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudIkepoliciesPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ikepolicies_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ikepolicies_post_responses.go new file mode 100644 index 00000000000..3b3d81964d7 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ikepolicies_post_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_policies + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudIkepoliciesPostReader is a Reader for the PcloudIkepoliciesPost structure. +type PcloudIkepoliciesPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudIkepoliciesPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudIkepoliciesPostOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudIkepoliciesPostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudIkepoliciesPostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewPcloudIkepoliciesPostForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewPcloudIkepoliciesPostConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudIkepoliciesPostUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudIkepoliciesPostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudIkepoliciesPostOK creates a PcloudIkepoliciesPostOK with default headers values +func NewPcloudIkepoliciesPostOK() *PcloudIkepoliciesPostOK { + return &PcloudIkepoliciesPostOK{} +} + +/* PcloudIkepoliciesPostOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudIkepoliciesPostOK struct { + Payload *models.IKEPolicy +} + +func (o *PcloudIkepoliciesPostOK) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies][%d] pcloudIkepoliciesPostOK %+v", 200, o.Payload) +} +func (o *PcloudIkepoliciesPostOK) GetPayload() *models.IKEPolicy { + return o.Payload +} + +func (o *PcloudIkepoliciesPostOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.IKEPolicy) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIkepoliciesPostBadRequest creates a PcloudIkepoliciesPostBadRequest with default headers values +func NewPcloudIkepoliciesPostBadRequest() *PcloudIkepoliciesPostBadRequest { + return &PcloudIkepoliciesPostBadRequest{} +} + +/* PcloudIkepoliciesPostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudIkepoliciesPostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudIkepoliciesPostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies][%d] pcloudIkepoliciesPostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudIkepoliciesPostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIkepoliciesPostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIkepoliciesPostUnauthorized creates a PcloudIkepoliciesPostUnauthorized with default headers values +func NewPcloudIkepoliciesPostUnauthorized() *PcloudIkepoliciesPostUnauthorized { + return &PcloudIkepoliciesPostUnauthorized{} +} + +/* PcloudIkepoliciesPostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudIkepoliciesPostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudIkepoliciesPostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies][%d] pcloudIkepoliciesPostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudIkepoliciesPostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIkepoliciesPostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIkepoliciesPostForbidden creates a PcloudIkepoliciesPostForbidden with default headers values +func NewPcloudIkepoliciesPostForbidden() *PcloudIkepoliciesPostForbidden { + return &PcloudIkepoliciesPostForbidden{} +} + +/* PcloudIkepoliciesPostForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type PcloudIkepoliciesPostForbidden struct { + Payload *models.Error +} + +func (o *PcloudIkepoliciesPostForbidden) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies][%d] pcloudIkepoliciesPostForbidden %+v", 403, o.Payload) +} +func (o *PcloudIkepoliciesPostForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIkepoliciesPostForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIkepoliciesPostConflict creates a PcloudIkepoliciesPostConflict with default headers values +func NewPcloudIkepoliciesPostConflict() *PcloudIkepoliciesPostConflict { + return &PcloudIkepoliciesPostConflict{} +} + +/* PcloudIkepoliciesPostConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type PcloudIkepoliciesPostConflict struct { + Payload *models.Error +} + +func (o *PcloudIkepoliciesPostConflict) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies][%d] pcloudIkepoliciesPostConflict %+v", 409, o.Payload) +} +func (o *PcloudIkepoliciesPostConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIkepoliciesPostConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIkepoliciesPostUnprocessableEntity creates a PcloudIkepoliciesPostUnprocessableEntity with default headers values +func NewPcloudIkepoliciesPostUnprocessableEntity() *PcloudIkepoliciesPostUnprocessableEntity { + return &PcloudIkepoliciesPostUnprocessableEntity{} +} + +/* PcloudIkepoliciesPostUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudIkepoliciesPostUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudIkepoliciesPostUnprocessableEntity) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies][%d] pcloudIkepoliciesPostUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudIkepoliciesPostUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIkepoliciesPostUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIkepoliciesPostInternalServerError creates a PcloudIkepoliciesPostInternalServerError with default headers values +func NewPcloudIkepoliciesPostInternalServerError() *PcloudIkepoliciesPostInternalServerError { + return &PcloudIkepoliciesPostInternalServerError{} +} + +/* PcloudIkepoliciesPostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudIkepoliciesPostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudIkepoliciesPostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies][%d] pcloudIkepoliciesPostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudIkepoliciesPostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIkepoliciesPostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ikepolicies_put_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ikepolicies_put_parameters.go new file mode 100644 index 00000000000..c845b8aee92 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ikepolicies_put_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_policies + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudIkepoliciesPutParams creates a new PcloudIkepoliciesPutParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudIkepoliciesPutParams() *PcloudIkepoliciesPutParams { + return &PcloudIkepoliciesPutParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudIkepoliciesPutParamsWithTimeout creates a new PcloudIkepoliciesPutParams object +// with the ability to set a timeout on a request. +func NewPcloudIkepoliciesPutParamsWithTimeout(timeout time.Duration) *PcloudIkepoliciesPutParams { + return &PcloudIkepoliciesPutParams{ + timeout: timeout, + } +} + +// NewPcloudIkepoliciesPutParamsWithContext creates a new PcloudIkepoliciesPutParams object +// with the ability to set a context for a request. +func NewPcloudIkepoliciesPutParamsWithContext(ctx context.Context) *PcloudIkepoliciesPutParams { + return &PcloudIkepoliciesPutParams{ + Context: ctx, + } +} + +// NewPcloudIkepoliciesPutParamsWithHTTPClient creates a new PcloudIkepoliciesPutParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudIkepoliciesPutParamsWithHTTPClient(client *http.Client) *PcloudIkepoliciesPutParams { + return &PcloudIkepoliciesPutParams{ + HTTPClient: client, + } +} + +/* PcloudIkepoliciesPutParams contains all the parameters to send to the API endpoint + for the pcloud ikepolicies put operation. + + Typically these are written to a http.Request. +*/ +type PcloudIkepoliciesPutParams struct { + + /* Body. + + Parameters for updating IKE Policy + */ + Body *models.IKEPolicyUpdate + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* IkePolicyID. + + ID of a IKE Policy + */ + IkePolicyID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud ikepolicies put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudIkepoliciesPutParams) WithDefaults() *PcloudIkepoliciesPutParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud ikepolicies put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudIkepoliciesPutParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud ikepolicies put params +func (o *PcloudIkepoliciesPutParams) WithTimeout(timeout time.Duration) *PcloudIkepoliciesPutParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud ikepolicies put params +func (o *PcloudIkepoliciesPutParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud ikepolicies put params +func (o *PcloudIkepoliciesPutParams) WithContext(ctx context.Context) *PcloudIkepoliciesPutParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud ikepolicies put params +func (o *PcloudIkepoliciesPutParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud ikepolicies put params +func (o *PcloudIkepoliciesPutParams) WithHTTPClient(client *http.Client) *PcloudIkepoliciesPutParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud ikepolicies put params +func (o *PcloudIkepoliciesPutParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud ikepolicies put params +func (o *PcloudIkepoliciesPutParams) WithBody(body *models.IKEPolicyUpdate) *PcloudIkepoliciesPutParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud ikepolicies put params +func (o *PcloudIkepoliciesPutParams) SetBody(body *models.IKEPolicyUpdate) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud ikepolicies put params +func (o *PcloudIkepoliciesPutParams) WithCloudInstanceID(cloudInstanceID string) *PcloudIkepoliciesPutParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud ikepolicies put params +func (o *PcloudIkepoliciesPutParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithIkePolicyID adds the ikePolicyID to the pcloud ikepolicies put params +func (o *PcloudIkepoliciesPutParams) WithIkePolicyID(ikePolicyID string) *PcloudIkepoliciesPutParams { + o.SetIkePolicyID(ikePolicyID) + return o +} + +// SetIkePolicyID adds the ikePolicyId to the pcloud ikepolicies put params +func (o *PcloudIkepoliciesPutParams) SetIkePolicyID(ikePolicyID string) { + o.IkePolicyID = ikePolicyID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudIkepoliciesPutParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param ike_policy_id + if err := r.SetPathParam("ike_policy_id", o.IkePolicyID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ikepolicies_put_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ikepolicies_put_responses.go new file mode 100644 index 00000000000..b9350c86f88 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ikepolicies_put_responses.go @@ -0,0 +1,257 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_policies + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudIkepoliciesPutReader is a Reader for the PcloudIkepoliciesPut structure. +type PcloudIkepoliciesPutReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudIkepoliciesPutReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudIkepoliciesPutOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudIkepoliciesPutBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudIkepoliciesPutUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewPcloudIkepoliciesPutForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudIkepoliciesPutUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudIkepoliciesPutInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudIkepoliciesPutOK creates a PcloudIkepoliciesPutOK with default headers values +func NewPcloudIkepoliciesPutOK() *PcloudIkepoliciesPutOK { + return &PcloudIkepoliciesPutOK{} +} + +/* PcloudIkepoliciesPutOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudIkepoliciesPutOK struct { + Payload *models.IKEPolicy +} + +func (o *PcloudIkepoliciesPutOK) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies/{ike_policy_id}][%d] pcloudIkepoliciesPutOK %+v", 200, o.Payload) +} +func (o *PcloudIkepoliciesPutOK) GetPayload() *models.IKEPolicy { + return o.Payload +} + +func (o *PcloudIkepoliciesPutOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.IKEPolicy) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIkepoliciesPutBadRequest creates a PcloudIkepoliciesPutBadRequest with default headers values +func NewPcloudIkepoliciesPutBadRequest() *PcloudIkepoliciesPutBadRequest { + return &PcloudIkepoliciesPutBadRequest{} +} + +/* PcloudIkepoliciesPutBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudIkepoliciesPutBadRequest struct { + Payload *models.Error +} + +func (o *PcloudIkepoliciesPutBadRequest) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies/{ike_policy_id}][%d] pcloudIkepoliciesPutBadRequest %+v", 400, o.Payload) +} +func (o *PcloudIkepoliciesPutBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIkepoliciesPutBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIkepoliciesPutUnauthorized creates a PcloudIkepoliciesPutUnauthorized with default headers values +func NewPcloudIkepoliciesPutUnauthorized() *PcloudIkepoliciesPutUnauthorized { + return &PcloudIkepoliciesPutUnauthorized{} +} + +/* PcloudIkepoliciesPutUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudIkepoliciesPutUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudIkepoliciesPutUnauthorized) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies/{ike_policy_id}][%d] pcloudIkepoliciesPutUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudIkepoliciesPutUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIkepoliciesPutUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIkepoliciesPutForbidden creates a PcloudIkepoliciesPutForbidden with default headers values +func NewPcloudIkepoliciesPutForbidden() *PcloudIkepoliciesPutForbidden { + return &PcloudIkepoliciesPutForbidden{} +} + +/* PcloudIkepoliciesPutForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type PcloudIkepoliciesPutForbidden struct { + Payload *models.Error +} + +func (o *PcloudIkepoliciesPutForbidden) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies/{ike_policy_id}][%d] pcloudIkepoliciesPutForbidden %+v", 403, o.Payload) +} +func (o *PcloudIkepoliciesPutForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIkepoliciesPutForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIkepoliciesPutUnprocessableEntity creates a PcloudIkepoliciesPutUnprocessableEntity with default headers values +func NewPcloudIkepoliciesPutUnprocessableEntity() *PcloudIkepoliciesPutUnprocessableEntity { + return &PcloudIkepoliciesPutUnprocessableEntity{} +} + +/* PcloudIkepoliciesPutUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudIkepoliciesPutUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudIkepoliciesPutUnprocessableEntity) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies/{ike_policy_id}][%d] pcloudIkepoliciesPutUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudIkepoliciesPutUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIkepoliciesPutUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIkepoliciesPutInternalServerError creates a PcloudIkepoliciesPutInternalServerError with default headers values +func NewPcloudIkepoliciesPutInternalServerError() *PcloudIkepoliciesPutInternalServerError { + return &PcloudIkepoliciesPutInternalServerError{} +} + +/* PcloudIkepoliciesPutInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudIkepoliciesPutInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudIkepoliciesPutInternalServerError) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ike-policies/{ike_policy_id}][%d] pcloudIkepoliciesPutInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudIkepoliciesPutInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIkepoliciesPutInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ipsecpolicies_delete_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ipsecpolicies_delete_parameters.go new file mode 100644 index 00000000000..fdd67659cc2 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ipsecpolicies_delete_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_policies + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudIpsecpoliciesDeleteParams creates a new PcloudIpsecpoliciesDeleteParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudIpsecpoliciesDeleteParams() *PcloudIpsecpoliciesDeleteParams { + return &PcloudIpsecpoliciesDeleteParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudIpsecpoliciesDeleteParamsWithTimeout creates a new PcloudIpsecpoliciesDeleteParams object +// with the ability to set a timeout on a request. +func NewPcloudIpsecpoliciesDeleteParamsWithTimeout(timeout time.Duration) *PcloudIpsecpoliciesDeleteParams { + return &PcloudIpsecpoliciesDeleteParams{ + timeout: timeout, + } +} + +// NewPcloudIpsecpoliciesDeleteParamsWithContext creates a new PcloudIpsecpoliciesDeleteParams object +// with the ability to set a context for a request. +func NewPcloudIpsecpoliciesDeleteParamsWithContext(ctx context.Context) *PcloudIpsecpoliciesDeleteParams { + return &PcloudIpsecpoliciesDeleteParams{ + Context: ctx, + } +} + +// NewPcloudIpsecpoliciesDeleteParamsWithHTTPClient creates a new PcloudIpsecpoliciesDeleteParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudIpsecpoliciesDeleteParamsWithHTTPClient(client *http.Client) *PcloudIpsecpoliciesDeleteParams { + return &PcloudIpsecpoliciesDeleteParams{ + HTTPClient: client, + } +} + +/* PcloudIpsecpoliciesDeleteParams contains all the parameters to send to the API endpoint + for the pcloud ipsecpolicies delete operation. + + Typically these are written to a http.Request. +*/ +type PcloudIpsecpoliciesDeleteParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* IpsecPolicyID. + + ID of a IPSec Policy + */ + IpsecPolicyID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud ipsecpolicies delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudIpsecpoliciesDeleteParams) WithDefaults() *PcloudIpsecpoliciesDeleteParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud ipsecpolicies delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudIpsecpoliciesDeleteParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud ipsecpolicies delete params +func (o *PcloudIpsecpoliciesDeleteParams) WithTimeout(timeout time.Duration) *PcloudIpsecpoliciesDeleteParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud ipsecpolicies delete params +func (o *PcloudIpsecpoliciesDeleteParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud ipsecpolicies delete params +func (o *PcloudIpsecpoliciesDeleteParams) WithContext(ctx context.Context) *PcloudIpsecpoliciesDeleteParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud ipsecpolicies delete params +func (o *PcloudIpsecpoliciesDeleteParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud ipsecpolicies delete params +func (o *PcloudIpsecpoliciesDeleteParams) WithHTTPClient(client *http.Client) *PcloudIpsecpoliciesDeleteParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud ipsecpolicies delete params +func (o *PcloudIpsecpoliciesDeleteParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud ipsecpolicies delete params +func (o *PcloudIpsecpoliciesDeleteParams) WithCloudInstanceID(cloudInstanceID string) *PcloudIpsecpoliciesDeleteParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud ipsecpolicies delete params +func (o *PcloudIpsecpoliciesDeleteParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithIpsecPolicyID adds the ipsecPolicyID to the pcloud ipsecpolicies delete params +func (o *PcloudIpsecpoliciesDeleteParams) WithIpsecPolicyID(ipsecPolicyID string) *PcloudIpsecpoliciesDeleteParams { + o.SetIpsecPolicyID(ipsecPolicyID) + return o +} + +// SetIpsecPolicyID adds the ipsecPolicyId to the pcloud ipsecpolicies delete params +func (o *PcloudIpsecpoliciesDeleteParams) SetIpsecPolicyID(ipsecPolicyID string) { + o.IpsecPolicyID = ipsecPolicyID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudIpsecpoliciesDeleteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param ipsec_policy_id + if err := r.SetPathParam("ipsec_policy_id", o.IpsecPolicyID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ipsecpolicies_delete_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ipsecpolicies_delete_responses.go new file mode 100644 index 00000000000..0d01bf97cd6 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ipsecpolicies_delete_responses.go @@ -0,0 +1,255 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_policies + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudIpsecpoliciesDeleteReader is a Reader for the PcloudIpsecpoliciesDelete structure. +type PcloudIpsecpoliciesDeleteReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudIpsecpoliciesDeleteReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudIpsecpoliciesDeleteOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudIpsecpoliciesDeleteBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudIpsecpoliciesDeleteUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewPcloudIpsecpoliciesDeleteForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudIpsecpoliciesDeleteNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudIpsecpoliciesDeleteInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudIpsecpoliciesDeleteOK creates a PcloudIpsecpoliciesDeleteOK with default headers values +func NewPcloudIpsecpoliciesDeleteOK() *PcloudIpsecpoliciesDeleteOK { + return &PcloudIpsecpoliciesDeleteOK{} +} + +/* PcloudIpsecpoliciesDeleteOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudIpsecpoliciesDeleteOK struct { + Payload models.Object +} + +func (o *PcloudIpsecpoliciesDeleteOK) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies/{ipsec_policy_id}][%d] pcloudIpsecpoliciesDeleteOK %+v", 200, o.Payload) +} +func (o *PcloudIpsecpoliciesDeleteOK) GetPayload() models.Object { + return o.Payload +} + +func (o *PcloudIpsecpoliciesDeleteOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIpsecpoliciesDeleteBadRequest creates a PcloudIpsecpoliciesDeleteBadRequest with default headers values +func NewPcloudIpsecpoliciesDeleteBadRequest() *PcloudIpsecpoliciesDeleteBadRequest { + return &PcloudIpsecpoliciesDeleteBadRequest{} +} + +/* PcloudIpsecpoliciesDeleteBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudIpsecpoliciesDeleteBadRequest struct { + Payload *models.Error +} + +func (o *PcloudIpsecpoliciesDeleteBadRequest) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies/{ipsec_policy_id}][%d] pcloudIpsecpoliciesDeleteBadRequest %+v", 400, o.Payload) +} +func (o *PcloudIpsecpoliciesDeleteBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIpsecpoliciesDeleteBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIpsecpoliciesDeleteUnauthorized creates a PcloudIpsecpoliciesDeleteUnauthorized with default headers values +func NewPcloudIpsecpoliciesDeleteUnauthorized() *PcloudIpsecpoliciesDeleteUnauthorized { + return &PcloudIpsecpoliciesDeleteUnauthorized{} +} + +/* PcloudIpsecpoliciesDeleteUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudIpsecpoliciesDeleteUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudIpsecpoliciesDeleteUnauthorized) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies/{ipsec_policy_id}][%d] pcloudIpsecpoliciesDeleteUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudIpsecpoliciesDeleteUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIpsecpoliciesDeleteUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIpsecpoliciesDeleteForbidden creates a PcloudIpsecpoliciesDeleteForbidden with default headers values +func NewPcloudIpsecpoliciesDeleteForbidden() *PcloudIpsecpoliciesDeleteForbidden { + return &PcloudIpsecpoliciesDeleteForbidden{} +} + +/* PcloudIpsecpoliciesDeleteForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type PcloudIpsecpoliciesDeleteForbidden struct { + Payload *models.Error +} + +func (o *PcloudIpsecpoliciesDeleteForbidden) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies/{ipsec_policy_id}][%d] pcloudIpsecpoliciesDeleteForbidden %+v", 403, o.Payload) +} +func (o *PcloudIpsecpoliciesDeleteForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIpsecpoliciesDeleteForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIpsecpoliciesDeleteNotFound creates a PcloudIpsecpoliciesDeleteNotFound with default headers values +func NewPcloudIpsecpoliciesDeleteNotFound() *PcloudIpsecpoliciesDeleteNotFound { + return &PcloudIpsecpoliciesDeleteNotFound{} +} + +/* PcloudIpsecpoliciesDeleteNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudIpsecpoliciesDeleteNotFound struct { + Payload *models.Error +} + +func (o *PcloudIpsecpoliciesDeleteNotFound) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies/{ipsec_policy_id}][%d] pcloudIpsecpoliciesDeleteNotFound %+v", 404, o.Payload) +} +func (o *PcloudIpsecpoliciesDeleteNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIpsecpoliciesDeleteNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIpsecpoliciesDeleteInternalServerError creates a PcloudIpsecpoliciesDeleteInternalServerError with default headers values +func NewPcloudIpsecpoliciesDeleteInternalServerError() *PcloudIpsecpoliciesDeleteInternalServerError { + return &PcloudIpsecpoliciesDeleteInternalServerError{} +} + +/* PcloudIpsecpoliciesDeleteInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudIpsecpoliciesDeleteInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudIpsecpoliciesDeleteInternalServerError) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies/{ipsec_policy_id}][%d] pcloudIpsecpoliciesDeleteInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudIpsecpoliciesDeleteInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIpsecpoliciesDeleteInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ipsecpolicies_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ipsecpolicies_get_parameters.go new file mode 100644 index 00000000000..8f24e703cb7 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ipsecpolicies_get_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_policies + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudIpsecpoliciesGetParams creates a new PcloudIpsecpoliciesGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudIpsecpoliciesGetParams() *PcloudIpsecpoliciesGetParams { + return &PcloudIpsecpoliciesGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudIpsecpoliciesGetParamsWithTimeout creates a new PcloudIpsecpoliciesGetParams object +// with the ability to set a timeout on a request. +func NewPcloudIpsecpoliciesGetParamsWithTimeout(timeout time.Duration) *PcloudIpsecpoliciesGetParams { + return &PcloudIpsecpoliciesGetParams{ + timeout: timeout, + } +} + +// NewPcloudIpsecpoliciesGetParamsWithContext creates a new PcloudIpsecpoliciesGetParams object +// with the ability to set a context for a request. +func NewPcloudIpsecpoliciesGetParamsWithContext(ctx context.Context) *PcloudIpsecpoliciesGetParams { + return &PcloudIpsecpoliciesGetParams{ + Context: ctx, + } +} + +// NewPcloudIpsecpoliciesGetParamsWithHTTPClient creates a new PcloudIpsecpoliciesGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudIpsecpoliciesGetParamsWithHTTPClient(client *http.Client) *PcloudIpsecpoliciesGetParams { + return &PcloudIpsecpoliciesGetParams{ + HTTPClient: client, + } +} + +/* PcloudIpsecpoliciesGetParams contains all the parameters to send to the API endpoint + for the pcloud ipsecpolicies get operation. + + Typically these are written to a http.Request. +*/ +type PcloudIpsecpoliciesGetParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* IpsecPolicyID. + + ID of a IPSec Policy + */ + IpsecPolicyID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud ipsecpolicies get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudIpsecpoliciesGetParams) WithDefaults() *PcloudIpsecpoliciesGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud ipsecpolicies get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudIpsecpoliciesGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud ipsecpolicies get params +func (o *PcloudIpsecpoliciesGetParams) WithTimeout(timeout time.Duration) *PcloudIpsecpoliciesGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud ipsecpolicies get params +func (o *PcloudIpsecpoliciesGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud ipsecpolicies get params +func (o *PcloudIpsecpoliciesGetParams) WithContext(ctx context.Context) *PcloudIpsecpoliciesGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud ipsecpolicies get params +func (o *PcloudIpsecpoliciesGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud ipsecpolicies get params +func (o *PcloudIpsecpoliciesGetParams) WithHTTPClient(client *http.Client) *PcloudIpsecpoliciesGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud ipsecpolicies get params +func (o *PcloudIpsecpoliciesGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud ipsecpolicies get params +func (o *PcloudIpsecpoliciesGetParams) WithCloudInstanceID(cloudInstanceID string) *PcloudIpsecpoliciesGetParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud ipsecpolicies get params +func (o *PcloudIpsecpoliciesGetParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithIpsecPolicyID adds the ipsecPolicyID to the pcloud ipsecpolicies get params +func (o *PcloudIpsecpoliciesGetParams) WithIpsecPolicyID(ipsecPolicyID string) *PcloudIpsecpoliciesGetParams { + o.SetIpsecPolicyID(ipsecPolicyID) + return o +} + +// SetIpsecPolicyID adds the ipsecPolicyId to the pcloud ipsecpolicies get params +func (o *PcloudIpsecpoliciesGetParams) SetIpsecPolicyID(ipsecPolicyID string) { + o.IpsecPolicyID = ipsecPolicyID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudIpsecpoliciesGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param ipsec_policy_id + if err := r.SetPathParam("ipsec_policy_id", o.IpsecPolicyID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ipsecpolicies_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ipsecpolicies_get_responses.go new file mode 100644 index 00000000000..ddaa9a9b8e9 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ipsecpolicies_get_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_policies + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudIpsecpoliciesGetReader is a Reader for the PcloudIpsecpoliciesGet structure. +type PcloudIpsecpoliciesGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudIpsecpoliciesGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudIpsecpoliciesGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudIpsecpoliciesGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudIpsecpoliciesGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewPcloudIpsecpoliciesGetForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudIpsecpoliciesGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudIpsecpoliciesGetUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudIpsecpoliciesGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudIpsecpoliciesGetOK creates a PcloudIpsecpoliciesGetOK with default headers values +func NewPcloudIpsecpoliciesGetOK() *PcloudIpsecpoliciesGetOK { + return &PcloudIpsecpoliciesGetOK{} +} + +/* PcloudIpsecpoliciesGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudIpsecpoliciesGetOK struct { + Payload *models.IPSecPolicy +} + +func (o *PcloudIpsecpoliciesGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies/{ipsec_policy_id}][%d] pcloudIpsecpoliciesGetOK %+v", 200, o.Payload) +} +func (o *PcloudIpsecpoliciesGetOK) GetPayload() *models.IPSecPolicy { + return o.Payload +} + +func (o *PcloudIpsecpoliciesGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.IPSecPolicy) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIpsecpoliciesGetBadRequest creates a PcloudIpsecpoliciesGetBadRequest with default headers values +func NewPcloudIpsecpoliciesGetBadRequest() *PcloudIpsecpoliciesGetBadRequest { + return &PcloudIpsecpoliciesGetBadRequest{} +} + +/* PcloudIpsecpoliciesGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudIpsecpoliciesGetBadRequest struct { + Payload *models.Error +} + +func (o *PcloudIpsecpoliciesGetBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies/{ipsec_policy_id}][%d] pcloudIpsecpoliciesGetBadRequest %+v", 400, o.Payload) +} +func (o *PcloudIpsecpoliciesGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIpsecpoliciesGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIpsecpoliciesGetUnauthorized creates a PcloudIpsecpoliciesGetUnauthorized with default headers values +func NewPcloudIpsecpoliciesGetUnauthorized() *PcloudIpsecpoliciesGetUnauthorized { + return &PcloudIpsecpoliciesGetUnauthorized{} +} + +/* PcloudIpsecpoliciesGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudIpsecpoliciesGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudIpsecpoliciesGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies/{ipsec_policy_id}][%d] pcloudIpsecpoliciesGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudIpsecpoliciesGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIpsecpoliciesGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIpsecpoliciesGetForbidden creates a PcloudIpsecpoliciesGetForbidden with default headers values +func NewPcloudIpsecpoliciesGetForbidden() *PcloudIpsecpoliciesGetForbidden { + return &PcloudIpsecpoliciesGetForbidden{} +} + +/* PcloudIpsecpoliciesGetForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type PcloudIpsecpoliciesGetForbidden struct { + Payload *models.Error +} + +func (o *PcloudIpsecpoliciesGetForbidden) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies/{ipsec_policy_id}][%d] pcloudIpsecpoliciesGetForbidden %+v", 403, o.Payload) +} +func (o *PcloudIpsecpoliciesGetForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIpsecpoliciesGetForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIpsecpoliciesGetNotFound creates a PcloudIpsecpoliciesGetNotFound with default headers values +func NewPcloudIpsecpoliciesGetNotFound() *PcloudIpsecpoliciesGetNotFound { + return &PcloudIpsecpoliciesGetNotFound{} +} + +/* PcloudIpsecpoliciesGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudIpsecpoliciesGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudIpsecpoliciesGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies/{ipsec_policy_id}][%d] pcloudIpsecpoliciesGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudIpsecpoliciesGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIpsecpoliciesGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIpsecpoliciesGetUnprocessableEntity creates a PcloudIpsecpoliciesGetUnprocessableEntity with default headers values +func NewPcloudIpsecpoliciesGetUnprocessableEntity() *PcloudIpsecpoliciesGetUnprocessableEntity { + return &PcloudIpsecpoliciesGetUnprocessableEntity{} +} + +/* PcloudIpsecpoliciesGetUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudIpsecpoliciesGetUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudIpsecpoliciesGetUnprocessableEntity) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies/{ipsec_policy_id}][%d] pcloudIpsecpoliciesGetUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudIpsecpoliciesGetUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIpsecpoliciesGetUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIpsecpoliciesGetInternalServerError creates a PcloudIpsecpoliciesGetInternalServerError with default headers values +func NewPcloudIpsecpoliciesGetInternalServerError() *PcloudIpsecpoliciesGetInternalServerError { + return &PcloudIpsecpoliciesGetInternalServerError{} +} + +/* PcloudIpsecpoliciesGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudIpsecpoliciesGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudIpsecpoliciesGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies/{ipsec_policy_id}][%d] pcloudIpsecpoliciesGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudIpsecpoliciesGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIpsecpoliciesGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ipsecpolicies_getall_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ipsecpolicies_getall_parameters.go new file mode 100644 index 00000000000..6d9a00d3a36 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ipsecpolicies_getall_parameters.go @@ -0,0 +1,149 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_policies + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudIpsecpoliciesGetallParams creates a new PcloudIpsecpoliciesGetallParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudIpsecpoliciesGetallParams() *PcloudIpsecpoliciesGetallParams { + return &PcloudIpsecpoliciesGetallParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudIpsecpoliciesGetallParamsWithTimeout creates a new PcloudIpsecpoliciesGetallParams object +// with the ability to set a timeout on a request. +func NewPcloudIpsecpoliciesGetallParamsWithTimeout(timeout time.Duration) *PcloudIpsecpoliciesGetallParams { + return &PcloudIpsecpoliciesGetallParams{ + timeout: timeout, + } +} + +// NewPcloudIpsecpoliciesGetallParamsWithContext creates a new PcloudIpsecpoliciesGetallParams object +// with the ability to set a context for a request. +func NewPcloudIpsecpoliciesGetallParamsWithContext(ctx context.Context) *PcloudIpsecpoliciesGetallParams { + return &PcloudIpsecpoliciesGetallParams{ + Context: ctx, + } +} + +// NewPcloudIpsecpoliciesGetallParamsWithHTTPClient creates a new PcloudIpsecpoliciesGetallParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudIpsecpoliciesGetallParamsWithHTTPClient(client *http.Client) *PcloudIpsecpoliciesGetallParams { + return &PcloudIpsecpoliciesGetallParams{ + HTTPClient: client, + } +} + +/* PcloudIpsecpoliciesGetallParams contains all the parameters to send to the API endpoint + for the pcloud ipsecpolicies getall operation. + + Typically these are written to a http.Request. +*/ +type PcloudIpsecpoliciesGetallParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud ipsecpolicies getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudIpsecpoliciesGetallParams) WithDefaults() *PcloudIpsecpoliciesGetallParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud ipsecpolicies getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudIpsecpoliciesGetallParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud ipsecpolicies getall params +func (o *PcloudIpsecpoliciesGetallParams) WithTimeout(timeout time.Duration) *PcloudIpsecpoliciesGetallParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud ipsecpolicies getall params +func (o *PcloudIpsecpoliciesGetallParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud ipsecpolicies getall params +func (o *PcloudIpsecpoliciesGetallParams) WithContext(ctx context.Context) *PcloudIpsecpoliciesGetallParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud ipsecpolicies getall params +func (o *PcloudIpsecpoliciesGetallParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud ipsecpolicies getall params +func (o *PcloudIpsecpoliciesGetallParams) WithHTTPClient(client *http.Client) *PcloudIpsecpoliciesGetallParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud ipsecpolicies getall params +func (o *PcloudIpsecpoliciesGetallParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud ipsecpolicies getall params +func (o *PcloudIpsecpoliciesGetallParams) WithCloudInstanceID(cloudInstanceID string) *PcloudIpsecpoliciesGetallParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud ipsecpolicies getall params +func (o *PcloudIpsecpoliciesGetallParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudIpsecpoliciesGetallParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ipsecpolicies_getall_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ipsecpolicies_getall_responses.go new file mode 100644 index 00000000000..92925b59b4b --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ipsecpolicies_getall_responses.go @@ -0,0 +1,257 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_policies + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudIpsecpoliciesGetallReader is a Reader for the PcloudIpsecpoliciesGetall structure. +type PcloudIpsecpoliciesGetallReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudIpsecpoliciesGetallReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudIpsecpoliciesGetallOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudIpsecpoliciesGetallBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudIpsecpoliciesGetallUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewPcloudIpsecpoliciesGetallForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudIpsecpoliciesGetallNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudIpsecpoliciesGetallInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudIpsecpoliciesGetallOK creates a PcloudIpsecpoliciesGetallOK with default headers values +func NewPcloudIpsecpoliciesGetallOK() *PcloudIpsecpoliciesGetallOK { + return &PcloudIpsecpoliciesGetallOK{} +} + +/* PcloudIpsecpoliciesGetallOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudIpsecpoliciesGetallOK struct { + Payload *models.IPSecPolicies +} + +func (o *PcloudIpsecpoliciesGetallOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies][%d] pcloudIpsecpoliciesGetallOK %+v", 200, o.Payload) +} +func (o *PcloudIpsecpoliciesGetallOK) GetPayload() *models.IPSecPolicies { + return o.Payload +} + +func (o *PcloudIpsecpoliciesGetallOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.IPSecPolicies) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIpsecpoliciesGetallBadRequest creates a PcloudIpsecpoliciesGetallBadRequest with default headers values +func NewPcloudIpsecpoliciesGetallBadRequest() *PcloudIpsecpoliciesGetallBadRequest { + return &PcloudIpsecpoliciesGetallBadRequest{} +} + +/* PcloudIpsecpoliciesGetallBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudIpsecpoliciesGetallBadRequest struct { + Payload *models.Error +} + +func (o *PcloudIpsecpoliciesGetallBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies][%d] pcloudIpsecpoliciesGetallBadRequest %+v", 400, o.Payload) +} +func (o *PcloudIpsecpoliciesGetallBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIpsecpoliciesGetallBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIpsecpoliciesGetallUnauthorized creates a PcloudIpsecpoliciesGetallUnauthorized with default headers values +func NewPcloudIpsecpoliciesGetallUnauthorized() *PcloudIpsecpoliciesGetallUnauthorized { + return &PcloudIpsecpoliciesGetallUnauthorized{} +} + +/* PcloudIpsecpoliciesGetallUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudIpsecpoliciesGetallUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudIpsecpoliciesGetallUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies][%d] pcloudIpsecpoliciesGetallUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudIpsecpoliciesGetallUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIpsecpoliciesGetallUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIpsecpoliciesGetallForbidden creates a PcloudIpsecpoliciesGetallForbidden with default headers values +func NewPcloudIpsecpoliciesGetallForbidden() *PcloudIpsecpoliciesGetallForbidden { + return &PcloudIpsecpoliciesGetallForbidden{} +} + +/* PcloudIpsecpoliciesGetallForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type PcloudIpsecpoliciesGetallForbidden struct { + Payload *models.Error +} + +func (o *PcloudIpsecpoliciesGetallForbidden) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies][%d] pcloudIpsecpoliciesGetallForbidden %+v", 403, o.Payload) +} +func (o *PcloudIpsecpoliciesGetallForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIpsecpoliciesGetallForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIpsecpoliciesGetallNotFound creates a PcloudIpsecpoliciesGetallNotFound with default headers values +func NewPcloudIpsecpoliciesGetallNotFound() *PcloudIpsecpoliciesGetallNotFound { + return &PcloudIpsecpoliciesGetallNotFound{} +} + +/* PcloudIpsecpoliciesGetallNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudIpsecpoliciesGetallNotFound struct { + Payload *models.Error +} + +func (o *PcloudIpsecpoliciesGetallNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies][%d] pcloudIpsecpoliciesGetallNotFound %+v", 404, o.Payload) +} +func (o *PcloudIpsecpoliciesGetallNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIpsecpoliciesGetallNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIpsecpoliciesGetallInternalServerError creates a PcloudIpsecpoliciesGetallInternalServerError with default headers values +func NewPcloudIpsecpoliciesGetallInternalServerError() *PcloudIpsecpoliciesGetallInternalServerError { + return &PcloudIpsecpoliciesGetallInternalServerError{} +} + +/* PcloudIpsecpoliciesGetallInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudIpsecpoliciesGetallInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudIpsecpoliciesGetallInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies][%d] pcloudIpsecpoliciesGetallInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudIpsecpoliciesGetallInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIpsecpoliciesGetallInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ipsecpolicies_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ipsecpolicies_post_parameters.go new file mode 100644 index 00000000000..a09d4300f1a --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ipsecpolicies_post_parameters.go @@ -0,0 +1,173 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_policies + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudIpsecpoliciesPostParams creates a new PcloudIpsecpoliciesPostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudIpsecpoliciesPostParams() *PcloudIpsecpoliciesPostParams { + return &PcloudIpsecpoliciesPostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudIpsecpoliciesPostParamsWithTimeout creates a new PcloudIpsecpoliciesPostParams object +// with the ability to set a timeout on a request. +func NewPcloudIpsecpoliciesPostParamsWithTimeout(timeout time.Duration) *PcloudIpsecpoliciesPostParams { + return &PcloudIpsecpoliciesPostParams{ + timeout: timeout, + } +} + +// NewPcloudIpsecpoliciesPostParamsWithContext creates a new PcloudIpsecpoliciesPostParams object +// with the ability to set a context for a request. +func NewPcloudIpsecpoliciesPostParamsWithContext(ctx context.Context) *PcloudIpsecpoliciesPostParams { + return &PcloudIpsecpoliciesPostParams{ + Context: ctx, + } +} + +// NewPcloudIpsecpoliciesPostParamsWithHTTPClient creates a new PcloudIpsecpoliciesPostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudIpsecpoliciesPostParamsWithHTTPClient(client *http.Client) *PcloudIpsecpoliciesPostParams { + return &PcloudIpsecpoliciesPostParams{ + HTTPClient: client, + } +} + +/* PcloudIpsecpoliciesPostParams contains all the parameters to send to the API endpoint + for the pcloud ipsecpolicies post operation. + + Typically these are written to a http.Request. +*/ +type PcloudIpsecpoliciesPostParams struct { + + /* Body. + + Parameters for the creation of a new IPSec Policy + */ + Body *models.IPSecPolicyCreate + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud ipsecpolicies post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudIpsecpoliciesPostParams) WithDefaults() *PcloudIpsecpoliciesPostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud ipsecpolicies post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudIpsecpoliciesPostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud ipsecpolicies post params +func (o *PcloudIpsecpoliciesPostParams) WithTimeout(timeout time.Duration) *PcloudIpsecpoliciesPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud ipsecpolicies post params +func (o *PcloudIpsecpoliciesPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud ipsecpolicies post params +func (o *PcloudIpsecpoliciesPostParams) WithContext(ctx context.Context) *PcloudIpsecpoliciesPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud ipsecpolicies post params +func (o *PcloudIpsecpoliciesPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud ipsecpolicies post params +func (o *PcloudIpsecpoliciesPostParams) WithHTTPClient(client *http.Client) *PcloudIpsecpoliciesPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud ipsecpolicies post params +func (o *PcloudIpsecpoliciesPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud ipsecpolicies post params +func (o *PcloudIpsecpoliciesPostParams) WithBody(body *models.IPSecPolicyCreate) *PcloudIpsecpoliciesPostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud ipsecpolicies post params +func (o *PcloudIpsecpoliciesPostParams) SetBody(body *models.IPSecPolicyCreate) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud ipsecpolicies post params +func (o *PcloudIpsecpoliciesPostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudIpsecpoliciesPostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud ipsecpolicies post params +func (o *PcloudIpsecpoliciesPostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudIpsecpoliciesPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ipsecpolicies_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ipsecpolicies_post_responses.go new file mode 100644 index 00000000000..20620cea35d --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ipsecpolicies_post_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_policies + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudIpsecpoliciesPostReader is a Reader for the PcloudIpsecpoliciesPost structure. +type PcloudIpsecpoliciesPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudIpsecpoliciesPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudIpsecpoliciesPostOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudIpsecpoliciesPostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudIpsecpoliciesPostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewPcloudIpsecpoliciesPostForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewPcloudIpsecpoliciesPostConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudIpsecpoliciesPostUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudIpsecpoliciesPostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudIpsecpoliciesPostOK creates a PcloudIpsecpoliciesPostOK with default headers values +func NewPcloudIpsecpoliciesPostOK() *PcloudIpsecpoliciesPostOK { + return &PcloudIpsecpoliciesPostOK{} +} + +/* PcloudIpsecpoliciesPostOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudIpsecpoliciesPostOK struct { + Payload *models.IPSecPolicy +} + +func (o *PcloudIpsecpoliciesPostOK) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies][%d] pcloudIpsecpoliciesPostOK %+v", 200, o.Payload) +} +func (o *PcloudIpsecpoliciesPostOK) GetPayload() *models.IPSecPolicy { + return o.Payload +} + +func (o *PcloudIpsecpoliciesPostOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.IPSecPolicy) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIpsecpoliciesPostBadRequest creates a PcloudIpsecpoliciesPostBadRequest with default headers values +func NewPcloudIpsecpoliciesPostBadRequest() *PcloudIpsecpoliciesPostBadRequest { + return &PcloudIpsecpoliciesPostBadRequest{} +} + +/* PcloudIpsecpoliciesPostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudIpsecpoliciesPostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudIpsecpoliciesPostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies][%d] pcloudIpsecpoliciesPostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudIpsecpoliciesPostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIpsecpoliciesPostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIpsecpoliciesPostUnauthorized creates a PcloudIpsecpoliciesPostUnauthorized with default headers values +func NewPcloudIpsecpoliciesPostUnauthorized() *PcloudIpsecpoliciesPostUnauthorized { + return &PcloudIpsecpoliciesPostUnauthorized{} +} + +/* PcloudIpsecpoliciesPostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudIpsecpoliciesPostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudIpsecpoliciesPostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies][%d] pcloudIpsecpoliciesPostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudIpsecpoliciesPostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIpsecpoliciesPostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIpsecpoliciesPostForbidden creates a PcloudIpsecpoliciesPostForbidden with default headers values +func NewPcloudIpsecpoliciesPostForbidden() *PcloudIpsecpoliciesPostForbidden { + return &PcloudIpsecpoliciesPostForbidden{} +} + +/* PcloudIpsecpoliciesPostForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type PcloudIpsecpoliciesPostForbidden struct { + Payload *models.Error +} + +func (o *PcloudIpsecpoliciesPostForbidden) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies][%d] pcloudIpsecpoliciesPostForbidden %+v", 403, o.Payload) +} +func (o *PcloudIpsecpoliciesPostForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIpsecpoliciesPostForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIpsecpoliciesPostConflict creates a PcloudIpsecpoliciesPostConflict with default headers values +func NewPcloudIpsecpoliciesPostConflict() *PcloudIpsecpoliciesPostConflict { + return &PcloudIpsecpoliciesPostConflict{} +} + +/* PcloudIpsecpoliciesPostConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type PcloudIpsecpoliciesPostConflict struct { + Payload *models.Error +} + +func (o *PcloudIpsecpoliciesPostConflict) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies][%d] pcloudIpsecpoliciesPostConflict %+v", 409, o.Payload) +} +func (o *PcloudIpsecpoliciesPostConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIpsecpoliciesPostConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIpsecpoliciesPostUnprocessableEntity creates a PcloudIpsecpoliciesPostUnprocessableEntity with default headers values +func NewPcloudIpsecpoliciesPostUnprocessableEntity() *PcloudIpsecpoliciesPostUnprocessableEntity { + return &PcloudIpsecpoliciesPostUnprocessableEntity{} +} + +/* PcloudIpsecpoliciesPostUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudIpsecpoliciesPostUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudIpsecpoliciesPostUnprocessableEntity) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies][%d] pcloudIpsecpoliciesPostUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudIpsecpoliciesPostUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIpsecpoliciesPostUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIpsecpoliciesPostInternalServerError creates a PcloudIpsecpoliciesPostInternalServerError with default headers values +func NewPcloudIpsecpoliciesPostInternalServerError() *PcloudIpsecpoliciesPostInternalServerError { + return &PcloudIpsecpoliciesPostInternalServerError{} +} + +/* PcloudIpsecpoliciesPostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudIpsecpoliciesPostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudIpsecpoliciesPostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies][%d] pcloudIpsecpoliciesPostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudIpsecpoliciesPostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIpsecpoliciesPostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ipsecpolicies_put_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ipsecpolicies_put_parameters.go new file mode 100644 index 00000000000..4849277eaab --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ipsecpolicies_put_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_policies + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudIpsecpoliciesPutParams creates a new PcloudIpsecpoliciesPutParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudIpsecpoliciesPutParams() *PcloudIpsecpoliciesPutParams { + return &PcloudIpsecpoliciesPutParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudIpsecpoliciesPutParamsWithTimeout creates a new PcloudIpsecpoliciesPutParams object +// with the ability to set a timeout on a request. +func NewPcloudIpsecpoliciesPutParamsWithTimeout(timeout time.Duration) *PcloudIpsecpoliciesPutParams { + return &PcloudIpsecpoliciesPutParams{ + timeout: timeout, + } +} + +// NewPcloudIpsecpoliciesPutParamsWithContext creates a new PcloudIpsecpoliciesPutParams object +// with the ability to set a context for a request. +func NewPcloudIpsecpoliciesPutParamsWithContext(ctx context.Context) *PcloudIpsecpoliciesPutParams { + return &PcloudIpsecpoliciesPutParams{ + Context: ctx, + } +} + +// NewPcloudIpsecpoliciesPutParamsWithHTTPClient creates a new PcloudIpsecpoliciesPutParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudIpsecpoliciesPutParamsWithHTTPClient(client *http.Client) *PcloudIpsecpoliciesPutParams { + return &PcloudIpsecpoliciesPutParams{ + HTTPClient: client, + } +} + +/* PcloudIpsecpoliciesPutParams contains all the parameters to send to the API endpoint + for the pcloud ipsecpolicies put operation. + + Typically these are written to a http.Request. +*/ +type PcloudIpsecpoliciesPutParams struct { + + /* Body. + + Parameters for the update of an IPSec Policy + */ + Body *models.IPSecPolicyUpdate + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* IpsecPolicyID. + + ID of a IPSec Policy + */ + IpsecPolicyID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud ipsecpolicies put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudIpsecpoliciesPutParams) WithDefaults() *PcloudIpsecpoliciesPutParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud ipsecpolicies put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudIpsecpoliciesPutParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud ipsecpolicies put params +func (o *PcloudIpsecpoliciesPutParams) WithTimeout(timeout time.Duration) *PcloudIpsecpoliciesPutParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud ipsecpolicies put params +func (o *PcloudIpsecpoliciesPutParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud ipsecpolicies put params +func (o *PcloudIpsecpoliciesPutParams) WithContext(ctx context.Context) *PcloudIpsecpoliciesPutParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud ipsecpolicies put params +func (o *PcloudIpsecpoliciesPutParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud ipsecpolicies put params +func (o *PcloudIpsecpoliciesPutParams) WithHTTPClient(client *http.Client) *PcloudIpsecpoliciesPutParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud ipsecpolicies put params +func (o *PcloudIpsecpoliciesPutParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud ipsecpolicies put params +func (o *PcloudIpsecpoliciesPutParams) WithBody(body *models.IPSecPolicyUpdate) *PcloudIpsecpoliciesPutParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud ipsecpolicies put params +func (o *PcloudIpsecpoliciesPutParams) SetBody(body *models.IPSecPolicyUpdate) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud ipsecpolicies put params +func (o *PcloudIpsecpoliciesPutParams) WithCloudInstanceID(cloudInstanceID string) *PcloudIpsecpoliciesPutParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud ipsecpolicies put params +func (o *PcloudIpsecpoliciesPutParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithIpsecPolicyID adds the ipsecPolicyID to the pcloud ipsecpolicies put params +func (o *PcloudIpsecpoliciesPutParams) WithIpsecPolicyID(ipsecPolicyID string) *PcloudIpsecpoliciesPutParams { + o.SetIpsecPolicyID(ipsecPolicyID) + return o +} + +// SetIpsecPolicyID adds the ipsecPolicyId to the pcloud ipsecpolicies put params +func (o *PcloudIpsecpoliciesPutParams) SetIpsecPolicyID(ipsecPolicyID string) { + o.IpsecPolicyID = ipsecPolicyID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudIpsecpoliciesPutParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param ipsec_policy_id + if err := r.SetPathParam("ipsec_policy_id", o.IpsecPolicyID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ipsecpolicies_put_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ipsecpolicies_put_responses.go new file mode 100644 index 00000000000..feb151312c7 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies/pcloud_ipsecpolicies_put_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_v_p_n_policies + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudIpsecpoliciesPutReader is a Reader for the PcloudIpsecpoliciesPut structure. +type PcloudIpsecpoliciesPutReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudIpsecpoliciesPutReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudIpsecpoliciesPutOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudIpsecpoliciesPutBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudIpsecpoliciesPutUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewPcloudIpsecpoliciesPutForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewPcloudIpsecpoliciesPutConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudIpsecpoliciesPutUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudIpsecpoliciesPutInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudIpsecpoliciesPutOK creates a PcloudIpsecpoliciesPutOK with default headers values +func NewPcloudIpsecpoliciesPutOK() *PcloudIpsecpoliciesPutOK { + return &PcloudIpsecpoliciesPutOK{} +} + +/* PcloudIpsecpoliciesPutOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudIpsecpoliciesPutOK struct { + Payload *models.IPSecPolicy +} + +func (o *PcloudIpsecpoliciesPutOK) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies/{ipsec_policy_id}][%d] pcloudIpsecpoliciesPutOK %+v", 200, o.Payload) +} +func (o *PcloudIpsecpoliciesPutOK) GetPayload() *models.IPSecPolicy { + return o.Payload +} + +func (o *PcloudIpsecpoliciesPutOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.IPSecPolicy) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIpsecpoliciesPutBadRequest creates a PcloudIpsecpoliciesPutBadRequest with default headers values +func NewPcloudIpsecpoliciesPutBadRequest() *PcloudIpsecpoliciesPutBadRequest { + return &PcloudIpsecpoliciesPutBadRequest{} +} + +/* PcloudIpsecpoliciesPutBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudIpsecpoliciesPutBadRequest struct { + Payload *models.Error +} + +func (o *PcloudIpsecpoliciesPutBadRequest) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies/{ipsec_policy_id}][%d] pcloudIpsecpoliciesPutBadRequest %+v", 400, o.Payload) +} +func (o *PcloudIpsecpoliciesPutBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIpsecpoliciesPutBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIpsecpoliciesPutUnauthorized creates a PcloudIpsecpoliciesPutUnauthorized with default headers values +func NewPcloudIpsecpoliciesPutUnauthorized() *PcloudIpsecpoliciesPutUnauthorized { + return &PcloudIpsecpoliciesPutUnauthorized{} +} + +/* PcloudIpsecpoliciesPutUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudIpsecpoliciesPutUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudIpsecpoliciesPutUnauthorized) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies/{ipsec_policy_id}][%d] pcloudIpsecpoliciesPutUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudIpsecpoliciesPutUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIpsecpoliciesPutUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIpsecpoliciesPutForbidden creates a PcloudIpsecpoliciesPutForbidden with default headers values +func NewPcloudIpsecpoliciesPutForbidden() *PcloudIpsecpoliciesPutForbidden { + return &PcloudIpsecpoliciesPutForbidden{} +} + +/* PcloudIpsecpoliciesPutForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type PcloudIpsecpoliciesPutForbidden struct { + Payload *models.Error +} + +func (o *PcloudIpsecpoliciesPutForbidden) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies/{ipsec_policy_id}][%d] pcloudIpsecpoliciesPutForbidden %+v", 403, o.Payload) +} +func (o *PcloudIpsecpoliciesPutForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIpsecpoliciesPutForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIpsecpoliciesPutConflict creates a PcloudIpsecpoliciesPutConflict with default headers values +func NewPcloudIpsecpoliciesPutConflict() *PcloudIpsecpoliciesPutConflict { + return &PcloudIpsecpoliciesPutConflict{} +} + +/* PcloudIpsecpoliciesPutConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type PcloudIpsecpoliciesPutConflict struct { + Payload *models.Error +} + +func (o *PcloudIpsecpoliciesPutConflict) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies/{ipsec_policy_id}][%d] pcloudIpsecpoliciesPutConflict %+v", 409, o.Payload) +} +func (o *PcloudIpsecpoliciesPutConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIpsecpoliciesPutConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIpsecpoliciesPutUnprocessableEntity creates a PcloudIpsecpoliciesPutUnprocessableEntity with default headers values +func NewPcloudIpsecpoliciesPutUnprocessableEntity() *PcloudIpsecpoliciesPutUnprocessableEntity { + return &PcloudIpsecpoliciesPutUnprocessableEntity{} +} + +/* PcloudIpsecpoliciesPutUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudIpsecpoliciesPutUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudIpsecpoliciesPutUnprocessableEntity) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies/{ipsec_policy_id}][%d] pcloudIpsecpoliciesPutUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudIpsecpoliciesPutUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIpsecpoliciesPutUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudIpsecpoliciesPutInternalServerError creates a PcloudIpsecpoliciesPutInternalServerError with default headers values +func NewPcloudIpsecpoliciesPutInternalServerError() *PcloudIpsecpoliciesPutInternalServerError { + return &PcloudIpsecpoliciesPutInternalServerError{} +} + +/* PcloudIpsecpoliciesPutInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudIpsecpoliciesPutInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudIpsecpoliciesPutInternalServerError) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/vpn/ipsec-policies/{ipsec_policy_id}][%d] pcloudIpsecpoliciesPutInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudIpsecpoliciesPutInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudIpsecpoliciesPutInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/p_cloud_volumes_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/p_cloud_volumes_client.go new file mode 100644 index 00000000000..d0afc8f4369 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/p_cloud_volumes_client.go @@ -0,0 +1,1023 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new p cloud volumes API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for p cloud volumes API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + PcloudCloudinstancesVolumesActionPost(params *PcloudCloudinstancesVolumesActionPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesVolumesActionPostAccepted, error) + + PcloudCloudinstancesVolumesDelete(params *PcloudCloudinstancesVolumesDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesVolumesDeleteOK, error) + + PcloudCloudinstancesVolumesGet(params *PcloudCloudinstancesVolumesGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesVolumesGetOK, error) + + PcloudCloudinstancesVolumesGetall(params *PcloudCloudinstancesVolumesGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesVolumesGetallOK, error) + + PcloudCloudinstancesVolumesPost(params *PcloudCloudinstancesVolumesPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesVolumesPostAccepted, error) + + PcloudCloudinstancesVolumesPut(params *PcloudCloudinstancesVolumesPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesVolumesPutOK, error) + + PcloudPvminstancesVolumesDelete(params *PcloudPvminstancesVolumesDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesVolumesDeleteAccepted, error) + + PcloudPvminstancesVolumesGet(params *PcloudPvminstancesVolumesGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesVolumesGetOK, error) + + PcloudPvminstancesVolumesGetall(params *PcloudPvminstancesVolumesGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesVolumesGetallOK, error) + + PcloudPvminstancesVolumesPost(params *PcloudPvminstancesVolumesPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesVolumesPostOK, error) + + PcloudPvminstancesVolumesPut(params *PcloudPvminstancesVolumesPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesVolumesPutOK, error) + + PcloudPvminstancesVolumesSetbootPut(params *PcloudPvminstancesVolumesSetbootPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesVolumesSetbootPutOK, error) + + PcloudV2PvminstancesVolumesPost(params *PcloudV2PvminstancesVolumesPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV2PvminstancesVolumesPostAccepted, error) + + PcloudV2VolumesClonePost(params *PcloudV2VolumesClonePostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV2VolumesClonePostAccepted, error) + + PcloudV2VolumesClonetasksGet(params *PcloudV2VolumesClonetasksGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV2VolumesClonetasksGetOK, error) + + PcloudV2VolumesPost(params *PcloudV2VolumesPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV2VolumesPostCreated, error) + + PcloudV2VolumescloneCancelPost(params *PcloudV2VolumescloneCancelPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV2VolumescloneCancelPostAccepted, error) + + PcloudV2VolumescloneDelete(params *PcloudV2VolumescloneDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV2VolumescloneDeleteOK, error) + + PcloudV2VolumescloneExecutePost(params *PcloudV2VolumescloneExecutePostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV2VolumescloneExecutePostAccepted, error) + + PcloudV2VolumescloneGet(params *PcloudV2VolumescloneGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV2VolumescloneGetOK, error) + + PcloudV2VolumescloneGetall(params *PcloudV2VolumescloneGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV2VolumescloneGetallOK, error) + + PcloudV2VolumesclonePost(params *PcloudV2VolumesclonePostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV2VolumesclonePostAccepted, error) + + PcloudV2VolumescloneStartPost(params *PcloudV2VolumescloneStartPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV2VolumescloneStartPostOK, error) + + PcloudVolumesClonePost(params *PcloudVolumesClonePostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudVolumesClonePostOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + PcloudCloudinstancesVolumesActionPost performs an action on a volume +*/ +func (a *Client) PcloudCloudinstancesVolumesActionPost(params *PcloudCloudinstancesVolumesActionPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesVolumesActionPostAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudinstancesVolumesActionPostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.cloudinstances.volumes.action.post", + Method: "POST", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/volumes/{volume_id}/action", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudinstancesVolumesActionPostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudCloudinstancesVolumesActionPostAccepted) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.cloudinstances.volumes.action.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudCloudinstancesVolumesDelete deletes a cloud instance volume +*/ +func (a *Client) PcloudCloudinstancesVolumesDelete(params *PcloudCloudinstancesVolumesDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesVolumesDeleteOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudinstancesVolumesDeleteParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.cloudinstances.volumes.delete", + Method: "DELETE", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/volumes/{volume_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudinstancesVolumesDeleteReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudCloudinstancesVolumesDeleteOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.cloudinstances.volumes.delete: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudCloudinstancesVolumesGet detaileds info of a volume +*/ +func (a *Client) PcloudCloudinstancesVolumesGet(params *PcloudCloudinstancesVolumesGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesVolumesGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudinstancesVolumesGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.cloudinstances.volumes.get", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/volumes/{volume_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudinstancesVolumesGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudCloudinstancesVolumesGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.cloudinstances.volumes.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudCloudinstancesVolumesGetall lists all volumes for this cloud instance +*/ +func (a *Client) PcloudCloudinstancesVolumesGetall(params *PcloudCloudinstancesVolumesGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesVolumesGetallOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudinstancesVolumesGetallParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.cloudinstances.volumes.getall", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/volumes", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudinstancesVolumesGetallReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudCloudinstancesVolumesGetallOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.cloudinstances.volumes.getall: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudCloudinstancesVolumesPost creates a new data volume +*/ +func (a *Client) PcloudCloudinstancesVolumesPost(params *PcloudCloudinstancesVolumesPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesVolumesPostAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudinstancesVolumesPostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.cloudinstances.volumes.post", + Method: "POST", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/volumes", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudinstancesVolumesPostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudCloudinstancesVolumesPostAccepted) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.cloudinstances.volumes.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudCloudinstancesVolumesPut updates a cloud instance volume +*/ +func (a *Client) PcloudCloudinstancesVolumesPut(params *PcloudCloudinstancesVolumesPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudCloudinstancesVolumesPutOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudinstancesVolumesPutParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.cloudinstances.volumes.put", + Method: "PUT", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/volumes/{volume_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudinstancesVolumesPutReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudCloudinstancesVolumesPutOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.cloudinstances.volumes.put: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudPvminstancesVolumesDelete detaches a volume from a p VM instance +*/ +func (a *Client) PcloudPvminstancesVolumesDelete(params *PcloudPvminstancesVolumesDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesVolumesDeleteAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudPvminstancesVolumesDeleteParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.pvminstances.volumes.delete", + Method: "DELETE", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudPvminstancesVolumesDeleteReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudPvminstancesVolumesDeleteAccepted) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.pvminstances.volumes.delete: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudPvminstancesVolumesGet detaileds info of a volume attached to a p VM instance +*/ +func (a *Client) PcloudPvminstancesVolumesGet(params *PcloudPvminstancesVolumesGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesVolumesGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudPvminstancesVolumesGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.pvminstances.volumes.get", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudPvminstancesVolumesGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudPvminstancesVolumesGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.pvminstances.volumes.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudPvminstancesVolumesGetall lists all volumes attached to a p VM instance +*/ +func (a *Client) PcloudPvminstancesVolumesGetall(params *PcloudPvminstancesVolumesGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesVolumesGetallOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudPvminstancesVolumesGetallParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.pvminstances.volumes.getall", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudPvminstancesVolumesGetallReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudPvminstancesVolumesGetallOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.pvminstances.volumes.getall: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudPvminstancesVolumesPost attaches a volume to a p VM instance +*/ +func (a *Client) PcloudPvminstancesVolumesPost(params *PcloudPvminstancesVolumesPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesVolumesPostOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudPvminstancesVolumesPostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.pvminstances.volumes.post", + Method: "POST", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudPvminstancesVolumesPostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudPvminstancesVolumesPostOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.pvminstances.volumes.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudPvminstancesVolumesPut updates a volume attached to a p VM instance +*/ +func (a *Client) PcloudPvminstancesVolumesPut(params *PcloudPvminstancesVolumesPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesVolumesPutOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudPvminstancesVolumesPutParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.pvminstances.volumes.put", + Method: "PUT", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudPvminstancesVolumesPutReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudPvminstancesVolumesPutOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.pvminstances.volumes.put: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudPvminstancesVolumesSetbootPut sets the p VM instance volume as the boot volume +*/ +func (a *Client) PcloudPvminstancesVolumesSetbootPut(params *PcloudPvminstancesVolumesSetbootPutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudPvminstancesVolumesSetbootPutOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudPvminstancesVolumesSetbootPutParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.pvminstances.volumes.setboot.put", + Method: "PUT", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}/setboot", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudPvminstancesVolumesSetbootPutReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudPvminstancesVolumesSetbootPutOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.pvminstances.volumes.setboot.put: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudV2PvminstancesVolumesPost attaches all volumes to a p VM instance +*/ +func (a *Client) PcloudV2PvminstancesVolumesPost(params *PcloudV2PvminstancesVolumesPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV2PvminstancesVolumesPostAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudV2PvminstancesVolumesPostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.v2.pvminstances.volumes.post", + Method: "POST", + PathPattern: "/pcloud/v2/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudV2PvminstancesVolumesPostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudV2PvminstancesVolumesPostAccepted) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.v2.pvminstances.volumes.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudV2VolumesClonePost creates a volume clone for specified volumes +*/ +func (a *Client) PcloudV2VolumesClonePost(params *PcloudV2VolumesClonePostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV2VolumesClonePostAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudV2VolumesClonePostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.v2.volumes.clone.post", + Method: "POST", + PathPattern: "/pcloud/v2/cloud-instances/{cloud_instance_id}/volumes/clone", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudV2VolumesClonePostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudV2VolumesClonePostAccepted) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.v2.volumes.clone.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudV2VolumesClonetasksGet gets the status of a volumes clone request for the specified clone task ID +*/ +func (a *Client) PcloudV2VolumesClonetasksGet(params *PcloudV2VolumesClonetasksGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV2VolumesClonetasksGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudV2VolumesClonetasksGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.v2.volumes.clonetasks.get", + Method: "GET", + PathPattern: "/pcloud/v2/cloud-instances/{cloud_instance_id}/volumes/clone-tasks/{clone_task_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudV2VolumesClonetasksGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudV2VolumesClonetasksGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.v2.volumes.clonetasks.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudV2VolumesPost creates multiple data volumes from a single definition +*/ +func (a *Client) PcloudV2VolumesPost(params *PcloudV2VolumesPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV2VolumesPostCreated, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudV2VolumesPostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.v2.volumes.post", + Method: "POST", + PathPattern: "/pcloud/v2/cloud-instances/{cloud_instance_id}/volumes", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudV2VolumesPostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudV2VolumesPostCreated) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.v2.volumes.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudV2VolumescloneCancelPost cancels a volumes clone request initiates the cleanup action cleanup action performs the cleanup of the preparatory clones and snapshot volumes +*/ +func (a *Client) PcloudV2VolumescloneCancelPost(params *PcloudV2VolumescloneCancelPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV2VolumescloneCancelPostAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudV2VolumescloneCancelPostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.v2.volumesclone.cancel.post", + Method: "POST", + PathPattern: "/pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone/{volumes_clone_id}/cancel", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudV2VolumescloneCancelPostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudV2VolumescloneCancelPostAccepted) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.v2.volumesclone.cancel.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudV2VolumescloneDelete deletes a volumes clone request +*/ +func (a *Client) PcloudV2VolumescloneDelete(params *PcloudV2VolumescloneDeleteParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV2VolumescloneDeleteOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudV2VolumescloneDeleteParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.v2.volumesclone.delete", + Method: "DELETE", + PathPattern: "/pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone/{volumes_clone_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudV2VolumescloneDeleteReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudV2VolumescloneDeleteOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.v2.volumesclone.delete: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudV2VolumescloneExecutePost initiates the execute action for a volumes clone request execute action creates the cloned volumes using the volume snapshots +*/ +func (a *Client) PcloudV2VolumescloneExecutePost(params *PcloudV2VolumescloneExecutePostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV2VolumescloneExecutePostAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudV2VolumescloneExecutePostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.v2.volumesclone.execute.post", + Method: "POST", + PathPattern: "/pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone/{volumes_clone_id}/execute", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudV2VolumescloneExecutePostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudV2VolumescloneExecutePostAccepted) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.v2.volumesclone.execute.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudV2VolumescloneGet gets the details for a volumes clone request +*/ +func (a *Client) PcloudV2VolumescloneGet(params *PcloudV2VolumescloneGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV2VolumescloneGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudV2VolumescloneGetParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.v2.volumesclone.get", + Method: "GET", + PathPattern: "/pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone/{volumes_clone_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudV2VolumescloneGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudV2VolumescloneGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.v2.volumesclone.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudV2VolumescloneGetall gets the list of volumes clone request for a cloud instance +*/ +func (a *Client) PcloudV2VolumescloneGetall(params *PcloudV2VolumescloneGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV2VolumescloneGetallOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudV2VolumescloneGetallParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.v2.volumesclone.getall", + Method: "GET", + PathPattern: "/pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudV2VolumescloneGetallReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudV2VolumescloneGetallOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.v2.volumesclone.getall: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudV2VolumesclonePost creates a new volumes clone request and initiates the prepare action requires a minimum of two volumes requires a minimum of one volume to be in the in use state requires a unique volumes clone name prepare action does the preparatory work for creating the snapshot volumes +*/ +func (a *Client) PcloudV2VolumesclonePost(params *PcloudV2VolumesclonePostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV2VolumesclonePostAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudV2VolumesclonePostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.v2.volumesclone.post", + Method: "POST", + PathPattern: "/pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudV2VolumesclonePostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudV2VolumesclonePostAccepted) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.v2.volumesclone.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudV2VolumescloneStartPost initiates the start action for a volumes clone request start action starts the consistency group to initiate the flash copy +*/ +func (a *Client) PcloudV2VolumescloneStartPost(params *PcloudV2VolumescloneStartPostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudV2VolumescloneStartPostOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudV2VolumescloneStartPostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.v2.volumesclone.start.post", + Method: "POST", + PathPattern: "/pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone/{volumes_clone_id}/start", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudV2VolumescloneStartPostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudV2VolumescloneStartPostOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.v2.volumesclone.start.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PcloudVolumesClonePost creates a volume clone for specified volumes +*/ +func (a *Client) PcloudVolumesClonePost(params *PcloudVolumesClonePostParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PcloudVolumesClonePostOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudVolumesClonePostParams() + } + op := &runtime.ClientOperation{ + ID: "pcloud.volumes.clone.post", + Method: "POST", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/volumes/clone", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudVolumesClonePostReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PcloudVolumesClonePostOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for pcloud.volumes.clone.post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_action_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_action_post_parameters.go new file mode 100644 index 00000000000..a66e7a29b36 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_action_post_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudCloudinstancesVolumesActionPostParams creates a new PcloudCloudinstancesVolumesActionPostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudCloudinstancesVolumesActionPostParams() *PcloudCloudinstancesVolumesActionPostParams { + return &PcloudCloudinstancesVolumesActionPostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudinstancesVolumesActionPostParamsWithTimeout creates a new PcloudCloudinstancesVolumesActionPostParams object +// with the ability to set a timeout on a request. +func NewPcloudCloudinstancesVolumesActionPostParamsWithTimeout(timeout time.Duration) *PcloudCloudinstancesVolumesActionPostParams { + return &PcloudCloudinstancesVolumesActionPostParams{ + timeout: timeout, + } +} + +// NewPcloudCloudinstancesVolumesActionPostParamsWithContext creates a new PcloudCloudinstancesVolumesActionPostParams object +// with the ability to set a context for a request. +func NewPcloudCloudinstancesVolumesActionPostParamsWithContext(ctx context.Context) *PcloudCloudinstancesVolumesActionPostParams { + return &PcloudCloudinstancesVolumesActionPostParams{ + Context: ctx, + } +} + +// NewPcloudCloudinstancesVolumesActionPostParamsWithHTTPClient creates a new PcloudCloudinstancesVolumesActionPostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudCloudinstancesVolumesActionPostParamsWithHTTPClient(client *http.Client) *PcloudCloudinstancesVolumesActionPostParams { + return &PcloudCloudinstancesVolumesActionPostParams{ + HTTPClient: client, + } +} + +/* PcloudCloudinstancesVolumesActionPostParams contains all the parameters to send to the API endpoint + for the pcloud cloudinstances volumes action post operation. + + Typically these are written to a http.Request. +*/ +type PcloudCloudinstancesVolumesActionPostParams struct { + + /* Body. + + Parameters for the desired action + */ + Body *models.VolumeAction + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* VolumeID. + + Volume ID + */ + VolumeID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud cloudinstances volumes action post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesVolumesActionPostParams) WithDefaults() *PcloudCloudinstancesVolumesActionPostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud cloudinstances volumes action post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesVolumesActionPostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud cloudinstances volumes action post params +func (o *PcloudCloudinstancesVolumesActionPostParams) WithTimeout(timeout time.Duration) *PcloudCloudinstancesVolumesActionPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudinstances volumes action post params +func (o *PcloudCloudinstancesVolumesActionPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudinstances volumes action post params +func (o *PcloudCloudinstancesVolumesActionPostParams) WithContext(ctx context.Context) *PcloudCloudinstancesVolumesActionPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudinstances volumes action post params +func (o *PcloudCloudinstancesVolumesActionPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudinstances volumes action post params +func (o *PcloudCloudinstancesVolumesActionPostParams) WithHTTPClient(client *http.Client) *PcloudCloudinstancesVolumesActionPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudinstances volumes action post params +func (o *PcloudCloudinstancesVolumesActionPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud cloudinstances volumes action post params +func (o *PcloudCloudinstancesVolumesActionPostParams) WithBody(body *models.VolumeAction) *PcloudCloudinstancesVolumesActionPostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud cloudinstances volumes action post params +func (o *PcloudCloudinstancesVolumesActionPostParams) SetBody(body *models.VolumeAction) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudinstances volumes action post params +func (o *PcloudCloudinstancesVolumesActionPostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudinstancesVolumesActionPostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudinstances volumes action post params +func (o *PcloudCloudinstancesVolumesActionPostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithVolumeID adds the volumeID to the pcloud cloudinstances volumes action post params +func (o *PcloudCloudinstancesVolumesActionPostParams) WithVolumeID(volumeID string) *PcloudCloudinstancesVolumesActionPostParams { + o.SetVolumeID(volumeID) + return o +} + +// SetVolumeID adds the volumeId to the pcloud cloudinstances volumes action post params +func (o *PcloudCloudinstancesVolumesActionPostParams) SetVolumeID(volumeID string) { + o.VolumeID = volumeID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudinstancesVolumesActionPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param volume_id + if err := r.SetPathParam("volume_id", o.VolumeID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_action_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_action_post_responses.go new file mode 100644 index 00000000000..24d75e2cd2f --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_action_post_responses.go @@ -0,0 +1,217 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudinstancesVolumesActionPostReader is a Reader for the PcloudCloudinstancesVolumesActionPost structure. +type PcloudCloudinstancesVolumesActionPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudinstancesVolumesActionPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 202: + result := NewPcloudCloudinstancesVolumesActionPostAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudCloudinstancesVolumesActionPostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudCloudinstancesVolumesActionPostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudCloudinstancesVolumesActionPostNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudCloudinstancesVolumesActionPostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudCloudinstancesVolumesActionPostAccepted creates a PcloudCloudinstancesVolumesActionPostAccepted with default headers values +func NewPcloudCloudinstancesVolumesActionPostAccepted() *PcloudCloudinstancesVolumesActionPostAccepted { + return &PcloudCloudinstancesVolumesActionPostAccepted{} +} + +/* PcloudCloudinstancesVolumesActionPostAccepted describes a response with status code 202, with default header values. + +Accepted +*/ +type PcloudCloudinstancesVolumesActionPostAccepted struct { + Payload models.Object +} + +func (o *PcloudCloudinstancesVolumesActionPostAccepted) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes/{volume_id}/action][%d] pcloudCloudinstancesVolumesActionPostAccepted %+v", 202, o.Payload) +} +func (o *PcloudCloudinstancesVolumesActionPostAccepted) GetPayload() models.Object { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesActionPostAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesVolumesActionPostBadRequest creates a PcloudCloudinstancesVolumesActionPostBadRequest with default headers values +func NewPcloudCloudinstancesVolumesActionPostBadRequest() *PcloudCloudinstancesVolumesActionPostBadRequest { + return &PcloudCloudinstancesVolumesActionPostBadRequest{} +} + +/* PcloudCloudinstancesVolumesActionPostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudCloudinstancesVolumesActionPostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesVolumesActionPostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes/{volume_id}/action][%d] pcloudCloudinstancesVolumesActionPostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudCloudinstancesVolumesActionPostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesActionPostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesVolumesActionPostUnauthorized creates a PcloudCloudinstancesVolumesActionPostUnauthorized with default headers values +func NewPcloudCloudinstancesVolumesActionPostUnauthorized() *PcloudCloudinstancesVolumesActionPostUnauthorized { + return &PcloudCloudinstancesVolumesActionPostUnauthorized{} +} + +/* PcloudCloudinstancesVolumesActionPostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudCloudinstancesVolumesActionPostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesVolumesActionPostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes/{volume_id}/action][%d] pcloudCloudinstancesVolumesActionPostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudCloudinstancesVolumesActionPostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesActionPostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesVolumesActionPostNotFound creates a PcloudCloudinstancesVolumesActionPostNotFound with default headers values +func NewPcloudCloudinstancesVolumesActionPostNotFound() *PcloudCloudinstancesVolumesActionPostNotFound { + return &PcloudCloudinstancesVolumesActionPostNotFound{} +} + +/* PcloudCloudinstancesVolumesActionPostNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudCloudinstancesVolumesActionPostNotFound struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesVolumesActionPostNotFound) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes/{volume_id}/action][%d] pcloudCloudinstancesVolumesActionPostNotFound %+v", 404, o.Payload) +} +func (o *PcloudCloudinstancesVolumesActionPostNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesActionPostNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesVolumesActionPostInternalServerError creates a PcloudCloudinstancesVolumesActionPostInternalServerError with default headers values +func NewPcloudCloudinstancesVolumesActionPostInternalServerError() *PcloudCloudinstancesVolumesActionPostInternalServerError { + return &PcloudCloudinstancesVolumesActionPostInternalServerError{} +} + +/* PcloudCloudinstancesVolumesActionPostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudCloudinstancesVolumesActionPostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesVolumesActionPostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes/{volume_id}/action][%d] pcloudCloudinstancesVolumesActionPostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudCloudinstancesVolumesActionPostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesActionPostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_delete_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_delete_parameters.go new file mode 100644 index 00000000000..d6066439cc9 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_delete_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudCloudinstancesVolumesDeleteParams creates a new PcloudCloudinstancesVolumesDeleteParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudCloudinstancesVolumesDeleteParams() *PcloudCloudinstancesVolumesDeleteParams { + return &PcloudCloudinstancesVolumesDeleteParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudinstancesVolumesDeleteParamsWithTimeout creates a new PcloudCloudinstancesVolumesDeleteParams object +// with the ability to set a timeout on a request. +func NewPcloudCloudinstancesVolumesDeleteParamsWithTimeout(timeout time.Duration) *PcloudCloudinstancesVolumesDeleteParams { + return &PcloudCloudinstancesVolumesDeleteParams{ + timeout: timeout, + } +} + +// NewPcloudCloudinstancesVolumesDeleteParamsWithContext creates a new PcloudCloudinstancesVolumesDeleteParams object +// with the ability to set a context for a request. +func NewPcloudCloudinstancesVolumesDeleteParamsWithContext(ctx context.Context) *PcloudCloudinstancesVolumesDeleteParams { + return &PcloudCloudinstancesVolumesDeleteParams{ + Context: ctx, + } +} + +// NewPcloudCloudinstancesVolumesDeleteParamsWithHTTPClient creates a new PcloudCloudinstancesVolumesDeleteParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudCloudinstancesVolumesDeleteParamsWithHTTPClient(client *http.Client) *PcloudCloudinstancesVolumesDeleteParams { + return &PcloudCloudinstancesVolumesDeleteParams{ + HTTPClient: client, + } +} + +/* PcloudCloudinstancesVolumesDeleteParams contains all the parameters to send to the API endpoint + for the pcloud cloudinstances volumes delete operation. + + Typically these are written to a http.Request. +*/ +type PcloudCloudinstancesVolumesDeleteParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* VolumeID. + + Volume ID + */ + VolumeID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud cloudinstances volumes delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesVolumesDeleteParams) WithDefaults() *PcloudCloudinstancesVolumesDeleteParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud cloudinstances volumes delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesVolumesDeleteParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud cloudinstances volumes delete params +func (o *PcloudCloudinstancesVolumesDeleteParams) WithTimeout(timeout time.Duration) *PcloudCloudinstancesVolumesDeleteParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudinstances volumes delete params +func (o *PcloudCloudinstancesVolumesDeleteParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudinstances volumes delete params +func (o *PcloudCloudinstancesVolumesDeleteParams) WithContext(ctx context.Context) *PcloudCloudinstancesVolumesDeleteParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudinstances volumes delete params +func (o *PcloudCloudinstancesVolumesDeleteParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudinstances volumes delete params +func (o *PcloudCloudinstancesVolumesDeleteParams) WithHTTPClient(client *http.Client) *PcloudCloudinstancesVolumesDeleteParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudinstances volumes delete params +func (o *PcloudCloudinstancesVolumesDeleteParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudinstances volumes delete params +func (o *PcloudCloudinstancesVolumesDeleteParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudinstancesVolumesDeleteParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudinstances volumes delete params +func (o *PcloudCloudinstancesVolumesDeleteParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithVolumeID adds the volumeID to the pcloud cloudinstances volumes delete params +func (o *PcloudCloudinstancesVolumesDeleteParams) WithVolumeID(volumeID string) *PcloudCloudinstancesVolumesDeleteParams { + o.SetVolumeID(volumeID) + return o +} + +// SetVolumeID adds the volumeId to the pcloud cloudinstances volumes delete params +func (o *PcloudCloudinstancesVolumesDeleteParams) SetVolumeID(volumeID string) { + o.VolumeID = volumeID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudinstancesVolumesDeleteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param volume_id + if err := r.SetPathParam("volume_id", o.VolumeID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_delete_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_delete_responses.go new file mode 100644 index 00000000000..eb7f8fbf965 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_delete_responses.go @@ -0,0 +1,217 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudinstancesVolumesDeleteReader is a Reader for the PcloudCloudinstancesVolumesDelete structure. +type PcloudCloudinstancesVolumesDeleteReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudinstancesVolumesDeleteReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudCloudinstancesVolumesDeleteOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudCloudinstancesVolumesDeleteBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudCloudinstancesVolumesDeleteUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 410: + result := NewPcloudCloudinstancesVolumesDeleteGone() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudCloudinstancesVolumesDeleteInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudCloudinstancesVolumesDeleteOK creates a PcloudCloudinstancesVolumesDeleteOK with default headers values +func NewPcloudCloudinstancesVolumesDeleteOK() *PcloudCloudinstancesVolumesDeleteOK { + return &PcloudCloudinstancesVolumesDeleteOK{} +} + +/* PcloudCloudinstancesVolumesDeleteOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudCloudinstancesVolumesDeleteOK struct { + Payload models.Object +} + +func (o *PcloudCloudinstancesVolumesDeleteOK) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes/{volume_id}][%d] pcloudCloudinstancesVolumesDeleteOK %+v", 200, o.Payload) +} +func (o *PcloudCloudinstancesVolumesDeleteOK) GetPayload() models.Object { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesDeleteOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesVolumesDeleteBadRequest creates a PcloudCloudinstancesVolumesDeleteBadRequest with default headers values +func NewPcloudCloudinstancesVolumesDeleteBadRequest() *PcloudCloudinstancesVolumesDeleteBadRequest { + return &PcloudCloudinstancesVolumesDeleteBadRequest{} +} + +/* PcloudCloudinstancesVolumesDeleteBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudCloudinstancesVolumesDeleteBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesVolumesDeleteBadRequest) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes/{volume_id}][%d] pcloudCloudinstancesVolumesDeleteBadRequest %+v", 400, o.Payload) +} +func (o *PcloudCloudinstancesVolumesDeleteBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesDeleteBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesVolumesDeleteUnauthorized creates a PcloudCloudinstancesVolumesDeleteUnauthorized with default headers values +func NewPcloudCloudinstancesVolumesDeleteUnauthorized() *PcloudCloudinstancesVolumesDeleteUnauthorized { + return &PcloudCloudinstancesVolumesDeleteUnauthorized{} +} + +/* PcloudCloudinstancesVolumesDeleteUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudCloudinstancesVolumesDeleteUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesVolumesDeleteUnauthorized) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes/{volume_id}][%d] pcloudCloudinstancesVolumesDeleteUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudCloudinstancesVolumesDeleteUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesDeleteUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesVolumesDeleteGone creates a PcloudCloudinstancesVolumesDeleteGone with default headers values +func NewPcloudCloudinstancesVolumesDeleteGone() *PcloudCloudinstancesVolumesDeleteGone { + return &PcloudCloudinstancesVolumesDeleteGone{} +} + +/* PcloudCloudinstancesVolumesDeleteGone describes a response with status code 410, with default header values. + +Gone +*/ +type PcloudCloudinstancesVolumesDeleteGone struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesVolumesDeleteGone) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes/{volume_id}][%d] pcloudCloudinstancesVolumesDeleteGone %+v", 410, o.Payload) +} +func (o *PcloudCloudinstancesVolumesDeleteGone) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesDeleteGone) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesVolumesDeleteInternalServerError creates a PcloudCloudinstancesVolumesDeleteInternalServerError with default headers values +func NewPcloudCloudinstancesVolumesDeleteInternalServerError() *PcloudCloudinstancesVolumesDeleteInternalServerError { + return &PcloudCloudinstancesVolumesDeleteInternalServerError{} +} + +/* PcloudCloudinstancesVolumesDeleteInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudCloudinstancesVolumesDeleteInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesVolumesDeleteInternalServerError) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes/{volume_id}][%d] pcloudCloudinstancesVolumesDeleteInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudCloudinstancesVolumesDeleteInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesDeleteInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_get_parameters.go new file mode 100644 index 00000000000..df8f8e699b3 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_get_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudCloudinstancesVolumesGetParams creates a new PcloudCloudinstancesVolumesGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudCloudinstancesVolumesGetParams() *PcloudCloudinstancesVolumesGetParams { + return &PcloudCloudinstancesVolumesGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudinstancesVolumesGetParamsWithTimeout creates a new PcloudCloudinstancesVolumesGetParams object +// with the ability to set a timeout on a request. +func NewPcloudCloudinstancesVolumesGetParamsWithTimeout(timeout time.Duration) *PcloudCloudinstancesVolumesGetParams { + return &PcloudCloudinstancesVolumesGetParams{ + timeout: timeout, + } +} + +// NewPcloudCloudinstancesVolumesGetParamsWithContext creates a new PcloudCloudinstancesVolumesGetParams object +// with the ability to set a context for a request. +func NewPcloudCloudinstancesVolumesGetParamsWithContext(ctx context.Context) *PcloudCloudinstancesVolumesGetParams { + return &PcloudCloudinstancesVolumesGetParams{ + Context: ctx, + } +} + +// NewPcloudCloudinstancesVolumesGetParamsWithHTTPClient creates a new PcloudCloudinstancesVolumesGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudCloudinstancesVolumesGetParamsWithHTTPClient(client *http.Client) *PcloudCloudinstancesVolumesGetParams { + return &PcloudCloudinstancesVolumesGetParams{ + HTTPClient: client, + } +} + +/* PcloudCloudinstancesVolumesGetParams contains all the parameters to send to the API endpoint + for the pcloud cloudinstances volumes get operation. + + Typically these are written to a http.Request. +*/ +type PcloudCloudinstancesVolumesGetParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* VolumeID. + + Volume ID + */ + VolumeID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud cloudinstances volumes get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesVolumesGetParams) WithDefaults() *PcloudCloudinstancesVolumesGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud cloudinstances volumes get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesVolumesGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud cloudinstances volumes get params +func (o *PcloudCloudinstancesVolumesGetParams) WithTimeout(timeout time.Duration) *PcloudCloudinstancesVolumesGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudinstances volumes get params +func (o *PcloudCloudinstancesVolumesGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudinstances volumes get params +func (o *PcloudCloudinstancesVolumesGetParams) WithContext(ctx context.Context) *PcloudCloudinstancesVolumesGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudinstances volumes get params +func (o *PcloudCloudinstancesVolumesGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudinstances volumes get params +func (o *PcloudCloudinstancesVolumesGetParams) WithHTTPClient(client *http.Client) *PcloudCloudinstancesVolumesGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudinstances volumes get params +func (o *PcloudCloudinstancesVolumesGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudinstances volumes get params +func (o *PcloudCloudinstancesVolumesGetParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudinstancesVolumesGetParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudinstances volumes get params +func (o *PcloudCloudinstancesVolumesGetParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithVolumeID adds the volumeID to the pcloud cloudinstances volumes get params +func (o *PcloudCloudinstancesVolumesGetParams) WithVolumeID(volumeID string) *PcloudCloudinstancesVolumesGetParams { + o.SetVolumeID(volumeID) + return o +} + +// SetVolumeID adds the volumeId to the pcloud cloudinstances volumes get params +func (o *PcloudCloudinstancesVolumesGetParams) SetVolumeID(volumeID string) { + o.VolumeID = volumeID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudinstancesVolumesGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param volume_id + if err := r.SetPathParam("volume_id", o.VolumeID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_get_responses.go new file mode 100644 index 00000000000..896d21be08c --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_get_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudinstancesVolumesGetReader is a Reader for the PcloudCloudinstancesVolumesGet structure. +type PcloudCloudinstancesVolumesGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudinstancesVolumesGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudCloudinstancesVolumesGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudCloudinstancesVolumesGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudCloudinstancesVolumesGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudCloudinstancesVolumesGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudCloudinstancesVolumesGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudCloudinstancesVolumesGetOK creates a PcloudCloudinstancesVolumesGetOK with default headers values +func NewPcloudCloudinstancesVolumesGetOK() *PcloudCloudinstancesVolumesGetOK { + return &PcloudCloudinstancesVolumesGetOK{} +} + +/* PcloudCloudinstancesVolumesGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudCloudinstancesVolumesGetOK struct { + Payload *models.Volume +} + +func (o *PcloudCloudinstancesVolumesGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes/{volume_id}][%d] pcloudCloudinstancesVolumesGetOK %+v", 200, o.Payload) +} +func (o *PcloudCloudinstancesVolumesGetOK) GetPayload() *models.Volume { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Volume) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesVolumesGetBadRequest creates a PcloudCloudinstancesVolumesGetBadRequest with default headers values +func NewPcloudCloudinstancesVolumesGetBadRequest() *PcloudCloudinstancesVolumesGetBadRequest { + return &PcloudCloudinstancesVolumesGetBadRequest{} +} + +/* PcloudCloudinstancesVolumesGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudCloudinstancesVolumesGetBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesVolumesGetBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes/{volume_id}][%d] pcloudCloudinstancesVolumesGetBadRequest %+v", 400, o.Payload) +} +func (o *PcloudCloudinstancesVolumesGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesVolumesGetUnauthorized creates a PcloudCloudinstancesVolumesGetUnauthorized with default headers values +func NewPcloudCloudinstancesVolumesGetUnauthorized() *PcloudCloudinstancesVolumesGetUnauthorized { + return &PcloudCloudinstancesVolumesGetUnauthorized{} +} + +/* PcloudCloudinstancesVolumesGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudCloudinstancesVolumesGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesVolumesGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes/{volume_id}][%d] pcloudCloudinstancesVolumesGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudCloudinstancesVolumesGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesVolumesGetNotFound creates a PcloudCloudinstancesVolumesGetNotFound with default headers values +func NewPcloudCloudinstancesVolumesGetNotFound() *PcloudCloudinstancesVolumesGetNotFound { + return &PcloudCloudinstancesVolumesGetNotFound{} +} + +/* PcloudCloudinstancesVolumesGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudCloudinstancesVolumesGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesVolumesGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes/{volume_id}][%d] pcloudCloudinstancesVolumesGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudCloudinstancesVolumesGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesVolumesGetInternalServerError creates a PcloudCloudinstancesVolumesGetInternalServerError with default headers values +func NewPcloudCloudinstancesVolumesGetInternalServerError() *PcloudCloudinstancesVolumesGetInternalServerError { + return &PcloudCloudinstancesVolumesGetInternalServerError{} +} + +/* PcloudCloudinstancesVolumesGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudCloudinstancesVolumesGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesVolumesGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes/{volume_id}][%d] pcloudCloudinstancesVolumesGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudCloudinstancesVolumesGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_getall_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_getall_parameters.go new file mode 100644 index 00000000000..55d12effb28 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_getall_parameters.go @@ -0,0 +1,218 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewPcloudCloudinstancesVolumesGetallParams creates a new PcloudCloudinstancesVolumesGetallParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudCloudinstancesVolumesGetallParams() *PcloudCloudinstancesVolumesGetallParams { + return &PcloudCloudinstancesVolumesGetallParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudinstancesVolumesGetallParamsWithTimeout creates a new PcloudCloudinstancesVolumesGetallParams object +// with the ability to set a timeout on a request. +func NewPcloudCloudinstancesVolumesGetallParamsWithTimeout(timeout time.Duration) *PcloudCloudinstancesVolumesGetallParams { + return &PcloudCloudinstancesVolumesGetallParams{ + timeout: timeout, + } +} + +// NewPcloudCloudinstancesVolumesGetallParamsWithContext creates a new PcloudCloudinstancesVolumesGetallParams object +// with the ability to set a context for a request. +func NewPcloudCloudinstancesVolumesGetallParamsWithContext(ctx context.Context) *PcloudCloudinstancesVolumesGetallParams { + return &PcloudCloudinstancesVolumesGetallParams{ + Context: ctx, + } +} + +// NewPcloudCloudinstancesVolumesGetallParamsWithHTTPClient creates a new PcloudCloudinstancesVolumesGetallParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudCloudinstancesVolumesGetallParamsWithHTTPClient(client *http.Client) *PcloudCloudinstancesVolumesGetallParams { + return &PcloudCloudinstancesVolumesGetallParams{ + HTTPClient: client, + } +} + +/* PcloudCloudinstancesVolumesGetallParams contains all the parameters to send to the API endpoint + for the pcloud cloudinstances volumes getall operation. + + Typically these are written to a http.Request. +*/ +type PcloudCloudinstancesVolumesGetallParams struct { + + /* Affinity. + + A pvmInstance (id or name), limits a volumes list response to only volumes that have affinity to the pvmInstance + */ + Affinity *string + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* ReplicationEnabled. + + true or false, limits a volumes list to replication or non replication enabled volumes + */ + ReplicationEnabled *bool + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud cloudinstances volumes getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesVolumesGetallParams) WithDefaults() *PcloudCloudinstancesVolumesGetallParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud cloudinstances volumes getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesVolumesGetallParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud cloudinstances volumes getall params +func (o *PcloudCloudinstancesVolumesGetallParams) WithTimeout(timeout time.Duration) *PcloudCloudinstancesVolumesGetallParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudinstances volumes getall params +func (o *PcloudCloudinstancesVolumesGetallParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudinstances volumes getall params +func (o *PcloudCloudinstancesVolumesGetallParams) WithContext(ctx context.Context) *PcloudCloudinstancesVolumesGetallParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudinstances volumes getall params +func (o *PcloudCloudinstancesVolumesGetallParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudinstances volumes getall params +func (o *PcloudCloudinstancesVolumesGetallParams) WithHTTPClient(client *http.Client) *PcloudCloudinstancesVolumesGetallParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudinstances volumes getall params +func (o *PcloudCloudinstancesVolumesGetallParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithAffinity adds the affinity to the pcloud cloudinstances volumes getall params +func (o *PcloudCloudinstancesVolumesGetallParams) WithAffinity(affinity *string) *PcloudCloudinstancesVolumesGetallParams { + o.SetAffinity(affinity) + return o +} + +// SetAffinity adds the affinity to the pcloud cloudinstances volumes getall params +func (o *PcloudCloudinstancesVolumesGetallParams) SetAffinity(affinity *string) { + o.Affinity = affinity +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudinstances volumes getall params +func (o *PcloudCloudinstancesVolumesGetallParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudinstancesVolumesGetallParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudinstances volumes getall params +func (o *PcloudCloudinstancesVolumesGetallParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithReplicationEnabled adds the replicationEnabled to the pcloud cloudinstances volumes getall params +func (o *PcloudCloudinstancesVolumesGetallParams) WithReplicationEnabled(replicationEnabled *bool) *PcloudCloudinstancesVolumesGetallParams { + o.SetReplicationEnabled(replicationEnabled) + return o +} + +// SetReplicationEnabled adds the replicationEnabled to the pcloud cloudinstances volumes getall params +func (o *PcloudCloudinstancesVolumesGetallParams) SetReplicationEnabled(replicationEnabled *bool) { + o.ReplicationEnabled = replicationEnabled +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudinstancesVolumesGetallParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.Affinity != nil { + + // query param affinity + var qrAffinity string + + if o.Affinity != nil { + qrAffinity = *o.Affinity + } + qAffinity := qrAffinity + if qAffinity != "" { + + if err := r.SetQueryParam("affinity", qAffinity); err != nil { + return err + } + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if o.ReplicationEnabled != nil { + + // query param replicationEnabled + var qrReplicationEnabled bool + + if o.ReplicationEnabled != nil { + qrReplicationEnabled = *o.ReplicationEnabled + } + qReplicationEnabled := swag.FormatBool(qrReplicationEnabled) + if qReplicationEnabled != "" { + + if err := r.SetQueryParam("replicationEnabled", qReplicationEnabled); err != nil { + return err + } + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_getall_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_getall_responses.go new file mode 100644 index 00000000000..88e6badbeff --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_getall_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudinstancesVolumesGetallReader is a Reader for the PcloudCloudinstancesVolumesGetall structure. +type PcloudCloudinstancesVolumesGetallReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudinstancesVolumesGetallReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudCloudinstancesVolumesGetallOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudCloudinstancesVolumesGetallBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudCloudinstancesVolumesGetallUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudCloudinstancesVolumesGetallNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudCloudinstancesVolumesGetallInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudCloudinstancesVolumesGetallOK creates a PcloudCloudinstancesVolumesGetallOK with default headers values +func NewPcloudCloudinstancesVolumesGetallOK() *PcloudCloudinstancesVolumesGetallOK { + return &PcloudCloudinstancesVolumesGetallOK{} +} + +/* PcloudCloudinstancesVolumesGetallOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudCloudinstancesVolumesGetallOK struct { + Payload *models.Volumes +} + +func (o *PcloudCloudinstancesVolumesGetallOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes][%d] pcloudCloudinstancesVolumesGetallOK %+v", 200, o.Payload) +} +func (o *PcloudCloudinstancesVolumesGetallOK) GetPayload() *models.Volumes { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesGetallOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Volumes) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesVolumesGetallBadRequest creates a PcloudCloudinstancesVolumesGetallBadRequest with default headers values +func NewPcloudCloudinstancesVolumesGetallBadRequest() *PcloudCloudinstancesVolumesGetallBadRequest { + return &PcloudCloudinstancesVolumesGetallBadRequest{} +} + +/* PcloudCloudinstancesVolumesGetallBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudCloudinstancesVolumesGetallBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesVolumesGetallBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes][%d] pcloudCloudinstancesVolumesGetallBadRequest %+v", 400, o.Payload) +} +func (o *PcloudCloudinstancesVolumesGetallBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesGetallBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesVolumesGetallUnauthorized creates a PcloudCloudinstancesVolumesGetallUnauthorized with default headers values +func NewPcloudCloudinstancesVolumesGetallUnauthorized() *PcloudCloudinstancesVolumesGetallUnauthorized { + return &PcloudCloudinstancesVolumesGetallUnauthorized{} +} + +/* PcloudCloudinstancesVolumesGetallUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudCloudinstancesVolumesGetallUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesVolumesGetallUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes][%d] pcloudCloudinstancesVolumesGetallUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudCloudinstancesVolumesGetallUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesGetallUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesVolumesGetallNotFound creates a PcloudCloudinstancesVolumesGetallNotFound with default headers values +func NewPcloudCloudinstancesVolumesGetallNotFound() *PcloudCloudinstancesVolumesGetallNotFound { + return &PcloudCloudinstancesVolumesGetallNotFound{} +} + +/* PcloudCloudinstancesVolumesGetallNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudCloudinstancesVolumesGetallNotFound struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesVolumesGetallNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes][%d] pcloudCloudinstancesVolumesGetallNotFound %+v", 404, o.Payload) +} +func (o *PcloudCloudinstancesVolumesGetallNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesGetallNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesVolumesGetallInternalServerError creates a PcloudCloudinstancesVolumesGetallInternalServerError with default headers values +func NewPcloudCloudinstancesVolumesGetallInternalServerError() *PcloudCloudinstancesVolumesGetallInternalServerError { + return &PcloudCloudinstancesVolumesGetallInternalServerError{} +} + +/* PcloudCloudinstancesVolumesGetallInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudCloudinstancesVolumesGetallInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesVolumesGetallInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes][%d] pcloudCloudinstancesVolumesGetallInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudCloudinstancesVolumesGetallInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesGetallInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_post_parameters.go new file mode 100644 index 00000000000..456bf17a9b9 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_post_parameters.go @@ -0,0 +1,173 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudCloudinstancesVolumesPostParams creates a new PcloudCloudinstancesVolumesPostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudCloudinstancesVolumesPostParams() *PcloudCloudinstancesVolumesPostParams { + return &PcloudCloudinstancesVolumesPostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudinstancesVolumesPostParamsWithTimeout creates a new PcloudCloudinstancesVolumesPostParams object +// with the ability to set a timeout on a request. +func NewPcloudCloudinstancesVolumesPostParamsWithTimeout(timeout time.Duration) *PcloudCloudinstancesVolumesPostParams { + return &PcloudCloudinstancesVolumesPostParams{ + timeout: timeout, + } +} + +// NewPcloudCloudinstancesVolumesPostParamsWithContext creates a new PcloudCloudinstancesVolumesPostParams object +// with the ability to set a context for a request. +func NewPcloudCloudinstancesVolumesPostParamsWithContext(ctx context.Context) *PcloudCloudinstancesVolumesPostParams { + return &PcloudCloudinstancesVolumesPostParams{ + Context: ctx, + } +} + +// NewPcloudCloudinstancesVolumesPostParamsWithHTTPClient creates a new PcloudCloudinstancesVolumesPostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudCloudinstancesVolumesPostParamsWithHTTPClient(client *http.Client) *PcloudCloudinstancesVolumesPostParams { + return &PcloudCloudinstancesVolumesPostParams{ + HTTPClient: client, + } +} + +/* PcloudCloudinstancesVolumesPostParams contains all the parameters to send to the API endpoint + for the pcloud cloudinstances volumes post operation. + + Typically these are written to a http.Request. +*/ +type PcloudCloudinstancesVolumesPostParams struct { + + /* Body. + + Parameters for the creation of a new data volume + */ + Body *models.CreateDataVolume + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud cloudinstances volumes post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesVolumesPostParams) WithDefaults() *PcloudCloudinstancesVolumesPostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud cloudinstances volumes post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesVolumesPostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud cloudinstances volumes post params +func (o *PcloudCloudinstancesVolumesPostParams) WithTimeout(timeout time.Duration) *PcloudCloudinstancesVolumesPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudinstances volumes post params +func (o *PcloudCloudinstancesVolumesPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudinstances volumes post params +func (o *PcloudCloudinstancesVolumesPostParams) WithContext(ctx context.Context) *PcloudCloudinstancesVolumesPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudinstances volumes post params +func (o *PcloudCloudinstancesVolumesPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudinstances volumes post params +func (o *PcloudCloudinstancesVolumesPostParams) WithHTTPClient(client *http.Client) *PcloudCloudinstancesVolumesPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudinstances volumes post params +func (o *PcloudCloudinstancesVolumesPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud cloudinstances volumes post params +func (o *PcloudCloudinstancesVolumesPostParams) WithBody(body *models.CreateDataVolume) *PcloudCloudinstancesVolumesPostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud cloudinstances volumes post params +func (o *PcloudCloudinstancesVolumesPostParams) SetBody(body *models.CreateDataVolume) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudinstances volumes post params +func (o *PcloudCloudinstancesVolumesPostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudinstancesVolumesPostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudinstances volumes post params +func (o *PcloudCloudinstancesVolumesPostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudinstancesVolumesPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_post_responses.go new file mode 100644 index 00000000000..258e913a868 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_post_responses.go @@ -0,0 +1,257 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudinstancesVolumesPostReader is a Reader for the PcloudCloudinstancesVolumesPost structure. +type PcloudCloudinstancesVolumesPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudinstancesVolumesPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 202: + result := NewPcloudCloudinstancesVolumesPostAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudCloudinstancesVolumesPostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudCloudinstancesVolumesPostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewPcloudCloudinstancesVolumesPostConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudCloudinstancesVolumesPostUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudCloudinstancesVolumesPostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudCloudinstancesVolumesPostAccepted creates a PcloudCloudinstancesVolumesPostAccepted with default headers values +func NewPcloudCloudinstancesVolumesPostAccepted() *PcloudCloudinstancesVolumesPostAccepted { + return &PcloudCloudinstancesVolumesPostAccepted{} +} + +/* PcloudCloudinstancesVolumesPostAccepted describes a response with status code 202, with default header values. + +Accepted +*/ +type PcloudCloudinstancesVolumesPostAccepted struct { + Payload *models.Volume +} + +func (o *PcloudCloudinstancesVolumesPostAccepted) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes][%d] pcloudCloudinstancesVolumesPostAccepted %+v", 202, o.Payload) +} +func (o *PcloudCloudinstancesVolumesPostAccepted) GetPayload() *models.Volume { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesPostAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Volume) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesVolumesPostBadRequest creates a PcloudCloudinstancesVolumesPostBadRequest with default headers values +func NewPcloudCloudinstancesVolumesPostBadRequest() *PcloudCloudinstancesVolumesPostBadRequest { + return &PcloudCloudinstancesVolumesPostBadRequest{} +} + +/* PcloudCloudinstancesVolumesPostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudCloudinstancesVolumesPostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesVolumesPostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes][%d] pcloudCloudinstancesVolumesPostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudCloudinstancesVolumesPostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesPostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesVolumesPostUnauthorized creates a PcloudCloudinstancesVolumesPostUnauthorized with default headers values +func NewPcloudCloudinstancesVolumesPostUnauthorized() *PcloudCloudinstancesVolumesPostUnauthorized { + return &PcloudCloudinstancesVolumesPostUnauthorized{} +} + +/* PcloudCloudinstancesVolumesPostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudCloudinstancesVolumesPostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesVolumesPostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes][%d] pcloudCloudinstancesVolumesPostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudCloudinstancesVolumesPostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesPostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesVolumesPostConflict creates a PcloudCloudinstancesVolumesPostConflict with default headers values +func NewPcloudCloudinstancesVolumesPostConflict() *PcloudCloudinstancesVolumesPostConflict { + return &PcloudCloudinstancesVolumesPostConflict{} +} + +/* PcloudCloudinstancesVolumesPostConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type PcloudCloudinstancesVolumesPostConflict struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesVolumesPostConflict) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes][%d] pcloudCloudinstancesVolumesPostConflict %+v", 409, o.Payload) +} +func (o *PcloudCloudinstancesVolumesPostConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesPostConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesVolumesPostUnprocessableEntity creates a PcloudCloudinstancesVolumesPostUnprocessableEntity with default headers values +func NewPcloudCloudinstancesVolumesPostUnprocessableEntity() *PcloudCloudinstancesVolumesPostUnprocessableEntity { + return &PcloudCloudinstancesVolumesPostUnprocessableEntity{} +} + +/* PcloudCloudinstancesVolumesPostUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudCloudinstancesVolumesPostUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesVolumesPostUnprocessableEntity) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes][%d] pcloudCloudinstancesVolumesPostUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudCloudinstancesVolumesPostUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesPostUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesVolumesPostInternalServerError creates a PcloudCloudinstancesVolumesPostInternalServerError with default headers values +func NewPcloudCloudinstancesVolumesPostInternalServerError() *PcloudCloudinstancesVolumesPostInternalServerError { + return &PcloudCloudinstancesVolumesPostInternalServerError{} +} + +/* PcloudCloudinstancesVolumesPostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudCloudinstancesVolumesPostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesVolumesPostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes][%d] pcloudCloudinstancesVolumesPostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudCloudinstancesVolumesPostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesPostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_put_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_put_parameters.go new file mode 100644 index 00000000000..3c0e47c964e --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_put_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudCloudinstancesVolumesPutParams creates a new PcloudCloudinstancesVolumesPutParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudCloudinstancesVolumesPutParams() *PcloudCloudinstancesVolumesPutParams { + return &PcloudCloudinstancesVolumesPutParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudinstancesVolumesPutParamsWithTimeout creates a new PcloudCloudinstancesVolumesPutParams object +// with the ability to set a timeout on a request. +func NewPcloudCloudinstancesVolumesPutParamsWithTimeout(timeout time.Duration) *PcloudCloudinstancesVolumesPutParams { + return &PcloudCloudinstancesVolumesPutParams{ + timeout: timeout, + } +} + +// NewPcloudCloudinstancesVolumesPutParamsWithContext creates a new PcloudCloudinstancesVolumesPutParams object +// with the ability to set a context for a request. +func NewPcloudCloudinstancesVolumesPutParamsWithContext(ctx context.Context) *PcloudCloudinstancesVolumesPutParams { + return &PcloudCloudinstancesVolumesPutParams{ + Context: ctx, + } +} + +// NewPcloudCloudinstancesVolumesPutParamsWithHTTPClient creates a new PcloudCloudinstancesVolumesPutParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudCloudinstancesVolumesPutParamsWithHTTPClient(client *http.Client) *PcloudCloudinstancesVolumesPutParams { + return &PcloudCloudinstancesVolumesPutParams{ + HTTPClient: client, + } +} + +/* PcloudCloudinstancesVolumesPutParams contains all the parameters to send to the API endpoint + for the pcloud cloudinstances volumes put operation. + + Typically these are written to a http.Request. +*/ +type PcloudCloudinstancesVolumesPutParams struct { + + /* Body. + + Parameters to update a cloud instance volume + */ + Body *models.UpdateVolume + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* VolumeID. + + Volume ID + */ + VolumeID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud cloudinstances volumes put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesVolumesPutParams) WithDefaults() *PcloudCloudinstancesVolumesPutParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud cloudinstances volumes put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudCloudinstancesVolumesPutParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud cloudinstances volumes put params +func (o *PcloudCloudinstancesVolumesPutParams) WithTimeout(timeout time.Duration) *PcloudCloudinstancesVolumesPutParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudinstances volumes put params +func (o *PcloudCloudinstancesVolumesPutParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudinstances volumes put params +func (o *PcloudCloudinstancesVolumesPutParams) WithContext(ctx context.Context) *PcloudCloudinstancesVolumesPutParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudinstances volumes put params +func (o *PcloudCloudinstancesVolumesPutParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudinstances volumes put params +func (o *PcloudCloudinstancesVolumesPutParams) WithHTTPClient(client *http.Client) *PcloudCloudinstancesVolumesPutParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudinstances volumes put params +func (o *PcloudCloudinstancesVolumesPutParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud cloudinstances volumes put params +func (o *PcloudCloudinstancesVolumesPutParams) WithBody(body *models.UpdateVolume) *PcloudCloudinstancesVolumesPutParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud cloudinstances volumes put params +func (o *PcloudCloudinstancesVolumesPutParams) SetBody(body *models.UpdateVolume) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudinstances volumes put params +func (o *PcloudCloudinstancesVolumesPutParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudinstancesVolumesPutParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudinstances volumes put params +func (o *PcloudCloudinstancesVolumesPutParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithVolumeID adds the volumeID to the pcloud cloudinstances volumes put params +func (o *PcloudCloudinstancesVolumesPutParams) WithVolumeID(volumeID string) *PcloudCloudinstancesVolumesPutParams { + o.SetVolumeID(volumeID) + return o +} + +// SetVolumeID adds the volumeId to the pcloud cloudinstances volumes put params +func (o *PcloudCloudinstancesVolumesPutParams) SetVolumeID(volumeID string) { + o.VolumeID = volumeID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudinstancesVolumesPutParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param volume_id + if err := r.SetPathParam("volume_id", o.VolumeID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_put_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_put_responses.go new file mode 100644 index 00000000000..37837d85419 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_cloudinstances_volumes_put_responses.go @@ -0,0 +1,257 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudinstancesVolumesPutReader is a Reader for the PcloudCloudinstancesVolumesPut structure. +type PcloudCloudinstancesVolumesPutReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudinstancesVolumesPutReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudCloudinstancesVolumesPutOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudCloudinstancesVolumesPutBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudCloudinstancesVolumesPutUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewPcloudCloudinstancesVolumesPutConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudCloudinstancesVolumesPutUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudCloudinstancesVolumesPutInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudCloudinstancesVolumesPutOK creates a PcloudCloudinstancesVolumesPutOK with default headers values +func NewPcloudCloudinstancesVolumesPutOK() *PcloudCloudinstancesVolumesPutOK { + return &PcloudCloudinstancesVolumesPutOK{} +} + +/* PcloudCloudinstancesVolumesPutOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudCloudinstancesVolumesPutOK struct { + Payload *models.Volume +} + +func (o *PcloudCloudinstancesVolumesPutOK) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes/{volume_id}][%d] pcloudCloudinstancesVolumesPutOK %+v", 200, o.Payload) +} +func (o *PcloudCloudinstancesVolumesPutOK) GetPayload() *models.Volume { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesPutOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Volume) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesVolumesPutBadRequest creates a PcloudCloudinstancesVolumesPutBadRequest with default headers values +func NewPcloudCloudinstancesVolumesPutBadRequest() *PcloudCloudinstancesVolumesPutBadRequest { + return &PcloudCloudinstancesVolumesPutBadRequest{} +} + +/* PcloudCloudinstancesVolumesPutBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudCloudinstancesVolumesPutBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesVolumesPutBadRequest) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes/{volume_id}][%d] pcloudCloudinstancesVolumesPutBadRequest %+v", 400, o.Payload) +} +func (o *PcloudCloudinstancesVolumesPutBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesPutBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesVolumesPutUnauthorized creates a PcloudCloudinstancesVolumesPutUnauthorized with default headers values +func NewPcloudCloudinstancesVolumesPutUnauthorized() *PcloudCloudinstancesVolumesPutUnauthorized { + return &PcloudCloudinstancesVolumesPutUnauthorized{} +} + +/* PcloudCloudinstancesVolumesPutUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudCloudinstancesVolumesPutUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesVolumesPutUnauthorized) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes/{volume_id}][%d] pcloudCloudinstancesVolumesPutUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudCloudinstancesVolumesPutUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesPutUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesVolumesPutConflict creates a PcloudCloudinstancesVolumesPutConflict with default headers values +func NewPcloudCloudinstancesVolumesPutConflict() *PcloudCloudinstancesVolumesPutConflict { + return &PcloudCloudinstancesVolumesPutConflict{} +} + +/* PcloudCloudinstancesVolumesPutConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type PcloudCloudinstancesVolumesPutConflict struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesVolumesPutConflict) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes/{volume_id}][%d] pcloudCloudinstancesVolumesPutConflict %+v", 409, o.Payload) +} +func (o *PcloudCloudinstancesVolumesPutConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesPutConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesVolumesPutUnprocessableEntity creates a PcloudCloudinstancesVolumesPutUnprocessableEntity with default headers values +func NewPcloudCloudinstancesVolumesPutUnprocessableEntity() *PcloudCloudinstancesVolumesPutUnprocessableEntity { + return &PcloudCloudinstancesVolumesPutUnprocessableEntity{} +} + +/* PcloudCloudinstancesVolumesPutUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudCloudinstancesVolumesPutUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesVolumesPutUnprocessableEntity) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes/{volume_id}][%d] pcloudCloudinstancesVolumesPutUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudCloudinstancesVolumesPutUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesPutUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesVolumesPutInternalServerError creates a PcloudCloudinstancesVolumesPutInternalServerError with default headers values +func NewPcloudCloudinstancesVolumesPutInternalServerError() *PcloudCloudinstancesVolumesPutInternalServerError { + return &PcloudCloudinstancesVolumesPutInternalServerError{} +} + +/* PcloudCloudinstancesVolumesPutInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudCloudinstancesVolumesPutInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesVolumesPutInternalServerError) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes/{volume_id}][%d] pcloudCloudinstancesVolumesPutInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudCloudinstancesVolumesPutInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudCloudinstancesVolumesPutInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_delete_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_delete_parameters.go new file mode 100644 index 00000000000..0facc81b622 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_delete_parameters.go @@ -0,0 +1,193 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudPvminstancesVolumesDeleteParams creates a new PcloudPvminstancesVolumesDeleteParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudPvminstancesVolumesDeleteParams() *PcloudPvminstancesVolumesDeleteParams { + return &PcloudPvminstancesVolumesDeleteParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudPvminstancesVolumesDeleteParamsWithTimeout creates a new PcloudPvminstancesVolumesDeleteParams object +// with the ability to set a timeout on a request. +func NewPcloudPvminstancesVolumesDeleteParamsWithTimeout(timeout time.Duration) *PcloudPvminstancesVolumesDeleteParams { + return &PcloudPvminstancesVolumesDeleteParams{ + timeout: timeout, + } +} + +// NewPcloudPvminstancesVolumesDeleteParamsWithContext creates a new PcloudPvminstancesVolumesDeleteParams object +// with the ability to set a context for a request. +func NewPcloudPvminstancesVolumesDeleteParamsWithContext(ctx context.Context) *PcloudPvminstancesVolumesDeleteParams { + return &PcloudPvminstancesVolumesDeleteParams{ + Context: ctx, + } +} + +// NewPcloudPvminstancesVolumesDeleteParamsWithHTTPClient creates a new PcloudPvminstancesVolumesDeleteParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudPvminstancesVolumesDeleteParamsWithHTTPClient(client *http.Client) *PcloudPvminstancesVolumesDeleteParams { + return &PcloudPvminstancesVolumesDeleteParams{ + HTTPClient: client, + } +} + +/* PcloudPvminstancesVolumesDeleteParams contains all the parameters to send to the API endpoint + for the pcloud pvminstances volumes delete operation. + + Typically these are written to a http.Request. +*/ +type PcloudPvminstancesVolumesDeleteParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* PvmInstanceID. + + PCloud PVM Instance ID + */ + PvmInstanceID string + + /* VolumeID. + + Volume ID + */ + VolumeID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud pvminstances volumes delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesVolumesDeleteParams) WithDefaults() *PcloudPvminstancesVolumesDeleteParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud pvminstances volumes delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesVolumesDeleteParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud pvminstances volumes delete params +func (o *PcloudPvminstancesVolumesDeleteParams) WithTimeout(timeout time.Duration) *PcloudPvminstancesVolumesDeleteParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud pvminstances volumes delete params +func (o *PcloudPvminstancesVolumesDeleteParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud pvminstances volumes delete params +func (o *PcloudPvminstancesVolumesDeleteParams) WithContext(ctx context.Context) *PcloudPvminstancesVolumesDeleteParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud pvminstances volumes delete params +func (o *PcloudPvminstancesVolumesDeleteParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud pvminstances volumes delete params +func (o *PcloudPvminstancesVolumesDeleteParams) WithHTTPClient(client *http.Client) *PcloudPvminstancesVolumesDeleteParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud pvminstances volumes delete params +func (o *PcloudPvminstancesVolumesDeleteParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud pvminstances volumes delete params +func (o *PcloudPvminstancesVolumesDeleteParams) WithCloudInstanceID(cloudInstanceID string) *PcloudPvminstancesVolumesDeleteParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud pvminstances volumes delete params +func (o *PcloudPvminstancesVolumesDeleteParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithPvmInstanceID adds the pvmInstanceID to the pcloud pvminstances volumes delete params +func (o *PcloudPvminstancesVolumesDeleteParams) WithPvmInstanceID(pvmInstanceID string) *PcloudPvminstancesVolumesDeleteParams { + o.SetPvmInstanceID(pvmInstanceID) + return o +} + +// SetPvmInstanceID adds the pvmInstanceId to the pcloud pvminstances volumes delete params +func (o *PcloudPvminstancesVolumesDeleteParams) SetPvmInstanceID(pvmInstanceID string) { + o.PvmInstanceID = pvmInstanceID +} + +// WithVolumeID adds the volumeID to the pcloud pvminstances volumes delete params +func (o *PcloudPvminstancesVolumesDeleteParams) WithVolumeID(volumeID string) *PcloudPvminstancesVolumesDeleteParams { + o.SetVolumeID(volumeID) + return o +} + +// SetVolumeID adds the volumeId to the pcloud pvminstances volumes delete params +func (o *PcloudPvminstancesVolumesDeleteParams) SetVolumeID(volumeID string) { + o.VolumeID = volumeID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudPvminstancesVolumesDeleteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param pvm_instance_id + if err := r.SetPathParam("pvm_instance_id", o.PvmInstanceID); err != nil { + return err + } + + // path param volume_id + if err := r.SetPathParam("volume_id", o.VolumeID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_delete_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_delete_responses.go new file mode 100644 index 00000000000..7965aa2c97b --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_delete_responses.go @@ -0,0 +1,293 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudPvminstancesVolumesDeleteReader is a Reader for the PcloudPvminstancesVolumesDelete structure. +type PcloudPvminstancesVolumesDeleteReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudPvminstancesVolumesDeleteReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 202: + result := NewPcloudPvminstancesVolumesDeleteAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudPvminstancesVolumesDeleteBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudPvminstancesVolumesDeleteUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewPcloudPvminstancesVolumesDeleteForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudPvminstancesVolumesDeleteNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewPcloudPvminstancesVolumesDeleteConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudPvminstancesVolumesDeleteInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudPvminstancesVolumesDeleteAccepted creates a PcloudPvminstancesVolumesDeleteAccepted with default headers values +func NewPcloudPvminstancesVolumesDeleteAccepted() *PcloudPvminstancesVolumesDeleteAccepted { + return &PcloudPvminstancesVolumesDeleteAccepted{} +} + +/* PcloudPvminstancesVolumesDeleteAccepted describes a response with status code 202, with default header values. + +OK +*/ +type PcloudPvminstancesVolumesDeleteAccepted struct { + Payload models.Object +} + +func (o *PcloudPvminstancesVolumesDeleteAccepted) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}][%d] pcloudPvminstancesVolumesDeleteAccepted %+v", 202, o.Payload) +} +func (o *PcloudPvminstancesVolumesDeleteAccepted) GetPayload() models.Object { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesDeleteAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesVolumesDeleteBadRequest creates a PcloudPvminstancesVolumesDeleteBadRequest with default headers values +func NewPcloudPvminstancesVolumesDeleteBadRequest() *PcloudPvminstancesVolumesDeleteBadRequest { + return &PcloudPvminstancesVolumesDeleteBadRequest{} +} + +/* PcloudPvminstancesVolumesDeleteBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudPvminstancesVolumesDeleteBadRequest struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesVolumesDeleteBadRequest) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}][%d] pcloudPvminstancesVolumesDeleteBadRequest %+v", 400, o.Payload) +} +func (o *PcloudPvminstancesVolumesDeleteBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesDeleteBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesVolumesDeleteUnauthorized creates a PcloudPvminstancesVolumesDeleteUnauthorized with default headers values +func NewPcloudPvminstancesVolumesDeleteUnauthorized() *PcloudPvminstancesVolumesDeleteUnauthorized { + return &PcloudPvminstancesVolumesDeleteUnauthorized{} +} + +/* PcloudPvminstancesVolumesDeleteUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudPvminstancesVolumesDeleteUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesVolumesDeleteUnauthorized) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}][%d] pcloudPvminstancesVolumesDeleteUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudPvminstancesVolumesDeleteUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesDeleteUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesVolumesDeleteForbidden creates a PcloudPvminstancesVolumesDeleteForbidden with default headers values +func NewPcloudPvminstancesVolumesDeleteForbidden() *PcloudPvminstancesVolumesDeleteForbidden { + return &PcloudPvminstancesVolumesDeleteForbidden{} +} + +/* PcloudPvminstancesVolumesDeleteForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type PcloudPvminstancesVolumesDeleteForbidden struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesVolumesDeleteForbidden) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}][%d] pcloudPvminstancesVolumesDeleteForbidden %+v", 403, o.Payload) +} +func (o *PcloudPvminstancesVolumesDeleteForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesDeleteForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesVolumesDeleteNotFound creates a PcloudPvminstancesVolumesDeleteNotFound with default headers values +func NewPcloudPvminstancesVolumesDeleteNotFound() *PcloudPvminstancesVolumesDeleteNotFound { + return &PcloudPvminstancesVolumesDeleteNotFound{} +} + +/* PcloudPvminstancesVolumesDeleteNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudPvminstancesVolumesDeleteNotFound struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesVolumesDeleteNotFound) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}][%d] pcloudPvminstancesVolumesDeleteNotFound %+v", 404, o.Payload) +} +func (o *PcloudPvminstancesVolumesDeleteNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesDeleteNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesVolumesDeleteConflict creates a PcloudPvminstancesVolumesDeleteConflict with default headers values +func NewPcloudPvminstancesVolumesDeleteConflict() *PcloudPvminstancesVolumesDeleteConflict { + return &PcloudPvminstancesVolumesDeleteConflict{} +} + +/* PcloudPvminstancesVolumesDeleteConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type PcloudPvminstancesVolumesDeleteConflict struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesVolumesDeleteConflict) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}][%d] pcloudPvminstancesVolumesDeleteConflict %+v", 409, o.Payload) +} +func (o *PcloudPvminstancesVolumesDeleteConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesDeleteConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesVolumesDeleteInternalServerError creates a PcloudPvminstancesVolumesDeleteInternalServerError with default headers values +func NewPcloudPvminstancesVolumesDeleteInternalServerError() *PcloudPvminstancesVolumesDeleteInternalServerError { + return &PcloudPvminstancesVolumesDeleteInternalServerError{} +} + +/* PcloudPvminstancesVolumesDeleteInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudPvminstancesVolumesDeleteInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesVolumesDeleteInternalServerError) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}][%d] pcloudPvminstancesVolumesDeleteInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudPvminstancesVolumesDeleteInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesDeleteInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_get_parameters.go new file mode 100644 index 00000000000..0307f189f6e --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_get_parameters.go @@ -0,0 +1,193 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudPvminstancesVolumesGetParams creates a new PcloudPvminstancesVolumesGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudPvminstancesVolumesGetParams() *PcloudPvminstancesVolumesGetParams { + return &PcloudPvminstancesVolumesGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudPvminstancesVolumesGetParamsWithTimeout creates a new PcloudPvminstancesVolumesGetParams object +// with the ability to set a timeout on a request. +func NewPcloudPvminstancesVolumesGetParamsWithTimeout(timeout time.Duration) *PcloudPvminstancesVolumesGetParams { + return &PcloudPvminstancesVolumesGetParams{ + timeout: timeout, + } +} + +// NewPcloudPvminstancesVolumesGetParamsWithContext creates a new PcloudPvminstancesVolumesGetParams object +// with the ability to set a context for a request. +func NewPcloudPvminstancesVolumesGetParamsWithContext(ctx context.Context) *PcloudPvminstancesVolumesGetParams { + return &PcloudPvminstancesVolumesGetParams{ + Context: ctx, + } +} + +// NewPcloudPvminstancesVolumesGetParamsWithHTTPClient creates a new PcloudPvminstancesVolumesGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudPvminstancesVolumesGetParamsWithHTTPClient(client *http.Client) *PcloudPvminstancesVolumesGetParams { + return &PcloudPvminstancesVolumesGetParams{ + HTTPClient: client, + } +} + +/* PcloudPvminstancesVolumesGetParams contains all the parameters to send to the API endpoint + for the pcloud pvminstances volumes get operation. + + Typically these are written to a http.Request. +*/ +type PcloudPvminstancesVolumesGetParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* PvmInstanceID. + + PCloud PVM Instance ID + */ + PvmInstanceID string + + /* VolumeID. + + Volume ID + */ + VolumeID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud pvminstances volumes get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesVolumesGetParams) WithDefaults() *PcloudPvminstancesVolumesGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud pvminstances volumes get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesVolumesGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud pvminstances volumes get params +func (o *PcloudPvminstancesVolumesGetParams) WithTimeout(timeout time.Duration) *PcloudPvminstancesVolumesGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud pvminstances volumes get params +func (o *PcloudPvminstancesVolumesGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud pvminstances volumes get params +func (o *PcloudPvminstancesVolumesGetParams) WithContext(ctx context.Context) *PcloudPvminstancesVolumesGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud pvminstances volumes get params +func (o *PcloudPvminstancesVolumesGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud pvminstances volumes get params +func (o *PcloudPvminstancesVolumesGetParams) WithHTTPClient(client *http.Client) *PcloudPvminstancesVolumesGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud pvminstances volumes get params +func (o *PcloudPvminstancesVolumesGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud pvminstances volumes get params +func (o *PcloudPvminstancesVolumesGetParams) WithCloudInstanceID(cloudInstanceID string) *PcloudPvminstancesVolumesGetParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud pvminstances volumes get params +func (o *PcloudPvminstancesVolumesGetParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithPvmInstanceID adds the pvmInstanceID to the pcloud pvminstances volumes get params +func (o *PcloudPvminstancesVolumesGetParams) WithPvmInstanceID(pvmInstanceID string) *PcloudPvminstancesVolumesGetParams { + o.SetPvmInstanceID(pvmInstanceID) + return o +} + +// SetPvmInstanceID adds the pvmInstanceId to the pcloud pvminstances volumes get params +func (o *PcloudPvminstancesVolumesGetParams) SetPvmInstanceID(pvmInstanceID string) { + o.PvmInstanceID = pvmInstanceID +} + +// WithVolumeID adds the volumeID to the pcloud pvminstances volumes get params +func (o *PcloudPvminstancesVolumesGetParams) WithVolumeID(volumeID string) *PcloudPvminstancesVolumesGetParams { + o.SetVolumeID(volumeID) + return o +} + +// SetVolumeID adds the volumeId to the pcloud pvminstances volumes get params +func (o *PcloudPvminstancesVolumesGetParams) SetVolumeID(volumeID string) { + o.VolumeID = volumeID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudPvminstancesVolumesGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param pvm_instance_id + if err := r.SetPathParam("pvm_instance_id", o.PvmInstanceID); err != nil { + return err + } + + // path param volume_id + if err := r.SetPathParam("volume_id", o.VolumeID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_get_responses.go new file mode 100644 index 00000000000..fa119079ee4 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_get_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudPvminstancesVolumesGetReader is a Reader for the PcloudPvminstancesVolumesGet structure. +type PcloudPvminstancesVolumesGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudPvminstancesVolumesGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudPvminstancesVolumesGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudPvminstancesVolumesGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudPvminstancesVolumesGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudPvminstancesVolumesGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudPvminstancesVolumesGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudPvminstancesVolumesGetOK creates a PcloudPvminstancesVolumesGetOK with default headers values +func NewPcloudPvminstancesVolumesGetOK() *PcloudPvminstancesVolumesGetOK { + return &PcloudPvminstancesVolumesGetOK{} +} + +/* PcloudPvminstancesVolumesGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudPvminstancesVolumesGetOK struct { + Payload *models.Volume +} + +func (o *PcloudPvminstancesVolumesGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}][%d] pcloudPvminstancesVolumesGetOK %+v", 200, o.Payload) +} +func (o *PcloudPvminstancesVolumesGetOK) GetPayload() *models.Volume { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Volume) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesVolumesGetBadRequest creates a PcloudPvminstancesVolumesGetBadRequest with default headers values +func NewPcloudPvminstancesVolumesGetBadRequest() *PcloudPvminstancesVolumesGetBadRequest { + return &PcloudPvminstancesVolumesGetBadRequest{} +} + +/* PcloudPvminstancesVolumesGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudPvminstancesVolumesGetBadRequest struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesVolumesGetBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}][%d] pcloudPvminstancesVolumesGetBadRequest %+v", 400, o.Payload) +} +func (o *PcloudPvminstancesVolumesGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesVolumesGetUnauthorized creates a PcloudPvminstancesVolumesGetUnauthorized with default headers values +func NewPcloudPvminstancesVolumesGetUnauthorized() *PcloudPvminstancesVolumesGetUnauthorized { + return &PcloudPvminstancesVolumesGetUnauthorized{} +} + +/* PcloudPvminstancesVolumesGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudPvminstancesVolumesGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesVolumesGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}][%d] pcloudPvminstancesVolumesGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudPvminstancesVolumesGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesVolumesGetNotFound creates a PcloudPvminstancesVolumesGetNotFound with default headers values +func NewPcloudPvminstancesVolumesGetNotFound() *PcloudPvminstancesVolumesGetNotFound { + return &PcloudPvminstancesVolumesGetNotFound{} +} + +/* PcloudPvminstancesVolumesGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudPvminstancesVolumesGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesVolumesGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}][%d] pcloudPvminstancesVolumesGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudPvminstancesVolumesGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesVolumesGetInternalServerError creates a PcloudPvminstancesVolumesGetInternalServerError with default headers values +func NewPcloudPvminstancesVolumesGetInternalServerError() *PcloudPvminstancesVolumesGetInternalServerError { + return &PcloudPvminstancesVolumesGetInternalServerError{} +} + +/* PcloudPvminstancesVolumesGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudPvminstancesVolumesGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesVolumesGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}][%d] pcloudPvminstancesVolumesGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudPvminstancesVolumesGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_getall_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_getall_parameters.go new file mode 100644 index 00000000000..ad7ca531864 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_getall_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudPvminstancesVolumesGetallParams creates a new PcloudPvminstancesVolumesGetallParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudPvminstancesVolumesGetallParams() *PcloudPvminstancesVolumesGetallParams { + return &PcloudPvminstancesVolumesGetallParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudPvminstancesVolumesGetallParamsWithTimeout creates a new PcloudPvminstancesVolumesGetallParams object +// with the ability to set a timeout on a request. +func NewPcloudPvminstancesVolumesGetallParamsWithTimeout(timeout time.Duration) *PcloudPvminstancesVolumesGetallParams { + return &PcloudPvminstancesVolumesGetallParams{ + timeout: timeout, + } +} + +// NewPcloudPvminstancesVolumesGetallParamsWithContext creates a new PcloudPvminstancesVolumesGetallParams object +// with the ability to set a context for a request. +func NewPcloudPvminstancesVolumesGetallParamsWithContext(ctx context.Context) *PcloudPvminstancesVolumesGetallParams { + return &PcloudPvminstancesVolumesGetallParams{ + Context: ctx, + } +} + +// NewPcloudPvminstancesVolumesGetallParamsWithHTTPClient creates a new PcloudPvminstancesVolumesGetallParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudPvminstancesVolumesGetallParamsWithHTTPClient(client *http.Client) *PcloudPvminstancesVolumesGetallParams { + return &PcloudPvminstancesVolumesGetallParams{ + HTTPClient: client, + } +} + +/* PcloudPvminstancesVolumesGetallParams contains all the parameters to send to the API endpoint + for the pcloud pvminstances volumes getall operation. + + Typically these are written to a http.Request. +*/ +type PcloudPvminstancesVolumesGetallParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* PvmInstanceID. + + PCloud PVM Instance ID + */ + PvmInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud pvminstances volumes getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesVolumesGetallParams) WithDefaults() *PcloudPvminstancesVolumesGetallParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud pvminstances volumes getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesVolumesGetallParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud pvminstances volumes getall params +func (o *PcloudPvminstancesVolumesGetallParams) WithTimeout(timeout time.Duration) *PcloudPvminstancesVolumesGetallParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud pvminstances volumes getall params +func (o *PcloudPvminstancesVolumesGetallParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud pvminstances volumes getall params +func (o *PcloudPvminstancesVolumesGetallParams) WithContext(ctx context.Context) *PcloudPvminstancesVolumesGetallParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud pvminstances volumes getall params +func (o *PcloudPvminstancesVolumesGetallParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud pvminstances volumes getall params +func (o *PcloudPvminstancesVolumesGetallParams) WithHTTPClient(client *http.Client) *PcloudPvminstancesVolumesGetallParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud pvminstances volumes getall params +func (o *PcloudPvminstancesVolumesGetallParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud pvminstances volumes getall params +func (o *PcloudPvminstancesVolumesGetallParams) WithCloudInstanceID(cloudInstanceID string) *PcloudPvminstancesVolumesGetallParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud pvminstances volumes getall params +func (o *PcloudPvminstancesVolumesGetallParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithPvmInstanceID adds the pvmInstanceID to the pcloud pvminstances volumes getall params +func (o *PcloudPvminstancesVolumesGetallParams) WithPvmInstanceID(pvmInstanceID string) *PcloudPvminstancesVolumesGetallParams { + o.SetPvmInstanceID(pvmInstanceID) + return o +} + +// SetPvmInstanceID adds the pvmInstanceId to the pcloud pvminstances volumes getall params +func (o *PcloudPvminstancesVolumesGetallParams) SetPvmInstanceID(pvmInstanceID string) { + o.PvmInstanceID = pvmInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudPvminstancesVolumesGetallParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param pvm_instance_id + if err := r.SetPathParam("pvm_instance_id", o.PvmInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_getall_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_getall_responses.go new file mode 100644 index 00000000000..7e98352931b --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_getall_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudPvminstancesVolumesGetallReader is a Reader for the PcloudPvminstancesVolumesGetall structure. +type PcloudPvminstancesVolumesGetallReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudPvminstancesVolumesGetallReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudPvminstancesVolumesGetallOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudPvminstancesVolumesGetallBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudPvminstancesVolumesGetallUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudPvminstancesVolumesGetallNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudPvminstancesVolumesGetallInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudPvminstancesVolumesGetallOK creates a PcloudPvminstancesVolumesGetallOK with default headers values +func NewPcloudPvminstancesVolumesGetallOK() *PcloudPvminstancesVolumesGetallOK { + return &PcloudPvminstancesVolumesGetallOK{} +} + +/* PcloudPvminstancesVolumesGetallOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudPvminstancesVolumesGetallOK struct { + Payload *models.Volumes +} + +func (o *PcloudPvminstancesVolumesGetallOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes][%d] pcloudPvminstancesVolumesGetallOK %+v", 200, o.Payload) +} +func (o *PcloudPvminstancesVolumesGetallOK) GetPayload() *models.Volumes { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesGetallOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Volumes) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesVolumesGetallBadRequest creates a PcloudPvminstancesVolumesGetallBadRequest with default headers values +func NewPcloudPvminstancesVolumesGetallBadRequest() *PcloudPvminstancesVolumesGetallBadRequest { + return &PcloudPvminstancesVolumesGetallBadRequest{} +} + +/* PcloudPvminstancesVolumesGetallBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudPvminstancesVolumesGetallBadRequest struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesVolumesGetallBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes][%d] pcloudPvminstancesVolumesGetallBadRequest %+v", 400, o.Payload) +} +func (o *PcloudPvminstancesVolumesGetallBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesGetallBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesVolumesGetallUnauthorized creates a PcloudPvminstancesVolumesGetallUnauthorized with default headers values +func NewPcloudPvminstancesVolumesGetallUnauthorized() *PcloudPvminstancesVolumesGetallUnauthorized { + return &PcloudPvminstancesVolumesGetallUnauthorized{} +} + +/* PcloudPvminstancesVolumesGetallUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudPvminstancesVolumesGetallUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesVolumesGetallUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes][%d] pcloudPvminstancesVolumesGetallUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudPvminstancesVolumesGetallUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesGetallUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesVolumesGetallNotFound creates a PcloudPvminstancesVolumesGetallNotFound with default headers values +func NewPcloudPvminstancesVolumesGetallNotFound() *PcloudPvminstancesVolumesGetallNotFound { + return &PcloudPvminstancesVolumesGetallNotFound{} +} + +/* PcloudPvminstancesVolumesGetallNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudPvminstancesVolumesGetallNotFound struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesVolumesGetallNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes][%d] pcloudPvminstancesVolumesGetallNotFound %+v", 404, o.Payload) +} +func (o *PcloudPvminstancesVolumesGetallNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesGetallNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesVolumesGetallInternalServerError creates a PcloudPvminstancesVolumesGetallInternalServerError with default headers values +func NewPcloudPvminstancesVolumesGetallInternalServerError() *PcloudPvminstancesVolumesGetallInternalServerError { + return &PcloudPvminstancesVolumesGetallInternalServerError{} +} + +/* PcloudPvminstancesVolumesGetallInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudPvminstancesVolumesGetallInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesVolumesGetallInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes][%d] pcloudPvminstancesVolumesGetallInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudPvminstancesVolumesGetallInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesGetallInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_post_parameters.go new file mode 100644 index 00000000000..e6144e828a1 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_post_parameters.go @@ -0,0 +1,193 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudPvminstancesVolumesPostParams creates a new PcloudPvminstancesVolumesPostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudPvminstancesVolumesPostParams() *PcloudPvminstancesVolumesPostParams { + return &PcloudPvminstancesVolumesPostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudPvminstancesVolumesPostParamsWithTimeout creates a new PcloudPvminstancesVolumesPostParams object +// with the ability to set a timeout on a request. +func NewPcloudPvminstancesVolumesPostParamsWithTimeout(timeout time.Duration) *PcloudPvminstancesVolumesPostParams { + return &PcloudPvminstancesVolumesPostParams{ + timeout: timeout, + } +} + +// NewPcloudPvminstancesVolumesPostParamsWithContext creates a new PcloudPvminstancesVolumesPostParams object +// with the ability to set a context for a request. +func NewPcloudPvminstancesVolumesPostParamsWithContext(ctx context.Context) *PcloudPvminstancesVolumesPostParams { + return &PcloudPvminstancesVolumesPostParams{ + Context: ctx, + } +} + +// NewPcloudPvminstancesVolumesPostParamsWithHTTPClient creates a new PcloudPvminstancesVolumesPostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudPvminstancesVolumesPostParamsWithHTTPClient(client *http.Client) *PcloudPvminstancesVolumesPostParams { + return &PcloudPvminstancesVolumesPostParams{ + HTTPClient: client, + } +} + +/* PcloudPvminstancesVolumesPostParams contains all the parameters to send to the API endpoint + for the pcloud pvminstances volumes post operation. + + Typically these are written to a http.Request. +*/ +type PcloudPvminstancesVolumesPostParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* PvmInstanceID. + + PCloud PVM Instance ID + */ + PvmInstanceID string + + /* VolumeID. + + Volume ID + */ + VolumeID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud pvminstances volumes post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesVolumesPostParams) WithDefaults() *PcloudPvminstancesVolumesPostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud pvminstances volumes post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesVolumesPostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud pvminstances volumes post params +func (o *PcloudPvminstancesVolumesPostParams) WithTimeout(timeout time.Duration) *PcloudPvminstancesVolumesPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud pvminstances volumes post params +func (o *PcloudPvminstancesVolumesPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud pvminstances volumes post params +func (o *PcloudPvminstancesVolumesPostParams) WithContext(ctx context.Context) *PcloudPvminstancesVolumesPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud pvminstances volumes post params +func (o *PcloudPvminstancesVolumesPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud pvminstances volumes post params +func (o *PcloudPvminstancesVolumesPostParams) WithHTTPClient(client *http.Client) *PcloudPvminstancesVolumesPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud pvminstances volumes post params +func (o *PcloudPvminstancesVolumesPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud pvminstances volumes post params +func (o *PcloudPvminstancesVolumesPostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudPvminstancesVolumesPostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud pvminstances volumes post params +func (o *PcloudPvminstancesVolumesPostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithPvmInstanceID adds the pvmInstanceID to the pcloud pvminstances volumes post params +func (o *PcloudPvminstancesVolumesPostParams) WithPvmInstanceID(pvmInstanceID string) *PcloudPvminstancesVolumesPostParams { + o.SetPvmInstanceID(pvmInstanceID) + return o +} + +// SetPvmInstanceID adds the pvmInstanceId to the pcloud pvminstances volumes post params +func (o *PcloudPvminstancesVolumesPostParams) SetPvmInstanceID(pvmInstanceID string) { + o.PvmInstanceID = pvmInstanceID +} + +// WithVolumeID adds the volumeID to the pcloud pvminstances volumes post params +func (o *PcloudPvminstancesVolumesPostParams) WithVolumeID(volumeID string) *PcloudPvminstancesVolumesPostParams { + o.SetVolumeID(volumeID) + return o +} + +// SetVolumeID adds the volumeId to the pcloud pvminstances volumes post params +func (o *PcloudPvminstancesVolumesPostParams) SetVolumeID(volumeID string) { + o.VolumeID = volumeID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudPvminstancesVolumesPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param pvm_instance_id + if err := r.SetPathParam("pvm_instance_id", o.PvmInstanceID); err != nil { + return err + } + + // path param volume_id + if err := r.SetPathParam("volume_id", o.VolumeID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_post_responses.go new file mode 100644 index 00000000000..85de2ff75ca --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_post_responses.go @@ -0,0 +1,293 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudPvminstancesVolumesPostReader is a Reader for the PcloudPvminstancesVolumesPost structure. +type PcloudPvminstancesVolumesPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudPvminstancesVolumesPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudPvminstancesVolumesPostOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudPvminstancesVolumesPostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudPvminstancesVolumesPostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewPcloudPvminstancesVolumesPostForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudPvminstancesVolumesPostNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewPcloudPvminstancesVolumesPostConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudPvminstancesVolumesPostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudPvminstancesVolumesPostOK creates a PcloudPvminstancesVolumesPostOK with default headers values +func NewPcloudPvminstancesVolumesPostOK() *PcloudPvminstancesVolumesPostOK { + return &PcloudPvminstancesVolumesPostOK{} +} + +/* PcloudPvminstancesVolumesPostOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudPvminstancesVolumesPostOK struct { + Payload models.Object +} + +func (o *PcloudPvminstancesVolumesPostOK) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}][%d] pcloudPvminstancesVolumesPostOK %+v", 200, o.Payload) +} +func (o *PcloudPvminstancesVolumesPostOK) GetPayload() models.Object { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesPostOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesVolumesPostBadRequest creates a PcloudPvminstancesVolumesPostBadRequest with default headers values +func NewPcloudPvminstancesVolumesPostBadRequest() *PcloudPvminstancesVolumesPostBadRequest { + return &PcloudPvminstancesVolumesPostBadRequest{} +} + +/* PcloudPvminstancesVolumesPostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudPvminstancesVolumesPostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesVolumesPostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}][%d] pcloudPvminstancesVolumesPostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudPvminstancesVolumesPostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesPostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesVolumesPostUnauthorized creates a PcloudPvminstancesVolumesPostUnauthorized with default headers values +func NewPcloudPvminstancesVolumesPostUnauthorized() *PcloudPvminstancesVolumesPostUnauthorized { + return &PcloudPvminstancesVolumesPostUnauthorized{} +} + +/* PcloudPvminstancesVolumesPostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudPvminstancesVolumesPostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesVolumesPostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}][%d] pcloudPvminstancesVolumesPostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudPvminstancesVolumesPostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesPostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesVolumesPostForbidden creates a PcloudPvminstancesVolumesPostForbidden with default headers values +func NewPcloudPvminstancesVolumesPostForbidden() *PcloudPvminstancesVolumesPostForbidden { + return &PcloudPvminstancesVolumesPostForbidden{} +} + +/* PcloudPvminstancesVolumesPostForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type PcloudPvminstancesVolumesPostForbidden struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesVolumesPostForbidden) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}][%d] pcloudPvminstancesVolumesPostForbidden %+v", 403, o.Payload) +} +func (o *PcloudPvminstancesVolumesPostForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesPostForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesVolumesPostNotFound creates a PcloudPvminstancesVolumesPostNotFound with default headers values +func NewPcloudPvminstancesVolumesPostNotFound() *PcloudPvminstancesVolumesPostNotFound { + return &PcloudPvminstancesVolumesPostNotFound{} +} + +/* PcloudPvminstancesVolumesPostNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudPvminstancesVolumesPostNotFound struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesVolumesPostNotFound) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}][%d] pcloudPvminstancesVolumesPostNotFound %+v", 404, o.Payload) +} +func (o *PcloudPvminstancesVolumesPostNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesPostNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesVolumesPostConflict creates a PcloudPvminstancesVolumesPostConflict with default headers values +func NewPcloudPvminstancesVolumesPostConflict() *PcloudPvminstancesVolumesPostConflict { + return &PcloudPvminstancesVolumesPostConflict{} +} + +/* PcloudPvminstancesVolumesPostConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type PcloudPvminstancesVolumesPostConflict struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesVolumesPostConflict) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}][%d] pcloudPvminstancesVolumesPostConflict %+v", 409, o.Payload) +} +func (o *PcloudPvminstancesVolumesPostConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesPostConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesVolumesPostInternalServerError creates a PcloudPvminstancesVolumesPostInternalServerError with default headers values +func NewPcloudPvminstancesVolumesPostInternalServerError() *PcloudPvminstancesVolumesPostInternalServerError { + return &PcloudPvminstancesVolumesPostInternalServerError{} +} + +/* PcloudPvminstancesVolumesPostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudPvminstancesVolumesPostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesVolumesPostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}][%d] pcloudPvminstancesVolumesPostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudPvminstancesVolumesPostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesPostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_put_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_put_parameters.go new file mode 100644 index 00000000000..01ba400c0b8 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_put_parameters.go @@ -0,0 +1,217 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudPvminstancesVolumesPutParams creates a new PcloudPvminstancesVolumesPutParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudPvminstancesVolumesPutParams() *PcloudPvminstancesVolumesPutParams { + return &PcloudPvminstancesVolumesPutParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudPvminstancesVolumesPutParamsWithTimeout creates a new PcloudPvminstancesVolumesPutParams object +// with the ability to set a timeout on a request. +func NewPcloudPvminstancesVolumesPutParamsWithTimeout(timeout time.Duration) *PcloudPvminstancesVolumesPutParams { + return &PcloudPvminstancesVolumesPutParams{ + timeout: timeout, + } +} + +// NewPcloudPvminstancesVolumesPutParamsWithContext creates a new PcloudPvminstancesVolumesPutParams object +// with the ability to set a context for a request. +func NewPcloudPvminstancesVolumesPutParamsWithContext(ctx context.Context) *PcloudPvminstancesVolumesPutParams { + return &PcloudPvminstancesVolumesPutParams{ + Context: ctx, + } +} + +// NewPcloudPvminstancesVolumesPutParamsWithHTTPClient creates a new PcloudPvminstancesVolumesPutParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudPvminstancesVolumesPutParamsWithHTTPClient(client *http.Client) *PcloudPvminstancesVolumesPutParams { + return &PcloudPvminstancesVolumesPutParams{ + HTTPClient: client, + } +} + +/* PcloudPvminstancesVolumesPutParams contains all the parameters to send to the API endpoint + for the pcloud pvminstances volumes put operation. + + Typically these are written to a http.Request. +*/ +type PcloudPvminstancesVolumesPutParams struct { + + /* Body. + + Parameters to update a volume attached to a PVMInstance + */ + Body *models.PVMInstanceVolumeUpdate + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* PvmInstanceID. + + PCloud PVM Instance ID + */ + PvmInstanceID string + + /* VolumeID. + + Volume ID + */ + VolumeID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud pvminstances volumes put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesVolumesPutParams) WithDefaults() *PcloudPvminstancesVolumesPutParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud pvminstances volumes put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesVolumesPutParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud pvminstances volumes put params +func (o *PcloudPvminstancesVolumesPutParams) WithTimeout(timeout time.Duration) *PcloudPvminstancesVolumesPutParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud pvminstances volumes put params +func (o *PcloudPvminstancesVolumesPutParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud pvminstances volumes put params +func (o *PcloudPvminstancesVolumesPutParams) WithContext(ctx context.Context) *PcloudPvminstancesVolumesPutParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud pvminstances volumes put params +func (o *PcloudPvminstancesVolumesPutParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud pvminstances volumes put params +func (o *PcloudPvminstancesVolumesPutParams) WithHTTPClient(client *http.Client) *PcloudPvminstancesVolumesPutParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud pvminstances volumes put params +func (o *PcloudPvminstancesVolumesPutParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud pvminstances volumes put params +func (o *PcloudPvminstancesVolumesPutParams) WithBody(body *models.PVMInstanceVolumeUpdate) *PcloudPvminstancesVolumesPutParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud pvminstances volumes put params +func (o *PcloudPvminstancesVolumesPutParams) SetBody(body *models.PVMInstanceVolumeUpdate) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud pvminstances volumes put params +func (o *PcloudPvminstancesVolumesPutParams) WithCloudInstanceID(cloudInstanceID string) *PcloudPvminstancesVolumesPutParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud pvminstances volumes put params +func (o *PcloudPvminstancesVolumesPutParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithPvmInstanceID adds the pvmInstanceID to the pcloud pvminstances volumes put params +func (o *PcloudPvminstancesVolumesPutParams) WithPvmInstanceID(pvmInstanceID string) *PcloudPvminstancesVolumesPutParams { + o.SetPvmInstanceID(pvmInstanceID) + return o +} + +// SetPvmInstanceID adds the pvmInstanceId to the pcloud pvminstances volumes put params +func (o *PcloudPvminstancesVolumesPutParams) SetPvmInstanceID(pvmInstanceID string) { + o.PvmInstanceID = pvmInstanceID +} + +// WithVolumeID adds the volumeID to the pcloud pvminstances volumes put params +func (o *PcloudPvminstancesVolumesPutParams) WithVolumeID(volumeID string) *PcloudPvminstancesVolumesPutParams { + o.SetVolumeID(volumeID) + return o +} + +// SetVolumeID adds the volumeId to the pcloud pvminstances volumes put params +func (o *PcloudPvminstancesVolumesPutParams) SetVolumeID(volumeID string) { + o.VolumeID = volumeID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudPvminstancesVolumesPutParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param pvm_instance_id + if err := r.SetPathParam("pvm_instance_id", o.PvmInstanceID); err != nil { + return err + } + + // path param volume_id + if err := r.SetPathParam("volume_id", o.VolumeID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_put_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_put_responses.go new file mode 100644 index 00000000000..a9da1b15a16 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_put_responses.go @@ -0,0 +1,141 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudPvminstancesVolumesPutReader is a Reader for the PcloudPvminstancesVolumesPut structure. +type PcloudPvminstancesVolumesPutReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudPvminstancesVolumesPutReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudPvminstancesVolumesPutOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudPvminstancesVolumesPutBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudPvminstancesVolumesPutInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudPvminstancesVolumesPutOK creates a PcloudPvminstancesVolumesPutOK with default headers values +func NewPcloudPvminstancesVolumesPutOK() *PcloudPvminstancesVolumesPutOK { + return &PcloudPvminstancesVolumesPutOK{} +} + +/* PcloudPvminstancesVolumesPutOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudPvminstancesVolumesPutOK struct { + Payload models.Object +} + +func (o *PcloudPvminstancesVolumesPutOK) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}][%d] pcloudPvminstancesVolumesPutOK %+v", 200, o.Payload) +} +func (o *PcloudPvminstancesVolumesPutOK) GetPayload() models.Object { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesPutOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesVolumesPutBadRequest creates a PcloudPvminstancesVolumesPutBadRequest with default headers values +func NewPcloudPvminstancesVolumesPutBadRequest() *PcloudPvminstancesVolumesPutBadRequest { + return &PcloudPvminstancesVolumesPutBadRequest{} +} + +/* PcloudPvminstancesVolumesPutBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudPvminstancesVolumesPutBadRequest struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesVolumesPutBadRequest) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}][%d] pcloudPvminstancesVolumesPutBadRequest %+v", 400, o.Payload) +} +func (o *PcloudPvminstancesVolumesPutBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesPutBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesVolumesPutInternalServerError creates a PcloudPvminstancesVolumesPutInternalServerError with default headers values +func NewPcloudPvminstancesVolumesPutInternalServerError() *PcloudPvminstancesVolumesPutInternalServerError { + return &PcloudPvminstancesVolumesPutInternalServerError{} +} + +/* PcloudPvminstancesVolumesPutInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudPvminstancesVolumesPutInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesVolumesPutInternalServerError) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}][%d] pcloudPvminstancesVolumesPutInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudPvminstancesVolumesPutInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesPutInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_setboot_put_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_setboot_put_parameters.go new file mode 100644 index 00000000000..77fab0cb54e --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_setboot_put_parameters.go @@ -0,0 +1,193 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudPvminstancesVolumesSetbootPutParams creates a new PcloudPvminstancesVolumesSetbootPutParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudPvminstancesVolumesSetbootPutParams() *PcloudPvminstancesVolumesSetbootPutParams { + return &PcloudPvminstancesVolumesSetbootPutParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudPvminstancesVolumesSetbootPutParamsWithTimeout creates a new PcloudPvminstancesVolumesSetbootPutParams object +// with the ability to set a timeout on a request. +func NewPcloudPvminstancesVolumesSetbootPutParamsWithTimeout(timeout time.Duration) *PcloudPvminstancesVolumesSetbootPutParams { + return &PcloudPvminstancesVolumesSetbootPutParams{ + timeout: timeout, + } +} + +// NewPcloudPvminstancesVolumesSetbootPutParamsWithContext creates a new PcloudPvminstancesVolumesSetbootPutParams object +// with the ability to set a context for a request. +func NewPcloudPvminstancesVolumesSetbootPutParamsWithContext(ctx context.Context) *PcloudPvminstancesVolumesSetbootPutParams { + return &PcloudPvminstancesVolumesSetbootPutParams{ + Context: ctx, + } +} + +// NewPcloudPvminstancesVolumesSetbootPutParamsWithHTTPClient creates a new PcloudPvminstancesVolumesSetbootPutParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudPvminstancesVolumesSetbootPutParamsWithHTTPClient(client *http.Client) *PcloudPvminstancesVolumesSetbootPutParams { + return &PcloudPvminstancesVolumesSetbootPutParams{ + HTTPClient: client, + } +} + +/* PcloudPvminstancesVolumesSetbootPutParams contains all the parameters to send to the API endpoint + for the pcloud pvminstances volumes setboot put operation. + + Typically these are written to a http.Request. +*/ +type PcloudPvminstancesVolumesSetbootPutParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* PvmInstanceID. + + PCloud PVM Instance ID + */ + PvmInstanceID string + + /* VolumeID. + + Volume ID + */ + VolumeID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud pvminstances volumes setboot put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesVolumesSetbootPutParams) WithDefaults() *PcloudPvminstancesVolumesSetbootPutParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud pvminstances volumes setboot put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudPvminstancesVolumesSetbootPutParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud pvminstances volumes setboot put params +func (o *PcloudPvminstancesVolumesSetbootPutParams) WithTimeout(timeout time.Duration) *PcloudPvminstancesVolumesSetbootPutParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud pvminstances volumes setboot put params +func (o *PcloudPvminstancesVolumesSetbootPutParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud pvminstances volumes setboot put params +func (o *PcloudPvminstancesVolumesSetbootPutParams) WithContext(ctx context.Context) *PcloudPvminstancesVolumesSetbootPutParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud pvminstances volumes setboot put params +func (o *PcloudPvminstancesVolumesSetbootPutParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud pvminstances volumes setboot put params +func (o *PcloudPvminstancesVolumesSetbootPutParams) WithHTTPClient(client *http.Client) *PcloudPvminstancesVolumesSetbootPutParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud pvminstances volumes setboot put params +func (o *PcloudPvminstancesVolumesSetbootPutParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud pvminstances volumes setboot put params +func (o *PcloudPvminstancesVolumesSetbootPutParams) WithCloudInstanceID(cloudInstanceID string) *PcloudPvminstancesVolumesSetbootPutParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud pvminstances volumes setboot put params +func (o *PcloudPvminstancesVolumesSetbootPutParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithPvmInstanceID adds the pvmInstanceID to the pcloud pvminstances volumes setboot put params +func (o *PcloudPvminstancesVolumesSetbootPutParams) WithPvmInstanceID(pvmInstanceID string) *PcloudPvminstancesVolumesSetbootPutParams { + o.SetPvmInstanceID(pvmInstanceID) + return o +} + +// SetPvmInstanceID adds the pvmInstanceId to the pcloud pvminstances volumes setboot put params +func (o *PcloudPvminstancesVolumesSetbootPutParams) SetPvmInstanceID(pvmInstanceID string) { + o.PvmInstanceID = pvmInstanceID +} + +// WithVolumeID adds the volumeID to the pcloud pvminstances volumes setboot put params +func (o *PcloudPvminstancesVolumesSetbootPutParams) WithVolumeID(volumeID string) *PcloudPvminstancesVolumesSetbootPutParams { + o.SetVolumeID(volumeID) + return o +} + +// SetVolumeID adds the volumeId to the pcloud pvminstances volumes setboot put params +func (o *PcloudPvminstancesVolumesSetbootPutParams) SetVolumeID(volumeID string) { + o.VolumeID = volumeID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudPvminstancesVolumesSetbootPutParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param pvm_instance_id + if err := r.SetPathParam("pvm_instance_id", o.PvmInstanceID); err != nil { + return err + } + + // path param volume_id + if err := r.SetPathParam("volume_id", o.VolumeID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_setboot_put_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_setboot_put_responses.go new file mode 100644 index 00000000000..0842e8f1cb5 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_pvminstances_volumes_setboot_put_responses.go @@ -0,0 +1,217 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudPvminstancesVolumesSetbootPutReader is a Reader for the PcloudPvminstancesVolumesSetbootPut structure. +type PcloudPvminstancesVolumesSetbootPutReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudPvminstancesVolumesSetbootPutReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudPvminstancesVolumesSetbootPutOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudPvminstancesVolumesSetbootPutBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudPvminstancesVolumesSetbootPutUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudPvminstancesVolumesSetbootPutNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudPvminstancesVolumesSetbootPutInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudPvminstancesVolumesSetbootPutOK creates a PcloudPvminstancesVolumesSetbootPutOK with default headers values +func NewPcloudPvminstancesVolumesSetbootPutOK() *PcloudPvminstancesVolumesSetbootPutOK { + return &PcloudPvminstancesVolumesSetbootPutOK{} +} + +/* PcloudPvminstancesVolumesSetbootPutOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudPvminstancesVolumesSetbootPutOK struct { + Payload models.Object +} + +func (o *PcloudPvminstancesVolumesSetbootPutOK) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}/setboot][%d] pcloudPvminstancesVolumesSetbootPutOK %+v", 200, o.Payload) +} +func (o *PcloudPvminstancesVolumesSetbootPutOK) GetPayload() models.Object { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesSetbootPutOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesVolumesSetbootPutBadRequest creates a PcloudPvminstancesVolumesSetbootPutBadRequest with default headers values +func NewPcloudPvminstancesVolumesSetbootPutBadRequest() *PcloudPvminstancesVolumesSetbootPutBadRequest { + return &PcloudPvminstancesVolumesSetbootPutBadRequest{} +} + +/* PcloudPvminstancesVolumesSetbootPutBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudPvminstancesVolumesSetbootPutBadRequest struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesVolumesSetbootPutBadRequest) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}/setboot][%d] pcloudPvminstancesVolumesSetbootPutBadRequest %+v", 400, o.Payload) +} +func (o *PcloudPvminstancesVolumesSetbootPutBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesSetbootPutBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesVolumesSetbootPutUnauthorized creates a PcloudPvminstancesVolumesSetbootPutUnauthorized with default headers values +func NewPcloudPvminstancesVolumesSetbootPutUnauthorized() *PcloudPvminstancesVolumesSetbootPutUnauthorized { + return &PcloudPvminstancesVolumesSetbootPutUnauthorized{} +} + +/* PcloudPvminstancesVolumesSetbootPutUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudPvminstancesVolumesSetbootPutUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesVolumesSetbootPutUnauthorized) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}/setboot][%d] pcloudPvminstancesVolumesSetbootPutUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudPvminstancesVolumesSetbootPutUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesSetbootPutUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesVolumesSetbootPutNotFound creates a PcloudPvminstancesVolumesSetbootPutNotFound with default headers values +func NewPcloudPvminstancesVolumesSetbootPutNotFound() *PcloudPvminstancesVolumesSetbootPutNotFound { + return &PcloudPvminstancesVolumesSetbootPutNotFound{} +} + +/* PcloudPvminstancesVolumesSetbootPutNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudPvminstancesVolumesSetbootPutNotFound struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesVolumesSetbootPutNotFound) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}/setboot][%d] pcloudPvminstancesVolumesSetbootPutNotFound %+v", 404, o.Payload) +} +func (o *PcloudPvminstancesVolumesSetbootPutNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesSetbootPutNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudPvminstancesVolumesSetbootPutInternalServerError creates a PcloudPvminstancesVolumesSetbootPutInternalServerError with default headers values +func NewPcloudPvminstancesVolumesSetbootPutInternalServerError() *PcloudPvminstancesVolumesSetbootPutInternalServerError { + return &PcloudPvminstancesVolumesSetbootPutInternalServerError{} +} + +/* PcloudPvminstancesVolumesSetbootPutInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudPvminstancesVolumesSetbootPutInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudPvminstancesVolumesSetbootPutInternalServerError) Error() string { + return fmt.Sprintf("[PUT /pcloud/v1/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes/{volume_id}/setboot][%d] pcloudPvminstancesVolumesSetbootPutInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudPvminstancesVolumesSetbootPutInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudPvminstancesVolumesSetbootPutInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_pvminstances_volumes_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_pvminstances_volumes_post_parameters.go new file mode 100644 index 00000000000..ba0f31924ce --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_pvminstances_volumes_post_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudV2PvminstancesVolumesPostParams creates a new PcloudV2PvminstancesVolumesPostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudV2PvminstancesVolumesPostParams() *PcloudV2PvminstancesVolumesPostParams { + return &PcloudV2PvminstancesVolumesPostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudV2PvminstancesVolumesPostParamsWithTimeout creates a new PcloudV2PvminstancesVolumesPostParams object +// with the ability to set a timeout on a request. +func NewPcloudV2PvminstancesVolumesPostParamsWithTimeout(timeout time.Duration) *PcloudV2PvminstancesVolumesPostParams { + return &PcloudV2PvminstancesVolumesPostParams{ + timeout: timeout, + } +} + +// NewPcloudV2PvminstancesVolumesPostParamsWithContext creates a new PcloudV2PvminstancesVolumesPostParams object +// with the ability to set a context for a request. +func NewPcloudV2PvminstancesVolumesPostParamsWithContext(ctx context.Context) *PcloudV2PvminstancesVolumesPostParams { + return &PcloudV2PvminstancesVolumesPostParams{ + Context: ctx, + } +} + +// NewPcloudV2PvminstancesVolumesPostParamsWithHTTPClient creates a new PcloudV2PvminstancesVolumesPostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudV2PvminstancesVolumesPostParamsWithHTTPClient(client *http.Client) *PcloudV2PvminstancesVolumesPostParams { + return &PcloudV2PvminstancesVolumesPostParams{ + HTTPClient: client, + } +} + +/* PcloudV2PvminstancesVolumesPostParams contains all the parameters to send to the API endpoint + for the pcloud v2 pvminstances volumes post operation. + + Typically these are written to a http.Request. +*/ +type PcloudV2PvminstancesVolumesPostParams struct { + + /* Body. + + Parameter to attach volumes to a PVMInstance + */ + Body *models.VolumesAttach + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* PvmInstanceID. + + PCloud PVM Instance ID + */ + PvmInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud v2 pvminstances volumes post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV2PvminstancesVolumesPostParams) WithDefaults() *PcloudV2PvminstancesVolumesPostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud v2 pvminstances volumes post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV2PvminstancesVolumesPostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud v2 pvminstances volumes post params +func (o *PcloudV2PvminstancesVolumesPostParams) WithTimeout(timeout time.Duration) *PcloudV2PvminstancesVolumesPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud v2 pvminstances volumes post params +func (o *PcloudV2PvminstancesVolumesPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud v2 pvminstances volumes post params +func (o *PcloudV2PvminstancesVolumesPostParams) WithContext(ctx context.Context) *PcloudV2PvminstancesVolumesPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud v2 pvminstances volumes post params +func (o *PcloudV2PvminstancesVolumesPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud v2 pvminstances volumes post params +func (o *PcloudV2PvminstancesVolumesPostParams) WithHTTPClient(client *http.Client) *PcloudV2PvminstancesVolumesPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud v2 pvminstances volumes post params +func (o *PcloudV2PvminstancesVolumesPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud v2 pvminstances volumes post params +func (o *PcloudV2PvminstancesVolumesPostParams) WithBody(body *models.VolumesAttach) *PcloudV2PvminstancesVolumesPostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud v2 pvminstances volumes post params +func (o *PcloudV2PvminstancesVolumesPostParams) SetBody(body *models.VolumesAttach) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud v2 pvminstances volumes post params +func (o *PcloudV2PvminstancesVolumesPostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudV2PvminstancesVolumesPostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud v2 pvminstances volumes post params +func (o *PcloudV2PvminstancesVolumesPostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithPvmInstanceID adds the pvmInstanceID to the pcloud v2 pvminstances volumes post params +func (o *PcloudV2PvminstancesVolumesPostParams) WithPvmInstanceID(pvmInstanceID string) *PcloudV2PvminstancesVolumesPostParams { + o.SetPvmInstanceID(pvmInstanceID) + return o +} + +// SetPvmInstanceID adds the pvmInstanceId to the pcloud v2 pvminstances volumes post params +func (o *PcloudV2PvminstancesVolumesPostParams) SetPvmInstanceID(pvmInstanceID string) { + o.PvmInstanceID = pvmInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudV2PvminstancesVolumesPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param pvm_instance_id + if err := r.SetPathParam("pvm_instance_id", o.PvmInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_pvminstances_volumes_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_pvminstances_volumes_post_responses.go new file mode 100644 index 00000000000..e7c8a6c588d --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_pvminstances_volumes_post_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudV2PvminstancesVolumesPostReader is a Reader for the PcloudV2PvminstancesVolumesPost structure. +type PcloudV2PvminstancesVolumesPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudV2PvminstancesVolumesPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 202: + result := NewPcloudV2PvminstancesVolumesPostAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudV2PvminstancesVolumesPostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudV2PvminstancesVolumesPostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudV2PvminstancesVolumesPostNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudV2PvminstancesVolumesPostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudV2PvminstancesVolumesPostAccepted creates a PcloudV2PvminstancesVolumesPostAccepted with default headers values +func NewPcloudV2PvminstancesVolumesPostAccepted() *PcloudV2PvminstancesVolumesPostAccepted { + return &PcloudV2PvminstancesVolumesPostAccepted{} +} + +/* PcloudV2PvminstancesVolumesPostAccepted describes a response with status code 202, with default header values. + +Accepted +*/ +type PcloudV2PvminstancesVolumesPostAccepted struct { + Payload *models.VolumesAttachmentResponse +} + +func (o *PcloudV2PvminstancesVolumesPostAccepted) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes][%d] pcloudV2PvminstancesVolumesPostAccepted %+v", 202, o.Payload) +} +func (o *PcloudV2PvminstancesVolumesPostAccepted) GetPayload() *models.VolumesAttachmentResponse { + return o.Payload +} + +func (o *PcloudV2PvminstancesVolumesPostAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.VolumesAttachmentResponse) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2PvminstancesVolumesPostBadRequest creates a PcloudV2PvminstancesVolumesPostBadRequest with default headers values +func NewPcloudV2PvminstancesVolumesPostBadRequest() *PcloudV2PvminstancesVolumesPostBadRequest { + return &PcloudV2PvminstancesVolumesPostBadRequest{} +} + +/* PcloudV2PvminstancesVolumesPostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudV2PvminstancesVolumesPostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudV2PvminstancesVolumesPostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes][%d] pcloudV2PvminstancesVolumesPostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudV2PvminstancesVolumesPostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2PvminstancesVolumesPostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2PvminstancesVolumesPostUnauthorized creates a PcloudV2PvminstancesVolumesPostUnauthorized with default headers values +func NewPcloudV2PvminstancesVolumesPostUnauthorized() *PcloudV2PvminstancesVolumesPostUnauthorized { + return &PcloudV2PvminstancesVolumesPostUnauthorized{} +} + +/* PcloudV2PvminstancesVolumesPostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudV2PvminstancesVolumesPostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudV2PvminstancesVolumesPostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes][%d] pcloudV2PvminstancesVolumesPostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudV2PvminstancesVolumesPostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2PvminstancesVolumesPostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2PvminstancesVolumesPostNotFound creates a PcloudV2PvminstancesVolumesPostNotFound with default headers values +func NewPcloudV2PvminstancesVolumesPostNotFound() *PcloudV2PvminstancesVolumesPostNotFound { + return &PcloudV2PvminstancesVolumesPostNotFound{} +} + +/* PcloudV2PvminstancesVolumesPostNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudV2PvminstancesVolumesPostNotFound struct { + Payload *models.Error +} + +func (o *PcloudV2PvminstancesVolumesPostNotFound) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes][%d] pcloudV2PvminstancesVolumesPostNotFound %+v", 404, o.Payload) +} +func (o *PcloudV2PvminstancesVolumesPostNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2PvminstancesVolumesPostNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2PvminstancesVolumesPostInternalServerError creates a PcloudV2PvminstancesVolumesPostInternalServerError with default headers values +func NewPcloudV2PvminstancesVolumesPostInternalServerError() *PcloudV2PvminstancesVolumesPostInternalServerError { + return &PcloudV2PvminstancesVolumesPostInternalServerError{} +} + +/* PcloudV2PvminstancesVolumesPostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudV2PvminstancesVolumesPostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudV2PvminstancesVolumesPostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/pvm-instances/{pvm_instance_id}/volumes][%d] pcloudV2PvminstancesVolumesPostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudV2PvminstancesVolumesPostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2PvminstancesVolumesPostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumes_clone_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumes_clone_post_parameters.go new file mode 100644 index 00000000000..99a119e98ae --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumes_clone_post_parameters.go @@ -0,0 +1,173 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudV2VolumesClonePostParams creates a new PcloudV2VolumesClonePostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudV2VolumesClonePostParams() *PcloudV2VolumesClonePostParams { + return &PcloudV2VolumesClonePostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudV2VolumesClonePostParamsWithTimeout creates a new PcloudV2VolumesClonePostParams object +// with the ability to set a timeout on a request. +func NewPcloudV2VolumesClonePostParamsWithTimeout(timeout time.Duration) *PcloudV2VolumesClonePostParams { + return &PcloudV2VolumesClonePostParams{ + timeout: timeout, + } +} + +// NewPcloudV2VolumesClonePostParamsWithContext creates a new PcloudV2VolumesClonePostParams object +// with the ability to set a context for a request. +func NewPcloudV2VolumesClonePostParamsWithContext(ctx context.Context) *PcloudV2VolumesClonePostParams { + return &PcloudV2VolumesClonePostParams{ + Context: ctx, + } +} + +// NewPcloudV2VolumesClonePostParamsWithHTTPClient creates a new PcloudV2VolumesClonePostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudV2VolumesClonePostParamsWithHTTPClient(client *http.Client) *PcloudV2VolumesClonePostParams { + return &PcloudV2VolumesClonePostParams{ + HTTPClient: client, + } +} + +/* PcloudV2VolumesClonePostParams contains all the parameters to send to the API endpoint + for the pcloud v2 volumes clone post operation. + + Typically these are written to a http.Request. +*/ +type PcloudV2VolumesClonePostParams struct { + + /* Body. + + Parameters for the cloning of volumes + */ + Body *models.VolumesCloneAsyncRequest + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud v2 volumes clone post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV2VolumesClonePostParams) WithDefaults() *PcloudV2VolumesClonePostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud v2 volumes clone post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV2VolumesClonePostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud v2 volumes clone post params +func (o *PcloudV2VolumesClonePostParams) WithTimeout(timeout time.Duration) *PcloudV2VolumesClonePostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud v2 volumes clone post params +func (o *PcloudV2VolumesClonePostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud v2 volumes clone post params +func (o *PcloudV2VolumesClonePostParams) WithContext(ctx context.Context) *PcloudV2VolumesClonePostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud v2 volumes clone post params +func (o *PcloudV2VolumesClonePostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud v2 volumes clone post params +func (o *PcloudV2VolumesClonePostParams) WithHTTPClient(client *http.Client) *PcloudV2VolumesClonePostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud v2 volumes clone post params +func (o *PcloudV2VolumesClonePostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud v2 volumes clone post params +func (o *PcloudV2VolumesClonePostParams) WithBody(body *models.VolumesCloneAsyncRequest) *PcloudV2VolumesClonePostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud v2 volumes clone post params +func (o *PcloudV2VolumesClonePostParams) SetBody(body *models.VolumesCloneAsyncRequest) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud v2 volumes clone post params +func (o *PcloudV2VolumesClonePostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudV2VolumesClonePostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud v2 volumes clone post params +func (o *PcloudV2VolumesClonePostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudV2VolumesClonePostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumes_clone_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumes_clone_post_responses.go new file mode 100644 index 00000000000..17b686b297e --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumes_clone_post_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudV2VolumesClonePostReader is a Reader for the PcloudV2VolumesClonePost structure. +type PcloudV2VolumesClonePostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudV2VolumesClonePostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 202: + result := NewPcloudV2VolumesClonePostAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudV2VolumesClonePostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudV2VolumesClonePostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudV2VolumesClonePostNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudV2VolumesClonePostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudV2VolumesClonePostAccepted creates a PcloudV2VolumesClonePostAccepted with default headers values +func NewPcloudV2VolumesClonePostAccepted() *PcloudV2VolumesClonePostAccepted { + return &PcloudV2VolumesClonePostAccepted{} +} + +/* PcloudV2VolumesClonePostAccepted describes a response with status code 202, with default header values. + +Accepted +*/ +type PcloudV2VolumesClonePostAccepted struct { + Payload *models.CloneTaskReference +} + +func (o *PcloudV2VolumesClonePostAccepted) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes/clone][%d] pcloudV2VolumesClonePostAccepted %+v", 202, o.Payload) +} +func (o *PcloudV2VolumesClonePostAccepted) GetPayload() *models.CloneTaskReference { + return o.Payload +} + +func (o *PcloudV2VolumesClonePostAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.CloneTaskReference) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumesClonePostBadRequest creates a PcloudV2VolumesClonePostBadRequest with default headers values +func NewPcloudV2VolumesClonePostBadRequest() *PcloudV2VolumesClonePostBadRequest { + return &PcloudV2VolumesClonePostBadRequest{} +} + +/* PcloudV2VolumesClonePostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudV2VolumesClonePostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudV2VolumesClonePostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes/clone][%d] pcloudV2VolumesClonePostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudV2VolumesClonePostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumesClonePostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumesClonePostUnauthorized creates a PcloudV2VolumesClonePostUnauthorized with default headers values +func NewPcloudV2VolumesClonePostUnauthorized() *PcloudV2VolumesClonePostUnauthorized { + return &PcloudV2VolumesClonePostUnauthorized{} +} + +/* PcloudV2VolumesClonePostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudV2VolumesClonePostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudV2VolumesClonePostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes/clone][%d] pcloudV2VolumesClonePostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudV2VolumesClonePostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumesClonePostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumesClonePostNotFound creates a PcloudV2VolumesClonePostNotFound with default headers values +func NewPcloudV2VolumesClonePostNotFound() *PcloudV2VolumesClonePostNotFound { + return &PcloudV2VolumesClonePostNotFound{} +} + +/* PcloudV2VolumesClonePostNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudV2VolumesClonePostNotFound struct { + Payload *models.Error +} + +func (o *PcloudV2VolumesClonePostNotFound) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes/clone][%d] pcloudV2VolumesClonePostNotFound %+v", 404, o.Payload) +} +func (o *PcloudV2VolumesClonePostNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumesClonePostNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumesClonePostInternalServerError creates a PcloudV2VolumesClonePostInternalServerError with default headers values +func NewPcloudV2VolumesClonePostInternalServerError() *PcloudV2VolumesClonePostInternalServerError { + return &PcloudV2VolumesClonePostInternalServerError{} +} + +/* PcloudV2VolumesClonePostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudV2VolumesClonePostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudV2VolumesClonePostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes/clone][%d] pcloudV2VolumesClonePostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudV2VolumesClonePostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumesClonePostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumes_clonetasks_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumes_clonetasks_get_parameters.go new file mode 100644 index 00000000000..b75497e1e31 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumes_clonetasks_get_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudV2VolumesClonetasksGetParams creates a new PcloudV2VolumesClonetasksGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudV2VolumesClonetasksGetParams() *PcloudV2VolumesClonetasksGetParams { + return &PcloudV2VolumesClonetasksGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudV2VolumesClonetasksGetParamsWithTimeout creates a new PcloudV2VolumesClonetasksGetParams object +// with the ability to set a timeout on a request. +func NewPcloudV2VolumesClonetasksGetParamsWithTimeout(timeout time.Duration) *PcloudV2VolumesClonetasksGetParams { + return &PcloudV2VolumesClonetasksGetParams{ + timeout: timeout, + } +} + +// NewPcloudV2VolumesClonetasksGetParamsWithContext creates a new PcloudV2VolumesClonetasksGetParams object +// with the ability to set a context for a request. +func NewPcloudV2VolumesClonetasksGetParamsWithContext(ctx context.Context) *PcloudV2VolumesClonetasksGetParams { + return &PcloudV2VolumesClonetasksGetParams{ + Context: ctx, + } +} + +// NewPcloudV2VolumesClonetasksGetParamsWithHTTPClient creates a new PcloudV2VolumesClonetasksGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudV2VolumesClonetasksGetParamsWithHTTPClient(client *http.Client) *PcloudV2VolumesClonetasksGetParams { + return &PcloudV2VolumesClonetasksGetParams{ + HTTPClient: client, + } +} + +/* PcloudV2VolumesClonetasksGetParams contains all the parameters to send to the API endpoint + for the pcloud v2 volumes clonetasks get operation. + + Typically these are written to a http.Request. +*/ +type PcloudV2VolumesClonetasksGetParams struct { + + /* CloneTaskID. + + Volumes Clone Task ID + */ + CloneTaskID string + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud v2 volumes clonetasks get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV2VolumesClonetasksGetParams) WithDefaults() *PcloudV2VolumesClonetasksGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud v2 volumes clonetasks get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV2VolumesClonetasksGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud v2 volumes clonetasks get params +func (o *PcloudV2VolumesClonetasksGetParams) WithTimeout(timeout time.Duration) *PcloudV2VolumesClonetasksGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud v2 volumes clonetasks get params +func (o *PcloudV2VolumesClonetasksGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud v2 volumes clonetasks get params +func (o *PcloudV2VolumesClonetasksGetParams) WithContext(ctx context.Context) *PcloudV2VolumesClonetasksGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud v2 volumes clonetasks get params +func (o *PcloudV2VolumesClonetasksGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud v2 volumes clonetasks get params +func (o *PcloudV2VolumesClonetasksGetParams) WithHTTPClient(client *http.Client) *PcloudV2VolumesClonetasksGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud v2 volumes clonetasks get params +func (o *PcloudV2VolumesClonetasksGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloneTaskID adds the cloneTaskID to the pcloud v2 volumes clonetasks get params +func (o *PcloudV2VolumesClonetasksGetParams) WithCloneTaskID(cloneTaskID string) *PcloudV2VolumesClonetasksGetParams { + o.SetCloneTaskID(cloneTaskID) + return o +} + +// SetCloneTaskID adds the cloneTaskId to the pcloud v2 volumes clonetasks get params +func (o *PcloudV2VolumesClonetasksGetParams) SetCloneTaskID(cloneTaskID string) { + o.CloneTaskID = cloneTaskID +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud v2 volumes clonetasks get params +func (o *PcloudV2VolumesClonetasksGetParams) WithCloudInstanceID(cloudInstanceID string) *PcloudV2VolumesClonetasksGetParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud v2 volumes clonetasks get params +func (o *PcloudV2VolumesClonetasksGetParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudV2VolumesClonetasksGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param clone_task_id + if err := r.SetPathParam("clone_task_id", o.CloneTaskID); err != nil { + return err + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumes_clonetasks_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumes_clonetasks_get_responses.go new file mode 100644 index 00000000000..a59491866c9 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumes_clonetasks_get_responses.go @@ -0,0 +1,257 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudV2VolumesClonetasksGetReader is a Reader for the PcloudV2VolumesClonetasksGet structure. +type PcloudV2VolumesClonetasksGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudV2VolumesClonetasksGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudV2VolumesClonetasksGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudV2VolumesClonetasksGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudV2VolumesClonetasksGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudV2VolumesClonetasksGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewPcloudV2VolumesClonetasksGetConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudV2VolumesClonetasksGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudV2VolumesClonetasksGetOK creates a PcloudV2VolumesClonetasksGetOK with default headers values +func NewPcloudV2VolumesClonetasksGetOK() *PcloudV2VolumesClonetasksGetOK { + return &PcloudV2VolumesClonetasksGetOK{} +} + +/* PcloudV2VolumesClonetasksGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudV2VolumesClonetasksGetOK struct { + Payload *models.CloneTaskStatus +} + +func (o *PcloudV2VolumesClonetasksGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes/clone-tasks/{clone_task_id}][%d] pcloudV2VolumesClonetasksGetOK %+v", 200, o.Payload) +} +func (o *PcloudV2VolumesClonetasksGetOK) GetPayload() *models.CloneTaskStatus { + return o.Payload +} + +func (o *PcloudV2VolumesClonetasksGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.CloneTaskStatus) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumesClonetasksGetBadRequest creates a PcloudV2VolumesClonetasksGetBadRequest with default headers values +func NewPcloudV2VolumesClonetasksGetBadRequest() *PcloudV2VolumesClonetasksGetBadRequest { + return &PcloudV2VolumesClonetasksGetBadRequest{} +} + +/* PcloudV2VolumesClonetasksGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudV2VolumesClonetasksGetBadRequest struct { + Payload *models.Error +} + +func (o *PcloudV2VolumesClonetasksGetBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes/clone-tasks/{clone_task_id}][%d] pcloudV2VolumesClonetasksGetBadRequest %+v", 400, o.Payload) +} +func (o *PcloudV2VolumesClonetasksGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumesClonetasksGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumesClonetasksGetUnauthorized creates a PcloudV2VolumesClonetasksGetUnauthorized with default headers values +func NewPcloudV2VolumesClonetasksGetUnauthorized() *PcloudV2VolumesClonetasksGetUnauthorized { + return &PcloudV2VolumesClonetasksGetUnauthorized{} +} + +/* PcloudV2VolumesClonetasksGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudV2VolumesClonetasksGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudV2VolumesClonetasksGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes/clone-tasks/{clone_task_id}][%d] pcloudV2VolumesClonetasksGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudV2VolumesClonetasksGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumesClonetasksGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumesClonetasksGetNotFound creates a PcloudV2VolumesClonetasksGetNotFound with default headers values +func NewPcloudV2VolumesClonetasksGetNotFound() *PcloudV2VolumesClonetasksGetNotFound { + return &PcloudV2VolumesClonetasksGetNotFound{} +} + +/* PcloudV2VolumesClonetasksGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudV2VolumesClonetasksGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudV2VolumesClonetasksGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes/clone-tasks/{clone_task_id}][%d] pcloudV2VolumesClonetasksGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudV2VolumesClonetasksGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumesClonetasksGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumesClonetasksGetConflict creates a PcloudV2VolumesClonetasksGetConflict with default headers values +func NewPcloudV2VolumesClonetasksGetConflict() *PcloudV2VolumesClonetasksGetConflict { + return &PcloudV2VolumesClonetasksGetConflict{} +} + +/* PcloudV2VolumesClonetasksGetConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type PcloudV2VolumesClonetasksGetConflict struct { + Payload *models.Error +} + +func (o *PcloudV2VolumesClonetasksGetConflict) Error() string { + return fmt.Sprintf("[GET /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes/clone-tasks/{clone_task_id}][%d] pcloudV2VolumesClonetasksGetConflict %+v", 409, o.Payload) +} +func (o *PcloudV2VolumesClonetasksGetConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumesClonetasksGetConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumesClonetasksGetInternalServerError creates a PcloudV2VolumesClonetasksGetInternalServerError with default headers values +func NewPcloudV2VolumesClonetasksGetInternalServerError() *PcloudV2VolumesClonetasksGetInternalServerError { + return &PcloudV2VolumesClonetasksGetInternalServerError{} +} + +/* PcloudV2VolumesClonetasksGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudV2VolumesClonetasksGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudV2VolumesClonetasksGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes/clone-tasks/{clone_task_id}][%d] pcloudV2VolumesClonetasksGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudV2VolumesClonetasksGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumesClonetasksGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumes_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumes_post_parameters.go new file mode 100644 index 00000000000..6ec3d1080df --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumes_post_parameters.go @@ -0,0 +1,173 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudV2VolumesPostParams creates a new PcloudV2VolumesPostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudV2VolumesPostParams() *PcloudV2VolumesPostParams { + return &PcloudV2VolumesPostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudV2VolumesPostParamsWithTimeout creates a new PcloudV2VolumesPostParams object +// with the ability to set a timeout on a request. +func NewPcloudV2VolumesPostParamsWithTimeout(timeout time.Duration) *PcloudV2VolumesPostParams { + return &PcloudV2VolumesPostParams{ + timeout: timeout, + } +} + +// NewPcloudV2VolumesPostParamsWithContext creates a new PcloudV2VolumesPostParams object +// with the ability to set a context for a request. +func NewPcloudV2VolumesPostParamsWithContext(ctx context.Context) *PcloudV2VolumesPostParams { + return &PcloudV2VolumesPostParams{ + Context: ctx, + } +} + +// NewPcloudV2VolumesPostParamsWithHTTPClient creates a new PcloudV2VolumesPostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudV2VolumesPostParamsWithHTTPClient(client *http.Client) *PcloudV2VolumesPostParams { + return &PcloudV2VolumesPostParams{ + HTTPClient: client, + } +} + +/* PcloudV2VolumesPostParams contains all the parameters to send to the API endpoint + for the pcloud v2 volumes post operation. + + Typically these are written to a http.Request. +*/ +type PcloudV2VolumesPostParams struct { + + /* Body. + + Parameters for creating multiple volumes + */ + Body *models.MultiVolumesCreate + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud v2 volumes post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV2VolumesPostParams) WithDefaults() *PcloudV2VolumesPostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud v2 volumes post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV2VolumesPostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud v2 volumes post params +func (o *PcloudV2VolumesPostParams) WithTimeout(timeout time.Duration) *PcloudV2VolumesPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud v2 volumes post params +func (o *PcloudV2VolumesPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud v2 volumes post params +func (o *PcloudV2VolumesPostParams) WithContext(ctx context.Context) *PcloudV2VolumesPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud v2 volumes post params +func (o *PcloudV2VolumesPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud v2 volumes post params +func (o *PcloudV2VolumesPostParams) WithHTTPClient(client *http.Client) *PcloudV2VolumesPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud v2 volumes post params +func (o *PcloudV2VolumesPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud v2 volumes post params +func (o *PcloudV2VolumesPostParams) WithBody(body *models.MultiVolumesCreate) *PcloudV2VolumesPostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud v2 volumes post params +func (o *PcloudV2VolumesPostParams) SetBody(body *models.MultiVolumesCreate) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud v2 volumes post params +func (o *PcloudV2VolumesPostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudV2VolumesPostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud v2 volumes post params +func (o *PcloudV2VolumesPostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudV2VolumesPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumes_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumes_post_responses.go new file mode 100644 index 00000000000..7101f333724 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumes_post_responses.go @@ -0,0 +1,257 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudV2VolumesPostReader is a Reader for the PcloudV2VolumesPost structure. +type PcloudV2VolumesPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudV2VolumesPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 201: + result := NewPcloudV2VolumesPostCreated() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudV2VolumesPostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudV2VolumesPostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewPcloudV2VolumesPostConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewPcloudV2VolumesPostUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudV2VolumesPostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudV2VolumesPostCreated creates a PcloudV2VolumesPostCreated with default headers values +func NewPcloudV2VolumesPostCreated() *PcloudV2VolumesPostCreated { + return &PcloudV2VolumesPostCreated{} +} + +/* PcloudV2VolumesPostCreated describes a response with status code 201, with default header values. + +Created +*/ +type PcloudV2VolumesPostCreated struct { + Payload *models.Volumes +} + +func (o *PcloudV2VolumesPostCreated) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes][%d] pcloudV2VolumesPostCreated %+v", 201, o.Payload) +} +func (o *PcloudV2VolumesPostCreated) GetPayload() *models.Volumes { + return o.Payload +} + +func (o *PcloudV2VolumesPostCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Volumes) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumesPostBadRequest creates a PcloudV2VolumesPostBadRequest with default headers values +func NewPcloudV2VolumesPostBadRequest() *PcloudV2VolumesPostBadRequest { + return &PcloudV2VolumesPostBadRequest{} +} + +/* PcloudV2VolumesPostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudV2VolumesPostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudV2VolumesPostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes][%d] pcloudV2VolumesPostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudV2VolumesPostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumesPostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumesPostUnauthorized creates a PcloudV2VolumesPostUnauthorized with default headers values +func NewPcloudV2VolumesPostUnauthorized() *PcloudV2VolumesPostUnauthorized { + return &PcloudV2VolumesPostUnauthorized{} +} + +/* PcloudV2VolumesPostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudV2VolumesPostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudV2VolumesPostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes][%d] pcloudV2VolumesPostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudV2VolumesPostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumesPostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumesPostConflict creates a PcloudV2VolumesPostConflict with default headers values +func NewPcloudV2VolumesPostConflict() *PcloudV2VolumesPostConflict { + return &PcloudV2VolumesPostConflict{} +} + +/* PcloudV2VolumesPostConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type PcloudV2VolumesPostConflict struct { + Payload *models.Error +} + +func (o *PcloudV2VolumesPostConflict) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes][%d] pcloudV2VolumesPostConflict %+v", 409, o.Payload) +} +func (o *PcloudV2VolumesPostConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumesPostConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumesPostUnprocessableEntity creates a PcloudV2VolumesPostUnprocessableEntity with default headers values +func NewPcloudV2VolumesPostUnprocessableEntity() *PcloudV2VolumesPostUnprocessableEntity { + return &PcloudV2VolumesPostUnprocessableEntity{} +} + +/* PcloudV2VolumesPostUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type PcloudV2VolumesPostUnprocessableEntity struct { + Payload *models.Error +} + +func (o *PcloudV2VolumesPostUnprocessableEntity) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes][%d] pcloudV2VolumesPostUnprocessableEntity %+v", 422, o.Payload) +} +func (o *PcloudV2VolumesPostUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumesPostUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumesPostInternalServerError creates a PcloudV2VolumesPostInternalServerError with default headers values +func NewPcloudV2VolumesPostInternalServerError() *PcloudV2VolumesPostInternalServerError { + return &PcloudV2VolumesPostInternalServerError{} +} + +/* PcloudV2VolumesPostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudV2VolumesPostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudV2VolumesPostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes][%d] pcloudV2VolumesPostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudV2VolumesPostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumesPostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_cancel_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_cancel_post_parameters.go new file mode 100644 index 00000000000..a71bc1d7eec --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_cancel_post_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudV2VolumescloneCancelPostParams creates a new PcloudV2VolumescloneCancelPostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudV2VolumescloneCancelPostParams() *PcloudV2VolumescloneCancelPostParams { + return &PcloudV2VolumescloneCancelPostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudV2VolumescloneCancelPostParamsWithTimeout creates a new PcloudV2VolumescloneCancelPostParams object +// with the ability to set a timeout on a request. +func NewPcloudV2VolumescloneCancelPostParamsWithTimeout(timeout time.Duration) *PcloudV2VolumescloneCancelPostParams { + return &PcloudV2VolumescloneCancelPostParams{ + timeout: timeout, + } +} + +// NewPcloudV2VolumescloneCancelPostParamsWithContext creates a new PcloudV2VolumescloneCancelPostParams object +// with the ability to set a context for a request. +func NewPcloudV2VolumescloneCancelPostParamsWithContext(ctx context.Context) *PcloudV2VolumescloneCancelPostParams { + return &PcloudV2VolumescloneCancelPostParams{ + Context: ctx, + } +} + +// NewPcloudV2VolumescloneCancelPostParamsWithHTTPClient creates a new PcloudV2VolumescloneCancelPostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudV2VolumescloneCancelPostParamsWithHTTPClient(client *http.Client) *PcloudV2VolumescloneCancelPostParams { + return &PcloudV2VolumescloneCancelPostParams{ + HTTPClient: client, + } +} + +/* PcloudV2VolumescloneCancelPostParams contains all the parameters to send to the API endpoint + for the pcloud v2 volumesclone cancel post operation. + + Typically these are written to a http.Request. +*/ +type PcloudV2VolumescloneCancelPostParams struct { + + /* Body. + + Parameters for cancelling a volumes-clone request + */ + Body *models.VolumesCloneCancel + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* VolumesCloneID. + + Volumes Clone ID + */ + VolumesCloneID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud v2 volumesclone cancel post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV2VolumescloneCancelPostParams) WithDefaults() *PcloudV2VolumescloneCancelPostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud v2 volumesclone cancel post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV2VolumescloneCancelPostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud v2 volumesclone cancel post params +func (o *PcloudV2VolumescloneCancelPostParams) WithTimeout(timeout time.Duration) *PcloudV2VolumescloneCancelPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud v2 volumesclone cancel post params +func (o *PcloudV2VolumescloneCancelPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud v2 volumesclone cancel post params +func (o *PcloudV2VolumescloneCancelPostParams) WithContext(ctx context.Context) *PcloudV2VolumescloneCancelPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud v2 volumesclone cancel post params +func (o *PcloudV2VolumescloneCancelPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud v2 volumesclone cancel post params +func (o *PcloudV2VolumescloneCancelPostParams) WithHTTPClient(client *http.Client) *PcloudV2VolumescloneCancelPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud v2 volumesclone cancel post params +func (o *PcloudV2VolumescloneCancelPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud v2 volumesclone cancel post params +func (o *PcloudV2VolumescloneCancelPostParams) WithBody(body *models.VolumesCloneCancel) *PcloudV2VolumescloneCancelPostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud v2 volumesclone cancel post params +func (o *PcloudV2VolumescloneCancelPostParams) SetBody(body *models.VolumesCloneCancel) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud v2 volumesclone cancel post params +func (o *PcloudV2VolumescloneCancelPostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudV2VolumescloneCancelPostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud v2 volumesclone cancel post params +func (o *PcloudV2VolumescloneCancelPostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithVolumesCloneID adds the volumesCloneID to the pcloud v2 volumesclone cancel post params +func (o *PcloudV2VolumescloneCancelPostParams) WithVolumesCloneID(volumesCloneID string) *PcloudV2VolumescloneCancelPostParams { + o.SetVolumesCloneID(volumesCloneID) + return o +} + +// SetVolumesCloneID adds the volumesCloneId to the pcloud v2 volumesclone cancel post params +func (o *PcloudV2VolumescloneCancelPostParams) SetVolumesCloneID(volumesCloneID string) { + o.VolumesCloneID = volumesCloneID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudV2VolumescloneCancelPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param volumes_clone_id + if err := r.SetPathParam("volumes_clone_id", o.VolumesCloneID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_cancel_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_cancel_post_responses.go new file mode 100644 index 00000000000..3d06fe1baec --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_cancel_post_responses.go @@ -0,0 +1,181 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudV2VolumescloneCancelPostReader is a Reader for the PcloudV2VolumescloneCancelPost structure. +type PcloudV2VolumescloneCancelPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudV2VolumescloneCancelPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 202: + result := NewPcloudV2VolumescloneCancelPostAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewPcloudV2VolumescloneCancelPostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudV2VolumescloneCancelPostNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudV2VolumescloneCancelPostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudV2VolumescloneCancelPostAccepted creates a PcloudV2VolumescloneCancelPostAccepted with default headers values +func NewPcloudV2VolumescloneCancelPostAccepted() *PcloudV2VolumescloneCancelPostAccepted { + return &PcloudV2VolumescloneCancelPostAccepted{} +} + +/* PcloudV2VolumescloneCancelPostAccepted describes a response with status code 202, with default header values. + +Accepted +*/ +type PcloudV2VolumescloneCancelPostAccepted struct { + Payload *models.VolumesClone +} + +func (o *PcloudV2VolumescloneCancelPostAccepted) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone/{volumes_clone_id}/cancel][%d] pcloudV2VolumescloneCancelPostAccepted %+v", 202, o.Payload) +} +func (o *PcloudV2VolumescloneCancelPostAccepted) GetPayload() *models.VolumesClone { + return o.Payload +} + +func (o *PcloudV2VolumescloneCancelPostAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.VolumesClone) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumescloneCancelPostUnauthorized creates a PcloudV2VolumescloneCancelPostUnauthorized with default headers values +func NewPcloudV2VolumescloneCancelPostUnauthorized() *PcloudV2VolumescloneCancelPostUnauthorized { + return &PcloudV2VolumescloneCancelPostUnauthorized{} +} + +/* PcloudV2VolumescloneCancelPostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudV2VolumescloneCancelPostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudV2VolumescloneCancelPostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone/{volumes_clone_id}/cancel][%d] pcloudV2VolumescloneCancelPostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudV2VolumescloneCancelPostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumescloneCancelPostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumescloneCancelPostNotFound creates a PcloudV2VolumescloneCancelPostNotFound with default headers values +func NewPcloudV2VolumescloneCancelPostNotFound() *PcloudV2VolumescloneCancelPostNotFound { + return &PcloudV2VolumescloneCancelPostNotFound{} +} + +/* PcloudV2VolumescloneCancelPostNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudV2VolumescloneCancelPostNotFound struct { + Payload *models.Error +} + +func (o *PcloudV2VolumescloneCancelPostNotFound) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone/{volumes_clone_id}/cancel][%d] pcloudV2VolumescloneCancelPostNotFound %+v", 404, o.Payload) +} +func (o *PcloudV2VolumescloneCancelPostNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumescloneCancelPostNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumescloneCancelPostInternalServerError creates a PcloudV2VolumescloneCancelPostInternalServerError with default headers values +func NewPcloudV2VolumescloneCancelPostInternalServerError() *PcloudV2VolumescloneCancelPostInternalServerError { + return &PcloudV2VolumescloneCancelPostInternalServerError{} +} + +/* PcloudV2VolumescloneCancelPostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudV2VolumescloneCancelPostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudV2VolumescloneCancelPostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone/{volumes_clone_id}/cancel][%d] pcloudV2VolumescloneCancelPostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudV2VolumescloneCancelPostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumescloneCancelPostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_delete_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_delete_parameters.go new file mode 100644 index 00000000000..bee811980f6 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_delete_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudV2VolumescloneDeleteParams creates a new PcloudV2VolumescloneDeleteParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudV2VolumescloneDeleteParams() *PcloudV2VolumescloneDeleteParams { + return &PcloudV2VolumescloneDeleteParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudV2VolumescloneDeleteParamsWithTimeout creates a new PcloudV2VolumescloneDeleteParams object +// with the ability to set a timeout on a request. +func NewPcloudV2VolumescloneDeleteParamsWithTimeout(timeout time.Duration) *PcloudV2VolumescloneDeleteParams { + return &PcloudV2VolumescloneDeleteParams{ + timeout: timeout, + } +} + +// NewPcloudV2VolumescloneDeleteParamsWithContext creates a new PcloudV2VolumescloneDeleteParams object +// with the ability to set a context for a request. +func NewPcloudV2VolumescloneDeleteParamsWithContext(ctx context.Context) *PcloudV2VolumescloneDeleteParams { + return &PcloudV2VolumescloneDeleteParams{ + Context: ctx, + } +} + +// NewPcloudV2VolumescloneDeleteParamsWithHTTPClient creates a new PcloudV2VolumescloneDeleteParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudV2VolumescloneDeleteParamsWithHTTPClient(client *http.Client) *PcloudV2VolumescloneDeleteParams { + return &PcloudV2VolumescloneDeleteParams{ + HTTPClient: client, + } +} + +/* PcloudV2VolumescloneDeleteParams contains all the parameters to send to the API endpoint + for the pcloud v2 volumesclone delete operation. + + Typically these are written to a http.Request. +*/ +type PcloudV2VolumescloneDeleteParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* VolumesCloneID. + + Volumes Clone ID + */ + VolumesCloneID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud v2 volumesclone delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV2VolumescloneDeleteParams) WithDefaults() *PcloudV2VolumescloneDeleteParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud v2 volumesclone delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV2VolumescloneDeleteParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud v2 volumesclone delete params +func (o *PcloudV2VolumescloneDeleteParams) WithTimeout(timeout time.Duration) *PcloudV2VolumescloneDeleteParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud v2 volumesclone delete params +func (o *PcloudV2VolumescloneDeleteParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud v2 volumesclone delete params +func (o *PcloudV2VolumescloneDeleteParams) WithContext(ctx context.Context) *PcloudV2VolumescloneDeleteParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud v2 volumesclone delete params +func (o *PcloudV2VolumescloneDeleteParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud v2 volumesclone delete params +func (o *PcloudV2VolumescloneDeleteParams) WithHTTPClient(client *http.Client) *PcloudV2VolumescloneDeleteParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud v2 volumesclone delete params +func (o *PcloudV2VolumescloneDeleteParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud v2 volumesclone delete params +func (o *PcloudV2VolumescloneDeleteParams) WithCloudInstanceID(cloudInstanceID string) *PcloudV2VolumescloneDeleteParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud v2 volumesclone delete params +func (o *PcloudV2VolumescloneDeleteParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithVolumesCloneID adds the volumesCloneID to the pcloud v2 volumesclone delete params +func (o *PcloudV2VolumescloneDeleteParams) WithVolumesCloneID(volumesCloneID string) *PcloudV2VolumescloneDeleteParams { + o.SetVolumesCloneID(volumesCloneID) + return o +} + +// SetVolumesCloneID adds the volumesCloneId to the pcloud v2 volumesclone delete params +func (o *PcloudV2VolumescloneDeleteParams) SetVolumesCloneID(volumesCloneID string) { + o.VolumesCloneID = volumesCloneID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudV2VolumescloneDeleteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param volumes_clone_id + if err := r.SetPathParam("volumes_clone_id", o.VolumesCloneID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_delete_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_delete_responses.go new file mode 100644 index 00000000000..2dc153ace69 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_delete_responses.go @@ -0,0 +1,217 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudV2VolumescloneDeleteReader is a Reader for the PcloudV2VolumescloneDelete structure. +type PcloudV2VolumescloneDeleteReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudV2VolumescloneDeleteReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudV2VolumescloneDeleteOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudV2VolumescloneDeleteBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudV2VolumescloneDeleteUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudV2VolumescloneDeleteNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudV2VolumescloneDeleteInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudV2VolumescloneDeleteOK creates a PcloudV2VolumescloneDeleteOK with default headers values +func NewPcloudV2VolumescloneDeleteOK() *PcloudV2VolumescloneDeleteOK { + return &PcloudV2VolumescloneDeleteOK{} +} + +/* PcloudV2VolumescloneDeleteOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudV2VolumescloneDeleteOK struct { + Payload models.Object +} + +func (o *PcloudV2VolumescloneDeleteOK) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone/{volumes_clone_id}][%d] pcloudV2VolumescloneDeleteOK %+v", 200, o.Payload) +} +func (o *PcloudV2VolumescloneDeleteOK) GetPayload() models.Object { + return o.Payload +} + +func (o *PcloudV2VolumescloneDeleteOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumescloneDeleteBadRequest creates a PcloudV2VolumescloneDeleteBadRequest with default headers values +func NewPcloudV2VolumescloneDeleteBadRequest() *PcloudV2VolumescloneDeleteBadRequest { + return &PcloudV2VolumescloneDeleteBadRequest{} +} + +/* PcloudV2VolumescloneDeleteBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudV2VolumescloneDeleteBadRequest struct { + Payload *models.Error +} + +func (o *PcloudV2VolumescloneDeleteBadRequest) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone/{volumes_clone_id}][%d] pcloudV2VolumescloneDeleteBadRequest %+v", 400, o.Payload) +} +func (o *PcloudV2VolumescloneDeleteBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumescloneDeleteBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumescloneDeleteUnauthorized creates a PcloudV2VolumescloneDeleteUnauthorized with default headers values +func NewPcloudV2VolumescloneDeleteUnauthorized() *PcloudV2VolumescloneDeleteUnauthorized { + return &PcloudV2VolumescloneDeleteUnauthorized{} +} + +/* PcloudV2VolumescloneDeleteUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudV2VolumescloneDeleteUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudV2VolumescloneDeleteUnauthorized) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone/{volumes_clone_id}][%d] pcloudV2VolumescloneDeleteUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudV2VolumescloneDeleteUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumescloneDeleteUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumescloneDeleteNotFound creates a PcloudV2VolumescloneDeleteNotFound with default headers values +func NewPcloudV2VolumescloneDeleteNotFound() *PcloudV2VolumescloneDeleteNotFound { + return &PcloudV2VolumescloneDeleteNotFound{} +} + +/* PcloudV2VolumescloneDeleteNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudV2VolumescloneDeleteNotFound struct { + Payload *models.Error +} + +func (o *PcloudV2VolumescloneDeleteNotFound) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone/{volumes_clone_id}][%d] pcloudV2VolumescloneDeleteNotFound %+v", 404, o.Payload) +} +func (o *PcloudV2VolumescloneDeleteNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumescloneDeleteNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumescloneDeleteInternalServerError creates a PcloudV2VolumescloneDeleteInternalServerError with default headers values +func NewPcloudV2VolumescloneDeleteInternalServerError() *PcloudV2VolumescloneDeleteInternalServerError { + return &PcloudV2VolumescloneDeleteInternalServerError{} +} + +/* PcloudV2VolumescloneDeleteInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudV2VolumescloneDeleteInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudV2VolumescloneDeleteInternalServerError) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone/{volumes_clone_id}][%d] pcloudV2VolumescloneDeleteInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudV2VolumescloneDeleteInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumescloneDeleteInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_execute_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_execute_post_parameters.go new file mode 100644 index 00000000000..f3d74219a2f --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_execute_post_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudV2VolumescloneExecutePostParams creates a new PcloudV2VolumescloneExecutePostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudV2VolumescloneExecutePostParams() *PcloudV2VolumescloneExecutePostParams { + return &PcloudV2VolumescloneExecutePostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudV2VolumescloneExecutePostParamsWithTimeout creates a new PcloudV2VolumescloneExecutePostParams object +// with the ability to set a timeout on a request. +func NewPcloudV2VolumescloneExecutePostParamsWithTimeout(timeout time.Duration) *PcloudV2VolumescloneExecutePostParams { + return &PcloudV2VolumescloneExecutePostParams{ + timeout: timeout, + } +} + +// NewPcloudV2VolumescloneExecutePostParamsWithContext creates a new PcloudV2VolumescloneExecutePostParams object +// with the ability to set a context for a request. +func NewPcloudV2VolumescloneExecutePostParamsWithContext(ctx context.Context) *PcloudV2VolumescloneExecutePostParams { + return &PcloudV2VolumescloneExecutePostParams{ + Context: ctx, + } +} + +// NewPcloudV2VolumescloneExecutePostParamsWithHTTPClient creates a new PcloudV2VolumescloneExecutePostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudV2VolumescloneExecutePostParamsWithHTTPClient(client *http.Client) *PcloudV2VolumescloneExecutePostParams { + return &PcloudV2VolumescloneExecutePostParams{ + HTTPClient: client, + } +} + +/* PcloudV2VolumescloneExecutePostParams contains all the parameters to send to the API endpoint + for the pcloud v2 volumesclone execute post operation. + + Typically these are written to a http.Request. +*/ +type PcloudV2VolumescloneExecutePostParams struct { + + /* Body. + + Parameters for the cloning of volumes + */ + Body *models.VolumesCloneExecute + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* VolumesCloneID. + + Volumes Clone ID + */ + VolumesCloneID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud v2 volumesclone execute post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV2VolumescloneExecutePostParams) WithDefaults() *PcloudV2VolumescloneExecutePostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud v2 volumesclone execute post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV2VolumescloneExecutePostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud v2 volumesclone execute post params +func (o *PcloudV2VolumescloneExecutePostParams) WithTimeout(timeout time.Duration) *PcloudV2VolumescloneExecutePostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud v2 volumesclone execute post params +func (o *PcloudV2VolumescloneExecutePostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud v2 volumesclone execute post params +func (o *PcloudV2VolumescloneExecutePostParams) WithContext(ctx context.Context) *PcloudV2VolumescloneExecutePostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud v2 volumesclone execute post params +func (o *PcloudV2VolumescloneExecutePostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud v2 volumesclone execute post params +func (o *PcloudV2VolumescloneExecutePostParams) WithHTTPClient(client *http.Client) *PcloudV2VolumescloneExecutePostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud v2 volumesclone execute post params +func (o *PcloudV2VolumescloneExecutePostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud v2 volumesclone execute post params +func (o *PcloudV2VolumescloneExecutePostParams) WithBody(body *models.VolumesCloneExecute) *PcloudV2VolumescloneExecutePostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud v2 volumesclone execute post params +func (o *PcloudV2VolumescloneExecutePostParams) SetBody(body *models.VolumesCloneExecute) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud v2 volumesclone execute post params +func (o *PcloudV2VolumescloneExecutePostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudV2VolumescloneExecutePostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud v2 volumesclone execute post params +func (o *PcloudV2VolumescloneExecutePostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithVolumesCloneID adds the volumesCloneID to the pcloud v2 volumesclone execute post params +func (o *PcloudV2VolumescloneExecutePostParams) WithVolumesCloneID(volumesCloneID string) *PcloudV2VolumescloneExecutePostParams { + o.SetVolumesCloneID(volumesCloneID) + return o +} + +// SetVolumesCloneID adds the volumesCloneId to the pcloud v2 volumesclone execute post params +func (o *PcloudV2VolumescloneExecutePostParams) SetVolumesCloneID(volumesCloneID string) { + o.VolumesCloneID = volumesCloneID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudV2VolumescloneExecutePostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param volumes_clone_id + if err := r.SetPathParam("volumes_clone_id", o.VolumesCloneID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_execute_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_execute_post_responses.go new file mode 100644 index 00000000000..4523d858fde --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_execute_post_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudV2VolumescloneExecutePostReader is a Reader for the PcloudV2VolumescloneExecutePost structure. +type PcloudV2VolumescloneExecutePostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudV2VolumescloneExecutePostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 202: + result := NewPcloudV2VolumescloneExecutePostAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudV2VolumescloneExecutePostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudV2VolumescloneExecutePostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudV2VolumescloneExecutePostNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudV2VolumescloneExecutePostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudV2VolumescloneExecutePostAccepted creates a PcloudV2VolumescloneExecutePostAccepted with default headers values +func NewPcloudV2VolumescloneExecutePostAccepted() *PcloudV2VolumescloneExecutePostAccepted { + return &PcloudV2VolumescloneExecutePostAccepted{} +} + +/* PcloudV2VolumescloneExecutePostAccepted describes a response with status code 202, with default header values. + +Accepted +*/ +type PcloudV2VolumescloneExecutePostAccepted struct { + Payload *models.VolumesClone +} + +func (o *PcloudV2VolumescloneExecutePostAccepted) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone/{volumes_clone_id}/execute][%d] pcloudV2VolumescloneExecutePostAccepted %+v", 202, o.Payload) +} +func (o *PcloudV2VolumescloneExecutePostAccepted) GetPayload() *models.VolumesClone { + return o.Payload +} + +func (o *PcloudV2VolumescloneExecutePostAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.VolumesClone) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumescloneExecutePostBadRequest creates a PcloudV2VolumescloneExecutePostBadRequest with default headers values +func NewPcloudV2VolumescloneExecutePostBadRequest() *PcloudV2VolumescloneExecutePostBadRequest { + return &PcloudV2VolumescloneExecutePostBadRequest{} +} + +/* PcloudV2VolumescloneExecutePostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudV2VolumescloneExecutePostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudV2VolumescloneExecutePostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone/{volumes_clone_id}/execute][%d] pcloudV2VolumescloneExecutePostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudV2VolumescloneExecutePostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumescloneExecutePostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumescloneExecutePostUnauthorized creates a PcloudV2VolumescloneExecutePostUnauthorized with default headers values +func NewPcloudV2VolumescloneExecutePostUnauthorized() *PcloudV2VolumescloneExecutePostUnauthorized { + return &PcloudV2VolumescloneExecutePostUnauthorized{} +} + +/* PcloudV2VolumescloneExecutePostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudV2VolumescloneExecutePostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudV2VolumescloneExecutePostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone/{volumes_clone_id}/execute][%d] pcloudV2VolumescloneExecutePostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudV2VolumescloneExecutePostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumescloneExecutePostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumescloneExecutePostNotFound creates a PcloudV2VolumescloneExecutePostNotFound with default headers values +func NewPcloudV2VolumescloneExecutePostNotFound() *PcloudV2VolumescloneExecutePostNotFound { + return &PcloudV2VolumescloneExecutePostNotFound{} +} + +/* PcloudV2VolumescloneExecutePostNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudV2VolumescloneExecutePostNotFound struct { + Payload *models.Error +} + +func (o *PcloudV2VolumescloneExecutePostNotFound) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone/{volumes_clone_id}/execute][%d] pcloudV2VolumescloneExecutePostNotFound %+v", 404, o.Payload) +} +func (o *PcloudV2VolumescloneExecutePostNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumescloneExecutePostNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumescloneExecutePostInternalServerError creates a PcloudV2VolumescloneExecutePostInternalServerError with default headers values +func NewPcloudV2VolumescloneExecutePostInternalServerError() *PcloudV2VolumescloneExecutePostInternalServerError { + return &PcloudV2VolumescloneExecutePostInternalServerError{} +} + +/* PcloudV2VolumescloneExecutePostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudV2VolumescloneExecutePostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudV2VolumescloneExecutePostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone/{volumes_clone_id}/execute][%d] pcloudV2VolumescloneExecutePostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudV2VolumescloneExecutePostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumescloneExecutePostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_get_parameters.go new file mode 100644 index 00000000000..0a9c293e307 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_get_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudV2VolumescloneGetParams creates a new PcloudV2VolumescloneGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudV2VolumescloneGetParams() *PcloudV2VolumescloneGetParams { + return &PcloudV2VolumescloneGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudV2VolumescloneGetParamsWithTimeout creates a new PcloudV2VolumescloneGetParams object +// with the ability to set a timeout on a request. +func NewPcloudV2VolumescloneGetParamsWithTimeout(timeout time.Duration) *PcloudV2VolumescloneGetParams { + return &PcloudV2VolumescloneGetParams{ + timeout: timeout, + } +} + +// NewPcloudV2VolumescloneGetParamsWithContext creates a new PcloudV2VolumescloneGetParams object +// with the ability to set a context for a request. +func NewPcloudV2VolumescloneGetParamsWithContext(ctx context.Context) *PcloudV2VolumescloneGetParams { + return &PcloudV2VolumescloneGetParams{ + Context: ctx, + } +} + +// NewPcloudV2VolumescloneGetParamsWithHTTPClient creates a new PcloudV2VolumescloneGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudV2VolumescloneGetParamsWithHTTPClient(client *http.Client) *PcloudV2VolumescloneGetParams { + return &PcloudV2VolumescloneGetParams{ + HTTPClient: client, + } +} + +/* PcloudV2VolumescloneGetParams contains all the parameters to send to the API endpoint + for the pcloud v2 volumesclone get operation. + + Typically these are written to a http.Request. +*/ +type PcloudV2VolumescloneGetParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* VolumesCloneID. + + Volumes Clone ID + */ + VolumesCloneID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud v2 volumesclone get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV2VolumescloneGetParams) WithDefaults() *PcloudV2VolumescloneGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud v2 volumesclone get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV2VolumescloneGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud v2 volumesclone get params +func (o *PcloudV2VolumescloneGetParams) WithTimeout(timeout time.Duration) *PcloudV2VolumescloneGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud v2 volumesclone get params +func (o *PcloudV2VolumescloneGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud v2 volumesclone get params +func (o *PcloudV2VolumescloneGetParams) WithContext(ctx context.Context) *PcloudV2VolumescloneGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud v2 volumesclone get params +func (o *PcloudV2VolumescloneGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud v2 volumesclone get params +func (o *PcloudV2VolumescloneGetParams) WithHTTPClient(client *http.Client) *PcloudV2VolumescloneGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud v2 volumesclone get params +func (o *PcloudV2VolumescloneGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud v2 volumesclone get params +func (o *PcloudV2VolumescloneGetParams) WithCloudInstanceID(cloudInstanceID string) *PcloudV2VolumescloneGetParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud v2 volumesclone get params +func (o *PcloudV2VolumescloneGetParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithVolumesCloneID adds the volumesCloneID to the pcloud v2 volumesclone get params +func (o *PcloudV2VolumescloneGetParams) WithVolumesCloneID(volumesCloneID string) *PcloudV2VolumescloneGetParams { + o.SetVolumesCloneID(volumesCloneID) + return o +} + +// SetVolumesCloneID adds the volumesCloneId to the pcloud v2 volumesclone get params +func (o *PcloudV2VolumescloneGetParams) SetVolumesCloneID(volumesCloneID string) { + o.VolumesCloneID = volumesCloneID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudV2VolumescloneGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param volumes_clone_id + if err := r.SetPathParam("volumes_clone_id", o.VolumesCloneID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_get_responses.go new file mode 100644 index 00000000000..f1dfe63fb35 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_get_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudV2VolumescloneGetReader is a Reader for the PcloudV2VolumescloneGet structure. +type PcloudV2VolumescloneGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudV2VolumescloneGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudV2VolumescloneGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudV2VolumescloneGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudV2VolumescloneGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudV2VolumescloneGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudV2VolumescloneGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudV2VolumescloneGetOK creates a PcloudV2VolumescloneGetOK with default headers values +func NewPcloudV2VolumescloneGetOK() *PcloudV2VolumescloneGetOK { + return &PcloudV2VolumescloneGetOK{} +} + +/* PcloudV2VolumescloneGetOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudV2VolumescloneGetOK struct { + Payload *models.VolumesCloneDetail +} + +func (o *PcloudV2VolumescloneGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone/{volumes_clone_id}][%d] pcloudV2VolumescloneGetOK %+v", 200, o.Payload) +} +func (o *PcloudV2VolumescloneGetOK) GetPayload() *models.VolumesCloneDetail { + return o.Payload +} + +func (o *PcloudV2VolumescloneGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.VolumesCloneDetail) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumescloneGetBadRequest creates a PcloudV2VolumescloneGetBadRequest with default headers values +func NewPcloudV2VolumescloneGetBadRequest() *PcloudV2VolumescloneGetBadRequest { + return &PcloudV2VolumescloneGetBadRequest{} +} + +/* PcloudV2VolumescloneGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudV2VolumescloneGetBadRequest struct { + Payload *models.Error +} + +func (o *PcloudV2VolumescloneGetBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone/{volumes_clone_id}][%d] pcloudV2VolumescloneGetBadRequest %+v", 400, o.Payload) +} +func (o *PcloudV2VolumescloneGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumescloneGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumescloneGetUnauthorized creates a PcloudV2VolumescloneGetUnauthorized with default headers values +func NewPcloudV2VolumescloneGetUnauthorized() *PcloudV2VolumescloneGetUnauthorized { + return &PcloudV2VolumescloneGetUnauthorized{} +} + +/* PcloudV2VolumescloneGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudV2VolumescloneGetUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudV2VolumescloneGetUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone/{volumes_clone_id}][%d] pcloudV2VolumescloneGetUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudV2VolumescloneGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumescloneGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumescloneGetNotFound creates a PcloudV2VolumescloneGetNotFound with default headers values +func NewPcloudV2VolumescloneGetNotFound() *PcloudV2VolumescloneGetNotFound { + return &PcloudV2VolumescloneGetNotFound{} +} + +/* PcloudV2VolumescloneGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudV2VolumescloneGetNotFound struct { + Payload *models.Error +} + +func (o *PcloudV2VolumescloneGetNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone/{volumes_clone_id}][%d] pcloudV2VolumescloneGetNotFound %+v", 404, o.Payload) +} +func (o *PcloudV2VolumescloneGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumescloneGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumescloneGetInternalServerError creates a PcloudV2VolumescloneGetInternalServerError with default headers values +func NewPcloudV2VolumescloneGetInternalServerError() *PcloudV2VolumescloneGetInternalServerError { + return &PcloudV2VolumescloneGetInternalServerError{} +} + +/* PcloudV2VolumescloneGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudV2VolumescloneGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudV2VolumescloneGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone/{volumes_clone_id}][%d] pcloudV2VolumescloneGetInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudV2VolumescloneGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumescloneGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_getall_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_getall_parameters.go new file mode 100644 index 00000000000..f18506d0621 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_getall_parameters.go @@ -0,0 +1,192 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudV2VolumescloneGetallParams creates a new PcloudV2VolumescloneGetallParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudV2VolumescloneGetallParams() *PcloudV2VolumescloneGetallParams { + return &PcloudV2VolumescloneGetallParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudV2VolumescloneGetallParamsWithTimeout creates a new PcloudV2VolumescloneGetallParams object +// with the ability to set a timeout on a request. +func NewPcloudV2VolumescloneGetallParamsWithTimeout(timeout time.Duration) *PcloudV2VolumescloneGetallParams { + return &PcloudV2VolumescloneGetallParams{ + timeout: timeout, + } +} + +// NewPcloudV2VolumescloneGetallParamsWithContext creates a new PcloudV2VolumescloneGetallParams object +// with the ability to set a context for a request. +func NewPcloudV2VolumescloneGetallParamsWithContext(ctx context.Context) *PcloudV2VolumescloneGetallParams { + return &PcloudV2VolumescloneGetallParams{ + Context: ctx, + } +} + +// NewPcloudV2VolumescloneGetallParamsWithHTTPClient creates a new PcloudV2VolumescloneGetallParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudV2VolumescloneGetallParamsWithHTTPClient(client *http.Client) *PcloudV2VolumescloneGetallParams { + return &PcloudV2VolumescloneGetallParams{ + HTTPClient: client, + } +} + +/* PcloudV2VolumescloneGetallParams contains all the parameters to send to the API endpoint + for the pcloud v2 volumesclone getall operation. + + Typically these are written to a http.Request. +*/ +type PcloudV2VolumescloneGetallParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* Filter. + + volumes-clone filter to limit list items: + prepare - includes status values (preparing, prepared) + start - includes status values (starting, available) + execute - includes status values (executing, available-rollback) + cancel - includes status values (cancelling) + completed - includes status values (completed) + failed - includes status values (failed) + cancelled - includes status values (cancelled) + finalized - included status values (completed, failed, cancelled) + + */ + Filter *string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud v2 volumesclone getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV2VolumescloneGetallParams) WithDefaults() *PcloudV2VolumescloneGetallParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud v2 volumesclone getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV2VolumescloneGetallParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud v2 volumesclone getall params +func (o *PcloudV2VolumescloneGetallParams) WithTimeout(timeout time.Duration) *PcloudV2VolumescloneGetallParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud v2 volumesclone getall params +func (o *PcloudV2VolumescloneGetallParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud v2 volumesclone getall params +func (o *PcloudV2VolumescloneGetallParams) WithContext(ctx context.Context) *PcloudV2VolumescloneGetallParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud v2 volumesclone getall params +func (o *PcloudV2VolumescloneGetallParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud v2 volumesclone getall params +func (o *PcloudV2VolumescloneGetallParams) WithHTTPClient(client *http.Client) *PcloudV2VolumescloneGetallParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud v2 volumesclone getall params +func (o *PcloudV2VolumescloneGetallParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud v2 volumesclone getall params +func (o *PcloudV2VolumescloneGetallParams) WithCloudInstanceID(cloudInstanceID string) *PcloudV2VolumescloneGetallParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud v2 volumesclone getall params +func (o *PcloudV2VolumescloneGetallParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithFilter adds the filter to the pcloud v2 volumesclone getall params +func (o *PcloudV2VolumescloneGetallParams) WithFilter(filter *string) *PcloudV2VolumescloneGetallParams { + o.SetFilter(filter) + return o +} + +// SetFilter adds the filter to the pcloud v2 volumesclone getall params +func (o *PcloudV2VolumescloneGetallParams) SetFilter(filter *string) { + o.Filter = filter +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudV2VolumescloneGetallParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if o.Filter != nil { + + // query param filter + var qrFilter string + + if o.Filter != nil { + qrFilter = *o.Filter + } + qFilter := qrFilter + if qFilter != "" { + + if err := r.SetQueryParam("filter", qFilter); err != nil { + return err + } + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_getall_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_getall_responses.go new file mode 100644 index 00000000000..ed1b66608fe --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_getall_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudV2VolumescloneGetallReader is a Reader for the PcloudV2VolumescloneGetall structure. +type PcloudV2VolumescloneGetallReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudV2VolumescloneGetallReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudV2VolumescloneGetallOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudV2VolumescloneGetallBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudV2VolumescloneGetallUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudV2VolumescloneGetallNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudV2VolumescloneGetallInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudV2VolumescloneGetallOK creates a PcloudV2VolumescloneGetallOK with default headers values +func NewPcloudV2VolumescloneGetallOK() *PcloudV2VolumescloneGetallOK { + return &PcloudV2VolumescloneGetallOK{} +} + +/* PcloudV2VolumescloneGetallOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudV2VolumescloneGetallOK struct { + Payload *models.VolumesClones +} + +func (o *PcloudV2VolumescloneGetallOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone][%d] pcloudV2VolumescloneGetallOK %+v", 200, o.Payload) +} +func (o *PcloudV2VolumescloneGetallOK) GetPayload() *models.VolumesClones { + return o.Payload +} + +func (o *PcloudV2VolumescloneGetallOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.VolumesClones) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumescloneGetallBadRequest creates a PcloudV2VolumescloneGetallBadRequest with default headers values +func NewPcloudV2VolumescloneGetallBadRequest() *PcloudV2VolumescloneGetallBadRequest { + return &PcloudV2VolumescloneGetallBadRequest{} +} + +/* PcloudV2VolumescloneGetallBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudV2VolumescloneGetallBadRequest struct { + Payload *models.Error +} + +func (o *PcloudV2VolumescloneGetallBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone][%d] pcloudV2VolumescloneGetallBadRequest %+v", 400, o.Payload) +} +func (o *PcloudV2VolumescloneGetallBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumescloneGetallBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumescloneGetallUnauthorized creates a PcloudV2VolumescloneGetallUnauthorized with default headers values +func NewPcloudV2VolumescloneGetallUnauthorized() *PcloudV2VolumescloneGetallUnauthorized { + return &PcloudV2VolumescloneGetallUnauthorized{} +} + +/* PcloudV2VolumescloneGetallUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudV2VolumescloneGetallUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudV2VolumescloneGetallUnauthorized) Error() string { + return fmt.Sprintf("[GET /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone][%d] pcloudV2VolumescloneGetallUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudV2VolumescloneGetallUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumescloneGetallUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumescloneGetallNotFound creates a PcloudV2VolumescloneGetallNotFound with default headers values +func NewPcloudV2VolumescloneGetallNotFound() *PcloudV2VolumescloneGetallNotFound { + return &PcloudV2VolumescloneGetallNotFound{} +} + +/* PcloudV2VolumescloneGetallNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudV2VolumescloneGetallNotFound struct { + Payload *models.Error +} + +func (o *PcloudV2VolumescloneGetallNotFound) Error() string { + return fmt.Sprintf("[GET /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone][%d] pcloudV2VolumescloneGetallNotFound %+v", 404, o.Payload) +} +func (o *PcloudV2VolumescloneGetallNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumescloneGetallNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumescloneGetallInternalServerError creates a PcloudV2VolumescloneGetallInternalServerError with default headers values +func NewPcloudV2VolumescloneGetallInternalServerError() *PcloudV2VolumescloneGetallInternalServerError { + return &PcloudV2VolumescloneGetallInternalServerError{} +} + +/* PcloudV2VolumescloneGetallInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudV2VolumescloneGetallInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudV2VolumescloneGetallInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone][%d] pcloudV2VolumescloneGetallInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudV2VolumescloneGetallInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumescloneGetallInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_post_parameters.go new file mode 100644 index 00000000000..f728df4e876 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_post_parameters.go @@ -0,0 +1,173 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudV2VolumesclonePostParams creates a new PcloudV2VolumesclonePostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudV2VolumesclonePostParams() *PcloudV2VolumesclonePostParams { + return &PcloudV2VolumesclonePostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudV2VolumesclonePostParamsWithTimeout creates a new PcloudV2VolumesclonePostParams object +// with the ability to set a timeout on a request. +func NewPcloudV2VolumesclonePostParamsWithTimeout(timeout time.Duration) *PcloudV2VolumesclonePostParams { + return &PcloudV2VolumesclonePostParams{ + timeout: timeout, + } +} + +// NewPcloudV2VolumesclonePostParamsWithContext creates a new PcloudV2VolumesclonePostParams object +// with the ability to set a context for a request. +func NewPcloudV2VolumesclonePostParamsWithContext(ctx context.Context) *PcloudV2VolumesclonePostParams { + return &PcloudV2VolumesclonePostParams{ + Context: ctx, + } +} + +// NewPcloudV2VolumesclonePostParamsWithHTTPClient creates a new PcloudV2VolumesclonePostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudV2VolumesclonePostParamsWithHTTPClient(client *http.Client) *PcloudV2VolumesclonePostParams { + return &PcloudV2VolumesclonePostParams{ + HTTPClient: client, + } +} + +/* PcloudV2VolumesclonePostParams contains all the parameters to send to the API endpoint + for the pcloud v2 volumesclone post operation. + + Typically these are written to a http.Request. +*/ +type PcloudV2VolumesclonePostParams struct { + + /* Body. + + Parameters for preparing a set of volumes to be cloned + */ + Body *models.VolumesCloneCreate + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud v2 volumesclone post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV2VolumesclonePostParams) WithDefaults() *PcloudV2VolumesclonePostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud v2 volumesclone post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV2VolumesclonePostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud v2 volumesclone post params +func (o *PcloudV2VolumesclonePostParams) WithTimeout(timeout time.Duration) *PcloudV2VolumesclonePostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud v2 volumesclone post params +func (o *PcloudV2VolumesclonePostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud v2 volumesclone post params +func (o *PcloudV2VolumesclonePostParams) WithContext(ctx context.Context) *PcloudV2VolumesclonePostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud v2 volumesclone post params +func (o *PcloudV2VolumesclonePostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud v2 volumesclone post params +func (o *PcloudV2VolumesclonePostParams) WithHTTPClient(client *http.Client) *PcloudV2VolumesclonePostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud v2 volumesclone post params +func (o *PcloudV2VolumesclonePostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud v2 volumesclone post params +func (o *PcloudV2VolumesclonePostParams) WithBody(body *models.VolumesCloneCreate) *PcloudV2VolumesclonePostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud v2 volumesclone post params +func (o *PcloudV2VolumesclonePostParams) SetBody(body *models.VolumesCloneCreate) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud v2 volumesclone post params +func (o *PcloudV2VolumesclonePostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudV2VolumesclonePostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud v2 volumesclone post params +func (o *PcloudV2VolumesclonePostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudV2VolumesclonePostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_post_responses.go new file mode 100644 index 00000000000..6caa458fd9e --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_post_responses.go @@ -0,0 +1,257 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudV2VolumesclonePostReader is a Reader for the PcloudV2VolumesclonePost structure. +type PcloudV2VolumesclonePostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudV2VolumesclonePostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 202: + result := NewPcloudV2VolumesclonePostAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudV2VolumesclonePostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudV2VolumesclonePostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewPcloudV2VolumesclonePostForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudV2VolumesclonePostNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudV2VolumesclonePostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudV2VolumesclonePostAccepted creates a PcloudV2VolumesclonePostAccepted with default headers values +func NewPcloudV2VolumesclonePostAccepted() *PcloudV2VolumesclonePostAccepted { + return &PcloudV2VolumesclonePostAccepted{} +} + +/* PcloudV2VolumesclonePostAccepted describes a response with status code 202, with default header values. + +Accepted +*/ +type PcloudV2VolumesclonePostAccepted struct { + Payload *models.VolumesClone +} + +func (o *PcloudV2VolumesclonePostAccepted) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone][%d] pcloudV2VolumesclonePostAccepted %+v", 202, o.Payload) +} +func (o *PcloudV2VolumesclonePostAccepted) GetPayload() *models.VolumesClone { + return o.Payload +} + +func (o *PcloudV2VolumesclonePostAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.VolumesClone) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumesclonePostBadRequest creates a PcloudV2VolumesclonePostBadRequest with default headers values +func NewPcloudV2VolumesclonePostBadRequest() *PcloudV2VolumesclonePostBadRequest { + return &PcloudV2VolumesclonePostBadRequest{} +} + +/* PcloudV2VolumesclonePostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudV2VolumesclonePostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudV2VolumesclonePostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone][%d] pcloudV2VolumesclonePostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudV2VolumesclonePostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumesclonePostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumesclonePostUnauthorized creates a PcloudV2VolumesclonePostUnauthorized with default headers values +func NewPcloudV2VolumesclonePostUnauthorized() *PcloudV2VolumesclonePostUnauthorized { + return &PcloudV2VolumesclonePostUnauthorized{} +} + +/* PcloudV2VolumesclonePostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudV2VolumesclonePostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudV2VolumesclonePostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone][%d] pcloudV2VolumesclonePostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudV2VolumesclonePostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumesclonePostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumesclonePostForbidden creates a PcloudV2VolumesclonePostForbidden with default headers values +func NewPcloudV2VolumesclonePostForbidden() *PcloudV2VolumesclonePostForbidden { + return &PcloudV2VolumesclonePostForbidden{} +} + +/* PcloudV2VolumesclonePostForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type PcloudV2VolumesclonePostForbidden struct { + Payload *models.Error +} + +func (o *PcloudV2VolumesclonePostForbidden) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone][%d] pcloudV2VolumesclonePostForbidden %+v", 403, o.Payload) +} +func (o *PcloudV2VolumesclonePostForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumesclonePostForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumesclonePostNotFound creates a PcloudV2VolumesclonePostNotFound with default headers values +func NewPcloudV2VolumesclonePostNotFound() *PcloudV2VolumesclonePostNotFound { + return &PcloudV2VolumesclonePostNotFound{} +} + +/* PcloudV2VolumesclonePostNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudV2VolumesclonePostNotFound struct { + Payload *models.Error +} + +func (o *PcloudV2VolumesclonePostNotFound) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone][%d] pcloudV2VolumesclonePostNotFound %+v", 404, o.Payload) +} +func (o *PcloudV2VolumesclonePostNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumesclonePostNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumesclonePostInternalServerError creates a PcloudV2VolumesclonePostInternalServerError with default headers values +func NewPcloudV2VolumesclonePostInternalServerError() *PcloudV2VolumesclonePostInternalServerError { + return &PcloudV2VolumesclonePostInternalServerError{} +} + +/* PcloudV2VolumesclonePostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudV2VolumesclonePostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudV2VolumesclonePostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone][%d] pcloudV2VolumesclonePostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudV2VolumesclonePostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumesclonePostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_start_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_start_post_parameters.go new file mode 100644 index 00000000000..86e9c246841 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_start_post_parameters.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPcloudV2VolumescloneStartPostParams creates a new PcloudV2VolumescloneStartPostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudV2VolumescloneStartPostParams() *PcloudV2VolumescloneStartPostParams { + return &PcloudV2VolumescloneStartPostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudV2VolumescloneStartPostParamsWithTimeout creates a new PcloudV2VolumescloneStartPostParams object +// with the ability to set a timeout on a request. +func NewPcloudV2VolumescloneStartPostParamsWithTimeout(timeout time.Duration) *PcloudV2VolumescloneStartPostParams { + return &PcloudV2VolumescloneStartPostParams{ + timeout: timeout, + } +} + +// NewPcloudV2VolumescloneStartPostParamsWithContext creates a new PcloudV2VolumescloneStartPostParams object +// with the ability to set a context for a request. +func NewPcloudV2VolumescloneStartPostParamsWithContext(ctx context.Context) *PcloudV2VolumescloneStartPostParams { + return &PcloudV2VolumescloneStartPostParams{ + Context: ctx, + } +} + +// NewPcloudV2VolumescloneStartPostParamsWithHTTPClient creates a new PcloudV2VolumescloneStartPostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudV2VolumescloneStartPostParamsWithHTTPClient(client *http.Client) *PcloudV2VolumescloneStartPostParams { + return &PcloudV2VolumescloneStartPostParams{ + HTTPClient: client, + } +} + +/* PcloudV2VolumescloneStartPostParams contains all the parameters to send to the API endpoint + for the pcloud v2 volumesclone start post operation. + + Typically these are written to a http.Request. +*/ +type PcloudV2VolumescloneStartPostParams struct { + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + /* VolumesCloneID. + + Volumes Clone ID + */ + VolumesCloneID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud v2 volumesclone start post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV2VolumescloneStartPostParams) WithDefaults() *PcloudV2VolumescloneStartPostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud v2 volumesclone start post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudV2VolumescloneStartPostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud v2 volumesclone start post params +func (o *PcloudV2VolumescloneStartPostParams) WithTimeout(timeout time.Duration) *PcloudV2VolumescloneStartPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud v2 volumesclone start post params +func (o *PcloudV2VolumescloneStartPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud v2 volumesclone start post params +func (o *PcloudV2VolumescloneStartPostParams) WithContext(ctx context.Context) *PcloudV2VolumescloneStartPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud v2 volumesclone start post params +func (o *PcloudV2VolumescloneStartPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud v2 volumesclone start post params +func (o *PcloudV2VolumescloneStartPostParams) WithHTTPClient(client *http.Client) *PcloudV2VolumescloneStartPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud v2 volumesclone start post params +func (o *PcloudV2VolumescloneStartPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud v2 volumesclone start post params +func (o *PcloudV2VolumescloneStartPostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudV2VolumescloneStartPostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud v2 volumesclone start post params +func (o *PcloudV2VolumescloneStartPostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithVolumesCloneID adds the volumesCloneID to the pcloud v2 volumesclone start post params +func (o *PcloudV2VolumescloneStartPostParams) WithVolumesCloneID(volumesCloneID string) *PcloudV2VolumescloneStartPostParams { + o.SetVolumesCloneID(volumesCloneID) + return o +} + +// SetVolumesCloneID adds the volumesCloneId to the pcloud v2 volumesclone start post params +func (o *PcloudV2VolumescloneStartPostParams) SetVolumesCloneID(volumesCloneID string) { + o.VolumesCloneID = volumesCloneID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudV2VolumescloneStartPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // path param volumes_clone_id + if err := r.SetPathParam("volumes_clone_id", o.VolumesCloneID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_start_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_start_post_responses.go new file mode 100644 index 00000000000..a144d63d50e --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_v2_volumesclone_start_post_responses.go @@ -0,0 +1,181 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudV2VolumescloneStartPostReader is a Reader for the PcloudV2VolumescloneStartPost structure. +type PcloudV2VolumescloneStartPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudV2VolumescloneStartPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudV2VolumescloneStartPostOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewPcloudV2VolumescloneStartPostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPcloudV2VolumescloneStartPostNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudV2VolumescloneStartPostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudV2VolumescloneStartPostOK creates a PcloudV2VolumescloneStartPostOK with default headers values +func NewPcloudV2VolumescloneStartPostOK() *PcloudV2VolumescloneStartPostOK { + return &PcloudV2VolumescloneStartPostOK{} +} + +/* PcloudV2VolumescloneStartPostOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudV2VolumescloneStartPostOK struct { + Payload *models.VolumesClone +} + +func (o *PcloudV2VolumescloneStartPostOK) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone/{volumes_clone_id}/start][%d] pcloudV2VolumescloneStartPostOK %+v", 200, o.Payload) +} +func (o *PcloudV2VolumescloneStartPostOK) GetPayload() *models.VolumesClone { + return o.Payload +} + +func (o *PcloudV2VolumescloneStartPostOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.VolumesClone) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumescloneStartPostUnauthorized creates a PcloudV2VolumescloneStartPostUnauthorized with default headers values +func NewPcloudV2VolumescloneStartPostUnauthorized() *PcloudV2VolumescloneStartPostUnauthorized { + return &PcloudV2VolumescloneStartPostUnauthorized{} +} + +/* PcloudV2VolumescloneStartPostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudV2VolumescloneStartPostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudV2VolumescloneStartPostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone/{volumes_clone_id}/start][%d] pcloudV2VolumescloneStartPostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudV2VolumescloneStartPostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumescloneStartPostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumescloneStartPostNotFound creates a PcloudV2VolumescloneStartPostNotFound with default headers values +func NewPcloudV2VolumescloneStartPostNotFound() *PcloudV2VolumescloneStartPostNotFound { + return &PcloudV2VolumescloneStartPostNotFound{} +} + +/* PcloudV2VolumescloneStartPostNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PcloudV2VolumescloneStartPostNotFound struct { + Payload *models.Error +} + +func (o *PcloudV2VolumescloneStartPostNotFound) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone/{volumes_clone_id}/start][%d] pcloudV2VolumescloneStartPostNotFound %+v", 404, o.Payload) +} +func (o *PcloudV2VolumescloneStartPostNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumescloneStartPostNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudV2VolumescloneStartPostInternalServerError creates a PcloudV2VolumescloneStartPostInternalServerError with default headers values +func NewPcloudV2VolumescloneStartPostInternalServerError() *PcloudV2VolumescloneStartPostInternalServerError { + return &PcloudV2VolumescloneStartPostInternalServerError{} +} + +/* PcloudV2VolumescloneStartPostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudV2VolumescloneStartPostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudV2VolumescloneStartPostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v2/cloud-instances/{cloud_instance_id}/volumes-clone/{volumes_clone_id}/start][%d] pcloudV2VolumescloneStartPostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudV2VolumescloneStartPostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudV2VolumescloneStartPostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_volumes_clone_post_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_volumes_clone_post_parameters.go new file mode 100644 index 00000000000..44e22ad18e0 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_volumes_clone_post_parameters.go @@ -0,0 +1,173 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewPcloudVolumesClonePostParams creates a new PcloudVolumesClonePostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPcloudVolumesClonePostParams() *PcloudVolumesClonePostParams { + return &PcloudVolumesClonePostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudVolumesClonePostParamsWithTimeout creates a new PcloudVolumesClonePostParams object +// with the ability to set a timeout on a request. +func NewPcloudVolumesClonePostParamsWithTimeout(timeout time.Duration) *PcloudVolumesClonePostParams { + return &PcloudVolumesClonePostParams{ + timeout: timeout, + } +} + +// NewPcloudVolumesClonePostParamsWithContext creates a new PcloudVolumesClonePostParams object +// with the ability to set a context for a request. +func NewPcloudVolumesClonePostParamsWithContext(ctx context.Context) *PcloudVolumesClonePostParams { + return &PcloudVolumesClonePostParams{ + Context: ctx, + } +} + +// NewPcloudVolumesClonePostParamsWithHTTPClient creates a new PcloudVolumesClonePostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPcloudVolumesClonePostParamsWithHTTPClient(client *http.Client) *PcloudVolumesClonePostParams { + return &PcloudVolumesClonePostParams{ + HTTPClient: client, + } +} + +/* PcloudVolumesClonePostParams contains all the parameters to send to the API endpoint + for the pcloud volumes clone post operation. + + Typically these are written to a http.Request. +*/ +type PcloudVolumesClonePostParams struct { + + /* Body. + + Parameters for the cloning of volumes + */ + Body *models.VolumesCloneRequest + + /* CloudInstanceID. + + Cloud Instance ID of a PCloud Instance + */ + CloudInstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the pcloud volumes clone post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudVolumesClonePostParams) WithDefaults() *PcloudVolumesClonePostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the pcloud volumes clone post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PcloudVolumesClonePostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the pcloud volumes clone post params +func (o *PcloudVolumesClonePostParams) WithTimeout(timeout time.Duration) *PcloudVolumesClonePostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud volumes clone post params +func (o *PcloudVolumesClonePostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud volumes clone post params +func (o *PcloudVolumesClonePostParams) WithContext(ctx context.Context) *PcloudVolumesClonePostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud volumes clone post params +func (o *PcloudVolumesClonePostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud volumes clone post params +func (o *PcloudVolumesClonePostParams) WithHTTPClient(client *http.Client) *PcloudVolumesClonePostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud volumes clone post params +func (o *PcloudVolumesClonePostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the pcloud volumes clone post params +func (o *PcloudVolumesClonePostParams) WithBody(body *models.VolumesCloneRequest) *PcloudVolumesClonePostParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the pcloud volumes clone post params +func (o *PcloudVolumesClonePostParams) SetBody(body *models.VolumesCloneRequest) { + o.Body = body +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud volumes clone post params +func (o *PcloudVolumesClonePostParams) WithCloudInstanceID(cloudInstanceID string) *PcloudVolumesClonePostParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud volumes clone post params +func (o *PcloudVolumesClonePostParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudVolumesClonePostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_volumes_clone_post_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_volumes_clone_post_responses.go new file mode 100644 index 00000000000..5c13855d743 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes/pcloud_volumes_clone_post_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_volumes + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudVolumesClonePostReader is a Reader for the PcloudVolumesClonePost structure. +type PcloudVolumesClonePostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudVolumesClonePostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPcloudVolumesClonePostOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPcloudVolumesClonePostBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPcloudVolumesClonePostUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewPcloudVolumesClonePostConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPcloudVolumesClonePostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPcloudVolumesClonePostOK creates a PcloudVolumesClonePostOK with default headers values +func NewPcloudVolumesClonePostOK() *PcloudVolumesClonePostOK { + return &PcloudVolumesClonePostOK{} +} + +/* PcloudVolumesClonePostOK describes a response with status code 200, with default header values. + +OK +*/ +type PcloudVolumesClonePostOK struct { + Payload *models.VolumesCloneResponse +} + +func (o *PcloudVolumesClonePostOK) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes/clone][%d] pcloudVolumesClonePostOK %+v", 200, o.Payload) +} +func (o *PcloudVolumesClonePostOK) GetPayload() *models.VolumesCloneResponse { + return o.Payload +} + +func (o *PcloudVolumesClonePostOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.VolumesCloneResponse) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVolumesClonePostBadRequest creates a PcloudVolumesClonePostBadRequest with default headers values +func NewPcloudVolumesClonePostBadRequest() *PcloudVolumesClonePostBadRequest { + return &PcloudVolumesClonePostBadRequest{} +} + +/* PcloudVolumesClonePostBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PcloudVolumesClonePostBadRequest struct { + Payload *models.Error +} + +func (o *PcloudVolumesClonePostBadRequest) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes/clone][%d] pcloudVolumesClonePostBadRequest %+v", 400, o.Payload) +} +func (o *PcloudVolumesClonePostBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVolumesClonePostBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVolumesClonePostUnauthorized creates a PcloudVolumesClonePostUnauthorized with default headers values +func NewPcloudVolumesClonePostUnauthorized() *PcloudVolumesClonePostUnauthorized { + return &PcloudVolumesClonePostUnauthorized{} +} + +/* PcloudVolumesClonePostUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PcloudVolumesClonePostUnauthorized struct { + Payload *models.Error +} + +func (o *PcloudVolumesClonePostUnauthorized) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes/clone][%d] pcloudVolumesClonePostUnauthorized %+v", 401, o.Payload) +} +func (o *PcloudVolumesClonePostUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVolumesClonePostUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVolumesClonePostConflict creates a PcloudVolumesClonePostConflict with default headers values +func NewPcloudVolumesClonePostConflict() *PcloudVolumesClonePostConflict { + return &PcloudVolumesClonePostConflict{} +} + +/* PcloudVolumesClonePostConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type PcloudVolumesClonePostConflict struct { + Payload *models.Error +} + +func (o *PcloudVolumesClonePostConflict) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes/clone][%d] pcloudVolumesClonePostConflict %+v", 409, o.Payload) +} +func (o *PcloudVolumesClonePostConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVolumesClonePostConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudVolumesClonePostInternalServerError creates a PcloudVolumesClonePostInternalServerError with default headers values +func NewPcloudVolumesClonePostInternalServerError() *PcloudVolumesClonePostInternalServerError { + return &PcloudVolumesClonePostInternalServerError{} +} + +/* PcloudVolumesClonePostInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PcloudVolumesClonePostInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudVolumesClonePostInternalServerError) Error() string { + return fmt.Sprintf("[POST /pcloud/v1/cloud-instances/{cloud_instance_id}/volumes/clone][%d] pcloudVolumesClonePostInternalServerError %+v", 500, o.Payload) +} +func (o *PcloudVolumesClonePostInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *PcloudVolumesClonePostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/power_iaas_api_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/power_iaas_api_client.go new file mode 100644 index 00000000000..749813a14ce --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/power_iaas_api_client.go @@ -0,0 +1,257 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package client + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/runtime" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/client/authentication" + "github.com/IBM-Cloud/power-go-client/power/client/bluemix_service_instances" + "github.com/IBM-Cloud/power-go-client/power/client/catalog" + "github.com/IBM-Cloud/power-go-client/power/client/hardware_platforms" + "github.com/IBM-Cloud/power-go-client/power/client/iaas_service_broker" + "github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions" + "github.com/IBM-Cloud/power-go-client/power/client/open_stacks" + "github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections" + "github.com/IBM-Cloud/power-go-client/power/client/p_cloud_events" + "github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images" + "github.com/IBM-Cloud/power-go-client/power/client/p_cloud_instances" + "github.com/IBM-Cloud/power-go-client/power/client/p_cloud_jobs" + "github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks" + "github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances" + "github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups" + "github.com/IBM-Cloud/power-go-client/power/client/p_cloud_s_a_p" + "github.com/IBM-Cloud/power-go-client/power/client/p_cloud_service_d_h_c_p" + "github.com/IBM-Cloud/power-go-client/power/client/p_cloud_snapshots" + "github.com/IBM-Cloud/power-go-client/power/client/p_cloud_storage_capacity" + "github.com/IBM-Cloud/power-go-client/power/client/p_cloud_system_pools" + "github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tasks" + "github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants" + "github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys" + "github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections" + "github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies" + "github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes" + "github.com/IBM-Cloud/power-go-client/power/client/service_bindings" + "github.com/IBM-Cloud/power-go-client/power/client/service_instances" + "github.com/IBM-Cloud/power-go-client/power/client/storage_types" + "github.com/IBM-Cloud/power-go-client/power/client/swagger_spec" +) + +// Default power iaas API HTTP client. +var Default = NewHTTPClient(nil) + +const ( + // DefaultHost is the default Host + // found in Meta (info) section of spec file + DefaultHost string = "localhost" + // DefaultBasePath is the default BasePath + // found in Meta (info) section of spec file + DefaultBasePath string = "/" +) + +// DefaultSchemes are the default schemes found in Meta (info) section of spec file +var DefaultSchemes = []string{"http"} + +// NewHTTPClient creates a new power iaas API HTTP client. +func NewHTTPClient(formats strfmt.Registry) *PowerIaasAPI { + return NewHTTPClientWithConfig(formats, nil) +} + +// NewHTTPClientWithConfig creates a new power iaas API HTTP client, +// using a customizable transport config. +func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *PowerIaasAPI { + // ensure nullable parameters have default + if cfg == nil { + cfg = DefaultTransportConfig() + } + + // create transport and client + transport := httptransport.New(cfg.Host, cfg.BasePath, cfg.Schemes) + return New(transport, formats) +} + +// New creates a new power iaas API client +func New(transport runtime.ClientTransport, formats strfmt.Registry) *PowerIaasAPI { + // ensure nullable parameters have default + if formats == nil { + formats = strfmt.Default + } + + cli := new(PowerIaasAPI) + cli.Transport = transport + cli.Authentication = authentication.New(transport, formats) + cli.BluemixServiceInstances = bluemix_service_instances.New(transport, formats) + cli.Catalog = catalog.New(transport, formats) + cli.HardwarePlatforms = hardware_platforms.New(transport, formats) + cli.IaasServiceBroker = iaas_service_broker.New(transport, formats) + cli.InternalStorageRegions = internal_storage_regions.New(transport, formats) + cli.OpenStacks = open_stacks.New(transport, formats) + cli.PCloudCloudConnections = p_cloud_cloud_connections.New(transport, formats) + cli.PCloudEvents = p_cloud_events.New(transport, formats) + cli.PCloudImages = p_cloud_images.New(transport, formats) + cli.PCloudInstances = p_cloud_instances.New(transport, formats) + cli.PCloudJobs = p_cloud_jobs.New(transport, formats) + cli.PCloudNetworks = p_cloud_networks.New(transport, formats) + cli.PCloudpVMInstances = p_cloud_p_vm_instances.New(transport, formats) + cli.PCloudPlacementGroups = p_cloud_placement_groups.New(transport, formats) + cli.PCloudsap = p_cloud_s_a_p.New(transport, formats) + cli.PCloudServicedhcp = p_cloud_service_d_h_c_p.New(transport, formats) + cli.PCloudSnapshots = p_cloud_snapshots.New(transport, formats) + cli.PCloudStorageCapacity = p_cloud_storage_capacity.New(transport, formats) + cli.PCloudSystemPools = p_cloud_system_pools.New(transport, formats) + cli.PCloudTasks = p_cloud_tasks.New(transport, formats) + cli.PCloudTenants = p_cloud_tenants.New(transport, formats) + cli.PCloudTenantsSSHKeys = p_cloud_tenants_ssh_keys.New(transport, formats) + cli.PCloudvpnConnections = p_cloud_v_p_n_connections.New(transport, formats) + cli.PCloudvpnPolicies = p_cloud_v_p_n_policies.New(transport, formats) + cli.PCloudVolumes = p_cloud_volumes.New(transport, formats) + cli.ServiceBindings = service_bindings.New(transport, formats) + cli.ServiceInstances = service_instances.New(transport, formats) + cli.StorageTypes = storage_types.New(transport, formats) + cli.SwaggerSpec = swagger_spec.New(transport, formats) + return cli +} + +// DefaultTransportConfig creates a TransportConfig with the +// default settings taken from the meta section of the spec file. +func DefaultTransportConfig() *TransportConfig { + return &TransportConfig{ + Host: DefaultHost, + BasePath: DefaultBasePath, + Schemes: DefaultSchemes, + } +} + +// TransportConfig contains the transport related info, +// found in the meta section of the spec file. +type TransportConfig struct { + Host string + BasePath string + Schemes []string +} + +// WithHost overrides the default host, +// provided by the meta section of the spec file. +func (cfg *TransportConfig) WithHost(host string) *TransportConfig { + cfg.Host = host + return cfg +} + +// WithBasePath overrides the default basePath, +// provided by the meta section of the spec file. +func (cfg *TransportConfig) WithBasePath(basePath string) *TransportConfig { + cfg.BasePath = basePath + return cfg +} + +// WithSchemes overrides the default schemes, +// provided by the meta section of the spec file. +func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig { + cfg.Schemes = schemes + return cfg +} + +// PowerIaasAPI is a client for power iaas API +type PowerIaasAPI struct { + Authentication authentication.ClientService + + BluemixServiceInstances bluemix_service_instances.ClientService + + Catalog catalog.ClientService + + HardwarePlatforms hardware_platforms.ClientService + + IaasServiceBroker iaas_service_broker.ClientService + + InternalStorageRegions internal_storage_regions.ClientService + + OpenStacks open_stacks.ClientService + + PCloudCloudConnections p_cloud_cloud_connections.ClientService + + PCloudEvents p_cloud_events.ClientService + + PCloudImages p_cloud_images.ClientService + + PCloudInstances p_cloud_instances.ClientService + + PCloudJobs p_cloud_jobs.ClientService + + PCloudNetworks p_cloud_networks.ClientService + + PCloudpVMInstances p_cloud_p_vm_instances.ClientService + + PCloudPlacementGroups p_cloud_placement_groups.ClientService + + PCloudsap p_cloud_s_a_p.ClientService + + PCloudServicedhcp p_cloud_service_d_h_c_p.ClientService + + PCloudSnapshots p_cloud_snapshots.ClientService + + PCloudStorageCapacity p_cloud_storage_capacity.ClientService + + PCloudSystemPools p_cloud_system_pools.ClientService + + PCloudTasks p_cloud_tasks.ClientService + + PCloudTenants p_cloud_tenants.ClientService + + PCloudTenantsSSHKeys p_cloud_tenants_ssh_keys.ClientService + + PCloudvpnConnections p_cloud_v_p_n_connections.ClientService + + PCloudvpnPolicies p_cloud_v_p_n_policies.ClientService + + PCloudVolumes p_cloud_volumes.ClientService + + ServiceBindings service_bindings.ClientService + + ServiceInstances service_instances.ClientService + + StorageTypes storage_types.ClientService + + SwaggerSpec swagger_spec.ClientService + + Transport runtime.ClientTransport +} + +// SetTransport changes the transport on the client and all its subresources +func (c *PowerIaasAPI) SetTransport(transport runtime.ClientTransport) { + c.Transport = transport + c.Authentication.SetTransport(transport) + c.BluemixServiceInstances.SetTransport(transport) + c.Catalog.SetTransport(transport) + c.HardwarePlatforms.SetTransport(transport) + c.IaasServiceBroker.SetTransport(transport) + c.InternalStorageRegions.SetTransport(transport) + c.OpenStacks.SetTransport(transport) + c.PCloudCloudConnections.SetTransport(transport) + c.PCloudEvents.SetTransport(transport) + c.PCloudImages.SetTransport(transport) + c.PCloudInstances.SetTransport(transport) + c.PCloudJobs.SetTransport(transport) + c.PCloudNetworks.SetTransport(transport) + c.PCloudpVMInstances.SetTransport(transport) + c.PCloudPlacementGroups.SetTransport(transport) + c.PCloudsap.SetTransport(transport) + c.PCloudServicedhcp.SetTransport(transport) + c.PCloudSnapshots.SetTransport(transport) + c.PCloudStorageCapacity.SetTransport(transport) + c.PCloudSystemPools.SetTransport(transport) + c.PCloudTasks.SetTransport(transport) + c.PCloudTenants.SetTransport(transport) + c.PCloudTenantsSSHKeys.SetTransport(transport) + c.PCloudvpnConnections.SetTransport(transport) + c.PCloudvpnPolicies.SetTransport(transport) + c.PCloudVolumes.SetTransport(transport) + c.ServiceBindings.SetTransport(transport) + c.ServiceInstances.SetTransport(transport) + c.StorageTypes.SetTransport(transport) + c.SwaggerSpec.SetTransport(transport) +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_bindings/service_binding_binding_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_bindings/service_binding_binding_parameters.go new file mode 100644 index 00000000000..e2a1fc917c5 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_bindings/service_binding_binding_parameters.go @@ -0,0 +1,277 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package service_bindings + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewServiceBindingBindingParams creates a new ServiceBindingBindingParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewServiceBindingBindingParams() *ServiceBindingBindingParams { + return &ServiceBindingBindingParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewServiceBindingBindingParamsWithTimeout creates a new ServiceBindingBindingParams object +// with the ability to set a timeout on a request. +func NewServiceBindingBindingParamsWithTimeout(timeout time.Duration) *ServiceBindingBindingParams { + return &ServiceBindingBindingParams{ + timeout: timeout, + } +} + +// NewServiceBindingBindingParamsWithContext creates a new ServiceBindingBindingParams object +// with the ability to set a context for a request. +func NewServiceBindingBindingParamsWithContext(ctx context.Context) *ServiceBindingBindingParams { + return &ServiceBindingBindingParams{ + Context: ctx, + } +} + +// NewServiceBindingBindingParamsWithHTTPClient creates a new ServiceBindingBindingParams object +// with the ability to set a custom HTTPClient for a request. +func NewServiceBindingBindingParamsWithHTTPClient(client *http.Client) *ServiceBindingBindingParams { + return &ServiceBindingBindingParams{ + HTTPClient: client, + } +} + +/* ServiceBindingBindingParams contains all the parameters to send to the API endpoint + for the service binding binding operation. + + Typically these are written to a http.Request. +*/ +type ServiceBindingBindingParams struct { + + /* XBrokerAPIOriginatingIdentity. + + identity of the user that initiated the request from the Platform + */ + XBrokerAPIOriginatingIdentity *string + + /* XBrokerAPIVersion. + + version number of the Service Broker API that the Platform will use + */ + XBrokerAPIVersion string + + /* AcceptsIncomplete. + + asynchronous operations supported + */ + AcceptsIncomplete *bool + + /* BindingID. + + binding id of binding to create + */ + BindingID string + + /* Body. + + parameters for the requested service binding + */ + Body *models.ServiceBindingRequest + + /* InstanceID. + + instance id of instance to provision + */ + InstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the service binding binding params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBindingBindingParams) WithDefaults() *ServiceBindingBindingParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the service binding binding params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBindingBindingParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the service binding binding params +func (o *ServiceBindingBindingParams) WithTimeout(timeout time.Duration) *ServiceBindingBindingParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the service binding binding params +func (o *ServiceBindingBindingParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the service binding binding params +func (o *ServiceBindingBindingParams) WithContext(ctx context.Context) *ServiceBindingBindingParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the service binding binding params +func (o *ServiceBindingBindingParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the service binding binding params +func (o *ServiceBindingBindingParams) WithHTTPClient(client *http.Client) *ServiceBindingBindingParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the service binding binding params +func (o *ServiceBindingBindingParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXBrokerAPIOriginatingIdentity adds the xBrokerAPIOriginatingIdentity to the service binding binding params +func (o *ServiceBindingBindingParams) WithXBrokerAPIOriginatingIdentity(xBrokerAPIOriginatingIdentity *string) *ServiceBindingBindingParams { + o.SetXBrokerAPIOriginatingIdentity(xBrokerAPIOriginatingIdentity) + return o +} + +// SetXBrokerAPIOriginatingIdentity adds the xBrokerApiOriginatingIdentity to the service binding binding params +func (o *ServiceBindingBindingParams) SetXBrokerAPIOriginatingIdentity(xBrokerAPIOriginatingIdentity *string) { + o.XBrokerAPIOriginatingIdentity = xBrokerAPIOriginatingIdentity +} + +// WithXBrokerAPIVersion adds the xBrokerAPIVersion to the service binding binding params +func (o *ServiceBindingBindingParams) WithXBrokerAPIVersion(xBrokerAPIVersion string) *ServiceBindingBindingParams { + o.SetXBrokerAPIVersion(xBrokerAPIVersion) + return o +} + +// SetXBrokerAPIVersion adds the xBrokerApiVersion to the service binding binding params +func (o *ServiceBindingBindingParams) SetXBrokerAPIVersion(xBrokerAPIVersion string) { + o.XBrokerAPIVersion = xBrokerAPIVersion +} + +// WithAcceptsIncomplete adds the acceptsIncomplete to the service binding binding params +func (o *ServiceBindingBindingParams) WithAcceptsIncomplete(acceptsIncomplete *bool) *ServiceBindingBindingParams { + o.SetAcceptsIncomplete(acceptsIncomplete) + return o +} + +// SetAcceptsIncomplete adds the acceptsIncomplete to the service binding binding params +func (o *ServiceBindingBindingParams) SetAcceptsIncomplete(acceptsIncomplete *bool) { + o.AcceptsIncomplete = acceptsIncomplete +} + +// WithBindingID adds the bindingID to the service binding binding params +func (o *ServiceBindingBindingParams) WithBindingID(bindingID string) *ServiceBindingBindingParams { + o.SetBindingID(bindingID) + return o +} + +// SetBindingID adds the bindingId to the service binding binding params +func (o *ServiceBindingBindingParams) SetBindingID(bindingID string) { + o.BindingID = bindingID +} + +// WithBody adds the body to the service binding binding params +func (o *ServiceBindingBindingParams) WithBody(body *models.ServiceBindingRequest) *ServiceBindingBindingParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the service binding binding params +func (o *ServiceBindingBindingParams) SetBody(body *models.ServiceBindingRequest) { + o.Body = body +} + +// WithInstanceID adds the instanceID to the service binding binding params +func (o *ServiceBindingBindingParams) WithInstanceID(instanceID string) *ServiceBindingBindingParams { + o.SetInstanceID(instanceID) + return o +} + +// SetInstanceID adds the instanceId to the service binding binding params +func (o *ServiceBindingBindingParams) SetInstanceID(instanceID string) { + o.InstanceID = instanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *ServiceBindingBindingParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XBrokerAPIOriginatingIdentity != nil { + + // header param X-Broker-API-Originating-Identity + if err := r.SetHeaderParam("X-Broker-API-Originating-Identity", *o.XBrokerAPIOriginatingIdentity); err != nil { + return err + } + } + + // header param X-Broker-API-Version + if err := r.SetHeaderParam("X-Broker-API-Version", o.XBrokerAPIVersion); err != nil { + return err + } + + if o.AcceptsIncomplete != nil { + + // query param accepts_incomplete + var qrAcceptsIncomplete bool + + if o.AcceptsIncomplete != nil { + qrAcceptsIncomplete = *o.AcceptsIncomplete + } + qAcceptsIncomplete := swag.FormatBool(qrAcceptsIncomplete) + if qAcceptsIncomplete != "" { + + if err := r.SetQueryParam("accepts_incomplete", qAcceptsIncomplete); err != nil { + return err + } + } + } + + // path param binding_id + if err := r.SetPathParam("binding_id", o.BindingID); err != nil { + return err + } + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param instance_id + if err := r.SetPathParam("instance_id", o.InstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_bindings/service_binding_binding_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_bindings/service_binding_binding_responses.go new file mode 100644 index 00000000000..8d6a348a2c6 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_bindings/service_binding_binding_responses.go @@ -0,0 +1,257 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package service_bindings + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// ServiceBindingBindingReader is a Reader for the ServiceBindingBinding structure. +type ServiceBindingBindingReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ServiceBindingBindingReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewServiceBindingBindingOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 201: + result := NewServiceBindingBindingCreated() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 202: + result := NewServiceBindingBindingAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewServiceBindingBindingBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewServiceBindingBindingConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewServiceBindingBindingUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewServiceBindingBindingOK creates a ServiceBindingBindingOK with default headers values +func NewServiceBindingBindingOK() *ServiceBindingBindingOK { + return &ServiceBindingBindingOK{} +} + +/* ServiceBindingBindingOK describes a response with status code 200, with default header values. + +OK +*/ +type ServiceBindingBindingOK struct { + Payload *models.ServiceBinding +} + +func (o *ServiceBindingBindingOK) Error() string { + return fmt.Sprintf("[PUT /v2/service_instances/{instance_id}/service_bindings/{binding_id}][%d] serviceBindingBindingOK %+v", 200, o.Payload) +} +func (o *ServiceBindingBindingOK) GetPayload() *models.ServiceBinding { + return o.Payload +} + +func (o *ServiceBindingBindingOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ServiceBinding) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBindingBindingCreated creates a ServiceBindingBindingCreated with default headers values +func NewServiceBindingBindingCreated() *ServiceBindingBindingCreated { + return &ServiceBindingBindingCreated{} +} + +/* ServiceBindingBindingCreated describes a response with status code 201, with default header values. + +Created +*/ +type ServiceBindingBindingCreated struct { + Payload *models.ServiceBinding +} + +func (o *ServiceBindingBindingCreated) Error() string { + return fmt.Sprintf("[PUT /v2/service_instances/{instance_id}/service_bindings/{binding_id}][%d] serviceBindingBindingCreated %+v", 201, o.Payload) +} +func (o *ServiceBindingBindingCreated) GetPayload() *models.ServiceBinding { + return o.Payload +} + +func (o *ServiceBindingBindingCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ServiceBinding) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBindingBindingAccepted creates a ServiceBindingBindingAccepted with default headers values +func NewServiceBindingBindingAccepted() *ServiceBindingBindingAccepted { + return &ServiceBindingBindingAccepted{} +} + +/* ServiceBindingBindingAccepted describes a response with status code 202, with default header values. + +Accepted +*/ +type ServiceBindingBindingAccepted struct { + Payload *models.AsyncOperation +} + +func (o *ServiceBindingBindingAccepted) Error() string { + return fmt.Sprintf("[PUT /v2/service_instances/{instance_id}/service_bindings/{binding_id}][%d] serviceBindingBindingAccepted %+v", 202, o.Payload) +} +func (o *ServiceBindingBindingAccepted) GetPayload() *models.AsyncOperation { + return o.Payload +} + +func (o *ServiceBindingBindingAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AsyncOperation) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBindingBindingBadRequest creates a ServiceBindingBindingBadRequest with default headers values +func NewServiceBindingBindingBadRequest() *ServiceBindingBindingBadRequest { + return &ServiceBindingBindingBadRequest{} +} + +/* ServiceBindingBindingBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type ServiceBindingBindingBadRequest struct { + Payload *models.Error +} + +func (o *ServiceBindingBindingBadRequest) Error() string { + return fmt.Sprintf("[PUT /v2/service_instances/{instance_id}/service_bindings/{binding_id}][%d] serviceBindingBindingBadRequest %+v", 400, o.Payload) +} +func (o *ServiceBindingBindingBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBindingBindingBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBindingBindingConflict creates a ServiceBindingBindingConflict with default headers values +func NewServiceBindingBindingConflict() *ServiceBindingBindingConflict { + return &ServiceBindingBindingConflict{} +} + +/* ServiceBindingBindingConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type ServiceBindingBindingConflict struct { + Payload *models.Error +} + +func (o *ServiceBindingBindingConflict) Error() string { + return fmt.Sprintf("[PUT /v2/service_instances/{instance_id}/service_bindings/{binding_id}][%d] serviceBindingBindingConflict %+v", 409, o.Payload) +} +func (o *ServiceBindingBindingConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBindingBindingConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBindingBindingUnprocessableEntity creates a ServiceBindingBindingUnprocessableEntity with default headers values +func NewServiceBindingBindingUnprocessableEntity() *ServiceBindingBindingUnprocessableEntity { + return &ServiceBindingBindingUnprocessableEntity{} +} + +/* ServiceBindingBindingUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type ServiceBindingBindingUnprocessableEntity struct { + Payload *models.Error +} + +func (o *ServiceBindingBindingUnprocessableEntity) Error() string { + return fmt.Sprintf("[PUT /v2/service_instances/{instance_id}/service_bindings/{binding_id}][%d] serviceBindingBindingUnprocessableEntity %+v", 422, o.Payload) +} +func (o *ServiceBindingBindingUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBindingBindingUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_bindings/service_binding_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_bindings/service_binding_get_parameters.go new file mode 100644 index 00000000000..98450eb6c29 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_bindings/service_binding_get_parameters.go @@ -0,0 +1,218 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package service_bindings + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewServiceBindingGetParams creates a new ServiceBindingGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewServiceBindingGetParams() *ServiceBindingGetParams { + return &ServiceBindingGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewServiceBindingGetParamsWithTimeout creates a new ServiceBindingGetParams object +// with the ability to set a timeout on a request. +func NewServiceBindingGetParamsWithTimeout(timeout time.Duration) *ServiceBindingGetParams { + return &ServiceBindingGetParams{ + timeout: timeout, + } +} + +// NewServiceBindingGetParamsWithContext creates a new ServiceBindingGetParams object +// with the ability to set a context for a request. +func NewServiceBindingGetParamsWithContext(ctx context.Context) *ServiceBindingGetParams { + return &ServiceBindingGetParams{ + Context: ctx, + } +} + +// NewServiceBindingGetParamsWithHTTPClient creates a new ServiceBindingGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewServiceBindingGetParamsWithHTTPClient(client *http.Client) *ServiceBindingGetParams { + return &ServiceBindingGetParams{ + HTTPClient: client, + } +} + +/* ServiceBindingGetParams contains all the parameters to send to the API endpoint + for the service binding get operation. + + Typically these are written to a http.Request. +*/ +type ServiceBindingGetParams struct { + + /* XBrokerAPIOriginatingIdentity. + + identity of the user that initiated the request from the Platform + */ + XBrokerAPIOriginatingIdentity *string + + /* XBrokerAPIVersion. + + version number of the Service Broker API that the Platform will use + */ + XBrokerAPIVersion string + + /* BindingID. + + binding id of binding to create + */ + BindingID string + + /* InstanceID. + + instance id of instance to provision + */ + InstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the service binding get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBindingGetParams) WithDefaults() *ServiceBindingGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the service binding get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBindingGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the service binding get params +func (o *ServiceBindingGetParams) WithTimeout(timeout time.Duration) *ServiceBindingGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the service binding get params +func (o *ServiceBindingGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the service binding get params +func (o *ServiceBindingGetParams) WithContext(ctx context.Context) *ServiceBindingGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the service binding get params +func (o *ServiceBindingGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the service binding get params +func (o *ServiceBindingGetParams) WithHTTPClient(client *http.Client) *ServiceBindingGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the service binding get params +func (o *ServiceBindingGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXBrokerAPIOriginatingIdentity adds the xBrokerAPIOriginatingIdentity to the service binding get params +func (o *ServiceBindingGetParams) WithXBrokerAPIOriginatingIdentity(xBrokerAPIOriginatingIdentity *string) *ServiceBindingGetParams { + o.SetXBrokerAPIOriginatingIdentity(xBrokerAPIOriginatingIdentity) + return o +} + +// SetXBrokerAPIOriginatingIdentity adds the xBrokerApiOriginatingIdentity to the service binding get params +func (o *ServiceBindingGetParams) SetXBrokerAPIOriginatingIdentity(xBrokerAPIOriginatingIdentity *string) { + o.XBrokerAPIOriginatingIdentity = xBrokerAPIOriginatingIdentity +} + +// WithXBrokerAPIVersion adds the xBrokerAPIVersion to the service binding get params +func (o *ServiceBindingGetParams) WithXBrokerAPIVersion(xBrokerAPIVersion string) *ServiceBindingGetParams { + o.SetXBrokerAPIVersion(xBrokerAPIVersion) + return o +} + +// SetXBrokerAPIVersion adds the xBrokerApiVersion to the service binding get params +func (o *ServiceBindingGetParams) SetXBrokerAPIVersion(xBrokerAPIVersion string) { + o.XBrokerAPIVersion = xBrokerAPIVersion +} + +// WithBindingID adds the bindingID to the service binding get params +func (o *ServiceBindingGetParams) WithBindingID(bindingID string) *ServiceBindingGetParams { + o.SetBindingID(bindingID) + return o +} + +// SetBindingID adds the bindingId to the service binding get params +func (o *ServiceBindingGetParams) SetBindingID(bindingID string) { + o.BindingID = bindingID +} + +// WithInstanceID adds the instanceID to the service binding get params +func (o *ServiceBindingGetParams) WithInstanceID(instanceID string) *ServiceBindingGetParams { + o.SetInstanceID(instanceID) + return o +} + +// SetInstanceID adds the instanceId to the service binding get params +func (o *ServiceBindingGetParams) SetInstanceID(instanceID string) { + o.InstanceID = instanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *ServiceBindingGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XBrokerAPIOriginatingIdentity != nil { + + // header param X-Broker-API-Originating-Identity + if err := r.SetHeaderParam("X-Broker-API-Originating-Identity", *o.XBrokerAPIOriginatingIdentity); err != nil { + return err + } + } + + // header param X-Broker-API-Version + if err := r.SetHeaderParam("X-Broker-API-Version", o.XBrokerAPIVersion); err != nil { + return err + } + + // path param binding_id + if err := r.SetPathParam("binding_id", o.BindingID); err != nil { + return err + } + + // path param instance_id + if err := r.SetPathParam("instance_id", o.InstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_bindings/service_binding_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_bindings/service_binding_get_responses.go new file mode 100644 index 00000000000..ba1f5d08def --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_bindings/service_binding_get_responses.go @@ -0,0 +1,105 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package service_bindings + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// ServiceBindingGetReader is a Reader for the ServiceBindingGet structure. +type ServiceBindingGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ServiceBindingGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewServiceBindingGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 404: + result := NewServiceBindingGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewServiceBindingGetOK creates a ServiceBindingGetOK with default headers values +func NewServiceBindingGetOK() *ServiceBindingGetOK { + return &ServiceBindingGetOK{} +} + +/* ServiceBindingGetOK describes a response with status code 200, with default header values. + +OK +*/ +type ServiceBindingGetOK struct { + Payload *models.ServiceBindingResource +} + +func (o *ServiceBindingGetOK) Error() string { + return fmt.Sprintf("[GET /v2/service_instances/{instance_id}/service_bindings/{binding_id}][%d] serviceBindingGetOK %+v", 200, o.Payload) +} +func (o *ServiceBindingGetOK) GetPayload() *models.ServiceBindingResource { + return o.Payload +} + +func (o *ServiceBindingGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ServiceBindingResource) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBindingGetNotFound creates a ServiceBindingGetNotFound with default headers values +func NewServiceBindingGetNotFound() *ServiceBindingGetNotFound { + return &ServiceBindingGetNotFound{} +} + +/* ServiceBindingGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type ServiceBindingGetNotFound struct { + Payload *models.Error +} + +func (o *ServiceBindingGetNotFound) Error() string { + return fmt.Sprintf("[GET /v2/service_instances/{instance_id}/service_bindings/{binding_id}][%d] serviceBindingGetNotFound %+v", 404, o.Payload) +} +func (o *ServiceBindingGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBindingGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_bindings/service_binding_last_operation_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_bindings/service_binding_last_operation_get_parameters.go new file mode 100644 index 00000000000..20ee289c29f --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_bindings/service_binding_last_operation_get_parameters.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package service_bindings + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewServiceBindingLastOperationGetParams creates a new ServiceBindingLastOperationGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewServiceBindingLastOperationGetParams() *ServiceBindingLastOperationGetParams { + return &ServiceBindingLastOperationGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewServiceBindingLastOperationGetParamsWithTimeout creates a new ServiceBindingLastOperationGetParams object +// with the ability to set a timeout on a request. +func NewServiceBindingLastOperationGetParamsWithTimeout(timeout time.Duration) *ServiceBindingLastOperationGetParams { + return &ServiceBindingLastOperationGetParams{ + timeout: timeout, + } +} + +// NewServiceBindingLastOperationGetParamsWithContext creates a new ServiceBindingLastOperationGetParams object +// with the ability to set a context for a request. +func NewServiceBindingLastOperationGetParamsWithContext(ctx context.Context) *ServiceBindingLastOperationGetParams { + return &ServiceBindingLastOperationGetParams{ + Context: ctx, + } +} + +// NewServiceBindingLastOperationGetParamsWithHTTPClient creates a new ServiceBindingLastOperationGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewServiceBindingLastOperationGetParamsWithHTTPClient(client *http.Client) *ServiceBindingLastOperationGetParams { + return &ServiceBindingLastOperationGetParams{ + HTTPClient: client, + } +} + +/* ServiceBindingLastOperationGetParams contains all the parameters to send to the API endpoint + for the service binding last operation get operation. + + Typically these are written to a http.Request. +*/ +type ServiceBindingLastOperationGetParams struct { + + /* XBrokerAPIVersion. + + version number of the Service Broker API that the Platform will use + */ + XBrokerAPIVersion string + + /* BindingID. + + binding id of binding to create + */ + BindingID string + + /* InstanceID. + + instance id of instance to provision + */ + InstanceID string + + /* Operation. + + a provided identifier for the operation + */ + Operation *string + + /* PlanID. + + id of the plan associated with the instance + */ + PlanID *string + + /* ServiceID. + + id of the service associated with the instance + */ + ServiceID *string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the service binding last operation get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBindingLastOperationGetParams) WithDefaults() *ServiceBindingLastOperationGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the service binding last operation get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBindingLastOperationGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the service binding last operation get params +func (o *ServiceBindingLastOperationGetParams) WithTimeout(timeout time.Duration) *ServiceBindingLastOperationGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the service binding last operation get params +func (o *ServiceBindingLastOperationGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the service binding last operation get params +func (o *ServiceBindingLastOperationGetParams) WithContext(ctx context.Context) *ServiceBindingLastOperationGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the service binding last operation get params +func (o *ServiceBindingLastOperationGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the service binding last operation get params +func (o *ServiceBindingLastOperationGetParams) WithHTTPClient(client *http.Client) *ServiceBindingLastOperationGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the service binding last operation get params +func (o *ServiceBindingLastOperationGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXBrokerAPIVersion adds the xBrokerAPIVersion to the service binding last operation get params +func (o *ServiceBindingLastOperationGetParams) WithXBrokerAPIVersion(xBrokerAPIVersion string) *ServiceBindingLastOperationGetParams { + o.SetXBrokerAPIVersion(xBrokerAPIVersion) + return o +} + +// SetXBrokerAPIVersion adds the xBrokerApiVersion to the service binding last operation get params +func (o *ServiceBindingLastOperationGetParams) SetXBrokerAPIVersion(xBrokerAPIVersion string) { + o.XBrokerAPIVersion = xBrokerAPIVersion +} + +// WithBindingID adds the bindingID to the service binding last operation get params +func (o *ServiceBindingLastOperationGetParams) WithBindingID(bindingID string) *ServiceBindingLastOperationGetParams { + o.SetBindingID(bindingID) + return o +} + +// SetBindingID adds the bindingId to the service binding last operation get params +func (o *ServiceBindingLastOperationGetParams) SetBindingID(bindingID string) { + o.BindingID = bindingID +} + +// WithInstanceID adds the instanceID to the service binding last operation get params +func (o *ServiceBindingLastOperationGetParams) WithInstanceID(instanceID string) *ServiceBindingLastOperationGetParams { + o.SetInstanceID(instanceID) + return o +} + +// SetInstanceID adds the instanceId to the service binding last operation get params +func (o *ServiceBindingLastOperationGetParams) SetInstanceID(instanceID string) { + o.InstanceID = instanceID +} + +// WithOperation adds the operation to the service binding last operation get params +func (o *ServiceBindingLastOperationGetParams) WithOperation(operation *string) *ServiceBindingLastOperationGetParams { + o.SetOperation(operation) + return o +} + +// SetOperation adds the operation to the service binding last operation get params +func (o *ServiceBindingLastOperationGetParams) SetOperation(operation *string) { + o.Operation = operation +} + +// WithPlanID adds the planID to the service binding last operation get params +func (o *ServiceBindingLastOperationGetParams) WithPlanID(planID *string) *ServiceBindingLastOperationGetParams { + o.SetPlanID(planID) + return o +} + +// SetPlanID adds the planId to the service binding last operation get params +func (o *ServiceBindingLastOperationGetParams) SetPlanID(planID *string) { + o.PlanID = planID +} + +// WithServiceID adds the serviceID to the service binding last operation get params +func (o *ServiceBindingLastOperationGetParams) WithServiceID(serviceID *string) *ServiceBindingLastOperationGetParams { + o.SetServiceID(serviceID) + return o +} + +// SetServiceID adds the serviceId to the service binding last operation get params +func (o *ServiceBindingLastOperationGetParams) SetServiceID(serviceID *string) { + o.ServiceID = serviceID +} + +// WriteToRequest writes these params to a swagger request +func (o *ServiceBindingLastOperationGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // header param X-Broker-API-Version + if err := r.SetHeaderParam("X-Broker-API-Version", o.XBrokerAPIVersion); err != nil { + return err + } + + // path param binding_id + if err := r.SetPathParam("binding_id", o.BindingID); err != nil { + return err + } + + // path param instance_id + if err := r.SetPathParam("instance_id", o.InstanceID); err != nil { + return err + } + + if o.Operation != nil { + + // query param operation + var qrOperation string + + if o.Operation != nil { + qrOperation = *o.Operation + } + qOperation := qrOperation + if qOperation != "" { + + if err := r.SetQueryParam("operation", qOperation); err != nil { + return err + } + } + } + + if o.PlanID != nil { + + // query param plan_id + var qrPlanID string + + if o.PlanID != nil { + qrPlanID = *o.PlanID + } + qPlanID := qrPlanID + if qPlanID != "" { + + if err := r.SetQueryParam("plan_id", qPlanID); err != nil { + return err + } + } + } + + if o.ServiceID != nil { + + // query param service_id + var qrServiceID string + + if o.ServiceID != nil { + qrServiceID = *o.ServiceID + } + qServiceID := qrServiceID + if qServiceID != "" { + + if err := r.SetQueryParam("service_id", qServiceID); err != nil { + return err + } + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_bindings/service_binding_last_operation_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_bindings/service_binding_last_operation_get_responses.go new file mode 100644 index 00000000000..46779aad171 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_bindings/service_binding_last_operation_get_responses.go @@ -0,0 +1,143 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package service_bindings + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// ServiceBindingLastOperationGetReader is a Reader for the ServiceBindingLastOperationGet structure. +type ServiceBindingLastOperationGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ServiceBindingLastOperationGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewServiceBindingLastOperationGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewServiceBindingLastOperationGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 410: + result := NewServiceBindingLastOperationGetGone() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewServiceBindingLastOperationGetOK creates a ServiceBindingLastOperationGetOK with default headers values +func NewServiceBindingLastOperationGetOK() *ServiceBindingLastOperationGetOK { + return &ServiceBindingLastOperationGetOK{} +} + +/* ServiceBindingLastOperationGetOK describes a response with status code 200, with default header values. + +OK +*/ +type ServiceBindingLastOperationGetOK struct { + Payload *models.LastOperationResource +} + +func (o *ServiceBindingLastOperationGetOK) Error() string { + return fmt.Sprintf("[GET /v2/service_instances/{instance_id}/service_bindings/{binding_id}/last_operation][%d] serviceBindingLastOperationGetOK %+v", 200, o.Payload) +} +func (o *ServiceBindingLastOperationGetOK) GetPayload() *models.LastOperationResource { + return o.Payload +} + +func (o *ServiceBindingLastOperationGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.LastOperationResource) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBindingLastOperationGetBadRequest creates a ServiceBindingLastOperationGetBadRequest with default headers values +func NewServiceBindingLastOperationGetBadRequest() *ServiceBindingLastOperationGetBadRequest { + return &ServiceBindingLastOperationGetBadRequest{} +} + +/* ServiceBindingLastOperationGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type ServiceBindingLastOperationGetBadRequest struct { + Payload *models.Error +} + +func (o *ServiceBindingLastOperationGetBadRequest) Error() string { + return fmt.Sprintf("[GET /v2/service_instances/{instance_id}/service_bindings/{binding_id}/last_operation][%d] serviceBindingLastOperationGetBadRequest %+v", 400, o.Payload) +} +func (o *ServiceBindingLastOperationGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBindingLastOperationGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBindingLastOperationGetGone creates a ServiceBindingLastOperationGetGone with default headers values +func NewServiceBindingLastOperationGetGone() *ServiceBindingLastOperationGetGone { + return &ServiceBindingLastOperationGetGone{} +} + +/* ServiceBindingLastOperationGetGone describes a response with status code 410, with default header values. + +Gone +*/ +type ServiceBindingLastOperationGetGone struct { + Payload *models.Error +} + +func (o *ServiceBindingLastOperationGetGone) Error() string { + return fmt.Sprintf("[GET /v2/service_instances/{instance_id}/service_bindings/{binding_id}/last_operation][%d] serviceBindingLastOperationGetGone %+v", 410, o.Payload) +} +func (o *ServiceBindingLastOperationGetGone) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBindingLastOperationGetGone) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_bindings/service_binding_unbinding_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_bindings/service_binding_unbinding_parameters.go new file mode 100644 index 00000000000..fb2dc202daf --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_bindings/service_binding_unbinding_parameters.go @@ -0,0 +1,307 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package service_bindings + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewServiceBindingUnbindingParams creates a new ServiceBindingUnbindingParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewServiceBindingUnbindingParams() *ServiceBindingUnbindingParams { + return &ServiceBindingUnbindingParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewServiceBindingUnbindingParamsWithTimeout creates a new ServiceBindingUnbindingParams object +// with the ability to set a timeout on a request. +func NewServiceBindingUnbindingParamsWithTimeout(timeout time.Duration) *ServiceBindingUnbindingParams { + return &ServiceBindingUnbindingParams{ + timeout: timeout, + } +} + +// NewServiceBindingUnbindingParamsWithContext creates a new ServiceBindingUnbindingParams object +// with the ability to set a context for a request. +func NewServiceBindingUnbindingParamsWithContext(ctx context.Context) *ServiceBindingUnbindingParams { + return &ServiceBindingUnbindingParams{ + Context: ctx, + } +} + +// NewServiceBindingUnbindingParamsWithHTTPClient creates a new ServiceBindingUnbindingParams object +// with the ability to set a custom HTTPClient for a request. +func NewServiceBindingUnbindingParamsWithHTTPClient(client *http.Client) *ServiceBindingUnbindingParams { + return &ServiceBindingUnbindingParams{ + HTTPClient: client, + } +} + +/* ServiceBindingUnbindingParams contains all the parameters to send to the API endpoint + for the service binding unbinding operation. + + Typically these are written to a http.Request. +*/ +type ServiceBindingUnbindingParams struct { + + /* XBrokerAPIOriginatingIdentity. + + identity of the user that initiated the request from the Platform + */ + XBrokerAPIOriginatingIdentity *string + + /* XBrokerAPIVersion. + + version number of the Service Broker API that the Platform will use + */ + XBrokerAPIVersion string + + /* AcceptsIncomplete. + + asynchronous operations supported + */ + AcceptsIncomplete *bool + + /* BindingID. + + binding id of binding to create + */ + BindingID string + + /* InstanceID. + + instance id of instance to provision + */ + InstanceID string + + /* PlanID. + + id of the plan associated with the instance being deleted + */ + PlanID string + + /* ServiceID. + + id of the service associated with the instance being deleted + */ + ServiceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the service binding unbinding params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBindingUnbindingParams) WithDefaults() *ServiceBindingUnbindingParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the service binding unbinding params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBindingUnbindingParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the service binding unbinding params +func (o *ServiceBindingUnbindingParams) WithTimeout(timeout time.Duration) *ServiceBindingUnbindingParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the service binding unbinding params +func (o *ServiceBindingUnbindingParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the service binding unbinding params +func (o *ServiceBindingUnbindingParams) WithContext(ctx context.Context) *ServiceBindingUnbindingParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the service binding unbinding params +func (o *ServiceBindingUnbindingParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the service binding unbinding params +func (o *ServiceBindingUnbindingParams) WithHTTPClient(client *http.Client) *ServiceBindingUnbindingParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the service binding unbinding params +func (o *ServiceBindingUnbindingParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXBrokerAPIOriginatingIdentity adds the xBrokerAPIOriginatingIdentity to the service binding unbinding params +func (o *ServiceBindingUnbindingParams) WithXBrokerAPIOriginatingIdentity(xBrokerAPIOriginatingIdentity *string) *ServiceBindingUnbindingParams { + o.SetXBrokerAPIOriginatingIdentity(xBrokerAPIOriginatingIdentity) + return o +} + +// SetXBrokerAPIOriginatingIdentity adds the xBrokerApiOriginatingIdentity to the service binding unbinding params +func (o *ServiceBindingUnbindingParams) SetXBrokerAPIOriginatingIdentity(xBrokerAPIOriginatingIdentity *string) { + o.XBrokerAPIOriginatingIdentity = xBrokerAPIOriginatingIdentity +} + +// WithXBrokerAPIVersion adds the xBrokerAPIVersion to the service binding unbinding params +func (o *ServiceBindingUnbindingParams) WithXBrokerAPIVersion(xBrokerAPIVersion string) *ServiceBindingUnbindingParams { + o.SetXBrokerAPIVersion(xBrokerAPIVersion) + return o +} + +// SetXBrokerAPIVersion adds the xBrokerApiVersion to the service binding unbinding params +func (o *ServiceBindingUnbindingParams) SetXBrokerAPIVersion(xBrokerAPIVersion string) { + o.XBrokerAPIVersion = xBrokerAPIVersion +} + +// WithAcceptsIncomplete adds the acceptsIncomplete to the service binding unbinding params +func (o *ServiceBindingUnbindingParams) WithAcceptsIncomplete(acceptsIncomplete *bool) *ServiceBindingUnbindingParams { + o.SetAcceptsIncomplete(acceptsIncomplete) + return o +} + +// SetAcceptsIncomplete adds the acceptsIncomplete to the service binding unbinding params +func (o *ServiceBindingUnbindingParams) SetAcceptsIncomplete(acceptsIncomplete *bool) { + o.AcceptsIncomplete = acceptsIncomplete +} + +// WithBindingID adds the bindingID to the service binding unbinding params +func (o *ServiceBindingUnbindingParams) WithBindingID(bindingID string) *ServiceBindingUnbindingParams { + o.SetBindingID(bindingID) + return o +} + +// SetBindingID adds the bindingId to the service binding unbinding params +func (o *ServiceBindingUnbindingParams) SetBindingID(bindingID string) { + o.BindingID = bindingID +} + +// WithInstanceID adds the instanceID to the service binding unbinding params +func (o *ServiceBindingUnbindingParams) WithInstanceID(instanceID string) *ServiceBindingUnbindingParams { + o.SetInstanceID(instanceID) + return o +} + +// SetInstanceID adds the instanceId to the service binding unbinding params +func (o *ServiceBindingUnbindingParams) SetInstanceID(instanceID string) { + o.InstanceID = instanceID +} + +// WithPlanID adds the planID to the service binding unbinding params +func (o *ServiceBindingUnbindingParams) WithPlanID(planID string) *ServiceBindingUnbindingParams { + o.SetPlanID(planID) + return o +} + +// SetPlanID adds the planId to the service binding unbinding params +func (o *ServiceBindingUnbindingParams) SetPlanID(planID string) { + o.PlanID = planID +} + +// WithServiceID adds the serviceID to the service binding unbinding params +func (o *ServiceBindingUnbindingParams) WithServiceID(serviceID string) *ServiceBindingUnbindingParams { + o.SetServiceID(serviceID) + return o +} + +// SetServiceID adds the serviceId to the service binding unbinding params +func (o *ServiceBindingUnbindingParams) SetServiceID(serviceID string) { + o.ServiceID = serviceID +} + +// WriteToRequest writes these params to a swagger request +func (o *ServiceBindingUnbindingParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XBrokerAPIOriginatingIdentity != nil { + + // header param X-Broker-API-Originating-Identity + if err := r.SetHeaderParam("X-Broker-API-Originating-Identity", *o.XBrokerAPIOriginatingIdentity); err != nil { + return err + } + } + + // header param X-Broker-API-Version + if err := r.SetHeaderParam("X-Broker-API-Version", o.XBrokerAPIVersion); err != nil { + return err + } + + if o.AcceptsIncomplete != nil { + + // query param accepts_incomplete + var qrAcceptsIncomplete bool + + if o.AcceptsIncomplete != nil { + qrAcceptsIncomplete = *o.AcceptsIncomplete + } + qAcceptsIncomplete := swag.FormatBool(qrAcceptsIncomplete) + if qAcceptsIncomplete != "" { + + if err := r.SetQueryParam("accepts_incomplete", qAcceptsIncomplete); err != nil { + return err + } + } + } + + // path param binding_id + if err := r.SetPathParam("binding_id", o.BindingID); err != nil { + return err + } + + // path param instance_id + if err := r.SetPathParam("instance_id", o.InstanceID); err != nil { + return err + } + + // query param plan_id + qrPlanID := o.PlanID + qPlanID := qrPlanID + if qPlanID != "" { + + if err := r.SetQueryParam("plan_id", qPlanID); err != nil { + return err + } + } + + // query param service_id + qrServiceID := o.ServiceID + qServiceID := qrServiceID + if qServiceID != "" { + + if err := r.SetQueryParam("service_id", qServiceID); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_bindings/service_binding_unbinding_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_bindings/service_binding_unbinding_responses.go new file mode 100644 index 00000000000..2416449a3f8 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_bindings/service_binding_unbinding_responses.go @@ -0,0 +1,179 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package service_bindings + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// ServiceBindingUnbindingReader is a Reader for the ServiceBindingUnbinding structure. +type ServiceBindingUnbindingReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ServiceBindingUnbindingReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewServiceBindingUnbindingOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 202: + result := NewServiceBindingUnbindingAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewServiceBindingUnbindingBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 410: + result := NewServiceBindingUnbindingGone() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewServiceBindingUnbindingOK creates a ServiceBindingUnbindingOK with default headers values +func NewServiceBindingUnbindingOK() *ServiceBindingUnbindingOK { + return &ServiceBindingUnbindingOK{} +} + +/* ServiceBindingUnbindingOK describes a response with status code 200, with default header values. + +OK +*/ +type ServiceBindingUnbindingOK struct { + Payload models.Object +} + +func (o *ServiceBindingUnbindingOK) Error() string { + return fmt.Sprintf("[DELETE /v2/service_instances/{instance_id}/service_bindings/{binding_id}][%d] serviceBindingUnbindingOK %+v", 200, o.Payload) +} +func (o *ServiceBindingUnbindingOK) GetPayload() models.Object { + return o.Payload +} + +func (o *ServiceBindingUnbindingOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBindingUnbindingAccepted creates a ServiceBindingUnbindingAccepted with default headers values +func NewServiceBindingUnbindingAccepted() *ServiceBindingUnbindingAccepted { + return &ServiceBindingUnbindingAccepted{} +} + +/* ServiceBindingUnbindingAccepted describes a response with status code 202, with default header values. + +Accepted +*/ +type ServiceBindingUnbindingAccepted struct { + Payload *models.AsyncOperation +} + +func (o *ServiceBindingUnbindingAccepted) Error() string { + return fmt.Sprintf("[DELETE /v2/service_instances/{instance_id}/service_bindings/{binding_id}][%d] serviceBindingUnbindingAccepted %+v", 202, o.Payload) +} +func (o *ServiceBindingUnbindingAccepted) GetPayload() *models.AsyncOperation { + return o.Payload +} + +func (o *ServiceBindingUnbindingAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AsyncOperation) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBindingUnbindingBadRequest creates a ServiceBindingUnbindingBadRequest with default headers values +func NewServiceBindingUnbindingBadRequest() *ServiceBindingUnbindingBadRequest { + return &ServiceBindingUnbindingBadRequest{} +} + +/* ServiceBindingUnbindingBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type ServiceBindingUnbindingBadRequest struct { + Payload *models.Error +} + +func (o *ServiceBindingUnbindingBadRequest) Error() string { + return fmt.Sprintf("[DELETE /v2/service_instances/{instance_id}/service_bindings/{binding_id}][%d] serviceBindingUnbindingBadRequest %+v", 400, o.Payload) +} +func (o *ServiceBindingUnbindingBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBindingUnbindingBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBindingUnbindingGone creates a ServiceBindingUnbindingGone with default headers values +func NewServiceBindingUnbindingGone() *ServiceBindingUnbindingGone { + return &ServiceBindingUnbindingGone{} +} + +/* ServiceBindingUnbindingGone describes a response with status code 410, with default header values. + +Gone +*/ +type ServiceBindingUnbindingGone struct { + Payload *models.Error +} + +func (o *ServiceBindingUnbindingGone) Error() string { + return fmt.Sprintf("[DELETE /v2/service_instances/{instance_id}/service_bindings/{binding_id}][%d] serviceBindingUnbindingGone %+v", 410, o.Payload) +} +func (o *ServiceBindingUnbindingGone) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBindingUnbindingGone) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_bindings/service_bindings_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_bindings/service_bindings_client.go new file mode 100644 index 00000000000..554b058d834 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_bindings/service_bindings_client.go @@ -0,0 +1,207 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package service_bindings + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new service bindings API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for service bindings API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + ServiceBindingBinding(params *ServiceBindingBindingParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceBindingBindingOK, *ServiceBindingBindingCreated, *ServiceBindingBindingAccepted, error) + + ServiceBindingGet(params *ServiceBindingGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceBindingGetOK, error) + + ServiceBindingLastOperationGet(params *ServiceBindingLastOperationGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceBindingLastOperationGetOK, error) + + ServiceBindingUnbinding(params *ServiceBindingUnbindingParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceBindingUnbindingOK, *ServiceBindingUnbindingAccepted, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + ServiceBindingBinding generations of a service binding +*/ +func (a *Client) ServiceBindingBinding(params *ServiceBindingBindingParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceBindingBindingOK, *ServiceBindingBindingCreated, *ServiceBindingBindingAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewServiceBindingBindingParams() + } + op := &runtime.ClientOperation{ + ID: "serviceBinding.binding", + Method: "PUT", + PathPattern: "/v2/service_instances/{instance_id}/service_bindings/{binding_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ServiceBindingBindingReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, nil, nil, err + } + switch value := result.(type) { + case *ServiceBindingBindingOK: + return value, nil, nil, nil + case *ServiceBindingBindingCreated: + return nil, value, nil, nil + case *ServiceBindingBindingAccepted: + return nil, nil, value, nil + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for service_bindings: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + ServiceBindingGet gets a service binding +*/ +func (a *Client) ServiceBindingGet(params *ServiceBindingGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceBindingGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewServiceBindingGetParams() + } + op := &runtime.ClientOperation{ + ID: "serviceBinding.get", + Method: "GET", + PathPattern: "/v2/service_instances/{instance_id}/service_bindings/{binding_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ServiceBindingGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ServiceBindingGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for serviceBinding.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + ServiceBindingLastOperationGet lasts requested operation state for service binding +*/ +func (a *Client) ServiceBindingLastOperationGet(params *ServiceBindingLastOperationGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceBindingLastOperationGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewServiceBindingLastOperationGetParams() + } + op := &runtime.ClientOperation{ + ID: "serviceBinding.lastOperation.get", + Method: "GET", + PathPattern: "/v2/service_instances/{instance_id}/service_bindings/{binding_id}/last_operation", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ServiceBindingLastOperationGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ServiceBindingLastOperationGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for serviceBinding.lastOperation.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + ServiceBindingUnbinding deprovisions of a service binding +*/ +func (a *Client) ServiceBindingUnbinding(params *ServiceBindingUnbindingParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceBindingUnbindingOK, *ServiceBindingUnbindingAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewServiceBindingUnbindingParams() + } + op := &runtime.ClientOperation{ + ID: "serviceBinding.unbinding", + Method: "DELETE", + PathPattern: "/v2/service_instances/{instance_id}/service_bindings/{binding_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ServiceBindingUnbindingReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, nil, err + } + switch value := result.(type) { + case *ServiceBindingUnbindingOK: + return value, nil, nil + case *ServiceBindingUnbindingAccepted: + return nil, value, nil + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for service_bindings: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instance_deprovision_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instance_deprovision_parameters.go new file mode 100644 index 00000000000..a9f8033ef78 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instance_deprovision_parameters.go @@ -0,0 +1,285 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package service_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewServiceInstanceDeprovisionParams creates a new ServiceInstanceDeprovisionParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewServiceInstanceDeprovisionParams() *ServiceInstanceDeprovisionParams { + return &ServiceInstanceDeprovisionParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewServiceInstanceDeprovisionParamsWithTimeout creates a new ServiceInstanceDeprovisionParams object +// with the ability to set a timeout on a request. +func NewServiceInstanceDeprovisionParamsWithTimeout(timeout time.Duration) *ServiceInstanceDeprovisionParams { + return &ServiceInstanceDeprovisionParams{ + timeout: timeout, + } +} + +// NewServiceInstanceDeprovisionParamsWithContext creates a new ServiceInstanceDeprovisionParams object +// with the ability to set a context for a request. +func NewServiceInstanceDeprovisionParamsWithContext(ctx context.Context) *ServiceInstanceDeprovisionParams { + return &ServiceInstanceDeprovisionParams{ + Context: ctx, + } +} + +// NewServiceInstanceDeprovisionParamsWithHTTPClient creates a new ServiceInstanceDeprovisionParams object +// with the ability to set a custom HTTPClient for a request. +func NewServiceInstanceDeprovisionParamsWithHTTPClient(client *http.Client) *ServiceInstanceDeprovisionParams { + return &ServiceInstanceDeprovisionParams{ + HTTPClient: client, + } +} + +/* ServiceInstanceDeprovisionParams contains all the parameters to send to the API endpoint + for the service instance deprovision operation. + + Typically these are written to a http.Request. +*/ +type ServiceInstanceDeprovisionParams struct { + + /* XBrokerAPIOriginatingIdentity. + + identity of the user that initiated the request from the Platform + */ + XBrokerAPIOriginatingIdentity *string + + /* XBrokerAPIVersion. + + version number of the Service Broker API that the Platform will use + */ + XBrokerAPIVersion string + + /* AcceptsIncomplete. + + asynchronous operations supported + */ + AcceptsIncomplete *bool + + /* InstanceID. + + instance id of instance to provision + */ + InstanceID string + + /* PlanID. + + id of the plan associated with the instance being deleted + */ + PlanID string + + /* ServiceID. + + id of the service associated with the instance being deleted + */ + ServiceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the service instance deprovision params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceInstanceDeprovisionParams) WithDefaults() *ServiceInstanceDeprovisionParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the service instance deprovision params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceInstanceDeprovisionParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the service instance deprovision params +func (o *ServiceInstanceDeprovisionParams) WithTimeout(timeout time.Duration) *ServiceInstanceDeprovisionParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the service instance deprovision params +func (o *ServiceInstanceDeprovisionParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the service instance deprovision params +func (o *ServiceInstanceDeprovisionParams) WithContext(ctx context.Context) *ServiceInstanceDeprovisionParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the service instance deprovision params +func (o *ServiceInstanceDeprovisionParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the service instance deprovision params +func (o *ServiceInstanceDeprovisionParams) WithHTTPClient(client *http.Client) *ServiceInstanceDeprovisionParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the service instance deprovision params +func (o *ServiceInstanceDeprovisionParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXBrokerAPIOriginatingIdentity adds the xBrokerAPIOriginatingIdentity to the service instance deprovision params +func (o *ServiceInstanceDeprovisionParams) WithXBrokerAPIOriginatingIdentity(xBrokerAPIOriginatingIdentity *string) *ServiceInstanceDeprovisionParams { + o.SetXBrokerAPIOriginatingIdentity(xBrokerAPIOriginatingIdentity) + return o +} + +// SetXBrokerAPIOriginatingIdentity adds the xBrokerApiOriginatingIdentity to the service instance deprovision params +func (o *ServiceInstanceDeprovisionParams) SetXBrokerAPIOriginatingIdentity(xBrokerAPIOriginatingIdentity *string) { + o.XBrokerAPIOriginatingIdentity = xBrokerAPIOriginatingIdentity +} + +// WithXBrokerAPIVersion adds the xBrokerAPIVersion to the service instance deprovision params +func (o *ServiceInstanceDeprovisionParams) WithXBrokerAPIVersion(xBrokerAPIVersion string) *ServiceInstanceDeprovisionParams { + o.SetXBrokerAPIVersion(xBrokerAPIVersion) + return o +} + +// SetXBrokerAPIVersion adds the xBrokerApiVersion to the service instance deprovision params +func (o *ServiceInstanceDeprovisionParams) SetXBrokerAPIVersion(xBrokerAPIVersion string) { + o.XBrokerAPIVersion = xBrokerAPIVersion +} + +// WithAcceptsIncomplete adds the acceptsIncomplete to the service instance deprovision params +func (o *ServiceInstanceDeprovisionParams) WithAcceptsIncomplete(acceptsIncomplete *bool) *ServiceInstanceDeprovisionParams { + o.SetAcceptsIncomplete(acceptsIncomplete) + return o +} + +// SetAcceptsIncomplete adds the acceptsIncomplete to the service instance deprovision params +func (o *ServiceInstanceDeprovisionParams) SetAcceptsIncomplete(acceptsIncomplete *bool) { + o.AcceptsIncomplete = acceptsIncomplete +} + +// WithInstanceID adds the instanceID to the service instance deprovision params +func (o *ServiceInstanceDeprovisionParams) WithInstanceID(instanceID string) *ServiceInstanceDeprovisionParams { + o.SetInstanceID(instanceID) + return o +} + +// SetInstanceID adds the instanceId to the service instance deprovision params +func (o *ServiceInstanceDeprovisionParams) SetInstanceID(instanceID string) { + o.InstanceID = instanceID +} + +// WithPlanID adds the planID to the service instance deprovision params +func (o *ServiceInstanceDeprovisionParams) WithPlanID(planID string) *ServiceInstanceDeprovisionParams { + o.SetPlanID(planID) + return o +} + +// SetPlanID adds the planId to the service instance deprovision params +func (o *ServiceInstanceDeprovisionParams) SetPlanID(planID string) { + o.PlanID = planID +} + +// WithServiceID adds the serviceID to the service instance deprovision params +func (o *ServiceInstanceDeprovisionParams) WithServiceID(serviceID string) *ServiceInstanceDeprovisionParams { + o.SetServiceID(serviceID) + return o +} + +// SetServiceID adds the serviceId to the service instance deprovision params +func (o *ServiceInstanceDeprovisionParams) SetServiceID(serviceID string) { + o.ServiceID = serviceID +} + +// WriteToRequest writes these params to a swagger request +func (o *ServiceInstanceDeprovisionParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XBrokerAPIOriginatingIdentity != nil { + + // header param X-Broker-API-Originating-Identity + if err := r.SetHeaderParam("X-Broker-API-Originating-Identity", *o.XBrokerAPIOriginatingIdentity); err != nil { + return err + } + } + + // header param X-Broker-API-Version + if err := r.SetHeaderParam("X-Broker-API-Version", o.XBrokerAPIVersion); err != nil { + return err + } + + if o.AcceptsIncomplete != nil { + + // query param accepts_incomplete + var qrAcceptsIncomplete bool + + if o.AcceptsIncomplete != nil { + qrAcceptsIncomplete = *o.AcceptsIncomplete + } + qAcceptsIncomplete := swag.FormatBool(qrAcceptsIncomplete) + if qAcceptsIncomplete != "" { + + if err := r.SetQueryParam("accepts_incomplete", qAcceptsIncomplete); err != nil { + return err + } + } + } + + // path param instance_id + if err := r.SetPathParam("instance_id", o.InstanceID); err != nil { + return err + } + + // query param plan_id + qrPlanID := o.PlanID + qPlanID := qrPlanID + if qPlanID != "" { + + if err := r.SetQueryParam("plan_id", qPlanID); err != nil { + return err + } + } + + // query param service_id + qrServiceID := o.ServiceID + qServiceID := qrServiceID + if qServiceID != "" { + + if err := r.SetQueryParam("service_id", qServiceID); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instance_deprovision_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instance_deprovision_responses.go new file mode 100644 index 00000000000..1ae4ec9dac2 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instance_deprovision_responses.go @@ -0,0 +1,217 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package service_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// ServiceInstanceDeprovisionReader is a Reader for the ServiceInstanceDeprovision structure. +type ServiceInstanceDeprovisionReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ServiceInstanceDeprovisionReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewServiceInstanceDeprovisionOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 202: + result := NewServiceInstanceDeprovisionAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewServiceInstanceDeprovisionBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 410: + result := NewServiceInstanceDeprovisionGone() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewServiceInstanceDeprovisionUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewServiceInstanceDeprovisionOK creates a ServiceInstanceDeprovisionOK with default headers values +func NewServiceInstanceDeprovisionOK() *ServiceInstanceDeprovisionOK { + return &ServiceInstanceDeprovisionOK{} +} + +/* ServiceInstanceDeprovisionOK describes a response with status code 200, with default header values. + +OK +*/ +type ServiceInstanceDeprovisionOK struct { + Payload models.Object +} + +func (o *ServiceInstanceDeprovisionOK) Error() string { + return fmt.Sprintf("[DELETE /v2/service_instances/{instance_id}][%d] serviceInstanceDeprovisionOK %+v", 200, o.Payload) +} +func (o *ServiceInstanceDeprovisionOK) GetPayload() models.Object { + return o.Payload +} + +func (o *ServiceInstanceDeprovisionOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceInstanceDeprovisionAccepted creates a ServiceInstanceDeprovisionAccepted with default headers values +func NewServiceInstanceDeprovisionAccepted() *ServiceInstanceDeprovisionAccepted { + return &ServiceInstanceDeprovisionAccepted{} +} + +/* ServiceInstanceDeprovisionAccepted describes a response with status code 202, with default header values. + +Accepted +*/ +type ServiceInstanceDeprovisionAccepted struct { + Payload *models.AsyncOperation +} + +func (o *ServiceInstanceDeprovisionAccepted) Error() string { + return fmt.Sprintf("[DELETE /v2/service_instances/{instance_id}][%d] serviceInstanceDeprovisionAccepted %+v", 202, o.Payload) +} +func (o *ServiceInstanceDeprovisionAccepted) GetPayload() *models.AsyncOperation { + return o.Payload +} + +func (o *ServiceInstanceDeprovisionAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AsyncOperation) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceInstanceDeprovisionBadRequest creates a ServiceInstanceDeprovisionBadRequest with default headers values +func NewServiceInstanceDeprovisionBadRequest() *ServiceInstanceDeprovisionBadRequest { + return &ServiceInstanceDeprovisionBadRequest{} +} + +/* ServiceInstanceDeprovisionBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type ServiceInstanceDeprovisionBadRequest struct { + Payload *models.Error +} + +func (o *ServiceInstanceDeprovisionBadRequest) Error() string { + return fmt.Sprintf("[DELETE /v2/service_instances/{instance_id}][%d] serviceInstanceDeprovisionBadRequest %+v", 400, o.Payload) +} +func (o *ServiceInstanceDeprovisionBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceInstanceDeprovisionBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceInstanceDeprovisionGone creates a ServiceInstanceDeprovisionGone with default headers values +func NewServiceInstanceDeprovisionGone() *ServiceInstanceDeprovisionGone { + return &ServiceInstanceDeprovisionGone{} +} + +/* ServiceInstanceDeprovisionGone describes a response with status code 410, with default header values. + +Gone +*/ +type ServiceInstanceDeprovisionGone struct { + Payload *models.Error +} + +func (o *ServiceInstanceDeprovisionGone) Error() string { + return fmt.Sprintf("[DELETE /v2/service_instances/{instance_id}][%d] serviceInstanceDeprovisionGone %+v", 410, o.Payload) +} +func (o *ServiceInstanceDeprovisionGone) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceInstanceDeprovisionGone) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceInstanceDeprovisionUnprocessableEntity creates a ServiceInstanceDeprovisionUnprocessableEntity with default headers values +func NewServiceInstanceDeprovisionUnprocessableEntity() *ServiceInstanceDeprovisionUnprocessableEntity { + return &ServiceInstanceDeprovisionUnprocessableEntity{} +} + +/* ServiceInstanceDeprovisionUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type ServiceInstanceDeprovisionUnprocessableEntity struct { + Payload *models.Error +} + +func (o *ServiceInstanceDeprovisionUnprocessableEntity) Error() string { + return fmt.Sprintf("[DELETE /v2/service_instances/{instance_id}][%d] serviceInstanceDeprovisionUnprocessableEntity %+v", 422, o.Payload) +} +func (o *ServiceInstanceDeprovisionUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceInstanceDeprovisionUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instance_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instance_get_parameters.go new file mode 100644 index 00000000000..c3594fe6d0b --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instance_get_parameters.go @@ -0,0 +1,196 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package service_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewServiceInstanceGetParams creates a new ServiceInstanceGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewServiceInstanceGetParams() *ServiceInstanceGetParams { + return &ServiceInstanceGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewServiceInstanceGetParamsWithTimeout creates a new ServiceInstanceGetParams object +// with the ability to set a timeout on a request. +func NewServiceInstanceGetParamsWithTimeout(timeout time.Duration) *ServiceInstanceGetParams { + return &ServiceInstanceGetParams{ + timeout: timeout, + } +} + +// NewServiceInstanceGetParamsWithContext creates a new ServiceInstanceGetParams object +// with the ability to set a context for a request. +func NewServiceInstanceGetParamsWithContext(ctx context.Context) *ServiceInstanceGetParams { + return &ServiceInstanceGetParams{ + Context: ctx, + } +} + +// NewServiceInstanceGetParamsWithHTTPClient creates a new ServiceInstanceGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewServiceInstanceGetParamsWithHTTPClient(client *http.Client) *ServiceInstanceGetParams { + return &ServiceInstanceGetParams{ + HTTPClient: client, + } +} + +/* ServiceInstanceGetParams contains all the parameters to send to the API endpoint + for the service instance get operation. + + Typically these are written to a http.Request. +*/ +type ServiceInstanceGetParams struct { + + /* XBrokerAPIOriginatingIdentity. + + identity of the user that initiated the request from the Platform + */ + XBrokerAPIOriginatingIdentity *string + + /* XBrokerAPIVersion. + + version number of the Service Broker API that the Platform will use + */ + XBrokerAPIVersion string + + /* InstanceID. + + instance id of instance to provision + */ + InstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the service instance get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceInstanceGetParams) WithDefaults() *ServiceInstanceGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the service instance get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceInstanceGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the service instance get params +func (o *ServiceInstanceGetParams) WithTimeout(timeout time.Duration) *ServiceInstanceGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the service instance get params +func (o *ServiceInstanceGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the service instance get params +func (o *ServiceInstanceGetParams) WithContext(ctx context.Context) *ServiceInstanceGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the service instance get params +func (o *ServiceInstanceGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the service instance get params +func (o *ServiceInstanceGetParams) WithHTTPClient(client *http.Client) *ServiceInstanceGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the service instance get params +func (o *ServiceInstanceGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXBrokerAPIOriginatingIdentity adds the xBrokerAPIOriginatingIdentity to the service instance get params +func (o *ServiceInstanceGetParams) WithXBrokerAPIOriginatingIdentity(xBrokerAPIOriginatingIdentity *string) *ServiceInstanceGetParams { + o.SetXBrokerAPIOriginatingIdentity(xBrokerAPIOriginatingIdentity) + return o +} + +// SetXBrokerAPIOriginatingIdentity adds the xBrokerApiOriginatingIdentity to the service instance get params +func (o *ServiceInstanceGetParams) SetXBrokerAPIOriginatingIdentity(xBrokerAPIOriginatingIdentity *string) { + o.XBrokerAPIOriginatingIdentity = xBrokerAPIOriginatingIdentity +} + +// WithXBrokerAPIVersion adds the xBrokerAPIVersion to the service instance get params +func (o *ServiceInstanceGetParams) WithXBrokerAPIVersion(xBrokerAPIVersion string) *ServiceInstanceGetParams { + o.SetXBrokerAPIVersion(xBrokerAPIVersion) + return o +} + +// SetXBrokerAPIVersion adds the xBrokerApiVersion to the service instance get params +func (o *ServiceInstanceGetParams) SetXBrokerAPIVersion(xBrokerAPIVersion string) { + o.XBrokerAPIVersion = xBrokerAPIVersion +} + +// WithInstanceID adds the instanceID to the service instance get params +func (o *ServiceInstanceGetParams) WithInstanceID(instanceID string) *ServiceInstanceGetParams { + o.SetInstanceID(instanceID) + return o +} + +// SetInstanceID adds the instanceId to the service instance get params +func (o *ServiceInstanceGetParams) SetInstanceID(instanceID string) { + o.InstanceID = instanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *ServiceInstanceGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XBrokerAPIOriginatingIdentity != nil { + + // header param X-Broker-API-Originating-Identity + if err := r.SetHeaderParam("X-Broker-API-Originating-Identity", *o.XBrokerAPIOriginatingIdentity); err != nil { + return err + } + } + + // header param X-Broker-API-Version + if err := r.SetHeaderParam("X-Broker-API-Version", o.XBrokerAPIVersion); err != nil { + return err + } + + // path param instance_id + if err := r.SetPathParam("instance_id", o.InstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instance_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instance_get_responses.go new file mode 100644 index 00000000000..94ecfeca2c9 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instance_get_responses.go @@ -0,0 +1,105 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package service_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// ServiceInstanceGetReader is a Reader for the ServiceInstanceGet structure. +type ServiceInstanceGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ServiceInstanceGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewServiceInstanceGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 404: + result := NewServiceInstanceGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewServiceInstanceGetOK creates a ServiceInstanceGetOK with default headers values +func NewServiceInstanceGetOK() *ServiceInstanceGetOK { + return &ServiceInstanceGetOK{} +} + +/* ServiceInstanceGetOK describes a response with status code 200, with default header values. + +OK +*/ +type ServiceInstanceGetOK struct { + Payload *models.ServiceInstanceResource +} + +func (o *ServiceInstanceGetOK) Error() string { + return fmt.Sprintf("[GET /v2/service_instances/{instance_id}][%d] serviceInstanceGetOK %+v", 200, o.Payload) +} +func (o *ServiceInstanceGetOK) GetPayload() *models.ServiceInstanceResource { + return o.Payload +} + +func (o *ServiceInstanceGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ServiceInstanceResource) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceInstanceGetNotFound creates a ServiceInstanceGetNotFound with default headers values +func NewServiceInstanceGetNotFound() *ServiceInstanceGetNotFound { + return &ServiceInstanceGetNotFound{} +} + +/* ServiceInstanceGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type ServiceInstanceGetNotFound struct { + Payload *models.Error +} + +func (o *ServiceInstanceGetNotFound) Error() string { + return fmt.Sprintf("[GET /v2/service_instances/{instance_id}][%d] serviceInstanceGetNotFound %+v", 404, o.Payload) +} +func (o *ServiceInstanceGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceInstanceGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instance_last_operation_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instance_last_operation_get_parameters.go new file mode 100644 index 00000000000..8c735cce5ef --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instance_last_operation_get_parameters.go @@ -0,0 +1,273 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package service_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewServiceInstanceLastOperationGetParams creates a new ServiceInstanceLastOperationGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewServiceInstanceLastOperationGetParams() *ServiceInstanceLastOperationGetParams { + return &ServiceInstanceLastOperationGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewServiceInstanceLastOperationGetParamsWithTimeout creates a new ServiceInstanceLastOperationGetParams object +// with the ability to set a timeout on a request. +func NewServiceInstanceLastOperationGetParamsWithTimeout(timeout time.Duration) *ServiceInstanceLastOperationGetParams { + return &ServiceInstanceLastOperationGetParams{ + timeout: timeout, + } +} + +// NewServiceInstanceLastOperationGetParamsWithContext creates a new ServiceInstanceLastOperationGetParams object +// with the ability to set a context for a request. +func NewServiceInstanceLastOperationGetParamsWithContext(ctx context.Context) *ServiceInstanceLastOperationGetParams { + return &ServiceInstanceLastOperationGetParams{ + Context: ctx, + } +} + +// NewServiceInstanceLastOperationGetParamsWithHTTPClient creates a new ServiceInstanceLastOperationGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewServiceInstanceLastOperationGetParamsWithHTTPClient(client *http.Client) *ServiceInstanceLastOperationGetParams { + return &ServiceInstanceLastOperationGetParams{ + HTTPClient: client, + } +} + +/* ServiceInstanceLastOperationGetParams contains all the parameters to send to the API endpoint + for the service instance last operation get operation. + + Typically these are written to a http.Request. +*/ +type ServiceInstanceLastOperationGetParams struct { + + /* XBrokerAPIVersion. + + version number of the Service Broker API that the Platform will use + */ + XBrokerAPIVersion string + + /* InstanceID. + + instance id of instance to provision + */ + InstanceID string + + /* Operation. + + a provided identifier for the operation + */ + Operation *string + + /* PlanID. + + id of the plan associated with the instance + */ + PlanID *string + + /* ServiceID. + + id of the service associated with the instance + */ + ServiceID *string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the service instance last operation get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceInstanceLastOperationGetParams) WithDefaults() *ServiceInstanceLastOperationGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the service instance last operation get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceInstanceLastOperationGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the service instance last operation get params +func (o *ServiceInstanceLastOperationGetParams) WithTimeout(timeout time.Duration) *ServiceInstanceLastOperationGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the service instance last operation get params +func (o *ServiceInstanceLastOperationGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the service instance last operation get params +func (o *ServiceInstanceLastOperationGetParams) WithContext(ctx context.Context) *ServiceInstanceLastOperationGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the service instance last operation get params +func (o *ServiceInstanceLastOperationGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the service instance last operation get params +func (o *ServiceInstanceLastOperationGetParams) WithHTTPClient(client *http.Client) *ServiceInstanceLastOperationGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the service instance last operation get params +func (o *ServiceInstanceLastOperationGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXBrokerAPIVersion adds the xBrokerAPIVersion to the service instance last operation get params +func (o *ServiceInstanceLastOperationGetParams) WithXBrokerAPIVersion(xBrokerAPIVersion string) *ServiceInstanceLastOperationGetParams { + o.SetXBrokerAPIVersion(xBrokerAPIVersion) + return o +} + +// SetXBrokerAPIVersion adds the xBrokerApiVersion to the service instance last operation get params +func (o *ServiceInstanceLastOperationGetParams) SetXBrokerAPIVersion(xBrokerAPIVersion string) { + o.XBrokerAPIVersion = xBrokerAPIVersion +} + +// WithInstanceID adds the instanceID to the service instance last operation get params +func (o *ServiceInstanceLastOperationGetParams) WithInstanceID(instanceID string) *ServiceInstanceLastOperationGetParams { + o.SetInstanceID(instanceID) + return o +} + +// SetInstanceID adds the instanceId to the service instance last operation get params +func (o *ServiceInstanceLastOperationGetParams) SetInstanceID(instanceID string) { + o.InstanceID = instanceID +} + +// WithOperation adds the operation to the service instance last operation get params +func (o *ServiceInstanceLastOperationGetParams) WithOperation(operation *string) *ServiceInstanceLastOperationGetParams { + o.SetOperation(operation) + return o +} + +// SetOperation adds the operation to the service instance last operation get params +func (o *ServiceInstanceLastOperationGetParams) SetOperation(operation *string) { + o.Operation = operation +} + +// WithPlanID adds the planID to the service instance last operation get params +func (o *ServiceInstanceLastOperationGetParams) WithPlanID(planID *string) *ServiceInstanceLastOperationGetParams { + o.SetPlanID(planID) + return o +} + +// SetPlanID adds the planId to the service instance last operation get params +func (o *ServiceInstanceLastOperationGetParams) SetPlanID(planID *string) { + o.PlanID = planID +} + +// WithServiceID adds the serviceID to the service instance last operation get params +func (o *ServiceInstanceLastOperationGetParams) WithServiceID(serviceID *string) *ServiceInstanceLastOperationGetParams { + o.SetServiceID(serviceID) + return o +} + +// SetServiceID adds the serviceId to the service instance last operation get params +func (o *ServiceInstanceLastOperationGetParams) SetServiceID(serviceID *string) { + o.ServiceID = serviceID +} + +// WriteToRequest writes these params to a swagger request +func (o *ServiceInstanceLastOperationGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // header param X-Broker-API-Version + if err := r.SetHeaderParam("X-Broker-API-Version", o.XBrokerAPIVersion); err != nil { + return err + } + + // path param instance_id + if err := r.SetPathParam("instance_id", o.InstanceID); err != nil { + return err + } + + if o.Operation != nil { + + // query param operation + var qrOperation string + + if o.Operation != nil { + qrOperation = *o.Operation + } + qOperation := qrOperation + if qOperation != "" { + + if err := r.SetQueryParam("operation", qOperation); err != nil { + return err + } + } + } + + if o.PlanID != nil { + + // query param plan_id + var qrPlanID string + + if o.PlanID != nil { + qrPlanID = *o.PlanID + } + qPlanID := qrPlanID + if qPlanID != "" { + + if err := r.SetQueryParam("plan_id", qPlanID); err != nil { + return err + } + } + } + + if o.ServiceID != nil { + + // query param service_id + var qrServiceID string + + if o.ServiceID != nil { + qrServiceID = *o.ServiceID + } + qServiceID := qrServiceID + if qServiceID != "" { + + if err := r.SetQueryParam("service_id", qServiceID); err != nil { + return err + } + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instance_last_operation_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instance_last_operation_get_responses.go new file mode 100644 index 00000000000..10e635bfcd5 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instance_last_operation_get_responses.go @@ -0,0 +1,143 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package service_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// ServiceInstanceLastOperationGetReader is a Reader for the ServiceInstanceLastOperationGet structure. +type ServiceInstanceLastOperationGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ServiceInstanceLastOperationGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewServiceInstanceLastOperationGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewServiceInstanceLastOperationGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 410: + result := NewServiceInstanceLastOperationGetGone() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewServiceInstanceLastOperationGetOK creates a ServiceInstanceLastOperationGetOK with default headers values +func NewServiceInstanceLastOperationGetOK() *ServiceInstanceLastOperationGetOK { + return &ServiceInstanceLastOperationGetOK{} +} + +/* ServiceInstanceLastOperationGetOK describes a response with status code 200, with default header values. + +OK +*/ +type ServiceInstanceLastOperationGetOK struct { + Payload *models.LastOperationResource +} + +func (o *ServiceInstanceLastOperationGetOK) Error() string { + return fmt.Sprintf("[GET /v2/service_instances/{instance_id}/last_operation][%d] serviceInstanceLastOperationGetOK %+v", 200, o.Payload) +} +func (o *ServiceInstanceLastOperationGetOK) GetPayload() *models.LastOperationResource { + return o.Payload +} + +func (o *ServiceInstanceLastOperationGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.LastOperationResource) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceInstanceLastOperationGetBadRequest creates a ServiceInstanceLastOperationGetBadRequest with default headers values +func NewServiceInstanceLastOperationGetBadRequest() *ServiceInstanceLastOperationGetBadRequest { + return &ServiceInstanceLastOperationGetBadRequest{} +} + +/* ServiceInstanceLastOperationGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type ServiceInstanceLastOperationGetBadRequest struct { + Payload *models.Error +} + +func (o *ServiceInstanceLastOperationGetBadRequest) Error() string { + return fmt.Sprintf("[GET /v2/service_instances/{instance_id}/last_operation][%d] serviceInstanceLastOperationGetBadRequest %+v", 400, o.Payload) +} +func (o *ServiceInstanceLastOperationGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceInstanceLastOperationGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceInstanceLastOperationGetGone creates a ServiceInstanceLastOperationGetGone with default headers values +func NewServiceInstanceLastOperationGetGone() *ServiceInstanceLastOperationGetGone { + return &ServiceInstanceLastOperationGetGone{} +} + +/* ServiceInstanceLastOperationGetGone describes a response with status code 410, with default header values. + +Gone +*/ +type ServiceInstanceLastOperationGetGone struct { + Payload *models.Error +} + +func (o *ServiceInstanceLastOperationGetGone) Error() string { + return fmt.Sprintf("[GET /v2/service_instances/{instance_id}/last_operation][%d] serviceInstanceLastOperationGetGone %+v", 410, o.Payload) +} +func (o *ServiceInstanceLastOperationGetGone) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceInstanceLastOperationGetGone) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instance_provision_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instance_provision_parameters.go new file mode 100644 index 00000000000..89458c04fcd --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instance_provision_parameters.go @@ -0,0 +1,255 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package service_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewServiceInstanceProvisionParams creates a new ServiceInstanceProvisionParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewServiceInstanceProvisionParams() *ServiceInstanceProvisionParams { + return &ServiceInstanceProvisionParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewServiceInstanceProvisionParamsWithTimeout creates a new ServiceInstanceProvisionParams object +// with the ability to set a timeout on a request. +func NewServiceInstanceProvisionParamsWithTimeout(timeout time.Duration) *ServiceInstanceProvisionParams { + return &ServiceInstanceProvisionParams{ + timeout: timeout, + } +} + +// NewServiceInstanceProvisionParamsWithContext creates a new ServiceInstanceProvisionParams object +// with the ability to set a context for a request. +func NewServiceInstanceProvisionParamsWithContext(ctx context.Context) *ServiceInstanceProvisionParams { + return &ServiceInstanceProvisionParams{ + Context: ctx, + } +} + +// NewServiceInstanceProvisionParamsWithHTTPClient creates a new ServiceInstanceProvisionParams object +// with the ability to set a custom HTTPClient for a request. +func NewServiceInstanceProvisionParamsWithHTTPClient(client *http.Client) *ServiceInstanceProvisionParams { + return &ServiceInstanceProvisionParams{ + HTTPClient: client, + } +} + +/* ServiceInstanceProvisionParams contains all the parameters to send to the API endpoint + for the service instance provision operation. + + Typically these are written to a http.Request. +*/ +type ServiceInstanceProvisionParams struct { + + /* XBrokerAPIOriginatingIdentity. + + identity of the user that initiated the request from the Platform + */ + XBrokerAPIOriginatingIdentity *string + + /* XBrokerAPIVersion. + + version number of the Service Broker API that the Platform will use + */ + XBrokerAPIVersion string + + /* AcceptsIncomplete. + + asynchronous operations supported + */ + AcceptsIncomplete *bool + + /* Body. + + parameters for the requested service instance provision + */ + Body *models.ServiceInstanceProvisionRequest + + /* InstanceID. + + instance id of instance to provision + */ + InstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the service instance provision params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceInstanceProvisionParams) WithDefaults() *ServiceInstanceProvisionParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the service instance provision params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceInstanceProvisionParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the service instance provision params +func (o *ServiceInstanceProvisionParams) WithTimeout(timeout time.Duration) *ServiceInstanceProvisionParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the service instance provision params +func (o *ServiceInstanceProvisionParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the service instance provision params +func (o *ServiceInstanceProvisionParams) WithContext(ctx context.Context) *ServiceInstanceProvisionParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the service instance provision params +func (o *ServiceInstanceProvisionParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the service instance provision params +func (o *ServiceInstanceProvisionParams) WithHTTPClient(client *http.Client) *ServiceInstanceProvisionParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the service instance provision params +func (o *ServiceInstanceProvisionParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXBrokerAPIOriginatingIdentity adds the xBrokerAPIOriginatingIdentity to the service instance provision params +func (o *ServiceInstanceProvisionParams) WithXBrokerAPIOriginatingIdentity(xBrokerAPIOriginatingIdentity *string) *ServiceInstanceProvisionParams { + o.SetXBrokerAPIOriginatingIdentity(xBrokerAPIOriginatingIdentity) + return o +} + +// SetXBrokerAPIOriginatingIdentity adds the xBrokerApiOriginatingIdentity to the service instance provision params +func (o *ServiceInstanceProvisionParams) SetXBrokerAPIOriginatingIdentity(xBrokerAPIOriginatingIdentity *string) { + o.XBrokerAPIOriginatingIdentity = xBrokerAPIOriginatingIdentity +} + +// WithXBrokerAPIVersion adds the xBrokerAPIVersion to the service instance provision params +func (o *ServiceInstanceProvisionParams) WithXBrokerAPIVersion(xBrokerAPIVersion string) *ServiceInstanceProvisionParams { + o.SetXBrokerAPIVersion(xBrokerAPIVersion) + return o +} + +// SetXBrokerAPIVersion adds the xBrokerApiVersion to the service instance provision params +func (o *ServiceInstanceProvisionParams) SetXBrokerAPIVersion(xBrokerAPIVersion string) { + o.XBrokerAPIVersion = xBrokerAPIVersion +} + +// WithAcceptsIncomplete adds the acceptsIncomplete to the service instance provision params +func (o *ServiceInstanceProvisionParams) WithAcceptsIncomplete(acceptsIncomplete *bool) *ServiceInstanceProvisionParams { + o.SetAcceptsIncomplete(acceptsIncomplete) + return o +} + +// SetAcceptsIncomplete adds the acceptsIncomplete to the service instance provision params +func (o *ServiceInstanceProvisionParams) SetAcceptsIncomplete(acceptsIncomplete *bool) { + o.AcceptsIncomplete = acceptsIncomplete +} + +// WithBody adds the body to the service instance provision params +func (o *ServiceInstanceProvisionParams) WithBody(body *models.ServiceInstanceProvisionRequest) *ServiceInstanceProvisionParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the service instance provision params +func (o *ServiceInstanceProvisionParams) SetBody(body *models.ServiceInstanceProvisionRequest) { + o.Body = body +} + +// WithInstanceID adds the instanceID to the service instance provision params +func (o *ServiceInstanceProvisionParams) WithInstanceID(instanceID string) *ServiceInstanceProvisionParams { + o.SetInstanceID(instanceID) + return o +} + +// SetInstanceID adds the instanceId to the service instance provision params +func (o *ServiceInstanceProvisionParams) SetInstanceID(instanceID string) { + o.InstanceID = instanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *ServiceInstanceProvisionParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XBrokerAPIOriginatingIdentity != nil { + + // header param X-Broker-API-Originating-Identity + if err := r.SetHeaderParam("X-Broker-API-Originating-Identity", *o.XBrokerAPIOriginatingIdentity); err != nil { + return err + } + } + + // header param X-Broker-API-Version + if err := r.SetHeaderParam("X-Broker-API-Version", o.XBrokerAPIVersion); err != nil { + return err + } + + if o.AcceptsIncomplete != nil { + + // query param accepts_incomplete + var qrAcceptsIncomplete bool + + if o.AcceptsIncomplete != nil { + qrAcceptsIncomplete = *o.AcceptsIncomplete + } + qAcceptsIncomplete := swag.FormatBool(qrAcceptsIncomplete) + if qAcceptsIncomplete != "" { + + if err := r.SetQueryParam("accepts_incomplete", qAcceptsIncomplete); err != nil { + return err + } + } + } + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param instance_id + if err := r.SetPathParam("instance_id", o.InstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instance_provision_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instance_provision_responses.go new file mode 100644 index 00000000000..1b457b956aa --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instance_provision_responses.go @@ -0,0 +1,257 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package service_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// ServiceInstanceProvisionReader is a Reader for the ServiceInstanceProvision structure. +type ServiceInstanceProvisionReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ServiceInstanceProvisionReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewServiceInstanceProvisionOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 201: + result := NewServiceInstanceProvisionCreated() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 202: + result := NewServiceInstanceProvisionAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewServiceInstanceProvisionBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewServiceInstanceProvisionConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewServiceInstanceProvisionUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewServiceInstanceProvisionOK creates a ServiceInstanceProvisionOK with default headers values +func NewServiceInstanceProvisionOK() *ServiceInstanceProvisionOK { + return &ServiceInstanceProvisionOK{} +} + +/* ServiceInstanceProvisionOK describes a response with status code 200, with default header values. + +OK +*/ +type ServiceInstanceProvisionOK struct { + Payload *models.ServiceInstanceProvision +} + +func (o *ServiceInstanceProvisionOK) Error() string { + return fmt.Sprintf("[PUT /v2/service_instances/{instance_id}][%d] serviceInstanceProvisionOK %+v", 200, o.Payload) +} +func (o *ServiceInstanceProvisionOK) GetPayload() *models.ServiceInstanceProvision { + return o.Payload +} + +func (o *ServiceInstanceProvisionOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ServiceInstanceProvision) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceInstanceProvisionCreated creates a ServiceInstanceProvisionCreated with default headers values +func NewServiceInstanceProvisionCreated() *ServiceInstanceProvisionCreated { + return &ServiceInstanceProvisionCreated{} +} + +/* ServiceInstanceProvisionCreated describes a response with status code 201, with default header values. + +Created +*/ +type ServiceInstanceProvisionCreated struct { + Payload *models.ServiceInstanceProvision +} + +func (o *ServiceInstanceProvisionCreated) Error() string { + return fmt.Sprintf("[PUT /v2/service_instances/{instance_id}][%d] serviceInstanceProvisionCreated %+v", 201, o.Payload) +} +func (o *ServiceInstanceProvisionCreated) GetPayload() *models.ServiceInstanceProvision { + return o.Payload +} + +func (o *ServiceInstanceProvisionCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ServiceInstanceProvision) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceInstanceProvisionAccepted creates a ServiceInstanceProvisionAccepted with default headers values +func NewServiceInstanceProvisionAccepted() *ServiceInstanceProvisionAccepted { + return &ServiceInstanceProvisionAccepted{} +} + +/* ServiceInstanceProvisionAccepted describes a response with status code 202, with default header values. + +Accepted +*/ +type ServiceInstanceProvisionAccepted struct { + Payload *models.ServiceInstanceAsyncOperation +} + +func (o *ServiceInstanceProvisionAccepted) Error() string { + return fmt.Sprintf("[PUT /v2/service_instances/{instance_id}][%d] serviceInstanceProvisionAccepted %+v", 202, o.Payload) +} +func (o *ServiceInstanceProvisionAccepted) GetPayload() *models.ServiceInstanceAsyncOperation { + return o.Payload +} + +func (o *ServiceInstanceProvisionAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ServiceInstanceAsyncOperation) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceInstanceProvisionBadRequest creates a ServiceInstanceProvisionBadRequest with default headers values +func NewServiceInstanceProvisionBadRequest() *ServiceInstanceProvisionBadRequest { + return &ServiceInstanceProvisionBadRequest{} +} + +/* ServiceInstanceProvisionBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type ServiceInstanceProvisionBadRequest struct { + Payload *models.Error +} + +func (o *ServiceInstanceProvisionBadRequest) Error() string { + return fmt.Sprintf("[PUT /v2/service_instances/{instance_id}][%d] serviceInstanceProvisionBadRequest %+v", 400, o.Payload) +} +func (o *ServiceInstanceProvisionBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceInstanceProvisionBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceInstanceProvisionConflict creates a ServiceInstanceProvisionConflict with default headers values +func NewServiceInstanceProvisionConflict() *ServiceInstanceProvisionConflict { + return &ServiceInstanceProvisionConflict{} +} + +/* ServiceInstanceProvisionConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type ServiceInstanceProvisionConflict struct { + Payload *models.Error +} + +func (o *ServiceInstanceProvisionConflict) Error() string { + return fmt.Sprintf("[PUT /v2/service_instances/{instance_id}][%d] serviceInstanceProvisionConflict %+v", 409, o.Payload) +} +func (o *ServiceInstanceProvisionConflict) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceInstanceProvisionConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceInstanceProvisionUnprocessableEntity creates a ServiceInstanceProvisionUnprocessableEntity with default headers values +func NewServiceInstanceProvisionUnprocessableEntity() *ServiceInstanceProvisionUnprocessableEntity { + return &ServiceInstanceProvisionUnprocessableEntity{} +} + +/* ServiceInstanceProvisionUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable Entity +*/ +type ServiceInstanceProvisionUnprocessableEntity struct { + Payload *models.Error +} + +func (o *ServiceInstanceProvisionUnprocessableEntity) Error() string { + return fmt.Sprintf("[PUT /v2/service_instances/{instance_id}][%d] serviceInstanceProvisionUnprocessableEntity %+v", 422, o.Payload) +} +func (o *ServiceInstanceProvisionUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceInstanceProvisionUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instance_update_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instance_update_parameters.go new file mode 100644 index 00000000000..0e27172b211 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instance_update_parameters.go @@ -0,0 +1,255 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package service_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// NewServiceInstanceUpdateParams creates a new ServiceInstanceUpdateParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewServiceInstanceUpdateParams() *ServiceInstanceUpdateParams { + return &ServiceInstanceUpdateParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewServiceInstanceUpdateParamsWithTimeout creates a new ServiceInstanceUpdateParams object +// with the ability to set a timeout on a request. +func NewServiceInstanceUpdateParamsWithTimeout(timeout time.Duration) *ServiceInstanceUpdateParams { + return &ServiceInstanceUpdateParams{ + timeout: timeout, + } +} + +// NewServiceInstanceUpdateParamsWithContext creates a new ServiceInstanceUpdateParams object +// with the ability to set a context for a request. +func NewServiceInstanceUpdateParamsWithContext(ctx context.Context) *ServiceInstanceUpdateParams { + return &ServiceInstanceUpdateParams{ + Context: ctx, + } +} + +// NewServiceInstanceUpdateParamsWithHTTPClient creates a new ServiceInstanceUpdateParams object +// with the ability to set a custom HTTPClient for a request. +func NewServiceInstanceUpdateParamsWithHTTPClient(client *http.Client) *ServiceInstanceUpdateParams { + return &ServiceInstanceUpdateParams{ + HTTPClient: client, + } +} + +/* ServiceInstanceUpdateParams contains all the parameters to send to the API endpoint + for the service instance update operation. + + Typically these are written to a http.Request. +*/ +type ServiceInstanceUpdateParams struct { + + /* XBrokerAPIOriginatingIdentity. + + identity of the user that initiated the request from the Platform + */ + XBrokerAPIOriginatingIdentity *string + + /* XBrokerAPIVersion. + + version number of the Service Broker API that the Platform will use + */ + XBrokerAPIVersion string + + /* AcceptsIncomplete. + + asynchronous operations supported + */ + AcceptsIncomplete *bool + + /* Body. + + parameters for the requested service instance update + */ + Body *models.ServiceInstanceUpdateRequest + + /* InstanceID. + + instance id of instance to provision + */ + InstanceID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the service instance update params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceInstanceUpdateParams) WithDefaults() *ServiceInstanceUpdateParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the service instance update params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceInstanceUpdateParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the service instance update params +func (o *ServiceInstanceUpdateParams) WithTimeout(timeout time.Duration) *ServiceInstanceUpdateParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the service instance update params +func (o *ServiceInstanceUpdateParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the service instance update params +func (o *ServiceInstanceUpdateParams) WithContext(ctx context.Context) *ServiceInstanceUpdateParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the service instance update params +func (o *ServiceInstanceUpdateParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the service instance update params +func (o *ServiceInstanceUpdateParams) WithHTTPClient(client *http.Client) *ServiceInstanceUpdateParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the service instance update params +func (o *ServiceInstanceUpdateParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXBrokerAPIOriginatingIdentity adds the xBrokerAPIOriginatingIdentity to the service instance update params +func (o *ServiceInstanceUpdateParams) WithXBrokerAPIOriginatingIdentity(xBrokerAPIOriginatingIdentity *string) *ServiceInstanceUpdateParams { + o.SetXBrokerAPIOriginatingIdentity(xBrokerAPIOriginatingIdentity) + return o +} + +// SetXBrokerAPIOriginatingIdentity adds the xBrokerApiOriginatingIdentity to the service instance update params +func (o *ServiceInstanceUpdateParams) SetXBrokerAPIOriginatingIdentity(xBrokerAPIOriginatingIdentity *string) { + o.XBrokerAPIOriginatingIdentity = xBrokerAPIOriginatingIdentity +} + +// WithXBrokerAPIVersion adds the xBrokerAPIVersion to the service instance update params +func (o *ServiceInstanceUpdateParams) WithXBrokerAPIVersion(xBrokerAPIVersion string) *ServiceInstanceUpdateParams { + o.SetXBrokerAPIVersion(xBrokerAPIVersion) + return o +} + +// SetXBrokerAPIVersion adds the xBrokerApiVersion to the service instance update params +func (o *ServiceInstanceUpdateParams) SetXBrokerAPIVersion(xBrokerAPIVersion string) { + o.XBrokerAPIVersion = xBrokerAPIVersion +} + +// WithAcceptsIncomplete adds the acceptsIncomplete to the service instance update params +func (o *ServiceInstanceUpdateParams) WithAcceptsIncomplete(acceptsIncomplete *bool) *ServiceInstanceUpdateParams { + o.SetAcceptsIncomplete(acceptsIncomplete) + return o +} + +// SetAcceptsIncomplete adds the acceptsIncomplete to the service instance update params +func (o *ServiceInstanceUpdateParams) SetAcceptsIncomplete(acceptsIncomplete *bool) { + o.AcceptsIncomplete = acceptsIncomplete +} + +// WithBody adds the body to the service instance update params +func (o *ServiceInstanceUpdateParams) WithBody(body *models.ServiceInstanceUpdateRequest) *ServiceInstanceUpdateParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the service instance update params +func (o *ServiceInstanceUpdateParams) SetBody(body *models.ServiceInstanceUpdateRequest) { + o.Body = body +} + +// WithInstanceID adds the instanceID to the service instance update params +func (o *ServiceInstanceUpdateParams) WithInstanceID(instanceID string) *ServiceInstanceUpdateParams { + o.SetInstanceID(instanceID) + return o +} + +// SetInstanceID adds the instanceId to the service instance update params +func (o *ServiceInstanceUpdateParams) SetInstanceID(instanceID string) { + o.InstanceID = instanceID +} + +// WriteToRequest writes these params to a swagger request +func (o *ServiceInstanceUpdateParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XBrokerAPIOriginatingIdentity != nil { + + // header param X-Broker-API-Originating-Identity + if err := r.SetHeaderParam("X-Broker-API-Originating-Identity", *o.XBrokerAPIOriginatingIdentity); err != nil { + return err + } + } + + // header param X-Broker-API-Version + if err := r.SetHeaderParam("X-Broker-API-Version", o.XBrokerAPIVersion); err != nil { + return err + } + + if o.AcceptsIncomplete != nil { + + // query param accepts_incomplete + var qrAcceptsIncomplete bool + + if o.AcceptsIncomplete != nil { + qrAcceptsIncomplete = *o.AcceptsIncomplete + } + qAcceptsIncomplete := swag.FormatBool(qrAcceptsIncomplete) + if qAcceptsIncomplete != "" { + + if err := r.SetQueryParam("accepts_incomplete", qAcceptsIncomplete); err != nil { + return err + } + } + } + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param instance_id + if err := r.SetPathParam("instance_id", o.InstanceID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instance_update_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instance_update_responses.go new file mode 100644 index 00000000000..b86564971bb --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instance_update_responses.go @@ -0,0 +1,179 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package service_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// ServiceInstanceUpdateReader is a Reader for the ServiceInstanceUpdate structure. +type ServiceInstanceUpdateReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ServiceInstanceUpdateReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewServiceInstanceUpdateOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 202: + result := NewServiceInstanceUpdateAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewServiceInstanceUpdateBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewServiceInstanceUpdateUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewServiceInstanceUpdateOK creates a ServiceInstanceUpdateOK with default headers values +func NewServiceInstanceUpdateOK() *ServiceInstanceUpdateOK { + return &ServiceInstanceUpdateOK{} +} + +/* ServiceInstanceUpdateOK describes a response with status code 200, with default header values. + +OK +*/ +type ServiceInstanceUpdateOK struct { + Payload models.Object +} + +func (o *ServiceInstanceUpdateOK) Error() string { + return fmt.Sprintf("[PATCH /v2/service_instances/{instance_id}][%d] serviceInstanceUpdateOK %+v", 200, o.Payload) +} +func (o *ServiceInstanceUpdateOK) GetPayload() models.Object { + return o.Payload +} + +func (o *ServiceInstanceUpdateOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceInstanceUpdateAccepted creates a ServiceInstanceUpdateAccepted with default headers values +func NewServiceInstanceUpdateAccepted() *ServiceInstanceUpdateAccepted { + return &ServiceInstanceUpdateAccepted{} +} + +/* ServiceInstanceUpdateAccepted describes a response with status code 202, with default header values. + +Accepted +*/ +type ServiceInstanceUpdateAccepted struct { + Payload *models.ServiceInstanceAsyncOperation +} + +func (o *ServiceInstanceUpdateAccepted) Error() string { + return fmt.Sprintf("[PATCH /v2/service_instances/{instance_id}][%d] serviceInstanceUpdateAccepted %+v", 202, o.Payload) +} +func (o *ServiceInstanceUpdateAccepted) GetPayload() *models.ServiceInstanceAsyncOperation { + return o.Payload +} + +func (o *ServiceInstanceUpdateAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ServiceInstanceAsyncOperation) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceInstanceUpdateBadRequest creates a ServiceInstanceUpdateBadRequest with default headers values +func NewServiceInstanceUpdateBadRequest() *ServiceInstanceUpdateBadRequest { + return &ServiceInstanceUpdateBadRequest{} +} + +/* ServiceInstanceUpdateBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type ServiceInstanceUpdateBadRequest struct { + Payload *models.Error +} + +func (o *ServiceInstanceUpdateBadRequest) Error() string { + return fmt.Sprintf("[PATCH /v2/service_instances/{instance_id}][%d] serviceInstanceUpdateBadRequest %+v", 400, o.Payload) +} +func (o *ServiceInstanceUpdateBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceInstanceUpdateBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceInstanceUpdateUnprocessableEntity creates a ServiceInstanceUpdateUnprocessableEntity with default headers values +func NewServiceInstanceUpdateUnprocessableEntity() *ServiceInstanceUpdateUnprocessableEntity { + return &ServiceInstanceUpdateUnprocessableEntity{} +} + +/* ServiceInstanceUpdateUnprocessableEntity describes a response with status code 422, with default header values. + +Unprocessable entity +*/ +type ServiceInstanceUpdateUnprocessableEntity struct { + Payload *models.Error +} + +func (o *ServiceInstanceUpdateUnprocessableEntity) Error() string { + return fmt.Sprintf("[PATCH /v2/service_instances/{instance_id}][%d] serviceInstanceUpdateUnprocessableEntity %+v", 422, o.Payload) +} +func (o *ServiceInstanceUpdateUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceInstanceUpdateUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instances_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instances_client.go new file mode 100644 index 00000000000..13b07b16890 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/service_instances/service_instances_client.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package service_instances + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new service instances API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for service instances API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + ServiceInstanceDeprovision(params *ServiceInstanceDeprovisionParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceInstanceDeprovisionOK, *ServiceInstanceDeprovisionAccepted, error) + + ServiceInstanceGet(params *ServiceInstanceGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceInstanceGetOK, error) + + ServiceInstanceLastOperationGet(params *ServiceInstanceLastOperationGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceInstanceLastOperationGetOK, error) + + ServiceInstanceProvision(params *ServiceInstanceProvisionParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceInstanceProvisionOK, *ServiceInstanceProvisionCreated, *ServiceInstanceProvisionAccepted, error) + + ServiceInstanceUpdate(params *ServiceInstanceUpdateParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceInstanceUpdateOK, *ServiceInstanceUpdateAccepted, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + ServiceInstanceDeprovision deprovisions a service instance +*/ +func (a *Client) ServiceInstanceDeprovision(params *ServiceInstanceDeprovisionParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceInstanceDeprovisionOK, *ServiceInstanceDeprovisionAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewServiceInstanceDeprovisionParams() + } + op := &runtime.ClientOperation{ + ID: "serviceInstance.deprovision", + Method: "DELETE", + PathPattern: "/v2/service_instances/{instance_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ServiceInstanceDeprovisionReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, nil, err + } + switch value := result.(type) { + case *ServiceInstanceDeprovisionOK: + return value, nil, nil + case *ServiceInstanceDeprovisionAccepted: + return nil, value, nil + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for service_instances: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + ServiceInstanceGet gets a service instance +*/ +func (a *Client) ServiceInstanceGet(params *ServiceInstanceGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceInstanceGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewServiceInstanceGetParams() + } + op := &runtime.ClientOperation{ + ID: "serviceInstance.get", + Method: "GET", + PathPattern: "/v2/service_instances/{instance_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ServiceInstanceGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ServiceInstanceGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for serviceInstance.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + ServiceInstanceLastOperationGet lasts requested operation state for service instance +*/ +func (a *Client) ServiceInstanceLastOperationGet(params *ServiceInstanceLastOperationGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceInstanceLastOperationGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewServiceInstanceLastOperationGetParams() + } + op := &runtime.ClientOperation{ + ID: "serviceInstance.lastOperation.get", + Method: "GET", + PathPattern: "/v2/service_instances/{instance_id}/last_operation", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ServiceInstanceLastOperationGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ServiceInstanceLastOperationGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for serviceInstance.lastOperation.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + ServiceInstanceProvision provisions a service instance +*/ +func (a *Client) ServiceInstanceProvision(params *ServiceInstanceProvisionParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceInstanceProvisionOK, *ServiceInstanceProvisionCreated, *ServiceInstanceProvisionAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewServiceInstanceProvisionParams() + } + op := &runtime.ClientOperation{ + ID: "serviceInstance.provision", + Method: "PUT", + PathPattern: "/v2/service_instances/{instance_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ServiceInstanceProvisionReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, nil, nil, err + } + switch value := result.(type) { + case *ServiceInstanceProvisionOK: + return value, nil, nil, nil + case *ServiceInstanceProvisionCreated: + return nil, value, nil, nil + case *ServiceInstanceProvisionAccepted: + return nil, nil, value, nil + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for service_instances: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + ServiceInstanceUpdate updates a service instance +*/ +func (a *Client) ServiceInstanceUpdate(params *ServiceInstanceUpdateParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ServiceInstanceUpdateOK, *ServiceInstanceUpdateAccepted, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewServiceInstanceUpdateParams() + } + op := &runtime.ClientOperation{ + ID: "serviceInstance.update", + Method: "PATCH", + PathPattern: "/v2/service_instances/{instance_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ServiceInstanceUpdateReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, nil, err + } + switch value := result.(type) { + case *ServiceInstanceUpdateOK: + return value, nil, nil + case *ServiceInstanceUpdateAccepted: + return nil, value, nil + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for service_instances: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/storage_types/service_broker_storagetypes_get_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/storage_types/service_broker_storagetypes_get_parameters.go new file mode 100644 index 00000000000..932bb7a0e93 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/storage_types/service_broker_storagetypes_get_parameters.go @@ -0,0 +1,126 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package storage_types + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewServiceBrokerStoragetypesGetParams creates a new ServiceBrokerStoragetypesGetParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewServiceBrokerStoragetypesGetParams() *ServiceBrokerStoragetypesGetParams { + return &ServiceBrokerStoragetypesGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewServiceBrokerStoragetypesGetParamsWithTimeout creates a new ServiceBrokerStoragetypesGetParams object +// with the ability to set a timeout on a request. +func NewServiceBrokerStoragetypesGetParamsWithTimeout(timeout time.Duration) *ServiceBrokerStoragetypesGetParams { + return &ServiceBrokerStoragetypesGetParams{ + timeout: timeout, + } +} + +// NewServiceBrokerStoragetypesGetParamsWithContext creates a new ServiceBrokerStoragetypesGetParams object +// with the ability to set a context for a request. +func NewServiceBrokerStoragetypesGetParamsWithContext(ctx context.Context) *ServiceBrokerStoragetypesGetParams { + return &ServiceBrokerStoragetypesGetParams{ + Context: ctx, + } +} + +// NewServiceBrokerStoragetypesGetParamsWithHTTPClient creates a new ServiceBrokerStoragetypesGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewServiceBrokerStoragetypesGetParamsWithHTTPClient(client *http.Client) *ServiceBrokerStoragetypesGetParams { + return &ServiceBrokerStoragetypesGetParams{ + HTTPClient: client, + } +} + +/* ServiceBrokerStoragetypesGetParams contains all the parameters to send to the API endpoint + for the service broker storagetypes get operation. + + Typically these are written to a http.Request. +*/ +type ServiceBrokerStoragetypesGetParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the service broker storagetypes get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerStoragetypesGetParams) WithDefaults() *ServiceBrokerStoragetypesGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the service broker storagetypes get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerStoragetypesGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the service broker storagetypes get params +func (o *ServiceBrokerStoragetypesGetParams) WithTimeout(timeout time.Duration) *ServiceBrokerStoragetypesGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the service broker storagetypes get params +func (o *ServiceBrokerStoragetypesGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the service broker storagetypes get params +func (o *ServiceBrokerStoragetypesGetParams) WithContext(ctx context.Context) *ServiceBrokerStoragetypesGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the service broker storagetypes get params +func (o *ServiceBrokerStoragetypesGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the service broker storagetypes get params +func (o *ServiceBrokerStoragetypesGetParams) WithHTTPClient(client *http.Client) *ServiceBrokerStoragetypesGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the service broker storagetypes get params +func (o *ServiceBrokerStoragetypesGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *ServiceBrokerStoragetypesGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/storage_types/service_broker_storagetypes_get_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/storage_types/service_broker_storagetypes_get_responses.go new file mode 100644 index 00000000000..30d420dd824 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/storage_types/service_broker_storagetypes_get_responses.go @@ -0,0 +1,103 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package storage_types + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// ServiceBrokerStoragetypesGetReader is a Reader for the ServiceBrokerStoragetypesGet structure. +type ServiceBrokerStoragetypesGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ServiceBrokerStoragetypesGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewServiceBrokerStoragetypesGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 500: + result := NewServiceBrokerStoragetypesGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewServiceBrokerStoragetypesGetOK creates a ServiceBrokerStoragetypesGetOK with default headers values +func NewServiceBrokerStoragetypesGetOK() *ServiceBrokerStoragetypesGetOK { + return &ServiceBrokerStoragetypesGetOK{} +} + +/* ServiceBrokerStoragetypesGetOK describes a response with status code 200, with default header values. + +OK +*/ +type ServiceBrokerStoragetypesGetOK struct { + Payload models.StorageTypes +} + +func (o *ServiceBrokerStoragetypesGetOK) Error() string { + return fmt.Sprintf("[GET /broker/v1/storage-types][%d] serviceBrokerStoragetypesGetOK %+v", 200, o.Payload) +} +func (o *ServiceBrokerStoragetypesGetOK) GetPayload() models.StorageTypes { + return o.Payload +} + +func (o *ServiceBrokerStoragetypesGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewServiceBrokerStoragetypesGetInternalServerError creates a ServiceBrokerStoragetypesGetInternalServerError with default headers values +func NewServiceBrokerStoragetypesGetInternalServerError() *ServiceBrokerStoragetypesGetInternalServerError { + return &ServiceBrokerStoragetypesGetInternalServerError{} +} + +/* ServiceBrokerStoragetypesGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type ServiceBrokerStoragetypesGetInternalServerError struct { + Payload *models.Error +} + +func (o *ServiceBrokerStoragetypesGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /broker/v1/storage-types][%d] serviceBrokerStoragetypesGetInternalServerError %+v", 500, o.Payload) +} +func (o *ServiceBrokerStoragetypesGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *ServiceBrokerStoragetypesGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/storage_types/storage_types_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/storage_types/storage_types_client.go new file mode 100644 index 00000000000..5adc4f1ed4f --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/storage_types/storage_types_client.go @@ -0,0 +1,79 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package storage_types + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new storage types API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for storage types API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + ServiceBrokerStoragetypesGet(params *ServiceBrokerStoragetypesGetParams, opts ...ClientOption) (*ServiceBrokerStoragetypesGetOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + ServiceBrokerStoragetypesGet availables storage types in a region +*/ +func (a *Client) ServiceBrokerStoragetypesGet(params *ServiceBrokerStoragetypesGetParams, opts ...ClientOption) (*ServiceBrokerStoragetypesGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewServiceBrokerStoragetypesGetParams() + } + op := &runtime.ClientOperation{ + ID: "serviceBroker.storagetypes.get", + Method: "GET", + PathPattern: "/broker/v1/storage-types", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ServiceBrokerStoragetypesGetReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ServiceBrokerStoragetypesGetOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for serviceBroker.storagetypes.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/swagger_spec/service_broker_swaggerspec_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/swagger_spec/service_broker_swaggerspec_parameters.go new file mode 100644 index 00000000000..12c76c9d807 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/swagger_spec/service_broker_swaggerspec_parameters.go @@ -0,0 +1,126 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package swagger_spec + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewServiceBrokerSwaggerspecParams creates a new ServiceBrokerSwaggerspecParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewServiceBrokerSwaggerspecParams() *ServiceBrokerSwaggerspecParams { + return &ServiceBrokerSwaggerspecParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewServiceBrokerSwaggerspecParamsWithTimeout creates a new ServiceBrokerSwaggerspecParams object +// with the ability to set a timeout on a request. +func NewServiceBrokerSwaggerspecParamsWithTimeout(timeout time.Duration) *ServiceBrokerSwaggerspecParams { + return &ServiceBrokerSwaggerspecParams{ + timeout: timeout, + } +} + +// NewServiceBrokerSwaggerspecParamsWithContext creates a new ServiceBrokerSwaggerspecParams object +// with the ability to set a context for a request. +func NewServiceBrokerSwaggerspecParamsWithContext(ctx context.Context) *ServiceBrokerSwaggerspecParams { + return &ServiceBrokerSwaggerspecParams{ + Context: ctx, + } +} + +// NewServiceBrokerSwaggerspecParamsWithHTTPClient creates a new ServiceBrokerSwaggerspecParams object +// with the ability to set a custom HTTPClient for a request. +func NewServiceBrokerSwaggerspecParamsWithHTTPClient(client *http.Client) *ServiceBrokerSwaggerspecParams { + return &ServiceBrokerSwaggerspecParams{ + HTTPClient: client, + } +} + +/* ServiceBrokerSwaggerspecParams contains all the parameters to send to the API endpoint + for the service broker swaggerspec operation. + + Typically these are written to a http.Request. +*/ +type ServiceBrokerSwaggerspecParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the service broker swaggerspec params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerSwaggerspecParams) WithDefaults() *ServiceBrokerSwaggerspecParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the service broker swaggerspec params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ServiceBrokerSwaggerspecParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the service broker swaggerspec params +func (o *ServiceBrokerSwaggerspecParams) WithTimeout(timeout time.Duration) *ServiceBrokerSwaggerspecParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the service broker swaggerspec params +func (o *ServiceBrokerSwaggerspecParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the service broker swaggerspec params +func (o *ServiceBrokerSwaggerspecParams) WithContext(ctx context.Context) *ServiceBrokerSwaggerspecParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the service broker swaggerspec params +func (o *ServiceBrokerSwaggerspecParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the service broker swaggerspec params +func (o *ServiceBrokerSwaggerspecParams) WithHTTPClient(client *http.Client) *ServiceBrokerSwaggerspecParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the service broker swaggerspec params +func (o *ServiceBrokerSwaggerspecParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *ServiceBrokerSwaggerspecParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/swagger_spec/service_broker_swaggerspec_responses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/swagger_spec/service_broker_swaggerspec_responses.go new file mode 100644 index 00000000000..7f37f6cdbd7 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/swagger_spec/service_broker_swaggerspec_responses.go @@ -0,0 +1,65 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package swagger_spec + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// ServiceBrokerSwaggerspecReader is a Reader for the ServiceBrokerSwaggerspec structure. +type ServiceBrokerSwaggerspecReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ServiceBrokerSwaggerspecReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewServiceBrokerSwaggerspecOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewServiceBrokerSwaggerspecOK creates a ServiceBrokerSwaggerspecOK with default headers values +func NewServiceBrokerSwaggerspecOK() *ServiceBrokerSwaggerspecOK { + return &ServiceBrokerSwaggerspecOK{} +} + +/* ServiceBrokerSwaggerspecOK describes a response with status code 200, with default header values. + +OK +*/ +type ServiceBrokerSwaggerspecOK struct { + Payload models.Object +} + +func (o *ServiceBrokerSwaggerspecOK) Error() string { + return fmt.Sprintf("[GET /v1/swagger.json][%d] serviceBrokerSwaggerspecOK %+v", 200, o.Payload) +} +func (o *ServiceBrokerSwaggerspecOK) GetPayload() models.Object { + return o.Payload +} + +func (o *ServiceBrokerSwaggerspecOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/client/swagger_spec/swagger_spec_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/client/swagger_spec/swagger_spec_client.go new file mode 100644 index 00000000000..d6ba1ec15ab --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/client/swagger_spec/swagger_spec_client.go @@ -0,0 +1,79 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package swagger_spec + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new swagger spec API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for swagger spec API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + ServiceBrokerSwaggerspec(params *ServiceBrokerSwaggerspecParams, opts ...ClientOption) (*ServiceBrokerSwaggerspecOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + ServiceBrokerSwaggerspec gets swagger json spec +*/ +func (a *Client) ServiceBrokerSwaggerspec(params *ServiceBrokerSwaggerspecParams, opts ...ClientOption) (*ServiceBrokerSwaggerspecOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewServiceBrokerSwaggerspecParams() + } + op := &runtime.ClientOperation{ + ID: "serviceBroker.swaggerspec", + Method: "GET", + PathPattern: "/v1/swagger.json", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ServiceBrokerSwaggerspecReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ServiceBrokerSwaggerspecOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for serviceBroker.swaggerspec: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/access_token.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/access_token.go new file mode 100644 index 00000000000..adc43d9e7bb --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/access_token.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// AccessToken access token +// +// swagger:model AccessToken +type AccessToken struct { + + // Access Token + // Required: true + AccessToken *string `json:"accessToken"` +} + +// Validate validates this access token +func (m *AccessToken) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAccessToken(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *AccessToken) validateAccessToken(formats strfmt.Registry) error { + + if err := validate.Required("accessToken", "body", m.AccessToken); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this access token based on context it is used +func (m *AccessToken) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *AccessToken) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *AccessToken) UnmarshalBinary(b []byte) error { + var res AccessToken + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/async_operation.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/async_operation.go new file mode 100644 index 00000000000..4fe9256236e --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/async_operation.go @@ -0,0 +1,50 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// AsyncOperation async operation +// +// swagger:model AsyncOperation +type AsyncOperation struct { + + // operation + Operation string `json:"operation,omitempty"` +} + +// Validate validates this async operation +func (m *AsyncOperation) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this async operation based on context it is used +func (m *AsyncOperation) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *AsyncOperation) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *AsyncOperation) UnmarshalBinary(b []byte) error { + var res AsyncOperation + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/available_stock_images.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/available_stock_images.go new file mode 100644 index 00000000000..ba40ca2d337 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/available_stock_images.go @@ -0,0 +1,69 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// AvailableStockImages A map of an array of stock images for each available storage type +// +// swagger:model AvailableStockImages +type AvailableStockImages map[string]StockImages + +// Validate validates this available stock images +func (m AvailableStockImages) Validate(formats strfmt.Registry) error { + var res []error + + for k := range m { + + if err := validate.Required(k, "body", m[k]); err != nil { + return err + } + + if err := m[k].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(k) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(k) + } + return err + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validate this available stock images based on the context it is used +func (m AvailableStockImages) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + for k := range m { + + if err := m[k].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(k) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(k) + } + return err + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/catalog.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/catalog.go new file mode 100644 index 00000000000..dab6aafe03e --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/catalog.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Catalog catalog +// +// swagger:model Catalog +type Catalog struct { + + // services + Services []*Service `json:"services"` +} + +// Validate validates this catalog +func (m *Catalog) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateServices(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Catalog) validateServices(formats strfmt.Registry) error { + if swag.IsZero(m.Services) { // not required + return nil + } + + for i := 0; i < len(m.Services); i++ { + if swag.IsZero(m.Services[i]) { // not required + continue + } + + if m.Services[i] != nil { + if err := m.Services[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("services" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("services" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this catalog based on the context it is used +func (m *Catalog) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateServices(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Catalog) contextValidateServices(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Services); i++ { + + if m.Services[i] != nil { + if err := m.Services[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("services" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("services" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Catalog) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Catalog) UnmarshalBinary(b []byte) error { + var res Catalog + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/clone_task_reference.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/clone_task_reference.go new file mode 100644 index 00000000000..80464044d8c --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/clone_task_reference.go @@ -0,0 +1,88 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// CloneTaskReference clone task reference +// +// swagger:model CloneTaskReference +type CloneTaskReference struct { + + // ID of a long running PowerVC clone task + // Required: true + CloneTaskID *string `json:"cloneTaskID"` + + // Link to PowerVC clone task resource + // Required: true + Href *string `json:"href"` +} + +// Validate validates this clone task reference +func (m *CloneTaskReference) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCloneTaskID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateHref(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloneTaskReference) validateCloneTaskID(formats strfmt.Registry) error { + + if err := validate.Required("cloneTaskID", "body", m.CloneTaskID); err != nil { + return err + } + + return nil +} + +func (m *CloneTaskReference) validateHref(formats strfmt.Registry) error { + + if err := validate.Required("href", "body", m.Href); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this clone task reference based on context it is used +func (m *CloneTaskReference) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *CloneTaskReference) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CloneTaskReference) UnmarshalBinary(b []byte) error { + var res CloneTaskReference + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/clone_task_status.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/clone_task_status.go new file mode 100644 index 00000000000..c17b76df8f4 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/clone_task_status.go @@ -0,0 +1,196 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// CloneTaskStatus clone task status +// +// swagger:model CloneTaskStatus +type CloneTaskStatus struct { + + // List of cloned volumes created from the clone volumes task + ClonedVolumes []*ClonedVolume `json:"clonedVolumes"` + + // The reason the clone volumes task has failed + FailedReason string `json:"failedReason,omitempty"` + + // Snapshot completion percentage + // Required: true + PercentComplete *int64 `json:"percentComplete"` + + // Status of the clone volumes task + // Required: true + // Enum: [running completed failed unknown] + Status *string `json:"status"` +} + +// Validate validates this clone task status +func (m *CloneTaskStatus) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateClonedVolumes(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePercentComplete(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStatus(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloneTaskStatus) validateClonedVolumes(formats strfmt.Registry) error { + if swag.IsZero(m.ClonedVolumes) { // not required + return nil + } + + for i := 0; i < len(m.ClonedVolumes); i++ { + if swag.IsZero(m.ClonedVolumes[i]) { // not required + continue + } + + if m.ClonedVolumes[i] != nil { + if err := m.ClonedVolumes[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("clonedVolumes" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("clonedVolumes" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *CloneTaskStatus) validatePercentComplete(formats strfmt.Registry) error { + + if err := validate.Required("percentComplete", "body", m.PercentComplete); err != nil { + return err + } + + return nil +} + +var cloneTaskStatusTypeStatusPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["running","completed","failed","unknown"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + cloneTaskStatusTypeStatusPropEnum = append(cloneTaskStatusTypeStatusPropEnum, v) + } +} + +const ( + + // CloneTaskStatusStatusRunning captures enum value "running" + CloneTaskStatusStatusRunning string = "running" + + // CloneTaskStatusStatusCompleted captures enum value "completed" + CloneTaskStatusStatusCompleted string = "completed" + + // CloneTaskStatusStatusFailed captures enum value "failed" + CloneTaskStatusStatusFailed string = "failed" + + // CloneTaskStatusStatusUnknown captures enum value "unknown" + CloneTaskStatusStatusUnknown string = "unknown" +) + +// prop value enum +func (m *CloneTaskStatus) validateStatusEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, cloneTaskStatusTypeStatusPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *CloneTaskStatus) validateStatus(formats strfmt.Registry) error { + + if err := validate.Required("status", "body", m.Status); err != nil { + return err + } + + // value enum + if err := m.validateStatusEnum("status", "body", *m.Status); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this clone task status based on the context it is used +func (m *CloneTaskStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateClonedVolumes(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloneTaskStatus) contextValidateClonedVolumes(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.ClonedVolumes); i++ { + + if m.ClonedVolumes[i] != nil { + if err := m.ClonedVolumes[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("clonedVolumes" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("clonedVolumes" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *CloneTaskStatus) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CloneTaskStatus) UnmarshalBinary(b []byte) error { + var res CloneTaskStatus + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloned_volume.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloned_volume.go new file mode 100644 index 00000000000..0431ea99070 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloned_volume.go @@ -0,0 +1,53 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ClonedVolume cloned volume +// +// swagger:model ClonedVolume +type ClonedVolume struct { + + // ID of the new cloned volume + ClonedVolumeID string `json:"clonedVolumeID,omitempty"` + + // ID of the source volume to be cloned + SourceVolumeID string `json:"sourceVolumeID,omitempty"` +} + +// Validate validates this cloned volume +func (m *ClonedVolume) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this cloned volume based on context it is used +func (m *ClonedVolume) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ClonedVolume) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ClonedVolume) UnmarshalBinary(b []byte) error { + var res ClonedVolume + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloned_volume_detail.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloned_volume_detail.go new file mode 100644 index 00000000000..67757963b8b --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloned_volume_detail.go @@ -0,0 +1,155 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ClonedVolumeDetail cloned volume detail +// +// swagger:model ClonedVolumeDetail +type ClonedVolumeDetail struct { + + // clone + // Required: true + Clone *VolumeInfo `json:"clone"` + + // source + // Required: true + Source *VolumeInfo `json:"source"` +} + +// Validate validates this cloned volume detail +func (m *ClonedVolumeDetail) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateClone(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSource(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ClonedVolumeDetail) validateClone(formats strfmt.Registry) error { + + if err := validate.Required("clone", "body", m.Clone); err != nil { + return err + } + + if m.Clone != nil { + if err := m.Clone.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("clone") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("clone") + } + return err + } + } + + return nil +} + +func (m *ClonedVolumeDetail) validateSource(formats strfmt.Registry) error { + + if err := validate.Required("source", "body", m.Source); err != nil { + return err + } + + if m.Source != nil { + if err := m.Source.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("source") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("source") + } + return err + } + } + + return nil +} + +// ContextValidate validate this cloned volume detail based on the context it is used +func (m *ClonedVolumeDetail) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateClone(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSource(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ClonedVolumeDetail) contextValidateClone(ctx context.Context, formats strfmt.Registry) error { + + if m.Clone != nil { + if err := m.Clone.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("clone") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("clone") + } + return err + } + } + + return nil +} + +func (m *ClonedVolumeDetail) contextValidateSource(ctx context.Context, formats strfmt.Registry) error { + + if m.Source != nil { + if err := m.Source.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("source") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("source") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ClonedVolumeDetail) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ClonedVolumeDetail) UnmarshalBinary(b []byte) error { + var res ClonedVolumeDetail + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection.go new file mode 100644 index 00000000000..b61c4a054a6 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection.go @@ -0,0 +1,384 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// CloudConnection cloud connection +// +// swagger:model CloudConnection +type CloudConnection struct { + + // classic + Classic *CloudConnectionEndpointClassic `json:"classic,omitempty"` + + // cloud connection ID + // Required: true + CloudConnectionID *string `json:"cloudConnectionID"` + + // creation date + // Required: true + // Format: date-time + CreationDate *strfmt.DateTime `json:"creationDate"` + + // enable global routing for this cloud connection (default=false) + // Required: true + GlobalRouting *bool `json:"globalRouting"` + + // IBM IP address + // Required: true + IbmIPAddress *string `json:"ibmIPAddress"` + + // link status + // Required: true + LinkStatus *string `json:"linkStatus"` + + // metered + // Required: true + Metered *bool `json:"metered"` + + // name of the cloud connection + // Required: true + Name *string `json:"name"` + + // Network References + Networks []*NetworkReference `json:"networks,omitempty"` + + // port + // Required: true + Port *string `json:"port"` + + // speed of the cloud connection (speed in megabits per second) + // Required: true + Speed *int64 `json:"speed"` + + // user IP address + // Required: true + UserIPAddress *string `json:"userIPAddress"` + + // vpc + Vpc *CloudConnectionEndpointVPC `json:"vpc,omitempty"` +} + +// Validate validates this cloud connection +func (m *CloudConnection) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateClassic(formats); err != nil { + res = append(res, err) + } + + if err := m.validateCloudConnectionID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateCreationDate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateGlobalRouting(formats); err != nil { + res = append(res, err) + } + + if err := m.validateIbmIPAddress(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLinkStatus(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMetered(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateNetworks(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePort(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSpeed(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUserIPAddress(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVpc(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudConnection) validateClassic(formats strfmt.Registry) error { + if swag.IsZero(m.Classic) { // not required + return nil + } + + if m.Classic != nil { + if err := m.Classic.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("classic") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("classic") + } + return err + } + } + + return nil +} + +func (m *CloudConnection) validateCloudConnectionID(formats strfmt.Registry) error { + + if err := validate.Required("cloudConnectionID", "body", m.CloudConnectionID); err != nil { + return err + } + + return nil +} + +func (m *CloudConnection) validateCreationDate(formats strfmt.Registry) error { + + if err := validate.Required("creationDate", "body", m.CreationDate); err != nil { + return err + } + + if err := validate.FormatOf("creationDate", "body", "date-time", m.CreationDate.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *CloudConnection) validateGlobalRouting(formats strfmt.Registry) error { + + if err := validate.Required("globalRouting", "body", m.GlobalRouting); err != nil { + return err + } + + return nil +} + +func (m *CloudConnection) validateIbmIPAddress(formats strfmt.Registry) error { + + if err := validate.Required("ibmIPAddress", "body", m.IbmIPAddress); err != nil { + return err + } + + return nil +} + +func (m *CloudConnection) validateLinkStatus(formats strfmt.Registry) error { + + if err := validate.Required("linkStatus", "body", m.LinkStatus); err != nil { + return err + } + + return nil +} + +func (m *CloudConnection) validateMetered(formats strfmt.Registry) error { + + if err := validate.Required("metered", "body", m.Metered); err != nil { + return err + } + + return nil +} + +func (m *CloudConnection) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *CloudConnection) validateNetworks(formats strfmt.Registry) error { + if swag.IsZero(m.Networks) { // not required + return nil + } + + for i := 0; i < len(m.Networks); i++ { + if swag.IsZero(m.Networks[i]) { // not required + continue + } + + if m.Networks[i] != nil { + if err := m.Networks[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("networks" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("networks" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *CloudConnection) validatePort(formats strfmt.Registry) error { + + if err := validate.Required("port", "body", m.Port); err != nil { + return err + } + + return nil +} + +func (m *CloudConnection) validateSpeed(formats strfmt.Registry) error { + + if err := validate.Required("speed", "body", m.Speed); err != nil { + return err + } + + return nil +} + +func (m *CloudConnection) validateUserIPAddress(formats strfmt.Registry) error { + + if err := validate.Required("userIPAddress", "body", m.UserIPAddress); err != nil { + return err + } + + return nil +} + +func (m *CloudConnection) validateVpc(formats strfmt.Registry) error { + if swag.IsZero(m.Vpc) { // not required + return nil + } + + if m.Vpc != nil { + if err := m.Vpc.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("vpc") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("vpc") + } + return err + } + } + + return nil +} + +// ContextValidate validate this cloud connection based on the context it is used +func (m *CloudConnection) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateClassic(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateNetworks(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateVpc(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudConnection) contextValidateClassic(ctx context.Context, formats strfmt.Registry) error { + + if m.Classic != nil { + if err := m.Classic.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("classic") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("classic") + } + return err + } + } + + return nil +} + +func (m *CloudConnection) contextValidateNetworks(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Networks); i++ { + + if m.Networks[i] != nil { + if err := m.Networks[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("networks" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("networks" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *CloudConnection) contextValidateVpc(ctx context.Context, formats strfmt.Registry) error { + + if m.Vpc != nil { + if err := m.Vpc.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("vpc") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("vpc") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *CloudConnection) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CloudConnection) UnmarshalBinary(b []byte) error { + var res CloudConnection + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection_create.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection_create.go new file mode 100644 index 00000000000..12231ad9df1 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection_create.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// CloudConnectionCreate cloud connection create +// +// swagger:model CloudConnectionCreate +type CloudConnectionCreate struct { + + // classic + Classic *CloudConnectionEndpointClassicUpdate `json:"classic,omitempty"` + + // enable global routing for this cloud connection (default=false) + GlobalRouting bool `json:"globalRouting,omitempty"` + + // enable metered for this cloud connection (default=false) + Metered bool `json:"metered,omitempty"` + + // name of the cloud connection + // Required: true + Name *string `json:"name"` + + // speed of the cloud connection (speed in megabits per second) + // Required: true + // Enum: [50 100 200 500 1000 2000 5000 10000] + Speed *int64 `json:"speed"` + + // list of subnets to attach to cloud connection + Subnets []string `json:"subnets"` + + // vpc + Vpc *CloudConnectionEndpointVPC `json:"vpc,omitempty"` +} + +// Validate validates this cloud connection create +func (m *CloudConnectionCreate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateClassic(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSpeed(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVpc(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudConnectionCreate) validateClassic(formats strfmt.Registry) error { + if swag.IsZero(m.Classic) { // not required + return nil + } + + if m.Classic != nil { + if err := m.Classic.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("classic") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("classic") + } + return err + } + } + + return nil +} + +func (m *CloudConnectionCreate) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +var cloudConnectionCreateTypeSpeedPropEnum []interface{} + +func init() { + var res []int64 + if err := json.Unmarshal([]byte(`[50,100,200,500,1000,2000,5000,10000]`), &res); err != nil { + panic(err) + } + for _, v := range res { + cloudConnectionCreateTypeSpeedPropEnum = append(cloudConnectionCreateTypeSpeedPropEnum, v) + } +} + +// prop value enum +func (m *CloudConnectionCreate) validateSpeedEnum(path, location string, value int64) error { + if err := validate.EnumCase(path, location, value, cloudConnectionCreateTypeSpeedPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *CloudConnectionCreate) validateSpeed(formats strfmt.Registry) error { + + if err := validate.Required("speed", "body", m.Speed); err != nil { + return err + } + + // value enum + if err := m.validateSpeedEnum("speed", "body", *m.Speed); err != nil { + return err + } + + return nil +} + +func (m *CloudConnectionCreate) validateVpc(formats strfmt.Registry) error { + if swag.IsZero(m.Vpc) { // not required + return nil + } + + if m.Vpc != nil { + if err := m.Vpc.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("vpc") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("vpc") + } + return err + } + } + + return nil +} + +// ContextValidate validate this cloud connection create based on the context it is used +func (m *CloudConnectionCreate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateClassic(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateVpc(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudConnectionCreate) contextValidateClassic(ctx context.Context, formats strfmt.Registry) error { + + if m.Classic != nil { + if err := m.Classic.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("classic") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("classic") + } + return err + } + } + + return nil +} + +func (m *CloudConnectionCreate) contextValidateVpc(ctx context.Context, formats strfmt.Registry) error { + + if m.Vpc != nil { + if err := m.Vpc.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("vpc") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("vpc") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *CloudConnectionCreate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CloudConnectionCreate) UnmarshalBinary(b []byte) error { + var res CloudConnectionCreate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection_create_response.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection_create_response.go new file mode 100644 index 00000000000..cf8c089942a --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection_create_response.go @@ -0,0 +1,160 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// CloudConnectionCreateResponse cloud connection create response +// +// swagger:model CloudConnectionCreateResponse +type CloudConnectionCreateResponse struct { + CloudConnection + + // job ref + JobRef *JobReference `json:"jobRef,omitempty"` +} + +// UnmarshalJSON unmarshals this object from a JSON structure +func (m *CloudConnectionCreateResponse) UnmarshalJSON(raw []byte) error { + // AO0 + var aO0 CloudConnection + if err := swag.ReadJSON(raw, &aO0); err != nil { + return err + } + m.CloudConnection = aO0 + + // now for regular properties + var propsCloudConnectionCreateResponse struct { + JobRef *JobReference `json:"jobRef,omitempty"` + } + if err := swag.ReadJSON(raw, &propsCloudConnectionCreateResponse); err != nil { + return err + } + m.JobRef = propsCloudConnectionCreateResponse.JobRef + + return nil +} + +// MarshalJSON marshals this object to a JSON structure +func (m CloudConnectionCreateResponse) MarshalJSON() ([]byte, error) { + _parts := make([][]byte, 0, 1) + + aO0, err := swag.WriteJSON(m.CloudConnection) + if err != nil { + return nil, err + } + _parts = append(_parts, aO0) + + // now for regular properties + var propsCloudConnectionCreateResponse struct { + JobRef *JobReference `json:"jobRef,omitempty"` + } + propsCloudConnectionCreateResponse.JobRef = m.JobRef + + jsonDataPropsCloudConnectionCreateResponse, errCloudConnectionCreateResponse := swag.WriteJSON(propsCloudConnectionCreateResponse) + if errCloudConnectionCreateResponse != nil { + return nil, errCloudConnectionCreateResponse + } + _parts = append(_parts, jsonDataPropsCloudConnectionCreateResponse) + return swag.ConcatJSON(_parts...), nil +} + +// Validate validates this cloud connection create response +func (m *CloudConnectionCreateResponse) Validate(formats strfmt.Registry) error { + var res []error + + // validation for a type composition with CloudConnection + if err := m.CloudConnection.Validate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateJobRef(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudConnectionCreateResponse) validateJobRef(formats strfmt.Registry) error { + if swag.IsZero(m.JobRef) { // not required + return nil + } + + if m.JobRef != nil { + if err := m.JobRef.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("jobRef") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("jobRef") + } + return err + } + } + + return nil +} + +// ContextValidate validate this cloud connection create response based on the context it is used +func (m *CloudConnectionCreateResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + // validation for a type composition with CloudConnection + if err := m.CloudConnection.ContextValidate(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateJobRef(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudConnectionCreateResponse) contextValidateJobRef(ctx context.Context, formats strfmt.Registry) error { + + if m.JobRef != nil { + if err := m.JobRef.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("jobRef") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("jobRef") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *CloudConnectionCreateResponse) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CloudConnectionCreateResponse) UnmarshalBinary(b []byte) error { + var res CloudConnectionCreateResponse + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection_endpoint_classic.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection_endpoint_classic.go new file mode 100644 index 00000000000..9ca73c49d34 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection_endpoint_classic.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// CloudConnectionEndpointClassic cloud connection endpoint classic +// +// swagger:model CloudConnectionEndpointClassic +type CloudConnectionEndpointClassic struct { + + // enable classic endpoint destination (default=false) + Enabled bool `json:"enabled"` + + // gre + Gre *CloudConnectionGRETunnel `json:"gre,omitempty"` +} + +// Validate validates this cloud connection endpoint classic +func (m *CloudConnectionEndpointClassic) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateGre(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudConnectionEndpointClassic) validateGre(formats strfmt.Registry) error { + if swag.IsZero(m.Gre) { // not required + return nil + } + + if m.Gre != nil { + if err := m.Gre.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("gre") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("gre") + } + return err + } + } + + return nil +} + +// ContextValidate validate this cloud connection endpoint classic based on the context it is used +func (m *CloudConnectionEndpointClassic) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateGre(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudConnectionEndpointClassic) contextValidateGre(ctx context.Context, formats strfmt.Registry) error { + + if m.Gre != nil { + if err := m.Gre.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("gre") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("gre") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *CloudConnectionEndpointClassic) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CloudConnectionEndpointClassic) UnmarshalBinary(b []byte) error { + var res CloudConnectionEndpointClassic + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection_endpoint_classic_update.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection_endpoint_classic_update.go new file mode 100644 index 00000000000..300fef2a19c --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection_endpoint_classic_update.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// CloudConnectionEndpointClassicUpdate cloud connection endpoint classic update +// +// swagger:model CloudConnectionEndpointClassicUpdate +type CloudConnectionEndpointClassicUpdate struct { + + // enable classic endpoint destination (default=false) + Enabled bool `json:"enabled"` + + // gre + Gre *CloudConnectionGRETunnelCreate `json:"gre,omitempty"` +} + +// Validate validates this cloud connection endpoint classic update +func (m *CloudConnectionEndpointClassicUpdate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateGre(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudConnectionEndpointClassicUpdate) validateGre(formats strfmt.Registry) error { + if swag.IsZero(m.Gre) { // not required + return nil + } + + if m.Gre != nil { + if err := m.Gre.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("gre") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("gre") + } + return err + } + } + + return nil +} + +// ContextValidate validate this cloud connection endpoint classic update based on the context it is used +func (m *CloudConnectionEndpointClassicUpdate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateGre(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudConnectionEndpointClassicUpdate) contextValidateGre(ctx context.Context, formats strfmt.Registry) error { + + if m.Gre != nil { + if err := m.Gre.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("gre") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("gre") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *CloudConnectionEndpointClassicUpdate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CloudConnectionEndpointClassicUpdate) UnmarshalBinary(b []byte) error { + var res CloudConnectionEndpointClassicUpdate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection_endpoint_v_p_c.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection_endpoint_v_p_c.go new file mode 100644 index 00000000000..873c365c195 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection_endpoint_v_p_c.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// CloudConnectionEndpointVPC cloud connection endpoint v p c +// +// swagger:model CloudConnectionEndpointVPC +type CloudConnectionEndpointVPC struct { + + // enable vpc for this cloud connection (default=false) + Enabled bool `json:"enabled"` + + // vpc connections + Vpcs []*CloudConnectionVPC `json:"vpcs,omitempty"` +} + +// Validate validates this cloud connection endpoint v p c +func (m *CloudConnectionEndpointVPC) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateVpcs(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudConnectionEndpointVPC) validateVpcs(formats strfmt.Registry) error { + if swag.IsZero(m.Vpcs) { // not required + return nil + } + + for i := 0; i < len(m.Vpcs); i++ { + if swag.IsZero(m.Vpcs[i]) { // not required + continue + } + + if m.Vpcs[i] != nil { + if err := m.Vpcs[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("vpcs" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("vpcs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this cloud connection endpoint v p c based on the context it is used +func (m *CloudConnectionEndpointVPC) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateVpcs(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudConnectionEndpointVPC) contextValidateVpcs(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Vpcs); i++ { + + if m.Vpcs[i] != nil { + if err := m.Vpcs[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("vpcs" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("vpcs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *CloudConnectionEndpointVPC) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CloudConnectionEndpointVPC) UnmarshalBinary(b []byte) error { + var res CloudConnectionEndpointVPC + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection_g_r_e_tunnel.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection_g_r_e_tunnel.go new file mode 100644 index 00000000000..df506624058 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection_g_r_e_tunnel.go @@ -0,0 +1,88 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// CloudConnectionGRETunnel cloud connection g r e tunnel +// +// swagger:model CloudConnectionGRETunnel +type CloudConnectionGRETunnel struct { + + // gre destination IP address + // Required: true + DestIPAddress *string `json:"destIPAddress"` + + // gre auto-assigned source IP address + // Required: true + SourceIPAddress *string `json:"sourceIPAddress"` +} + +// Validate validates this cloud connection g r e tunnel +func (m *CloudConnectionGRETunnel) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateDestIPAddress(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSourceIPAddress(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudConnectionGRETunnel) validateDestIPAddress(formats strfmt.Registry) error { + + if err := validate.Required("destIPAddress", "body", m.DestIPAddress); err != nil { + return err + } + + return nil +} + +func (m *CloudConnectionGRETunnel) validateSourceIPAddress(formats strfmt.Registry) error { + + if err := validate.Required("sourceIPAddress", "body", m.SourceIPAddress); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this cloud connection g r e tunnel based on context it is used +func (m *CloudConnectionGRETunnel) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *CloudConnectionGRETunnel) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CloudConnectionGRETunnel) UnmarshalBinary(b []byte) error { + var res CloudConnectionGRETunnel + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection_g_r_e_tunnel_create.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection_g_r_e_tunnel_create.go new file mode 100644 index 00000000000..3310bc0566b --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection_g_r_e_tunnel_create.go @@ -0,0 +1,88 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// CloudConnectionGRETunnelCreate cloud connection g r e tunnel create +// +// swagger:model CloudConnectionGRETunnelCreate +type CloudConnectionGRETunnelCreate struct { + + // gre network in CIDR notation (192.168.0.0/24) + // Required: true + Cidr *string `json:"cidr"` + + // gre destination IP address + // Required: true + DestIPAddress *string `json:"destIPAddress"` +} + +// Validate validates this cloud connection g r e tunnel create +func (m *CloudConnectionGRETunnelCreate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCidr(formats); err != nil { + res = append(res, err) + } + + if err := m.validateDestIPAddress(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudConnectionGRETunnelCreate) validateCidr(formats strfmt.Registry) error { + + if err := validate.Required("cidr", "body", m.Cidr); err != nil { + return err + } + + return nil +} + +func (m *CloudConnectionGRETunnelCreate) validateDestIPAddress(formats strfmt.Registry) error { + + if err := validate.Required("destIPAddress", "body", m.DestIPAddress); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this cloud connection g r e tunnel create based on context it is used +func (m *CloudConnectionGRETunnelCreate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *CloudConnectionGRETunnelCreate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CloudConnectionGRETunnelCreate) UnmarshalBinary(b []byte) error { + var res CloudConnectionGRETunnelCreate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection_update.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection_update.go new file mode 100644 index 00000000000..df7e0c302d1 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection_update.go @@ -0,0 +1,202 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// CloudConnectionUpdate cloud connection update +// +// swagger:model CloudConnectionUpdate +type CloudConnectionUpdate struct { + + // classic + Classic *CloudConnectionEndpointClassicUpdate `json:"classic,omitempty"` + + // enable global routing for this cloud connection (default=false) + GlobalRouting *bool `json:"globalRouting,omitempty"` + + // enable metered for this cloud connection (default=false) + Metered *bool `json:"metered,omitempty"` + + // name of the cloud connection + Name *string `json:"name,omitempty"` + + // speed of the cloud connection (speed in megabits per second) + // Enum: [50 100 200 500 1000 2000 5000 10000] + Speed *int64 `json:"speed,omitempty"` + + // vpc + Vpc *CloudConnectionEndpointVPC `json:"vpc,omitempty"` +} + +// Validate validates this cloud connection update +func (m *CloudConnectionUpdate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateClassic(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSpeed(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVpc(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudConnectionUpdate) validateClassic(formats strfmt.Registry) error { + if swag.IsZero(m.Classic) { // not required + return nil + } + + if m.Classic != nil { + if err := m.Classic.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("classic") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("classic") + } + return err + } + } + + return nil +} + +var cloudConnectionUpdateTypeSpeedPropEnum []interface{} + +func init() { + var res []int64 + if err := json.Unmarshal([]byte(`[50,100,200,500,1000,2000,5000,10000]`), &res); err != nil { + panic(err) + } + for _, v := range res { + cloudConnectionUpdateTypeSpeedPropEnum = append(cloudConnectionUpdateTypeSpeedPropEnum, v) + } +} + +// prop value enum +func (m *CloudConnectionUpdate) validateSpeedEnum(path, location string, value int64) error { + if err := validate.EnumCase(path, location, value, cloudConnectionUpdateTypeSpeedPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *CloudConnectionUpdate) validateSpeed(formats strfmt.Registry) error { + if swag.IsZero(m.Speed) { // not required + return nil + } + + // value enum + if err := m.validateSpeedEnum("speed", "body", *m.Speed); err != nil { + return err + } + + return nil +} + +func (m *CloudConnectionUpdate) validateVpc(formats strfmt.Registry) error { + if swag.IsZero(m.Vpc) { // not required + return nil + } + + if m.Vpc != nil { + if err := m.Vpc.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("vpc") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("vpc") + } + return err + } + } + + return nil +} + +// ContextValidate validate this cloud connection update based on the context it is used +func (m *CloudConnectionUpdate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateClassic(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateVpc(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudConnectionUpdate) contextValidateClassic(ctx context.Context, formats strfmt.Registry) error { + + if m.Classic != nil { + if err := m.Classic.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("classic") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("classic") + } + return err + } + } + + return nil +} + +func (m *CloudConnectionUpdate) contextValidateVpc(ctx context.Context, formats strfmt.Registry) error { + + if m.Vpc != nil { + if err := m.Vpc.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("vpc") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("vpc") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *CloudConnectionUpdate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CloudConnectionUpdate) UnmarshalBinary(b []byte) error { + var res CloudConnectionUpdate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection_v_p_c.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection_v_p_c.go new file mode 100644 index 00000000000..7aab62b3a71 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection_v_p_c.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// CloudConnectionVPC cloud connection v p c +// +// swagger:model CloudConnectionVPC +type CloudConnectionVPC struct { + + // vpc name + Name string `json:"name,omitempty"` + + // vpc id + // Required: true + VpcID *string `json:"vpcID"` +} + +// Validate validates this cloud connection v p c +func (m *CloudConnectionVPC) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateVpcID(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudConnectionVPC) validateVpcID(formats strfmt.Registry) error { + + if err := validate.Required("vpcID", "body", m.VpcID); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this cloud connection v p c based on context it is used +func (m *CloudConnectionVPC) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *CloudConnectionVPC) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CloudConnectionVPC) UnmarshalBinary(b []byte) error { + var res CloudConnectionVPC + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection_virtual_private_clouds.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection_virtual_private_clouds.go new file mode 100644 index 00000000000..5c97aab8b7f --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connection_virtual_private_clouds.go @@ -0,0 +1,226 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// CloudConnectionVirtualPrivateClouds cloud connection virtual private clouds +// +// swagger:model CloudConnectionVirtualPrivateClouds +type CloudConnectionVirtualPrivateClouds struct { + + // list of available virtual private clouds + // Required: true + VirtualPrivateClouds []*CloudConnectionVirtualPrivateCloud `json:"virtualPrivateClouds"` +} + +// Validate validates this cloud connection virtual private clouds +func (m *CloudConnectionVirtualPrivateClouds) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateVirtualPrivateClouds(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudConnectionVirtualPrivateClouds) validateVirtualPrivateClouds(formats strfmt.Registry) error { + + if err := validate.Required("virtualPrivateClouds", "body", m.VirtualPrivateClouds); err != nil { + return err + } + + for i := 0; i < len(m.VirtualPrivateClouds); i++ { + if swag.IsZero(m.VirtualPrivateClouds[i]) { // not required + continue + } + + if m.VirtualPrivateClouds[i] != nil { + if err := m.VirtualPrivateClouds[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("virtualPrivateClouds" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("virtualPrivateClouds" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this cloud connection virtual private clouds based on the context it is used +func (m *CloudConnectionVirtualPrivateClouds) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateVirtualPrivateClouds(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudConnectionVirtualPrivateClouds) contextValidateVirtualPrivateClouds(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.VirtualPrivateClouds); i++ { + + if m.VirtualPrivateClouds[i] != nil { + if err := m.VirtualPrivateClouds[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("virtualPrivateClouds" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("virtualPrivateClouds" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *CloudConnectionVirtualPrivateClouds) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CloudConnectionVirtualPrivateClouds) UnmarshalBinary(b []byte) error { + var res CloudConnectionVirtualPrivateClouds + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// CloudConnectionVirtualPrivateCloud cloud connection virtual private cloud +// +// swagger:model CloudConnectionVirtualPrivateCloud +type CloudConnectionVirtualPrivateCloud struct { + + // indicates if vpc uses classic architecture + // Required: true + ClassicAccess *bool `json:"classicAccess"` + + // name for the vpc + // Required: true + Name *string `json:"name"` + + // status of this vpc + // Required: true + Status *string `json:"status"` + + // virtual private cloud id + // Required: true + VpcID *string `json:"vpcID"` +} + +// Validate validates this cloud connection virtual private cloud +func (m *CloudConnectionVirtualPrivateCloud) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateClassicAccess(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStatus(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVpcID(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudConnectionVirtualPrivateCloud) validateClassicAccess(formats strfmt.Registry) error { + + if err := validate.Required("classicAccess", "body", m.ClassicAccess); err != nil { + return err + } + + return nil +} + +func (m *CloudConnectionVirtualPrivateCloud) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *CloudConnectionVirtualPrivateCloud) validateStatus(formats strfmt.Registry) error { + + if err := validate.Required("status", "body", m.Status); err != nil { + return err + } + + return nil +} + +func (m *CloudConnectionVirtualPrivateCloud) validateVpcID(formats strfmt.Registry) error { + + if err := validate.Required("vpcID", "body", m.VpcID); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this cloud connection virtual private cloud based on context it is used +func (m *CloudConnectionVirtualPrivateCloud) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *CloudConnectionVirtualPrivateCloud) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CloudConnectionVirtualPrivateCloud) UnmarshalBinary(b []byte) error { + var res CloudConnectionVirtualPrivateCloud + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connections.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connections.go new file mode 100644 index 00000000000..1c9696c6cdb --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_connections.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// CloudConnections cloud connections +// +// swagger:model CloudConnections +type CloudConnections struct { + + // Cloud Connections + // Required: true + CloudConnections []*CloudConnection `json:"cloudConnections"` +} + +// Validate validates this cloud connections +func (m *CloudConnections) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCloudConnections(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudConnections) validateCloudConnections(formats strfmt.Registry) error { + + if err := validate.Required("cloudConnections", "body", m.CloudConnections); err != nil { + return err + } + + for i := 0; i < len(m.CloudConnections); i++ { + if swag.IsZero(m.CloudConnections[i]) { // not required + continue + } + + if m.CloudConnections[i] != nil { + if err := m.CloudConnections[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("cloudConnections" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cloudConnections" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this cloud connections based on the context it is used +func (m *CloudConnections) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateCloudConnections(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudConnections) contextValidateCloudConnections(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.CloudConnections); i++ { + + if m.CloudConnections[i] != nil { + if err := m.CloudConnections[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("cloudConnections" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cloudConnections" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *CloudConnections) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CloudConnections) UnmarshalBinary(b []byte) error { + var res CloudConnections + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_instance.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_instance.go new file mode 100644 index 00000000000..307eab24199 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_instance.go @@ -0,0 +1,337 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// CloudInstance cloud instance +// +// swagger:model CloudInstance +type CloudInstance struct { + + // Cloud Instance Capabilities + Capabilities []string `json:"capabilities"` + + // Cloud Instance ID + // Required: true + CloudInstanceID *string `json:"cloudInstanceID"` + + // Indicates if the cloud instance is enabled + // Required: true + Enabled *bool `json:"enabled"` + + // Indicates if the cloud instance is initialized and ready for use + // Required: true + Initialized *bool `json:"initialized"` + + // Limits on the cloud instance + // Required: true + Limits *CloudInstanceUsageLimits `json:"limits"` + + // Cloud Instance Name + // Required: true + Name *string `json:"name"` + + // The open stack ID that controls this cloud instance + // Required: true + OpenstackID *string `json:"openstackID"` + + // PVM instances owned by the Cloud Instance + // Required: true + PvmInstances []*PVMInstanceReference `json:"pvmInstances"` + + // The region the cloud instance lives + // Required: true + Region *string `json:"region"` + + // The tenant ID that owns this cloud instance + // Required: true + TenantID *string `json:"tenantID"` + + // Current usage on the cloud instance + // Required: true + Usage *CloudInstanceUsageLimits `json:"usage"` +} + +// Validate validates this cloud instance +func (m *CloudInstance) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCloudInstanceID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateEnabled(formats); err != nil { + res = append(res, err) + } + + if err := m.validateInitialized(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLimits(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOpenstackID(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePvmInstances(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRegion(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTenantID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUsage(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudInstance) validateCloudInstanceID(formats strfmt.Registry) error { + + if err := validate.Required("cloudInstanceID", "body", m.CloudInstanceID); err != nil { + return err + } + + return nil +} + +func (m *CloudInstance) validateEnabled(formats strfmt.Registry) error { + + if err := validate.Required("enabled", "body", m.Enabled); err != nil { + return err + } + + return nil +} + +func (m *CloudInstance) validateInitialized(formats strfmt.Registry) error { + + if err := validate.Required("initialized", "body", m.Initialized); err != nil { + return err + } + + return nil +} + +func (m *CloudInstance) validateLimits(formats strfmt.Registry) error { + + if err := validate.Required("limits", "body", m.Limits); err != nil { + return err + } + + if m.Limits != nil { + if err := m.Limits.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("limits") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("limits") + } + return err + } + } + + return nil +} + +func (m *CloudInstance) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *CloudInstance) validateOpenstackID(formats strfmt.Registry) error { + + if err := validate.Required("openstackID", "body", m.OpenstackID); err != nil { + return err + } + + return nil +} + +func (m *CloudInstance) validatePvmInstances(formats strfmt.Registry) error { + + if err := validate.Required("pvmInstances", "body", m.PvmInstances); err != nil { + return err + } + + for i := 0; i < len(m.PvmInstances); i++ { + if swag.IsZero(m.PvmInstances[i]) { // not required + continue + } + + if m.PvmInstances[i] != nil { + if err := m.PvmInstances[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("pvmInstances" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("pvmInstances" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *CloudInstance) validateRegion(formats strfmt.Registry) error { + + if err := validate.Required("region", "body", m.Region); err != nil { + return err + } + + return nil +} + +func (m *CloudInstance) validateTenantID(formats strfmt.Registry) error { + + if err := validate.Required("tenantID", "body", m.TenantID); err != nil { + return err + } + + return nil +} + +func (m *CloudInstance) validateUsage(formats strfmt.Registry) error { + + if err := validate.Required("usage", "body", m.Usage); err != nil { + return err + } + + if m.Usage != nil { + if err := m.Usage.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("usage") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("usage") + } + return err + } + } + + return nil +} + +// ContextValidate validate this cloud instance based on the context it is used +func (m *CloudInstance) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateLimits(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidatePvmInstances(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateUsage(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudInstance) contextValidateLimits(ctx context.Context, formats strfmt.Registry) error { + + if m.Limits != nil { + if err := m.Limits.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("limits") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("limits") + } + return err + } + } + + return nil +} + +func (m *CloudInstance) contextValidatePvmInstances(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.PvmInstances); i++ { + + if m.PvmInstances[i] != nil { + if err := m.PvmInstances[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("pvmInstances" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("pvmInstances" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *CloudInstance) contextValidateUsage(ctx context.Context, formats strfmt.Registry) error { + + if m.Usage != nil { + if err := m.Usage.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("usage") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("usage") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *CloudInstance) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CloudInstance) UnmarshalBinary(b []byte) error { + var res CloudInstance + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_instance_create.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_instance_create.go new file mode 100644 index 00000000000..a94ca580bc6 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_instance_create.go @@ -0,0 +1,145 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// CloudInstanceCreate cloud instance create +// +// swagger:model CloudInstanceCreate +type CloudInstanceCreate struct { + + // Number of power instances allowed + Instances *float64 `json:"instances,omitempty"` + + // Amount of memory allowed + // Required: true + Memory *float64 `json:"memory"` + + // Number of processor units allowed + // Required: true + ProcUnits *float64 `json:"procUnits"` + + // Number of processors allowed + // Required: true + Processors *float64 `json:"processors"` + + // The region the cloud instance lives + // Required: true + Region *string `json:"region"` + + // Amount of storage allowed (TB) + Storage *float64 `json:"storage,omitempty"` + + // The tenant ID that owns this cloud instance + // Required: true + TenantID *string `json:"tenantID"` +} + +// Validate validates this cloud instance create +func (m *CloudInstanceCreate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateMemory(formats); err != nil { + res = append(res, err) + } + + if err := m.validateProcUnits(formats); err != nil { + res = append(res, err) + } + + if err := m.validateProcessors(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRegion(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTenantID(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudInstanceCreate) validateMemory(formats strfmt.Registry) error { + + if err := validate.Required("memory", "body", m.Memory); err != nil { + return err + } + + return nil +} + +func (m *CloudInstanceCreate) validateProcUnits(formats strfmt.Registry) error { + + if err := validate.Required("procUnits", "body", m.ProcUnits); err != nil { + return err + } + + return nil +} + +func (m *CloudInstanceCreate) validateProcessors(formats strfmt.Registry) error { + + if err := validate.Required("processors", "body", m.Processors); err != nil { + return err + } + + return nil +} + +func (m *CloudInstanceCreate) validateRegion(formats strfmt.Registry) error { + + if err := validate.Required("region", "body", m.Region); err != nil { + return err + } + + return nil +} + +func (m *CloudInstanceCreate) validateTenantID(formats strfmt.Registry) error { + + if err := validate.Required("tenantID", "body", m.TenantID); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this cloud instance create based on context it is used +func (m *CloudInstanceCreate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *CloudInstanceCreate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CloudInstanceCreate) UnmarshalBinary(b []byte) error { + var res CloudInstanceCreate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_instance_reference.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_instance_reference.go new file mode 100644 index 00000000000..22901098b01 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_instance_reference.go @@ -0,0 +1,212 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// CloudInstanceReference cloud instance reference +// +// swagger:model CloudInstanceReference +type CloudInstanceReference struct { + + // Cloud Instance Capabilities + Capabilities []string `json:"capabilities"` + + // Cloud Instance ID + // Required: true + CloudInstanceID *string `json:"cloudInstanceID"` + + // Indicates if the cloud instance is enabled + // Required: true + Enabled *bool `json:"enabled"` + + // Link to Cloud Instance resource + // Required: true + Href *string `json:"href"` + + // Indicates if the cloud instance is initialized and ready for use + // Required: true + Initialized *bool `json:"initialized"` + + // Limits on the cloud instance + // Required: true + Limits *CloudInstanceUsageLimits `json:"limits"` + + // Cloud Instance Name + // Required: true + Name *string `json:"name"` + + // The region the cloud instance lives + // Required: true + Region *string `json:"region"` +} + +// Validate validates this cloud instance reference +func (m *CloudInstanceReference) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCloudInstanceID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateEnabled(formats); err != nil { + res = append(res, err) + } + + if err := m.validateHref(formats); err != nil { + res = append(res, err) + } + + if err := m.validateInitialized(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLimits(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRegion(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudInstanceReference) validateCloudInstanceID(formats strfmt.Registry) error { + + if err := validate.Required("cloudInstanceID", "body", m.CloudInstanceID); err != nil { + return err + } + + return nil +} + +func (m *CloudInstanceReference) validateEnabled(formats strfmt.Registry) error { + + if err := validate.Required("enabled", "body", m.Enabled); err != nil { + return err + } + + return nil +} + +func (m *CloudInstanceReference) validateHref(formats strfmt.Registry) error { + + if err := validate.Required("href", "body", m.Href); err != nil { + return err + } + + return nil +} + +func (m *CloudInstanceReference) validateInitialized(formats strfmt.Registry) error { + + if err := validate.Required("initialized", "body", m.Initialized); err != nil { + return err + } + + return nil +} + +func (m *CloudInstanceReference) validateLimits(formats strfmt.Registry) error { + + if err := validate.Required("limits", "body", m.Limits); err != nil { + return err + } + + if m.Limits != nil { + if err := m.Limits.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("limits") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("limits") + } + return err + } + } + + return nil +} + +func (m *CloudInstanceReference) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *CloudInstanceReference) validateRegion(formats strfmt.Registry) error { + + if err := validate.Required("region", "body", m.Region); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this cloud instance reference based on the context it is used +func (m *CloudInstanceReference) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateLimits(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudInstanceReference) contextValidateLimits(ctx context.Context, formats strfmt.Registry) error { + + if m.Limits != nil { + if err := m.Limits.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("limits") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("limits") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *CloudInstanceReference) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CloudInstanceReference) UnmarshalBinary(b []byte) error { + var res CloudInstanceReference + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_instance_update.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_instance_update.go new file mode 100644 index 00000000000..a22c0677a83 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_instance_update.go @@ -0,0 +1,62 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// CloudInstanceUpdate cloud instance update +// +// swagger:model CloudInstanceUpdate +type CloudInstanceUpdate struct { + + // Number of power instances allowed + Instances *float64 `json:"instances,omitempty"` + + // Amount of memory allowed + Memory *float64 `json:"memory,omitempty"` + + // Number of processor units allowed + ProcUnits *float64 `json:"procUnits,omitempty"` + + // Number of processors allowed + Processors *float64 `json:"processors,omitempty"` + + // Amount of storage allowed (TB) + Storage *float64 `json:"storage,omitempty"` +} + +// Validate validates this cloud instance update +func (m *CloudInstanceUpdate) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this cloud instance update based on context it is used +func (m *CloudInstanceUpdate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *CloudInstanceUpdate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CloudInstanceUpdate) UnmarshalBinary(b []byte) error { + var res CloudInstanceUpdate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_instance_usage_limits.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_instance_usage_limits.go new file mode 100644 index 00000000000..ab8710d9ab4 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/cloud_instance_usage_limits.go @@ -0,0 +1,157 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// CloudInstanceUsageLimits cloud instance usage limits +// +// swagger:model CloudInstanceUsageLimits +type CloudInstanceUsageLimits struct { + + // Maximum memory (in GB) per PVMInstance + InstanceMemory *float64 `json:"instanceMemory,omitempty"` + + // Maximum proc units per PVMInstance + InstanceProcUnits *float64 `json:"instanceProcUnits,omitempty"` + + // Number of power instances allowed + // Required: true + Instances *float64 `json:"instances"` + + // Amount of memory allowed + // Required: true + Memory *float64 `json:"memory"` + + // Maximum network bandwidth to GCP Mbps + PeeringBandwidth *int64 `json:"peeringBandwidth,omitempty"` + + // Amount of peering networks allowed + PeeringNetworks *int64 `json:"peeringNetworks,omitempty"` + + // Number of processor units allowed + // Required: true + ProcUnits *float64 `json:"procUnits"` + + // Number of processors allowed + // Required: true + Processors *float64 `json:"processors"` + + // Amount of storage allowed (TB) + // Required: true + Storage *float64 `json:"storage"` + + // Amount of SSD storage allowed (TB) + StorageSSD *float64 `json:"storageSSD,omitempty"` + + // Amount of standard (HDD) storage allowed (TB) + StorageStandard *float64 `json:"storageStandard,omitempty"` +} + +// Validate validates this cloud instance usage limits +func (m *CloudInstanceUsageLimits) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateInstances(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMemory(formats); err != nil { + res = append(res, err) + } + + if err := m.validateProcUnits(formats); err != nil { + res = append(res, err) + } + + if err := m.validateProcessors(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStorage(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CloudInstanceUsageLimits) validateInstances(formats strfmt.Registry) error { + + if err := validate.Required("instances", "body", m.Instances); err != nil { + return err + } + + return nil +} + +func (m *CloudInstanceUsageLimits) validateMemory(formats strfmt.Registry) error { + + if err := validate.Required("memory", "body", m.Memory); err != nil { + return err + } + + return nil +} + +func (m *CloudInstanceUsageLimits) validateProcUnits(formats strfmt.Registry) error { + + if err := validate.Required("procUnits", "body", m.ProcUnits); err != nil { + return err + } + + return nil +} + +func (m *CloudInstanceUsageLimits) validateProcessors(formats strfmt.Registry) error { + + if err := validate.Required("processors", "body", m.Processors); err != nil { + return err + } + + return nil +} + +func (m *CloudInstanceUsageLimits) validateStorage(formats strfmt.Registry) error { + + if err := validate.Required("storage", "body", m.Storage); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this cloud instance usage limits based on context it is used +func (m *CloudInstanceUsageLimits) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *CloudInstanceUsageLimits) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CloudInstanceUsageLimits) UnmarshalBinary(b []byte) error { + var res CloudInstanceUsageLimits + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/console_language.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/console_language.go new file mode 100644 index 00000000000..76399a994a3 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/console_language.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ConsoleLanguage console language +// +// swagger:model ConsoleLanguage +type ConsoleLanguage struct { + + // language code + // Required: true + Code *string `json:"code"` + + // language description + Language string `json:"language,omitempty"` +} + +// Validate validates this console language +func (m *ConsoleLanguage) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCode(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ConsoleLanguage) validateCode(formats strfmt.Registry) error { + + if err := validate.Required("code", "body", m.Code); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this console language based on context it is used +func (m *ConsoleLanguage) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ConsoleLanguage) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ConsoleLanguage) UnmarshalBinary(b []byte) error { + var res ConsoleLanguage + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/console_languages.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/console_languages.go new file mode 100644 index 00000000000..adfe7d6540a --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/console_languages.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ConsoleLanguages console languages +// +// swagger:model ConsoleLanguages +type ConsoleLanguages struct { + + // console languages + // Required: true + ConsoleLanguages []*ConsoleLanguage `json:"consoleLanguages"` +} + +// Validate validates this console languages +func (m *ConsoleLanguages) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateConsoleLanguages(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ConsoleLanguages) validateConsoleLanguages(formats strfmt.Registry) error { + + if err := validate.Required("consoleLanguages", "body", m.ConsoleLanguages); err != nil { + return err + } + + for i := 0; i < len(m.ConsoleLanguages); i++ { + if swag.IsZero(m.ConsoleLanguages[i]) { // not required + continue + } + + if m.ConsoleLanguages[i] != nil { + if err := m.ConsoleLanguages[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("consoleLanguages" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("consoleLanguages" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this console languages based on the context it is used +func (m *ConsoleLanguages) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateConsoleLanguages(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ConsoleLanguages) contextValidateConsoleLanguages(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.ConsoleLanguages); i++ { + + if m.ConsoleLanguages[i] != nil { + if err := m.ConsoleLanguages[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("consoleLanguages" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("consoleLanguages" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ConsoleLanguages) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ConsoleLanguages) UnmarshalBinary(b []byte) error { + var res ConsoleLanguages + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/context.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/context.go new file mode 100644 index 00000000000..85e1cd011d1 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/context.go @@ -0,0 +1,11 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +// Context See [Context Conventions](https://github.com/openservicebrokerapi/servicebroker/blob/master/profile.md#context-object) for more details. +// +// swagger:model Context +type Context interface{} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/create_cos_image_import_job.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/create_cos_image_import_job.go new file mode 100644 index 00000000000..164c9a5a9da --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/create_cos_image_import_job.go @@ -0,0 +1,292 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// CreateCosImageImportJob create cos image import job +// +// swagger:model CreateCosImageImportJob +type CreateCosImageImportJob struct { + + // Cloud Object Storage access key; required for buckets with private access + AccessKey string `json:"accessKey,omitempty"` + + // indicates if the bucket has public or private access public access require no authentication keys private access requires hmac authentication keys (access,secret) + // Enum: [public private] + BucketAccess *string `json:"bucketAccess,omitempty"` + + // Cloud Object Storage bucket name; bucket-name[/optional/folder] + // Required: true + BucketName *string `json:"bucketName"` + + // Cloud Object Storage image filename + // Required: true + ImageFilename *string `json:"imageFilename"` + + // Name for the image that will be loaded into the boot image catalog + // Required: true + ImageName *string `json:"imageName"` + + // Image OS Type, required if importing a raw image; raw images can only be imported using the command line interface + // Enum: [aix ibmi rhel sles] + OsType string `json:"osType,omitempty"` + + // Cloud Object Storage region + // Required: true + Region *string `json:"region"` + + // Cloud Object Storage secret key; required for buckets with private access + SecretKey string `json:"secretKey,omitempty"` + + // Storage affinity data used for storage pool selection + StorageAffinity *StorageAffinity `json:"storageAffinity,omitempty"` + + // Storage pool where the image will be loaded, if provided then storageType and storageAffinity will be ignored + StoragePool string `json:"storagePool,omitempty"` + + // Type of storage; will be ignored if storagePool or storageAffinity is provided. If only using storageType for storage selection then the storage pool with the most available space will be selected + StorageType string `json:"storageType,omitempty"` +} + +// Validate validates this create cos image import job +func (m *CreateCosImageImportJob) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateBucketAccess(formats); err != nil { + res = append(res, err) + } + + if err := m.validateBucketName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateImageFilename(formats); err != nil { + res = append(res, err) + } + + if err := m.validateImageName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOsType(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRegion(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStorageAffinity(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +var createCosImageImportJobTypeBucketAccessPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["public","private"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + createCosImageImportJobTypeBucketAccessPropEnum = append(createCosImageImportJobTypeBucketAccessPropEnum, v) + } +} + +const ( + + // CreateCosImageImportJobBucketAccessPublic captures enum value "public" + CreateCosImageImportJobBucketAccessPublic string = "public" + + // CreateCosImageImportJobBucketAccessPrivate captures enum value "private" + CreateCosImageImportJobBucketAccessPrivate string = "private" +) + +// prop value enum +func (m *CreateCosImageImportJob) validateBucketAccessEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, createCosImageImportJobTypeBucketAccessPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *CreateCosImageImportJob) validateBucketAccess(formats strfmt.Registry) error { + if swag.IsZero(m.BucketAccess) { // not required + return nil + } + + // value enum + if err := m.validateBucketAccessEnum("bucketAccess", "body", *m.BucketAccess); err != nil { + return err + } + + return nil +} + +func (m *CreateCosImageImportJob) validateBucketName(formats strfmt.Registry) error { + + if err := validate.Required("bucketName", "body", m.BucketName); err != nil { + return err + } + + return nil +} + +func (m *CreateCosImageImportJob) validateImageFilename(formats strfmt.Registry) error { + + if err := validate.Required("imageFilename", "body", m.ImageFilename); err != nil { + return err + } + + return nil +} + +func (m *CreateCosImageImportJob) validateImageName(formats strfmt.Registry) error { + + if err := validate.Required("imageName", "body", m.ImageName); err != nil { + return err + } + + return nil +} + +var createCosImageImportJobTypeOsTypePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["aix","ibmi","rhel","sles"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + createCosImageImportJobTypeOsTypePropEnum = append(createCosImageImportJobTypeOsTypePropEnum, v) + } +} + +const ( + + // CreateCosImageImportJobOsTypeAix captures enum value "aix" + CreateCosImageImportJobOsTypeAix string = "aix" + + // CreateCosImageImportJobOsTypeIbmi captures enum value "ibmi" + CreateCosImageImportJobOsTypeIbmi string = "ibmi" + + // CreateCosImageImportJobOsTypeRhel captures enum value "rhel" + CreateCosImageImportJobOsTypeRhel string = "rhel" + + // CreateCosImageImportJobOsTypeSles captures enum value "sles" + CreateCosImageImportJobOsTypeSles string = "sles" +) + +// prop value enum +func (m *CreateCosImageImportJob) validateOsTypeEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, createCosImageImportJobTypeOsTypePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *CreateCosImageImportJob) validateOsType(formats strfmt.Registry) error { + if swag.IsZero(m.OsType) { // not required + return nil + } + + // value enum + if err := m.validateOsTypeEnum("osType", "body", m.OsType); err != nil { + return err + } + + return nil +} + +func (m *CreateCosImageImportJob) validateRegion(formats strfmt.Registry) error { + + if err := validate.Required("region", "body", m.Region); err != nil { + return err + } + + return nil +} + +func (m *CreateCosImageImportJob) validateStorageAffinity(formats strfmt.Registry) error { + if swag.IsZero(m.StorageAffinity) { // not required + return nil + } + + if m.StorageAffinity != nil { + if err := m.StorageAffinity.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("storageAffinity") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("storageAffinity") + } + return err + } + } + + return nil +} + +// ContextValidate validate this create cos image import job based on the context it is used +func (m *CreateCosImageImportJob) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateStorageAffinity(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CreateCosImageImportJob) contextValidateStorageAffinity(ctx context.Context, formats strfmt.Registry) error { + + if m.StorageAffinity != nil { + if err := m.StorageAffinity.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("storageAffinity") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("storageAffinity") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *CreateCosImageImportJob) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CreateCosImageImportJob) UnmarshalBinary(b []byte) error { + var res CreateCosImageImportJob + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/create_data_volume.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/create_data_volume.go new file mode 100644 index 00000000000..77dd2e4b1cf --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/create_data_volume.go @@ -0,0 +1,163 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// CreateDataVolume create data volume +// +// swagger:model CreateDataVolume +type CreateDataVolume struct { + + // PVM Instance (ID or Name) to base volume affinity policy against; required if requesting affinity and affinityVolume is not provided + AffinityPVMInstance *string `json:"affinityPVMInstance,omitempty"` + + // Affinity policy for data volume being created; ignored if volumePool provided; for policy 'affinity' requires one of affinityPVMInstance or affinityVolume to be specified; for policy 'anti-affinity' requires one of antiAffinityPVMInstances or antiAffinityVolumes to be specified + // Enum: [affinity anti-affinity] + AffinityPolicy *string `json:"affinityPolicy,omitempty"` + + // Volume (ID or Name) to base volume affinity policy against; required if requesting affinity and affinityPVMInstance is not provided + AffinityVolume *string `json:"affinityVolume,omitempty"` + + // List of pvmInstances to base volume anti-affinity policy against; required if requesting anti-affinity and antiAffinityVolumes is not provided + AntiAffinityPVMInstances []string `json:"antiAffinityPVMInstances"` + + // List of volumes to base volume anti-affinity policy against; required if requesting anti-affinity and antiAffinityPVMInstances is not provided + AntiAffinityVolumes []string `json:"antiAffinityVolumes"` + + // Type of Disk, required if affinityPolicy and volumePool not provided, otherwise ignored + DiskType string `json:"diskType,omitempty"` + + // Volume Name + // Required: true + Name *string `json:"name"` + + // Indicates if the volume should be replication enabled or not + ReplicationEnabled *bool `json:"replicationEnabled,omitempty"` + + // Indicates if the volume is shareable between VMs + Shareable *bool `json:"shareable,omitempty"` + + // Volume Size (GB) + // Required: true + Size *float64 `json:"size"` + + // Volume pool where the volume will be created; if provided then diskType and affinityPolicy values will be ignored + VolumePool string `json:"volumePool,omitempty"` +} + +// Validate validates this create data volume +func (m *CreateDataVolume) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAffinityPolicy(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSize(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +var createDataVolumeTypeAffinityPolicyPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["affinity","anti-affinity"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + createDataVolumeTypeAffinityPolicyPropEnum = append(createDataVolumeTypeAffinityPolicyPropEnum, v) + } +} + +const ( + + // CreateDataVolumeAffinityPolicyAffinity captures enum value "affinity" + CreateDataVolumeAffinityPolicyAffinity string = "affinity" + + // CreateDataVolumeAffinityPolicyAntiDashAffinity captures enum value "anti-affinity" + CreateDataVolumeAffinityPolicyAntiDashAffinity string = "anti-affinity" +) + +// prop value enum +func (m *CreateDataVolume) validateAffinityPolicyEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, createDataVolumeTypeAffinityPolicyPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *CreateDataVolume) validateAffinityPolicy(formats strfmt.Registry) error { + if swag.IsZero(m.AffinityPolicy) { // not required + return nil + } + + // value enum + if err := m.validateAffinityPolicyEnum("affinityPolicy", "body", *m.AffinityPolicy); err != nil { + return err + } + + return nil +} + +func (m *CreateDataVolume) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *CreateDataVolume) validateSize(formats strfmt.Registry) error { + + if err := validate.Required("size", "body", m.Size); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this create data volume based on context it is used +func (m *CreateDataVolume) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *CreateDataVolume) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CreateDataVolume) UnmarshalBinary(b []byte) error { + var res CreateDataVolume + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/create_image.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/create_image.go new file mode 100644 index 00000000000..b55fb483db9 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/create_image.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// CreateImage create image +// +// swagger:model CreateImage +type CreateImage struct { + + // Cloud Storage access key; required for import image + AccessKey string `json:"accessKey,omitempty"` + + // Cloud Storage bucket name; bucket-name[/optional/folder]; required for import image + BucketName string `json:"bucketName,omitempty"` + + // Type of Disk; will be ignored if storagePool or affinityPolicy is provided; Used only when importing an image from cloud storage. + DiskType string `json:"diskType,omitempty"` + + // Cloud Storage image filename; required for import image + ImageFilename string `json:"imageFilename,omitempty"` + + // Image ID of existing source image; required for copy image + ImageID string `json:"imageID,omitempty"` + + // Name to give created image; required for import image + ImageName string `json:"imageName,omitempty"` + + // (deprecated - replaced by region, imageFilename and bucketName) Path to image starting with service endpoint and ending with image filename + ImagePath string `json:"imagePath,omitempty"` + + // Image OS Type, required if importing a raw image; raw images can only be imported using the command line interface + // Enum: [aix ibmi rhel sles] + OsType string `json:"osType,omitempty"` + + // Cloud Storage Region; only required to access IBM Cloud Storage + Region string `json:"region,omitempty"` + + // Cloud Storage secret key; required for import image + SecretKey string `json:"secretKey,omitempty"` + + // Source of the image + // Required: true + // Enum: [root-project url] + Source *string `json:"source"` + + // The storage affinity data; ignored if storagePool is provided; Used only when importing an image from cloud storage. + StorageAffinity *StorageAffinity `json:"storageAffinity,omitempty"` + + // Storage pool where the image will be loaded; if provided then storageAffinity and diskType will be ignored; Used only when importing an image from cloud storage. + StoragePool string `json:"storagePool,omitempty"` +} + +// Validate validates this create image +func (m *CreateImage) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateOsType(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSource(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStorageAffinity(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +var createImageTypeOsTypePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["aix","ibmi","rhel","sles"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + createImageTypeOsTypePropEnum = append(createImageTypeOsTypePropEnum, v) + } +} + +const ( + + // CreateImageOsTypeAix captures enum value "aix" + CreateImageOsTypeAix string = "aix" + + // CreateImageOsTypeIbmi captures enum value "ibmi" + CreateImageOsTypeIbmi string = "ibmi" + + // CreateImageOsTypeRhel captures enum value "rhel" + CreateImageOsTypeRhel string = "rhel" + + // CreateImageOsTypeSles captures enum value "sles" + CreateImageOsTypeSles string = "sles" +) + +// prop value enum +func (m *CreateImage) validateOsTypeEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, createImageTypeOsTypePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *CreateImage) validateOsType(formats strfmt.Registry) error { + if swag.IsZero(m.OsType) { // not required + return nil + } + + // value enum + if err := m.validateOsTypeEnum("osType", "body", m.OsType); err != nil { + return err + } + + return nil +} + +var createImageTypeSourcePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["root-project","url"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + createImageTypeSourcePropEnum = append(createImageTypeSourcePropEnum, v) + } +} + +const ( + + // CreateImageSourceRootDashProject captures enum value "root-project" + CreateImageSourceRootDashProject string = "root-project" + + // CreateImageSourceURL captures enum value "url" + CreateImageSourceURL string = "url" +) + +// prop value enum +func (m *CreateImage) validateSourceEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, createImageTypeSourcePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *CreateImage) validateSource(formats strfmt.Registry) error { + + if err := validate.Required("source", "body", m.Source); err != nil { + return err + } + + // value enum + if err := m.validateSourceEnum("source", "body", *m.Source); err != nil { + return err + } + + return nil +} + +func (m *CreateImage) validateStorageAffinity(formats strfmt.Registry) error { + if swag.IsZero(m.StorageAffinity) { // not required + return nil + } + + if m.StorageAffinity != nil { + if err := m.StorageAffinity.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("storageAffinity") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("storageAffinity") + } + return err + } + } + + return nil +} + +// ContextValidate validate this create image based on the context it is used +func (m *CreateImage) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateStorageAffinity(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CreateImage) contextValidateStorageAffinity(ctx context.Context, formats strfmt.Registry) error { + + if m.StorageAffinity != nil { + if err := m.StorageAffinity.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("storageAffinity") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("storageAffinity") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *CreateImage) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CreateImage) UnmarshalBinary(b []byte) error { + var res CreateImage + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/d_h_c_p_server.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/d_h_c_p_server.go new file mode 100644 index 00000000000..5602d9d0a79 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/d_h_c_p_server.go @@ -0,0 +1,141 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// DHCPServer d h c p server +// +// swagger:model DHCPServer +type DHCPServer struct { + + // The ID of the DHCP Server + // Required: true + ID *string `json:"id"` + + // The DHCP Server private network + // Required: true + Network *DHCPServerNetwork `json:"network"` + + // The status of the DHCP Server + // Required: true + Status *string `json:"status"` +} + +// Validate validates this d h c p server +func (m *DHCPServer) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateNetwork(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStatus(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *DHCPServer) validateID(formats strfmt.Registry) error { + + if err := validate.Required("id", "body", m.ID); err != nil { + return err + } + + return nil +} + +func (m *DHCPServer) validateNetwork(formats strfmt.Registry) error { + + if err := validate.Required("network", "body", m.Network); err != nil { + return err + } + + if m.Network != nil { + if err := m.Network.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("network") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("network") + } + return err + } + } + + return nil +} + +func (m *DHCPServer) validateStatus(formats strfmt.Registry) error { + + if err := validate.Required("status", "body", m.Status); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this d h c p server based on the context it is used +func (m *DHCPServer) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateNetwork(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *DHCPServer) contextValidateNetwork(ctx context.Context, formats strfmt.Registry) error { + + if m.Network != nil { + if err := m.Network.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("network") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("network") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *DHCPServer) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *DHCPServer) UnmarshalBinary(b []byte) error { + var res DHCPServer + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/d_h_c_p_server_create.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/d_h_c_p_server_create.go new file mode 100644 index 00000000000..2098337b997 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/d_h_c_p_server_create.go @@ -0,0 +1,50 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// DHCPServerCreate d h c p server create +// +// swagger:model DHCPServerCreate +type DHCPServerCreate struct { + + // Optional cloud connection uuid to connect with DHCP private network + CloudConnectionID string `json:"cloudConnectionID,omitempty"` +} + +// Validate validates this d h c p server create +func (m *DHCPServerCreate) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this d h c p server create based on context it is used +func (m *DHCPServerCreate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *DHCPServerCreate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *DHCPServerCreate) UnmarshalBinary(b []byte) error { + var res DHCPServerCreate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/d_h_c_p_server_detail.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/d_h_c_p_server_detail.go new file mode 100644 index 00000000000..fc6284fff02 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/d_h_c_p_server_detail.go @@ -0,0 +1,199 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// DHCPServerDetail d h c p server detail +// +// swagger:model DHCPServerDetail +type DHCPServerDetail struct { + + // The ID of the DHCP Server + // Required: true + ID *string `json:"id"` + + // The list of DHCP Server PVM Instance leases + Leases []*DHCPServerLeases `json:"leases"` + + // The DHCP Server private network + // Required: true + Network *DHCPServerNetwork `json:"network"` + + // The status of the DHCP Server + // Required: true + Status *string `json:"status"` +} + +// Validate validates this d h c p server detail +func (m *DHCPServerDetail) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLeases(formats); err != nil { + res = append(res, err) + } + + if err := m.validateNetwork(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStatus(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *DHCPServerDetail) validateID(formats strfmt.Registry) error { + + if err := validate.Required("id", "body", m.ID); err != nil { + return err + } + + return nil +} + +func (m *DHCPServerDetail) validateLeases(formats strfmt.Registry) error { + if swag.IsZero(m.Leases) { // not required + return nil + } + + for i := 0; i < len(m.Leases); i++ { + if swag.IsZero(m.Leases[i]) { // not required + continue + } + + if m.Leases[i] != nil { + if err := m.Leases[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("leases" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("leases" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *DHCPServerDetail) validateNetwork(formats strfmt.Registry) error { + + if err := validate.Required("network", "body", m.Network); err != nil { + return err + } + + if m.Network != nil { + if err := m.Network.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("network") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("network") + } + return err + } + } + + return nil +} + +func (m *DHCPServerDetail) validateStatus(formats strfmt.Registry) error { + + if err := validate.Required("status", "body", m.Status); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this d h c p server detail based on the context it is used +func (m *DHCPServerDetail) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateLeases(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateNetwork(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *DHCPServerDetail) contextValidateLeases(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Leases); i++ { + + if m.Leases[i] != nil { + if err := m.Leases[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("leases" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("leases" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *DHCPServerDetail) contextValidateNetwork(ctx context.Context, formats strfmt.Registry) error { + + if m.Network != nil { + if err := m.Network.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("network") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("network") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *DHCPServerDetail) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *DHCPServerDetail) UnmarshalBinary(b []byte) error { + var res DHCPServerDetail + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/d_h_c_p_server_leases.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/d_h_c_p_server_leases.go new file mode 100644 index 00000000000..c2b6d3384f2 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/d_h_c_p_server_leases.go @@ -0,0 +1,88 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// DHCPServerLeases d h c p server leases +// +// swagger:model DHCPServerLeases +type DHCPServerLeases struct { + + // The IP of the PVM Instance + // Required: true + InstanceIP *string `json:"instanceIP"` + + // The MAC Address of the PVM Instance + // Required: true + InstanceMacAddress *string `json:"instanceMacAddress"` +} + +// Validate validates this d h c p server leases +func (m *DHCPServerLeases) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateInstanceIP(formats); err != nil { + res = append(res, err) + } + + if err := m.validateInstanceMacAddress(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *DHCPServerLeases) validateInstanceIP(formats strfmt.Registry) error { + + if err := validate.Required("instanceIP", "body", m.InstanceIP); err != nil { + return err + } + + return nil +} + +func (m *DHCPServerLeases) validateInstanceMacAddress(formats strfmt.Registry) error { + + if err := validate.Required("instanceMacAddress", "body", m.InstanceMacAddress); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this d h c p server leases based on context it is used +func (m *DHCPServerLeases) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *DHCPServerLeases) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *DHCPServerLeases) UnmarshalBinary(b []byte) error { + var res DHCPServerLeases + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/d_h_c_p_server_network.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/d_h_c_p_server_network.go new file mode 100644 index 00000000000..52e05233de5 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/d_h_c_p_server_network.go @@ -0,0 +1,88 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// DHCPServerNetwork d h c p server network +// +// swagger:model DHCPServerNetwork +type DHCPServerNetwork struct { + + // The ID of the network + // Required: true + ID *string `json:"id"` + + // The name of the network + // Required: true + Name *string `json:"name"` +} + +// Validate validates this d h c p server network +func (m *DHCPServerNetwork) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *DHCPServerNetwork) validateID(formats strfmt.Registry) error { + + if err := validate.Required("id", "body", m.ID); err != nil { + return err + } + + return nil +} + +func (m *DHCPServerNetwork) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this d h c p server network based on context it is used +func (m *DHCPServerNetwork) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *DHCPServerNetwork) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *DHCPServerNetwork) UnmarshalBinary(b []byte) error { + var res DHCPServerNetwork + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/d_h_c_p_servers.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/d_h_c_p_servers.go new file mode 100644 index 00000000000..947db73c45e --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/d_h_c_p_servers.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// DHCPServers The list of DHCP Servers +// +// swagger:model DHCPServers +type DHCPServers []*DHCPServer + +// Validate validates this d h c p servers +func (m DHCPServers) Validate(formats strfmt.Registry) error { + var res []error + + for i := 0; i < len(m); i++ { + if swag.IsZero(m[i]) { // not required + continue + } + + if m[i] != nil { + if err := m[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(strconv.Itoa(i)) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validate this d h c p servers based on the context it is used +func (m DHCPServers) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + for i := 0; i < len(m); i++ { + + if m[i] != nil { + if err := m[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(strconv.Itoa(i)) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/dashboard_client.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/dashboard_client.go new file mode 100644 index 00000000000..bb752401bd8 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/dashboard_client.go @@ -0,0 +1,56 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// DashboardClient dashboard client +// +// swagger:model DashboardClient +type DashboardClient struct { + + // id + ID string `json:"id,omitempty"` + + // redirect uri + RedirectURI string `json:"redirect_uri,omitempty"` + + // secret + Secret string `json:"secret,omitempty"` +} + +// Validate validates this dashboard client +func (m *DashboardClient) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this dashboard client based on context it is used +func (m *DashboardClient) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *DashboardClient) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *DashboardClient) UnmarshalBinary(b []byte) error { + var res DashboardClient + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/dead_peer_detection.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/dead_peer_detection.go new file mode 100644 index 00000000000..89688eaa114 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/dead_peer_detection.go @@ -0,0 +1,160 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// DeadPeerDetection Dead Peer Detection of the VPN Connection +// +// swagger:model DeadPeerDetection +type DeadPeerDetection struct { + + // Action to take when a Peer Gateway stops responding + // Required: true + // Enum: [restart] + Action *string `json:"action"` + + // How often to test that the Peer Gateway is responsive + // Example: 10 + // Required: true + // Maximum: 60 + // Minimum: 2 + Interval *int64 `json:"interval"` + + // The number of attempts to connect before tearing down the connection + // Example: 5 + // Required: true + // Maximum: 5 + // Minimum: 1 + Threshold *int64 `json:"threshold"` +} + +// Validate validates this dead peer detection +func (m *DeadPeerDetection) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAction(formats); err != nil { + res = append(res, err) + } + + if err := m.validateInterval(formats); err != nil { + res = append(res, err) + } + + if err := m.validateThreshold(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +var deadPeerDetectionTypeActionPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["restart"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + deadPeerDetectionTypeActionPropEnum = append(deadPeerDetectionTypeActionPropEnum, v) + } +} + +const ( + + // DeadPeerDetectionActionRestart captures enum value "restart" + DeadPeerDetectionActionRestart string = "restart" +) + +// prop value enum +func (m *DeadPeerDetection) validateActionEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, deadPeerDetectionTypeActionPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *DeadPeerDetection) validateAction(formats strfmt.Registry) error { + + if err := validate.Required("action", "body", m.Action); err != nil { + return err + } + + // value enum + if err := m.validateActionEnum("action", "body", *m.Action); err != nil { + return err + } + + return nil +} + +func (m *DeadPeerDetection) validateInterval(formats strfmt.Registry) error { + + if err := validate.Required("interval", "body", m.Interval); err != nil { + return err + } + + if err := validate.MinimumInt("interval", "body", *m.Interval, 2, false); err != nil { + return err + } + + if err := validate.MaximumInt("interval", "body", *m.Interval, 60, false); err != nil { + return err + } + + return nil +} + +func (m *DeadPeerDetection) validateThreshold(formats strfmt.Registry) error { + + if err := validate.Required("threshold", "body", m.Threshold); err != nil { + return err + } + + if err := validate.MinimumInt("threshold", "body", *m.Threshold, 1, false); err != nil { + return err + } + + if err := validate.MaximumInt("threshold", "body", *m.Threshold, 5, false); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this dead peer detection based on context it is used +func (m *DeadPeerDetection) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *DeadPeerDetection) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *DeadPeerDetection) UnmarshalBinary(b []byte) error { + var res DeadPeerDetection + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/device_code.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/device_code.go new file mode 100644 index 00000000000..7cb9a748806 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/device_code.go @@ -0,0 +1,139 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// DeviceCode device code +// +// swagger:model DeviceCode +type DeviceCode struct { + + // This code lets the device running the app securely determine whether the user has granted or denied access + // Required: true + DeviceCode *string `json:"deviceCode"` + + // The length of time, in seconds, that the device_code and user_code are valid + // Required: true + ExpiresIn *float64 `json:"expiresIn"` + + // The length of time, in seconds, that your device should wait between polling requests + // Required: true + Interval *float64 `json:"interval"` + + // The value given to the user to enter on device authentication page + // Required: true + UserCode *string `json:"userCode"` + + // A URL that the user must navigate to, on a separate device, to enter the user_code and grant or deny access to your application. Your user interface will also display this value + // Required: true + VerificationURL *string `json:"verificationURL"` +} + +// Validate validates this device code +func (m *DeviceCode) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateDeviceCode(formats); err != nil { + res = append(res, err) + } + + if err := m.validateExpiresIn(formats); err != nil { + res = append(res, err) + } + + if err := m.validateInterval(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUserCode(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVerificationURL(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *DeviceCode) validateDeviceCode(formats strfmt.Registry) error { + + if err := validate.Required("deviceCode", "body", m.DeviceCode); err != nil { + return err + } + + return nil +} + +func (m *DeviceCode) validateExpiresIn(formats strfmt.Registry) error { + + if err := validate.Required("expiresIn", "body", m.ExpiresIn); err != nil { + return err + } + + return nil +} + +func (m *DeviceCode) validateInterval(formats strfmt.Registry) error { + + if err := validate.Required("interval", "body", m.Interval); err != nil { + return err + } + + return nil +} + +func (m *DeviceCode) validateUserCode(formats strfmt.Registry) error { + + if err := validate.Required("userCode", "body", m.UserCode); err != nil { + return err + } + + return nil +} + +func (m *DeviceCode) validateVerificationURL(formats strfmt.Registry) error { + + if err := validate.Required("verificationURL", "body", m.VerificationURL); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this device code based on context it is used +func (m *DeviceCode) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *DeviceCode) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *DeviceCode) UnmarshalBinary(b []byte) error { + var res DeviceCode + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/error.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/error.go new file mode 100644 index 00000000000..a7c90934c30 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/error.go @@ -0,0 +1,59 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Error error +// +// swagger:model Error +type Error struct { + + // code + Code int64 `json:"code,omitempty"` + + // description + Description string `json:"description,omitempty"` + + // error + Error string `json:"error,omitempty"` + + // message + Message string `json:"message,omitempty"` +} + +// Validate validates this error +func (m *Error) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this error based on context it is used +func (m *Error) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Error) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Error) UnmarshalBinary(b []byte) error { + var res Error + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/event.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/event.go new file mode 100644 index 00000000000..b9190c8f625 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/event.go @@ -0,0 +1,274 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Event event +// +// swagger:model Event +type Event struct { + + // Type of action for this event + // Required: true + Action *string `json:"action"` + + // ID of the Activity + // Required: true + EventID *string `json:"eventID"` + + // Level of the event (notice, info, warning, error) + // Required: true + // Enum: [notice info warning error] + Level *string `json:"level"` + + // The (translated) message of the event + // Required: true + Message *string `json:"message"` + + // Any metadata associated with the event + Metadata interface{} `json:"metadata,omitempty"` + + // Type of resource for this event + // Required: true + Resource *string `json:"resource"` + + // Time of activity in ISO 8601 - RFC3339 + // Required: true + // Format: date-time + Time *strfmt.DateTime `json:"time"` + + // Time of activity in unix epoch + // Required: true + Timestamp *int64 `json:"timestamp"` + + // user + User *EventUser `json:"user,omitempty"` +} + +// Validate validates this event +func (m *Event) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAction(formats); err != nil { + res = append(res, err) + } + + if err := m.validateEventID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLevel(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMessage(formats); err != nil { + res = append(res, err) + } + + if err := m.validateResource(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTimestamp(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUser(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Event) validateAction(formats strfmt.Registry) error { + + if err := validate.Required("action", "body", m.Action); err != nil { + return err + } + + return nil +} + +func (m *Event) validateEventID(formats strfmt.Registry) error { + + if err := validate.Required("eventID", "body", m.EventID); err != nil { + return err + } + + return nil +} + +var eventTypeLevelPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["notice","info","warning","error"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + eventTypeLevelPropEnum = append(eventTypeLevelPropEnum, v) + } +} + +const ( + + // EventLevelNotice captures enum value "notice" + EventLevelNotice string = "notice" + + // EventLevelInfo captures enum value "info" + EventLevelInfo string = "info" + + // EventLevelWarning captures enum value "warning" + EventLevelWarning string = "warning" + + // EventLevelError captures enum value "error" + EventLevelError string = "error" +) + +// prop value enum +func (m *Event) validateLevelEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, eventTypeLevelPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *Event) validateLevel(formats strfmt.Registry) error { + + if err := validate.Required("level", "body", m.Level); err != nil { + return err + } + + // value enum + if err := m.validateLevelEnum("level", "body", *m.Level); err != nil { + return err + } + + return nil +} + +func (m *Event) validateMessage(formats strfmt.Registry) error { + + if err := validate.Required("message", "body", m.Message); err != nil { + return err + } + + return nil +} + +func (m *Event) validateResource(formats strfmt.Registry) error { + + if err := validate.Required("resource", "body", m.Resource); err != nil { + return err + } + + return nil +} + +func (m *Event) validateTime(formats strfmt.Registry) error { + + if err := validate.Required("time", "body", m.Time); err != nil { + return err + } + + if err := validate.FormatOf("time", "body", "date-time", m.Time.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *Event) validateTimestamp(formats strfmt.Registry) error { + + if err := validate.Required("timestamp", "body", m.Timestamp); err != nil { + return err + } + + return nil +} + +func (m *Event) validateUser(formats strfmt.Registry) error { + if swag.IsZero(m.User) { // not required + return nil + } + + if m.User != nil { + if err := m.User.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("user") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("user") + } + return err + } + } + + return nil +} + +// ContextValidate validate this event based on the context it is used +func (m *Event) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateUser(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Event) contextValidateUser(ctx context.Context, formats strfmt.Registry) error { + + if m.User != nil { + if err := m.User.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("user") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("user") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Event) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Event) UnmarshalBinary(b []byte) error { + var res Event + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/event_user.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/event_user.go new file mode 100644 index 00000000000..a20b42b1e9a --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/event_user.go @@ -0,0 +1,77 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// EventUser event user +// +// swagger:model EventUser +type EventUser struct { + + // Email of the User + Email string `json:"email,omitempty"` + + // Name of the User + Name string `json:"name,omitempty"` + + // ID of user who created/caused the event + // Required: true + UserID *string `json:"userID"` +} + +// Validate validates this event user +func (m *EventUser) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateUserID(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *EventUser) validateUserID(formats strfmt.Registry) error { + + if err := validate.Required("userID", "body", m.UserID); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this event user based on context it is used +func (m *EventUser) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *EventUser) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *EventUser) UnmarshalBinary(b []byte) error { + var res EventUser + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/events.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/events.go new file mode 100644 index 00000000000..721b97fcf45 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/events.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Events events +// +// swagger:model Events +type Events struct { + + // Events + // Required: true + Events []*Event `json:"events"` +} + +// Validate validates this events +func (m *Events) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateEvents(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Events) validateEvents(formats strfmt.Registry) error { + + if err := validate.Required("events", "body", m.Events); err != nil { + return err + } + + for i := 0; i < len(m.Events); i++ { + if swag.IsZero(m.Events[i]) { // not required + continue + } + + if m.Events[i] != nil { + if err := m.Events[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("events" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("events" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this events based on the context it is used +func (m *Events) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateEvents(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Events) contextValidateEvents(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Events); i++ { + + if m.Events[i] != nil { + if err := m.Events[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("events" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("events" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Events) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Events) UnmarshalBinary(b []byte) error { + var res Events + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/export_image.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/export_image.go new file mode 100644 index 00000000000..1f8a17dd228 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/export_image.go @@ -0,0 +1,94 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ExportImage export image +// +// swagger:model ExportImage +type ExportImage struct { + + // Cloud Object Storage Access key + // Required: true + AccessKey *string `json:"accessKey"` + + // Cloud Object Storage Bucket name + // Required: true + BucketName *string `json:"bucketName"` + + // Cloud Object Storage Region; required for IBM COS + Region string `json:"region,omitempty"` + + // Cloud Object Storage Secret key + SecretKey string `json:"secretKey,omitempty"` +} + +// Validate validates this export image +func (m *ExportImage) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAccessKey(formats); err != nil { + res = append(res, err) + } + + if err := m.validateBucketName(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ExportImage) validateAccessKey(formats strfmt.Registry) error { + + if err := validate.Required("accessKey", "body", m.AccessKey); err != nil { + return err + } + + return nil +} + +func (m *ExportImage) validateBucketName(formats strfmt.Registry) error { + + if err := validate.Required("bucketName", "body", m.BucketName); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this export image based on context it is used +func (m *ExportImage) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ExportImage) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ExportImage) UnmarshalBinary(b []byte) error { + var res ExportImage + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/hardware_platform.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/hardware_platform.go new file mode 100644 index 00000000000..8c78c41fcf9 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/hardware_platform.go @@ -0,0 +1,134 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// HardwarePlatform Hardware platform detailing its limits and statistics +// +// swagger:model HardwarePlatform +type HardwarePlatform struct { + + // Description + Description string `json:"description,omitempty"` + + // The DataCenter list of servers and their available resources + HostsResources []*HostResources `json:"hostsResources"` + + // Configured Memory GB + Memory float64 `json:"memory,omitempty"` + + // Processor to Memory (GB) Ratio + ProcessorMemoryRatio float64 `json:"processorMemoryRatio,omitempty"` + + // Configured Processors + Processors float64 `json:"processors,omitempty"` + + // Allowable granularity for shared processors + SharedProcessorStep float64 `json:"sharedProcessorStep,omitempty"` + + // Short code for hardware + Type string `json:"type,omitempty"` +} + +// Validate validates this hardware platform +func (m *HardwarePlatform) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateHostsResources(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *HardwarePlatform) validateHostsResources(formats strfmt.Registry) error { + if swag.IsZero(m.HostsResources) { // not required + return nil + } + + for i := 0; i < len(m.HostsResources); i++ { + if swag.IsZero(m.HostsResources[i]) { // not required + continue + } + + if m.HostsResources[i] != nil { + if err := m.HostsResources[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("hostsResources" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("hostsResources" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this hardware platform based on the context it is used +func (m *HardwarePlatform) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateHostsResources(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *HardwarePlatform) contextValidateHostsResources(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.HostsResources); i++ { + + if m.HostsResources[i] != nil { + if err := m.HostsResources[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("hostsResources" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("hostsResources" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *HardwarePlatform) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *HardwarePlatform) UnmarshalBinary(b []byte) error { + var res HardwarePlatform + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/hardware_platforms.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/hardware_platforms.go new file mode 100644 index 00000000000..8e98a5e08e2 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/hardware_platforms.go @@ -0,0 +1,67 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// HardwarePlatforms A map of hardware platforms detailing their limits and statistics +// +// swagger:model HardwarePlatforms +type HardwarePlatforms map[string]HardwarePlatform + +// Validate validates this hardware platforms +func (m HardwarePlatforms) Validate(formats strfmt.Registry) error { + var res []error + + for k := range m { + + if err := validate.Required(k, "body", m[k]); err != nil { + return err + } + if val, ok := m[k]; ok { + if err := val.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(k) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(k) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validate this hardware platforms based on the context it is used +func (m HardwarePlatforms) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + for k := range m { + + if val, ok := m[k]; ok { + if err := val.ContextValidate(ctx, formats); err != nil { + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/health.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/health.go new file mode 100644 index 00000000000..b94914a5e75 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/health.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Health health +// +// swagger:model Health +type Health struct { + + // Returns a description of the current servers health + // Required: true + Status *string `json:"status"` +} + +// Validate validates this health +func (m *Health) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateStatus(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Health) validateStatus(formats strfmt.Registry) error { + + if err := validate.Required("status", "body", m.Status); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this health based on context it is used +func (m *Health) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Health) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Health) UnmarshalBinary(b []byte) error { + var res Health + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/host_info.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/host_info.go new file mode 100644 index 00000000000..ab262805407 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/host_info.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// HostInfo host info +// +// swagger:model HostInfo +type HostInfo struct { + + // Host core information + // Required: true + Cores *HostResource `json:"cores"` + + // Hostname + // Required: true + Hostname *string `json:"hostname"` + + // IP Address + // Required: true + IPAddress *string `json:"ipAddress"` + + // Host memory information + // Required: true + Memory *HostResource `json:"memory"` + + // PVM Instances on host + // Required: true + PvmInstances []*HostPVMInstance `json:"pvmInstances"` +} + +// Validate validates this host info +func (m *HostInfo) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCores(formats); err != nil { + res = append(res, err) + } + + if err := m.validateHostname(formats); err != nil { + res = append(res, err) + } + + if err := m.validateIPAddress(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMemory(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePvmInstances(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *HostInfo) validateCores(formats strfmt.Registry) error { + + if err := validate.Required("cores", "body", m.Cores); err != nil { + return err + } + + if m.Cores != nil { + if err := m.Cores.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("cores") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cores") + } + return err + } + } + + return nil +} + +func (m *HostInfo) validateHostname(formats strfmt.Registry) error { + + if err := validate.Required("hostname", "body", m.Hostname); err != nil { + return err + } + + return nil +} + +func (m *HostInfo) validateIPAddress(formats strfmt.Registry) error { + + if err := validate.Required("ipAddress", "body", m.IPAddress); err != nil { + return err + } + + return nil +} + +func (m *HostInfo) validateMemory(formats strfmt.Registry) error { + + if err := validate.Required("memory", "body", m.Memory); err != nil { + return err + } + + if m.Memory != nil { + if err := m.Memory.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("memory") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("memory") + } + return err + } + } + + return nil +} + +func (m *HostInfo) validatePvmInstances(formats strfmt.Registry) error { + + if err := validate.Required("pvmInstances", "body", m.PvmInstances); err != nil { + return err + } + + for i := 0; i < len(m.PvmInstances); i++ { + if swag.IsZero(m.PvmInstances[i]) { // not required + continue + } + + if m.PvmInstances[i] != nil { + if err := m.PvmInstances[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("pvmInstances" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("pvmInstances" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this host info based on the context it is used +func (m *HostInfo) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateCores(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMemory(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidatePvmInstances(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *HostInfo) contextValidateCores(ctx context.Context, formats strfmt.Registry) error { + + if m.Cores != nil { + if err := m.Cores.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("cores") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cores") + } + return err + } + } + + return nil +} + +func (m *HostInfo) contextValidateMemory(ctx context.Context, formats strfmt.Registry) error { + + if m.Memory != nil { + if err := m.Memory.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("memory") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("memory") + } + return err + } + } + + return nil +} + +func (m *HostInfo) contextValidatePvmInstances(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.PvmInstances); i++ { + + if m.PvmInstances[i] != nil { + if err := m.PvmInstances[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("pvmInstances" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("pvmInstances" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *HostInfo) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *HostInfo) UnmarshalBinary(b []byte) error { + var res HostInfo + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/host_p_vm_instance.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/host_p_vm_instance.go new file mode 100644 index 00000000000..5a04d4fbd87 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/host_p_vm_instance.go @@ -0,0 +1,192 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// HostPVMInstance A pvm instance on host +// +// swagger:model HostPVMInstance +type HostPVMInstance struct { + + // Cloud Instance ID pvm instance is a member of + // Required: true + CloudInstanceID *string `json:"cloudInstanceID"` + + // Owner information of pvm instance + // Required: true + Owner *OwnerInfo `json:"owner"` + + // Instance ID + // Required: true + PvmInstanceID *string `json:"pvmInstanceID"` + + // Instance name + // Required: true + PvmName *string `json:"pvmName"` + + // State of pvm instance + // Required: true + State *string `json:"state"` + + // Tenant ID of pvm instance + // Required: true + TenantID *string `json:"tenantID"` +} + +// Validate validates this host p VM instance +func (m *HostPVMInstance) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCloudInstanceID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOwner(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePvmInstanceID(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePvmName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateState(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTenantID(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *HostPVMInstance) validateCloudInstanceID(formats strfmt.Registry) error { + + if err := validate.Required("cloudInstanceID", "body", m.CloudInstanceID); err != nil { + return err + } + + return nil +} + +func (m *HostPVMInstance) validateOwner(formats strfmt.Registry) error { + + if err := validate.Required("owner", "body", m.Owner); err != nil { + return err + } + + if m.Owner != nil { + if err := m.Owner.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("owner") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("owner") + } + return err + } + } + + return nil +} + +func (m *HostPVMInstance) validatePvmInstanceID(formats strfmt.Registry) error { + + if err := validate.Required("pvmInstanceID", "body", m.PvmInstanceID); err != nil { + return err + } + + return nil +} + +func (m *HostPVMInstance) validatePvmName(formats strfmt.Registry) error { + + if err := validate.Required("pvmName", "body", m.PvmName); err != nil { + return err + } + + return nil +} + +func (m *HostPVMInstance) validateState(formats strfmt.Registry) error { + + if err := validate.Required("state", "body", m.State); err != nil { + return err + } + + return nil +} + +func (m *HostPVMInstance) validateTenantID(formats strfmt.Registry) error { + + if err := validate.Required("tenantID", "body", m.TenantID); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this host p VM instance based on the context it is used +func (m *HostPVMInstance) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateOwner(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *HostPVMInstance) contextValidateOwner(ctx context.Context, formats strfmt.Registry) error { + + if m.Owner != nil { + if err := m.Owner.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("owner") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("owner") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *HostPVMInstance) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *HostPVMInstance) UnmarshalBinary(b []byte) error { + var res HostPVMInstance + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/host_resource.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/host_resource.go new file mode 100644 index 00000000000..aef626fbe8e --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/host_resource.go @@ -0,0 +1,105 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// HostResource host resource +// +// swagger:model HostResource +type HostResource struct { + + // Free + // Required: true + Free *float64 `json:"free"` + + // Total + // Required: true + Total *float64 `json:"total"` + + // Used + // Required: true + Used *float64 `json:"used"` +} + +// Validate validates this host resource +func (m *HostResource) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateFree(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTotal(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUsed(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *HostResource) validateFree(formats strfmt.Registry) error { + + if err := validate.Required("free", "body", m.Free); err != nil { + return err + } + + return nil +} + +func (m *HostResource) validateTotal(formats strfmt.Registry) error { + + if err := validate.Required("total", "body", m.Total); err != nil { + return err + } + + return nil +} + +func (m *HostResource) validateUsed(formats strfmt.Registry) error { + + if err := validate.Required("used", "body", m.Used); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this host resource based on context it is used +func (m *HostResource) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *HostResource) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *HostResource) UnmarshalBinary(b []byte) error { + var res HostResource + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/host_resources.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/host_resources.go new file mode 100644 index 00000000000..40b3b8652f1 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/host_resources.go @@ -0,0 +1,105 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// HostResources host resources +// +// swagger:model HostResources +type HostResources struct { + + // The host available Processor units + // Required: true + Cores *float64 `json:"cores"` + + // The host identifier + // Required: true + ID *int64 `json:"id"` + + // The host available RAM memory in GiB + // Required: true + Memory *int64 `json:"memory"` +} + +// Validate validates this host resources +func (m *HostResources) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCores(formats); err != nil { + res = append(res, err) + } + + if err := m.validateID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMemory(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *HostResources) validateCores(formats strfmt.Registry) error { + + if err := validate.Required("cores", "body", m.Cores); err != nil { + return err + } + + return nil +} + +func (m *HostResources) validateID(formats strfmt.Registry) error { + + if err := validate.Required("id", "body", m.ID); err != nil { + return err + } + + return nil +} + +func (m *HostResources) validateMemory(formats strfmt.Registry) error { + + if err := validate.Required("memory", "body", m.Memory); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this host resources based on context it is used +func (m *HostResources) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *HostResources) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *HostResources) UnmarshalBinary(b []byte) error { + var res HostResources + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policies.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policies.go new file mode 100644 index 00000000000..5cfe23d7a87 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policies.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// IKEPolicies i k e policies +// +// swagger:model IKEPolicies +type IKEPolicies struct { + + // IKE Policies array + // Required: true + IkePolicies []*IKEPolicy `json:"ikePolicies"` +} + +// Validate validates this i k e policies +func (m *IKEPolicies) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateIkePolicies(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *IKEPolicies) validateIkePolicies(formats strfmt.Registry) error { + + if err := validate.Required("ikePolicies", "body", m.IkePolicies); err != nil { + return err + } + + for i := 0; i < len(m.IkePolicies); i++ { + if swag.IsZero(m.IkePolicies[i]) { // not required + continue + } + + if m.IkePolicies[i] != nil { + if err := m.IkePolicies[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ikePolicies" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ikePolicies" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this i k e policies based on the context it is used +func (m *IKEPolicies) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateIkePolicies(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *IKEPolicies) contextValidateIkePolicies(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.IkePolicies); i++ { + + if m.IkePolicies[i] != nil { + if err := m.IkePolicies[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ikePolicies" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ikePolicies" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *IKEPolicies) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *IKEPolicies) UnmarshalBinary(b []byte) error { + var res IKEPolicies + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policy.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policy.go new file mode 100644 index 00000000000..c6eb1bd7968 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policy.go @@ -0,0 +1,353 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// IKEPolicy IKE Policy object +// +// swagger:model IKEPolicy +type IKEPolicy struct { + + // authentication + // Required: true + Authentication *IKEPolicyAuthentication `json:"authentication"` + + // DH group of the IKE Policy + // Example: 2 + // Required: true + // Enum: [1 2 5 14 19 20 24] + DhGroup *int64 `json:"dhGroup"` + + // encryption of the IKE Policy + // Example: aes-256-cbc + // Required: true + // Enum: [aes-256-cbc aes-192-cbc aes-128-cbc aes-256-gcm aes-128-gcm 3des-cbc] + Encryption *string `json:"encryption"` + + // unique identifier of the IKE Policy object + // Example: 7edc8988-eb18-4b5c-a594-0d73d8254463 + // Required: true + ID *string `json:"id"` + + // key lifetime + // Required: true + KeyLifetime *KeyLifetime `json:"keyLifetime"` + + // name of the IKE Policy + // Example: ikePolicy1 + // Required: true + Name *string `json:"name"` + + // version of the IKE Policy + // Example: 2 + // Required: true + // Enum: [1 2] + Version *int64 `json:"version"` +} + +// Validate validates this i k e policy +func (m *IKEPolicy) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAuthentication(formats); err != nil { + res = append(res, err) + } + + if err := m.validateDhGroup(formats); err != nil { + res = append(res, err) + } + + if err := m.validateEncryption(formats); err != nil { + res = append(res, err) + } + + if err := m.validateID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateKeyLifetime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVersion(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *IKEPolicy) validateAuthentication(formats strfmt.Registry) error { + + if err := validate.Required("authentication", "body", m.Authentication); err != nil { + return err + } + + if err := validate.Required("authentication", "body", m.Authentication); err != nil { + return err + } + + if m.Authentication != nil { + if err := m.Authentication.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("authentication") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("authentication") + } + return err + } + } + + return nil +} + +var iKEPolicyTypeDhGroupPropEnum []interface{} + +func init() { + var res []int64 + if err := json.Unmarshal([]byte(`[1,2,5,14,19,20,24]`), &res); err != nil { + panic(err) + } + for _, v := range res { + iKEPolicyTypeDhGroupPropEnum = append(iKEPolicyTypeDhGroupPropEnum, v) + } +} + +// prop value enum +func (m *IKEPolicy) validateDhGroupEnum(path, location string, value int64) error { + if err := validate.EnumCase(path, location, value, iKEPolicyTypeDhGroupPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *IKEPolicy) validateDhGroup(formats strfmt.Registry) error { + + if err := validate.Required("dhGroup", "body", m.DhGroup); err != nil { + return err + } + + // value enum + if err := m.validateDhGroupEnum("dhGroup", "body", *m.DhGroup); err != nil { + return err + } + + return nil +} + +var iKEPolicyTypeEncryptionPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["aes-256-cbc","aes-192-cbc","aes-128-cbc","aes-256-gcm","aes-128-gcm","3des-cbc"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + iKEPolicyTypeEncryptionPropEnum = append(iKEPolicyTypeEncryptionPropEnum, v) + } +} + +const ( + + // IKEPolicyEncryptionAesDash256DashCbc captures enum value "aes-256-cbc" + IKEPolicyEncryptionAesDash256DashCbc string = "aes-256-cbc" + + // IKEPolicyEncryptionAesDash192DashCbc captures enum value "aes-192-cbc" + IKEPolicyEncryptionAesDash192DashCbc string = "aes-192-cbc" + + // IKEPolicyEncryptionAesDash128DashCbc captures enum value "aes-128-cbc" + IKEPolicyEncryptionAesDash128DashCbc string = "aes-128-cbc" + + // IKEPolicyEncryptionAesDash256DashGcm captures enum value "aes-256-gcm" + IKEPolicyEncryptionAesDash256DashGcm string = "aes-256-gcm" + + // IKEPolicyEncryptionAesDash128DashGcm captures enum value "aes-128-gcm" + IKEPolicyEncryptionAesDash128DashGcm string = "aes-128-gcm" + + // IKEPolicyEncryptionNr3desDashCbc captures enum value "3des-cbc" + IKEPolicyEncryptionNr3desDashCbc string = "3des-cbc" +) + +// prop value enum +func (m *IKEPolicy) validateEncryptionEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, iKEPolicyTypeEncryptionPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *IKEPolicy) validateEncryption(formats strfmt.Registry) error { + + if err := validate.Required("encryption", "body", m.Encryption); err != nil { + return err + } + + // value enum + if err := m.validateEncryptionEnum("encryption", "body", *m.Encryption); err != nil { + return err + } + + return nil +} + +func (m *IKEPolicy) validateID(formats strfmt.Registry) error { + + if err := validate.Required("id", "body", m.ID); err != nil { + return err + } + + return nil +} + +func (m *IKEPolicy) validateKeyLifetime(formats strfmt.Registry) error { + + if err := validate.Required("keyLifetime", "body", m.KeyLifetime); err != nil { + return err + } + + if err := validate.Required("keyLifetime", "body", m.KeyLifetime); err != nil { + return err + } + + if m.KeyLifetime != nil { + if err := m.KeyLifetime.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("keyLifetime") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("keyLifetime") + } + return err + } + } + + return nil +} + +func (m *IKEPolicy) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +var iKEPolicyTypeVersionPropEnum []interface{} + +func init() { + var res []int64 + if err := json.Unmarshal([]byte(`[1,2]`), &res); err != nil { + panic(err) + } + for _, v := range res { + iKEPolicyTypeVersionPropEnum = append(iKEPolicyTypeVersionPropEnum, v) + } +} + +// prop value enum +func (m *IKEPolicy) validateVersionEnum(path, location string, value int64) error { + if err := validate.EnumCase(path, location, value, iKEPolicyTypeVersionPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *IKEPolicy) validateVersion(formats strfmt.Registry) error { + + if err := validate.Required("version", "body", m.Version); err != nil { + return err + } + + // value enum + if err := m.validateVersionEnum("version", "body", *m.Version); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this i k e policy based on the context it is used +func (m *IKEPolicy) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateAuthentication(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateKeyLifetime(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *IKEPolicy) contextValidateAuthentication(ctx context.Context, formats strfmt.Registry) error { + + if m.Authentication != nil { + if err := m.Authentication.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("authentication") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("authentication") + } + return err + } + } + + return nil +} + +func (m *IKEPolicy) contextValidateKeyLifetime(ctx context.Context, formats strfmt.Registry) error { + + if m.KeyLifetime != nil { + if err := m.KeyLifetime.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("keyLifetime") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("keyLifetime") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *IKEPolicy) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *IKEPolicy) UnmarshalBinary(b []byte) error { + var res IKEPolicy + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policy_authentication.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policy_authentication.go new file mode 100644 index 00000000000..8cdd1e861f4 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policy_authentication.go @@ -0,0 +1,85 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// IKEPolicyAuthentication authentication of the IKE policy +// Example: sha-256 +// +// swagger:model IKEPolicyAuthentication +type IKEPolicyAuthentication string + +func NewIKEPolicyAuthentication(value IKEPolicyAuthentication) *IKEPolicyAuthentication { + return &value +} + +// Pointer returns a pointer to a freshly-allocated IKEPolicyAuthentication. +func (m IKEPolicyAuthentication) Pointer() *IKEPolicyAuthentication { + return &m +} + +const ( + + // IKEPolicyAuthenticationShaDash256 captures enum value "sha-256" + IKEPolicyAuthenticationShaDash256 IKEPolicyAuthentication = "sha-256" + + // IKEPolicyAuthenticationShaDash384 captures enum value "sha-384" + IKEPolicyAuthenticationShaDash384 IKEPolicyAuthentication = "sha-384" + + // IKEPolicyAuthenticationSha1 captures enum value "sha1" + IKEPolicyAuthenticationSha1 IKEPolicyAuthentication = "sha1" + + // IKEPolicyAuthenticationNone captures enum value "none" + IKEPolicyAuthenticationNone IKEPolicyAuthentication = "none" +) + +// for schema +var iKEPolicyAuthenticationEnum []interface{} + +func init() { + var res []IKEPolicyAuthentication + if err := json.Unmarshal([]byte(`["sha-256","sha-384","sha1","none"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + iKEPolicyAuthenticationEnum = append(iKEPolicyAuthenticationEnum, v) + } +} + +func (m IKEPolicyAuthentication) validateIKEPolicyAuthenticationEnum(path, location string, value IKEPolicyAuthentication) error { + if err := validate.EnumCase(path, location, value, iKEPolicyAuthenticationEnum, true); err != nil { + return err + } + return nil +} + +// Validate validates this i k e policy authentication +func (m IKEPolicyAuthentication) Validate(formats strfmt.Registry) error { + var res []error + + // value enum + if err := m.validateIKEPolicyAuthenticationEnum("", "body", m); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validates this i k e policy authentication based on context it is used +func (m IKEPolicyAuthentication) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policy_authentications.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policy_authentications.go new file mode 100644 index 00000000000..930a3d61fb6 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policy_authentications.go @@ -0,0 +1,28 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" +) + +// IKEPolicyAuthentications i k e policy authentications +// Example: ["sha-256","sha-384","sha1","none"] +// +// swagger:model IKEPolicyAuthentications +type IKEPolicyAuthentications []string + +// Validate validates this i k e policy authentications +func (m IKEPolicyAuthentications) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this i k e policy authentications based on context it is used +func (m IKEPolicyAuthentications) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policy_create.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policy_create.go new file mode 100644 index 00000000000..decb59aa550 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policy_create.go @@ -0,0 +1,352 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// IKEPolicyCreate IKE Policy object used for creation +// +// swagger:model IKEPolicyCreate +type IKEPolicyCreate struct { + + // authentication + Authentication IKEPolicyAuthentication `json:"authentication,omitempty"` + + // DH group of the IKE Policy + // Example: 2 + // Required: true + // Enum: [1 2 5 14 19 20 24] + DhGroup *int64 `json:"dhGroup"` + + // encryption of the IKE Policy + // Example: aes-256-cbc + // Required: true + // Enum: [aes-256-cbc aes-192-cbc aes-128-cbc aes-256-gcm aes-128-gcm 3des-cbc] + Encryption *string `json:"encryption"` + + // key lifetime + // Required: true + KeyLifetime *KeyLifetime `json:"keyLifetime"` + + // name of the IKE Policy + // Example: ikePolicy1 + // Required: true + // Max Length: 47 + // Min Length: 1 + Name *string `json:"name"` + + // Preshared key used in this IKE Policy (length of preshared key must be even) + // Required: true + PresharedKey *string `json:"presharedKey"` + + // version of the IKE Policy + // Example: 2 + // Required: true + // Enum: [1 2] + Version *int64 `json:"version"` +} + +// Validate validates this i k e policy create +func (m *IKEPolicyCreate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAuthentication(formats); err != nil { + res = append(res, err) + } + + if err := m.validateDhGroup(formats); err != nil { + res = append(res, err) + } + + if err := m.validateEncryption(formats); err != nil { + res = append(res, err) + } + + if err := m.validateKeyLifetime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePresharedKey(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVersion(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *IKEPolicyCreate) validateAuthentication(formats strfmt.Registry) error { + if swag.IsZero(m.Authentication) { // not required + return nil + } + + if err := m.Authentication.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("authentication") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("authentication") + } + return err + } + + return nil +} + +var iKEPolicyCreateTypeDhGroupPropEnum []interface{} + +func init() { + var res []int64 + if err := json.Unmarshal([]byte(`[1,2,5,14,19,20,24]`), &res); err != nil { + panic(err) + } + for _, v := range res { + iKEPolicyCreateTypeDhGroupPropEnum = append(iKEPolicyCreateTypeDhGroupPropEnum, v) + } +} + +// prop value enum +func (m *IKEPolicyCreate) validateDhGroupEnum(path, location string, value int64) error { + if err := validate.EnumCase(path, location, value, iKEPolicyCreateTypeDhGroupPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *IKEPolicyCreate) validateDhGroup(formats strfmt.Registry) error { + + if err := validate.Required("dhGroup", "body", m.DhGroup); err != nil { + return err + } + + // value enum + if err := m.validateDhGroupEnum("dhGroup", "body", *m.DhGroup); err != nil { + return err + } + + return nil +} + +var iKEPolicyCreateTypeEncryptionPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["aes-256-cbc","aes-192-cbc","aes-128-cbc","aes-256-gcm","aes-128-gcm","3des-cbc"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + iKEPolicyCreateTypeEncryptionPropEnum = append(iKEPolicyCreateTypeEncryptionPropEnum, v) + } +} + +const ( + + // IKEPolicyCreateEncryptionAesDash256DashCbc captures enum value "aes-256-cbc" + IKEPolicyCreateEncryptionAesDash256DashCbc string = "aes-256-cbc" + + // IKEPolicyCreateEncryptionAesDash192DashCbc captures enum value "aes-192-cbc" + IKEPolicyCreateEncryptionAesDash192DashCbc string = "aes-192-cbc" + + // IKEPolicyCreateEncryptionAesDash128DashCbc captures enum value "aes-128-cbc" + IKEPolicyCreateEncryptionAesDash128DashCbc string = "aes-128-cbc" + + // IKEPolicyCreateEncryptionAesDash256DashGcm captures enum value "aes-256-gcm" + IKEPolicyCreateEncryptionAesDash256DashGcm string = "aes-256-gcm" + + // IKEPolicyCreateEncryptionAesDash128DashGcm captures enum value "aes-128-gcm" + IKEPolicyCreateEncryptionAesDash128DashGcm string = "aes-128-gcm" + + // IKEPolicyCreateEncryptionNr3desDashCbc captures enum value "3des-cbc" + IKEPolicyCreateEncryptionNr3desDashCbc string = "3des-cbc" +) + +// prop value enum +func (m *IKEPolicyCreate) validateEncryptionEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, iKEPolicyCreateTypeEncryptionPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *IKEPolicyCreate) validateEncryption(formats strfmt.Registry) error { + + if err := validate.Required("encryption", "body", m.Encryption); err != nil { + return err + } + + // value enum + if err := m.validateEncryptionEnum("encryption", "body", *m.Encryption); err != nil { + return err + } + + return nil +} + +func (m *IKEPolicyCreate) validateKeyLifetime(formats strfmt.Registry) error { + + if err := validate.Required("keyLifetime", "body", m.KeyLifetime); err != nil { + return err + } + + if err := validate.Required("keyLifetime", "body", m.KeyLifetime); err != nil { + return err + } + + if m.KeyLifetime != nil { + if err := m.KeyLifetime.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("keyLifetime") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("keyLifetime") + } + return err + } + } + + return nil +} + +func (m *IKEPolicyCreate) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + if err := validate.MinLength("name", "body", *m.Name, 1); err != nil { + return err + } + + if err := validate.MaxLength("name", "body", *m.Name, 47); err != nil { + return err + } + + return nil +} + +func (m *IKEPolicyCreate) validatePresharedKey(formats strfmt.Registry) error { + + if err := validate.Required("presharedKey", "body", m.PresharedKey); err != nil { + return err + } + + return nil +} + +var iKEPolicyCreateTypeVersionPropEnum []interface{} + +func init() { + var res []int64 + if err := json.Unmarshal([]byte(`[1,2]`), &res); err != nil { + panic(err) + } + for _, v := range res { + iKEPolicyCreateTypeVersionPropEnum = append(iKEPolicyCreateTypeVersionPropEnum, v) + } +} + +// prop value enum +func (m *IKEPolicyCreate) validateVersionEnum(path, location string, value int64) error { + if err := validate.EnumCase(path, location, value, iKEPolicyCreateTypeVersionPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *IKEPolicyCreate) validateVersion(formats strfmt.Registry) error { + + if err := validate.Required("version", "body", m.Version); err != nil { + return err + } + + // value enum + if err := m.validateVersionEnum("version", "body", *m.Version); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this i k e policy create based on the context it is used +func (m *IKEPolicyCreate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateAuthentication(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateKeyLifetime(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *IKEPolicyCreate) contextValidateAuthentication(ctx context.Context, formats strfmt.Registry) error { + + if err := m.Authentication.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("authentication") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("authentication") + } + return err + } + + return nil +} + +func (m *IKEPolicyCreate) contextValidateKeyLifetime(ctx context.Context, formats strfmt.Registry) error { + + if m.KeyLifetime != nil { + if err := m.KeyLifetime.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("keyLifetime") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("keyLifetime") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *IKEPolicyCreate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *IKEPolicyCreate) UnmarshalBinary(b []byte) error { + var res IKEPolicyCreate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policy_dh_groups.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policy_dh_groups.go new file mode 100644 index 00000000000..a41c32d0117 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policy_dh_groups.go @@ -0,0 +1,28 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" +) + +// IKEPolicyDhGroups i k e policy dh groups +// Example: [1,2,5,14,19,20,24] +// +// swagger:model IKEPolicyDhGroups +type IKEPolicyDhGroups []float64 + +// Validate validates this i k e policy dh groups +func (m IKEPolicyDhGroups) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this i k e policy dh groups based on context it is used +func (m IKEPolicyDhGroups) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policy_encryptions.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policy_encryptions.go new file mode 100644 index 00000000000..e4642753795 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policy_encryptions.go @@ -0,0 +1,28 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" +) + +// IKEPolicyEncryptions i k e policy encryptions +// Example: ["aes-256-cbc","aes-192-cbc","aes-128-cbc","aes-256-gcm","aes-128-gcm","3des-cbc"] +// +// swagger:model IKEPolicyEncryptions +type IKEPolicyEncryptions []string + +// Validate validates this i k e policy encryptions +func (m IKEPolicyEncryptions) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this i k e policy encryptions based on context it is used +func (m IKEPolicyEncryptions) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policy_options.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policy_options.go new file mode 100644 index 00000000000..20103eec80d --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policy_options.go @@ -0,0 +1,235 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// IKEPolicyOptions i k e policy options +// +// swagger:model IKEPolicyOptions +type IKEPolicyOptions struct { + + // authentications + // Required: true + Authentications IKEPolicyAuthentications `json:"authentications"` + + // dh groups + // Required: true + DhGroups IKEPolicyDhGroups `json:"dhGroups"` + + // encryptions + // Required: true + Encryptions IKEPolicyEncryptions `json:"encryptions"` + + // versions + // Required: true + Versions PolicyVersions `json:"versions"` +} + +// Validate validates this i k e policy options +func (m *IKEPolicyOptions) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAuthentications(formats); err != nil { + res = append(res, err) + } + + if err := m.validateDhGroups(formats); err != nil { + res = append(res, err) + } + + if err := m.validateEncryptions(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVersions(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *IKEPolicyOptions) validateAuthentications(formats strfmt.Registry) error { + + if err := validate.Required("authentications", "body", m.Authentications); err != nil { + return err + } + + if err := m.Authentications.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("authentications") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("authentications") + } + return err + } + + return nil +} + +func (m *IKEPolicyOptions) validateDhGroups(formats strfmt.Registry) error { + + if err := validate.Required("dhGroups", "body", m.DhGroups); err != nil { + return err + } + + if err := m.DhGroups.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("dhGroups") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("dhGroups") + } + return err + } + + return nil +} + +func (m *IKEPolicyOptions) validateEncryptions(formats strfmt.Registry) error { + + if err := validate.Required("encryptions", "body", m.Encryptions); err != nil { + return err + } + + if err := m.Encryptions.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("encryptions") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("encryptions") + } + return err + } + + return nil +} + +func (m *IKEPolicyOptions) validateVersions(formats strfmt.Registry) error { + + if err := validate.Required("versions", "body", m.Versions); err != nil { + return err + } + + if err := m.Versions.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("versions") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("versions") + } + return err + } + + return nil +} + +// ContextValidate validate this i k e policy options based on the context it is used +func (m *IKEPolicyOptions) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateAuthentications(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateDhGroups(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateEncryptions(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateVersions(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *IKEPolicyOptions) contextValidateAuthentications(ctx context.Context, formats strfmt.Registry) error { + + if err := m.Authentications.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("authentications") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("authentications") + } + return err + } + + return nil +} + +func (m *IKEPolicyOptions) contextValidateDhGroups(ctx context.Context, formats strfmt.Registry) error { + + if err := m.DhGroups.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("dhGroups") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("dhGroups") + } + return err + } + + return nil +} + +func (m *IKEPolicyOptions) contextValidateEncryptions(ctx context.Context, formats strfmt.Registry) error { + + if err := m.Encryptions.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("encryptions") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("encryptions") + } + return err + } + + return nil +} + +func (m *IKEPolicyOptions) contextValidateVersions(ctx context.Context, formats strfmt.Registry) error { + + if err := m.Versions.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("versions") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("versions") + } + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *IKEPolicyOptions) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *IKEPolicyOptions) UnmarshalBinary(b []byte) error { + var res IKEPolicyOptions + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policy_ref.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policy_ref.go new file mode 100644 index 00000000000..4efb0751f3f --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policy_ref.go @@ -0,0 +1,90 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// IKEPolicyRef IKE Policy reference object +// +// swagger:model IKEPolicyRef +type IKEPolicyRef struct { + + // unique identifier of IKE Policy + // Example: 6edc8988-ab18-4b5c-b123-0d73e8254463 + // Required: true + ID *string `json:"id"` + + // name of IKE Policy + // Example: IKE Policy 1 + // Required: true + Name *string `json:"name"` +} + +// Validate validates this i k e policy ref +func (m *IKEPolicyRef) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *IKEPolicyRef) validateID(formats strfmt.Registry) error { + + if err := validate.Required("id", "body", m.ID); err != nil { + return err + } + + return nil +} + +func (m *IKEPolicyRef) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this i k e policy ref based on context it is used +func (m *IKEPolicyRef) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *IKEPolicyRef) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *IKEPolicyRef) UnmarshalBinary(b []byte) error { + var res IKEPolicyRef + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policy_template.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policy_template.go new file mode 100644 index 00000000000..ac09368f8ee --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policy_template.go @@ -0,0 +1,183 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// IKEPolicyTemplate i k e policy template +// +// swagger:model IKEPolicyTemplate +type IKEPolicyTemplate struct { + + // ikePolicy Authentication default value + // Example: sha256 + // Required: true + Authentication *string `json:"authentication"` + + // ikePolicy DHGroup default value + // Example: 2 + // Required: true + DhGroup *int64 `json:"dhGroup"` + + // ikePolicy Encryption default value + // Example: aes-256-cbc + // Required: true + Encryption *string `json:"encryption"` + + // key lifetime + // Required: true + KeyLifetime *KeyLifetime `json:"keyLifetime"` + + // ikePolicy Version default value + // Example: 2 + // Required: true + Version *float64 `json:"version"` +} + +// Validate validates this i k e policy template +func (m *IKEPolicyTemplate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAuthentication(formats); err != nil { + res = append(res, err) + } + + if err := m.validateDhGroup(formats); err != nil { + res = append(res, err) + } + + if err := m.validateEncryption(formats); err != nil { + res = append(res, err) + } + + if err := m.validateKeyLifetime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVersion(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *IKEPolicyTemplate) validateAuthentication(formats strfmt.Registry) error { + + if err := validate.Required("authentication", "body", m.Authentication); err != nil { + return err + } + + return nil +} + +func (m *IKEPolicyTemplate) validateDhGroup(formats strfmt.Registry) error { + + if err := validate.Required("dhGroup", "body", m.DhGroup); err != nil { + return err + } + + return nil +} + +func (m *IKEPolicyTemplate) validateEncryption(formats strfmt.Registry) error { + + if err := validate.Required("encryption", "body", m.Encryption); err != nil { + return err + } + + return nil +} + +func (m *IKEPolicyTemplate) validateKeyLifetime(formats strfmt.Registry) error { + + if err := validate.Required("keyLifetime", "body", m.KeyLifetime); err != nil { + return err + } + + if err := validate.Required("keyLifetime", "body", m.KeyLifetime); err != nil { + return err + } + + if m.KeyLifetime != nil { + if err := m.KeyLifetime.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("keyLifetime") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("keyLifetime") + } + return err + } + } + + return nil +} + +func (m *IKEPolicyTemplate) validateVersion(formats strfmt.Registry) error { + + if err := validate.Required("version", "body", m.Version); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this i k e policy template based on the context it is used +func (m *IKEPolicyTemplate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateKeyLifetime(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *IKEPolicyTemplate) contextValidateKeyLifetime(ctx context.Context, formats strfmt.Registry) error { + + if m.KeyLifetime != nil { + if err := m.KeyLifetime.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("keyLifetime") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("keyLifetime") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *IKEPolicyTemplate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *IKEPolicyTemplate) UnmarshalBinary(b []byte) error { + var res IKEPolicyTemplate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policy_update.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policy_update.go new file mode 100644 index 00000000000..5d92a6607fe --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/i_k_e_policy_update.go @@ -0,0 +1,492 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// IKEPolicyUpdate IKE Policy object used for update +// +// Min Properties: 1 +// +// swagger:model IKEPolicyUpdate +type IKEPolicyUpdate struct { + + // authentication + Authentication IKEPolicyAuthentication `json:"authentication,omitempty"` + + // DH group of the IKE Policy + // Example: 2 + // Enum: [1 2 5 14 19 20 24] + DhGroup int64 `json:"dhGroup,omitempty"` + + // encryption of the IKE Policy + // Example: aes-256-cbc + // Enum: [aes-256-cbc aes-192-cbc aes-128-cbc aes-256-gcm aes-128-gcm 3des-cbc] + Encryption string `json:"encryption,omitempty"` + + // key lifetime + KeyLifetime KeyLifetime `json:"keyLifetime,omitempty"` + + // name of the IKE Policy + // Example: ikePolicy1 + // Max Length: 47 + // Min Length: 1 + Name string `json:"name,omitempty"` + + // Preshared key used in this IKE Policy (length of preshared key must be even) + PresharedKey string `json:"presharedKey,omitempty"` + + // version of the IKE Policy + // Example: 2 + // Enum: [1 2] + Version int64 `json:"version,omitempty"` + + // i k e policy update additional properties + IKEPolicyUpdateAdditionalProperties map[string]interface{} `json:"-"` +} + +// UnmarshalJSON unmarshals this object with additional properties from JSON +func (m *IKEPolicyUpdate) UnmarshalJSON(data []byte) error { + // stage 1, bind the properties + var stage1 struct { + + // authentication + Authentication IKEPolicyAuthentication `json:"authentication,omitempty"` + + // DH group of the IKE Policy + // Example: 2 + // Enum: [1 2 5 14 19 20 24] + DhGroup int64 `json:"dhGroup,omitempty"` + + // encryption of the IKE Policy + // Example: aes-256-cbc + // Enum: [aes-256-cbc aes-192-cbc aes-128-cbc aes-256-gcm aes-128-gcm 3des-cbc] + Encryption string `json:"encryption,omitempty"` + + // key lifetime + KeyLifetime KeyLifetime `json:"keyLifetime,omitempty"` + + // name of the IKE Policy + // Example: ikePolicy1 + // Max Length: 47 + // Min Length: 1 + Name string `json:"name,omitempty"` + + // Preshared key used in this IKE Policy (length of preshared key must be even) + PresharedKey string `json:"presharedKey,omitempty"` + + // version of the IKE Policy + // Example: 2 + // Enum: [1 2] + Version int64 `json:"version,omitempty"` + } + if err := json.Unmarshal(data, &stage1); err != nil { + return err + } + var rcv IKEPolicyUpdate + + rcv.Authentication = stage1.Authentication + rcv.DhGroup = stage1.DhGroup + rcv.Encryption = stage1.Encryption + rcv.KeyLifetime = stage1.KeyLifetime + rcv.Name = stage1.Name + rcv.PresharedKey = stage1.PresharedKey + rcv.Version = stage1.Version + *m = rcv + + // stage 2, remove properties and add to map + stage2 := make(map[string]json.RawMessage) + if err := json.Unmarshal(data, &stage2); err != nil { + return err + } + + delete(stage2, "authentication") + delete(stage2, "dhGroup") + delete(stage2, "encryption") + delete(stage2, "keyLifetime") + delete(stage2, "name") + delete(stage2, "presharedKey") + delete(stage2, "version") + // stage 3, add additional properties values + if len(stage2) > 0 { + result := make(map[string]interface{}) + for k, v := range stage2 { + var toadd interface{} + if err := json.Unmarshal(v, &toadd); err != nil { + return err + } + result[k] = toadd + } + m.IKEPolicyUpdateAdditionalProperties = result + } + + return nil +} + +// MarshalJSON marshals this object with additional properties into a JSON object +func (m IKEPolicyUpdate) MarshalJSON() ([]byte, error) { + var stage1 struct { + + // authentication + Authentication IKEPolicyAuthentication `json:"authentication,omitempty"` + + // DH group of the IKE Policy + // Example: 2 + // Enum: [1 2 5 14 19 20 24] + DhGroup int64 `json:"dhGroup,omitempty"` + + // encryption of the IKE Policy + // Example: aes-256-cbc + // Enum: [aes-256-cbc aes-192-cbc aes-128-cbc aes-256-gcm aes-128-gcm 3des-cbc] + Encryption string `json:"encryption,omitempty"` + + // key lifetime + KeyLifetime KeyLifetime `json:"keyLifetime,omitempty"` + + // name of the IKE Policy + // Example: ikePolicy1 + // Max Length: 47 + // Min Length: 1 + Name string `json:"name,omitempty"` + + // Preshared key used in this IKE Policy (length of preshared key must be even) + PresharedKey string `json:"presharedKey,omitempty"` + + // version of the IKE Policy + // Example: 2 + // Enum: [1 2] + Version int64 `json:"version,omitempty"` + } + + stage1.Authentication = m.Authentication + stage1.DhGroup = m.DhGroup + stage1.Encryption = m.Encryption + stage1.KeyLifetime = m.KeyLifetime + stage1.Name = m.Name + stage1.PresharedKey = m.PresharedKey + stage1.Version = m.Version + + // make JSON object for known properties + props, err := json.Marshal(stage1) + if err != nil { + return nil, err + } + + if len(m.IKEPolicyUpdateAdditionalProperties) == 0 { // no additional properties + return props, nil + } + + // make JSON object for the additional properties + additional, err := json.Marshal(m.IKEPolicyUpdateAdditionalProperties) + if err != nil { + return nil, err + } + + if len(props) < 3 { // "{}": only additional properties + return additional, nil + } + + // concatenate the 2 objects + return swag.ConcatJSON(props, additional), nil +} + +// Validate validates this i k e policy update +func (m *IKEPolicyUpdate) Validate(formats strfmt.Registry) error { + var res []error + + // short circuits minProperties > 0 + if m == nil { + return errors.TooFewProperties("", "body", 1) + } + + props := make(map[string]json.RawMessage, 7+10) + j, err := swag.WriteJSON(m) + if err != nil { + return err + } + + if err = swag.ReadJSON(j, &props); err != nil { + return err + } + + nprops := len(props) + + // minProperties: 1 + if nprops < 1 { + return errors.TooFewProperties("", "body", 1) + } + + if err := m.validateAuthentication(formats); err != nil { + res = append(res, err) + } + + if err := m.validateDhGroup(formats); err != nil { + res = append(res, err) + } + + if err := m.validateEncryption(formats); err != nil { + res = append(res, err) + } + + if err := m.validateKeyLifetime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVersion(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *IKEPolicyUpdate) validateAuthentication(formats strfmt.Registry) error { + if swag.IsZero(m.Authentication) { // not required + return nil + } + + if err := m.Authentication.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("authentication") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("authentication") + } + return err + } + + return nil +} + +var iKEPolicyUpdateTypeDhGroupPropEnum []interface{} + +func init() { + var res []int64 + if err := json.Unmarshal([]byte(`[1,2,5,14,19,20,24]`), &res); err != nil { + panic(err) + } + for _, v := range res { + iKEPolicyUpdateTypeDhGroupPropEnum = append(iKEPolicyUpdateTypeDhGroupPropEnum, v) + } +} + +// prop value enum +func (m *IKEPolicyUpdate) validateDhGroupEnum(path, location string, value int64) error { + if err := validate.EnumCase(path, location, value, iKEPolicyUpdateTypeDhGroupPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *IKEPolicyUpdate) validateDhGroup(formats strfmt.Registry) error { + if swag.IsZero(m.DhGroup) { // not required + return nil + } + + // value enum + if err := m.validateDhGroupEnum("dhGroup", "body", m.DhGroup); err != nil { + return err + } + + return nil +} + +var iKEPolicyUpdateTypeEncryptionPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["aes-256-cbc","aes-192-cbc","aes-128-cbc","aes-256-gcm","aes-128-gcm","3des-cbc"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + iKEPolicyUpdateTypeEncryptionPropEnum = append(iKEPolicyUpdateTypeEncryptionPropEnum, v) + } +} + +const ( + + // IKEPolicyUpdateEncryptionAesDash256DashCbc captures enum value "aes-256-cbc" + IKEPolicyUpdateEncryptionAesDash256DashCbc string = "aes-256-cbc" + + // IKEPolicyUpdateEncryptionAesDash192DashCbc captures enum value "aes-192-cbc" + IKEPolicyUpdateEncryptionAesDash192DashCbc string = "aes-192-cbc" + + // IKEPolicyUpdateEncryptionAesDash128DashCbc captures enum value "aes-128-cbc" + IKEPolicyUpdateEncryptionAesDash128DashCbc string = "aes-128-cbc" + + // IKEPolicyUpdateEncryptionAesDash256DashGcm captures enum value "aes-256-gcm" + IKEPolicyUpdateEncryptionAesDash256DashGcm string = "aes-256-gcm" + + // IKEPolicyUpdateEncryptionAesDash128DashGcm captures enum value "aes-128-gcm" + IKEPolicyUpdateEncryptionAesDash128DashGcm string = "aes-128-gcm" + + // IKEPolicyUpdateEncryptionNr3desDashCbc captures enum value "3des-cbc" + IKEPolicyUpdateEncryptionNr3desDashCbc string = "3des-cbc" +) + +// prop value enum +func (m *IKEPolicyUpdate) validateEncryptionEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, iKEPolicyUpdateTypeEncryptionPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *IKEPolicyUpdate) validateEncryption(formats strfmt.Registry) error { + if swag.IsZero(m.Encryption) { // not required + return nil + } + + // value enum + if err := m.validateEncryptionEnum("encryption", "body", m.Encryption); err != nil { + return err + } + + return nil +} + +func (m *IKEPolicyUpdate) validateKeyLifetime(formats strfmt.Registry) error { + if swag.IsZero(m.KeyLifetime) { // not required + return nil + } + + if err := m.KeyLifetime.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("keyLifetime") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("keyLifetime") + } + return err + } + + return nil +} + +func (m *IKEPolicyUpdate) validateName(formats strfmt.Registry) error { + if swag.IsZero(m.Name) { // not required + return nil + } + + if err := validate.MinLength("name", "body", m.Name, 1); err != nil { + return err + } + + if err := validate.MaxLength("name", "body", m.Name, 47); err != nil { + return err + } + + return nil +} + +var iKEPolicyUpdateTypeVersionPropEnum []interface{} + +func init() { + var res []int64 + if err := json.Unmarshal([]byte(`[1,2]`), &res); err != nil { + panic(err) + } + for _, v := range res { + iKEPolicyUpdateTypeVersionPropEnum = append(iKEPolicyUpdateTypeVersionPropEnum, v) + } +} + +// prop value enum +func (m *IKEPolicyUpdate) validateVersionEnum(path, location string, value int64) error { + if err := validate.EnumCase(path, location, value, iKEPolicyUpdateTypeVersionPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *IKEPolicyUpdate) validateVersion(formats strfmt.Registry) error { + if swag.IsZero(m.Version) { // not required + return nil + } + + // value enum + if err := m.validateVersionEnum("version", "body", m.Version); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this i k e policy update based on the context it is used +func (m *IKEPolicyUpdate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateAuthentication(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateKeyLifetime(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *IKEPolicyUpdate) contextValidateAuthentication(ctx context.Context, formats strfmt.Registry) error { + + if err := m.Authentication.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("authentication") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("authentication") + } + return err + } + + return nil +} + +func (m *IKEPolicyUpdate) contextValidateKeyLifetime(ctx context.Context, formats strfmt.Registry) error { + + if err := m.KeyLifetime.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("keyLifetime") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("keyLifetime") + } + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *IKEPolicyUpdate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *IKEPolicyUpdate) UnmarshalBinary(b []byte) error { + var res IKEPolicyUpdate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/image.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/image.go new file mode 100644 index 00000000000..1d79e34d139 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/image.go @@ -0,0 +1,347 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Image image +// +// swagger:model Image +type Image struct { + + // Creation Date + // Required: true + // Format: date-time + CreationDate *strfmt.DateTime `json:"creationDate"` + + // Description + Description string `json:"description,omitempty"` + + // Image ID + // Required: true + ImageID *string `json:"imageID"` + + // Last Update Date + // Required: true + // Format: date-time + LastUpdateDate *strfmt.DateTime `json:"lastUpdateDate"` + + // Image Name + // Required: true + Name *string `json:"name"` + + // List of Servers that have deployed the image + Servers []string `json:"servers"` + + // Image Size + // Required: true + Size *float64 `json:"size"` + + // specifications + Specifications *ImageSpecifications `json:"specifications,omitempty"` + + // Image State + State string `json:"state,omitempty"` + + // Storage pool where the image resides + // Required: true + StoragePool *string `json:"storagePool"` + + // Storage type for image + // Required: true + StorageType *string `json:"storageType"` + + // taskref + Taskref *TaskReference `json:"taskref,omitempty"` + + // Image Volumes + Volumes []*ImageVolume `json:"volumes"` +} + +// Validate validates this image +func (m *Image) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreationDate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateImageID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLastUpdateDate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSize(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSpecifications(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStoragePool(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStorageType(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTaskref(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVolumes(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Image) validateCreationDate(formats strfmt.Registry) error { + + if err := validate.Required("creationDate", "body", m.CreationDate); err != nil { + return err + } + + if err := validate.FormatOf("creationDate", "body", "date-time", m.CreationDate.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *Image) validateImageID(formats strfmt.Registry) error { + + if err := validate.Required("imageID", "body", m.ImageID); err != nil { + return err + } + + return nil +} + +func (m *Image) validateLastUpdateDate(formats strfmt.Registry) error { + + if err := validate.Required("lastUpdateDate", "body", m.LastUpdateDate); err != nil { + return err + } + + if err := validate.FormatOf("lastUpdateDate", "body", "date-time", m.LastUpdateDate.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *Image) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *Image) validateSize(formats strfmt.Registry) error { + + if err := validate.Required("size", "body", m.Size); err != nil { + return err + } + + return nil +} + +func (m *Image) validateSpecifications(formats strfmt.Registry) error { + if swag.IsZero(m.Specifications) { // not required + return nil + } + + if m.Specifications != nil { + if err := m.Specifications.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("specifications") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("specifications") + } + return err + } + } + + return nil +} + +func (m *Image) validateStoragePool(formats strfmt.Registry) error { + + if err := validate.Required("storagePool", "body", m.StoragePool); err != nil { + return err + } + + return nil +} + +func (m *Image) validateStorageType(formats strfmt.Registry) error { + + if err := validate.Required("storageType", "body", m.StorageType); err != nil { + return err + } + + return nil +} + +func (m *Image) validateTaskref(formats strfmt.Registry) error { + if swag.IsZero(m.Taskref) { // not required + return nil + } + + if m.Taskref != nil { + if err := m.Taskref.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("taskref") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("taskref") + } + return err + } + } + + return nil +} + +func (m *Image) validateVolumes(formats strfmt.Registry) error { + if swag.IsZero(m.Volumes) { // not required + return nil + } + + for i := 0; i < len(m.Volumes); i++ { + if swag.IsZero(m.Volumes[i]) { // not required + continue + } + + if m.Volumes[i] != nil { + if err := m.Volumes[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("volumes" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("volumes" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this image based on the context it is used +func (m *Image) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateSpecifications(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateTaskref(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateVolumes(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Image) contextValidateSpecifications(ctx context.Context, formats strfmt.Registry) error { + + if m.Specifications != nil { + if err := m.Specifications.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("specifications") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("specifications") + } + return err + } + } + + return nil +} + +func (m *Image) contextValidateTaskref(ctx context.Context, formats strfmt.Registry) error { + + if m.Taskref != nil { + if err := m.Taskref.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("taskref") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("taskref") + } + return err + } + } + + return nil +} + +func (m *Image) contextValidateVolumes(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Volumes); i++ { + + if m.Volumes[i] != nil { + if err := m.Volumes[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("volumes" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("volumes" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Image) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Image) UnmarshalBinary(b []byte) error { + var res Image + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/image_reference.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/image_reference.go new file mode 100644 index 00000000000..0d1fb25dcb0 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/image_reference.go @@ -0,0 +1,270 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ImageReference image reference +// +// swagger:model ImageReference +type ImageReference struct { + + // Creation Date + // Required: true + // Format: date-time + CreationDate *strfmt.DateTime `json:"creationDate"` + + // Description + // Required: true + Description *string `json:"description"` + + // Link to Image resource + // Required: true + Href *string `json:"href"` + + // Image ID + // Required: true + ImageID *string `json:"imageID"` + + // Last Update Date + // Required: true + // Format: date-time + LastUpdateDate *strfmt.DateTime `json:"lastUpdateDate"` + + // Image Name + // Required: true + Name *string `json:"name"` + + // specifications + // Required: true + Specifications *ImageSpecifications `json:"specifications"` + + // Image State + // Required: true + State *string `json:"state"` + + // Storage pool where image resides + // Required: true + StoragePool *string `json:"storagePool"` + + // Storage type for image + // Required: true + StorageType *string `json:"storageType"` +} + +// Validate validates this image reference +func (m *ImageReference) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreationDate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateDescription(formats); err != nil { + res = append(res, err) + } + + if err := m.validateHref(formats); err != nil { + res = append(res, err) + } + + if err := m.validateImageID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLastUpdateDate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSpecifications(formats); err != nil { + res = append(res, err) + } + + if err := m.validateState(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStoragePool(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStorageType(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ImageReference) validateCreationDate(formats strfmt.Registry) error { + + if err := validate.Required("creationDate", "body", m.CreationDate); err != nil { + return err + } + + if err := validate.FormatOf("creationDate", "body", "date-time", m.CreationDate.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *ImageReference) validateDescription(formats strfmt.Registry) error { + + if err := validate.Required("description", "body", m.Description); err != nil { + return err + } + + return nil +} + +func (m *ImageReference) validateHref(formats strfmt.Registry) error { + + if err := validate.Required("href", "body", m.Href); err != nil { + return err + } + + return nil +} + +func (m *ImageReference) validateImageID(formats strfmt.Registry) error { + + if err := validate.Required("imageID", "body", m.ImageID); err != nil { + return err + } + + return nil +} + +func (m *ImageReference) validateLastUpdateDate(formats strfmt.Registry) error { + + if err := validate.Required("lastUpdateDate", "body", m.LastUpdateDate); err != nil { + return err + } + + if err := validate.FormatOf("lastUpdateDate", "body", "date-time", m.LastUpdateDate.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *ImageReference) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *ImageReference) validateSpecifications(formats strfmt.Registry) error { + + if err := validate.Required("specifications", "body", m.Specifications); err != nil { + return err + } + + if m.Specifications != nil { + if err := m.Specifications.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("specifications") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("specifications") + } + return err + } + } + + return nil +} + +func (m *ImageReference) validateState(formats strfmt.Registry) error { + + if err := validate.Required("state", "body", m.State); err != nil { + return err + } + + return nil +} + +func (m *ImageReference) validateStoragePool(formats strfmt.Registry) error { + + if err := validate.Required("storagePool", "body", m.StoragePool); err != nil { + return err + } + + return nil +} + +func (m *ImageReference) validateStorageType(formats strfmt.Registry) error { + + if err := validate.Required("storageType", "body", m.StorageType); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this image reference based on the context it is used +func (m *ImageReference) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateSpecifications(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ImageReference) contextValidateSpecifications(ctx context.Context, formats strfmt.Registry) error { + + if m.Specifications != nil { + if err := m.Specifications.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("specifications") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("specifications") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ImageReference) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ImageReference) UnmarshalBinary(b []byte) error { + var res ImageReference + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/image_specifications.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/image_specifications.go new file mode 100644 index 00000000000..d5f71a0ea0b --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/image_specifications.go @@ -0,0 +1,68 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ImageSpecifications image specifications +// +// swagger:model ImageSpecifications +type ImageSpecifications struct { + + // Architecture + Architecture string `json:"architecture,omitempty"` + + // Container Format + ContainerFormat string `json:"containerFormat,omitempty"` + + // Disk Format + DiskFormat string `json:"diskFormat,omitempty"` + + // Endianness + Endianness string `json:"endianness,omitempty"` + + // Hypervisor Type + HypervisorType string `json:"hypervisorType,omitempty"` + + // Image Type + ImageType string `json:"imageType,omitempty"` + + // Operating System + OperatingSystem string `json:"operatingSystem,omitempty"` +} + +// Validate validates this image specifications +func (m *ImageSpecifications) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this image specifications based on context it is used +func (m *ImageSpecifications) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ImageSpecifications) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ImageSpecifications) UnmarshalBinary(b []byte) error { + var res ImageSpecifications + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/image_volume.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/image_volume.go new file mode 100644 index 00000000000..44e1899db85 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/image_volume.go @@ -0,0 +1,122 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ImageVolume image volume +// +// swagger:model ImageVolume +type ImageVolume struct { + + // Indicates if the volume is boot capable + // Required: true + Bootable *bool `json:"bootable"` + + // Volume Name + // Required: true + Name *string `json:"name"` + + // Volume Size + // Required: true + Size *float64 `json:"size"` + + // Volume ID + // Required: true + VolumeID *string `json:"volumeID"` +} + +// Validate validates this image volume +func (m *ImageVolume) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateBootable(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSize(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVolumeID(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ImageVolume) validateBootable(formats strfmt.Registry) error { + + if err := validate.Required("bootable", "body", m.Bootable); err != nil { + return err + } + + return nil +} + +func (m *ImageVolume) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *ImageVolume) validateSize(formats strfmt.Registry) error { + + if err := validate.Required("size", "body", m.Size); err != nil { + return err + } + + return nil +} + +func (m *ImageVolume) validateVolumeID(formats strfmt.Registry) error { + + if err := validate.Required("volumeID", "body", m.VolumeID); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this image volume based on context it is used +func (m *ImageVolume) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ImageVolume) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ImageVolume) UnmarshalBinary(b []byte) error { + var res ImageVolume + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/images.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/images.go new file mode 100644 index 00000000000..b9c4473c0c1 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/images.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Images images +// +// swagger:model Images +type Images struct { + + // Images + // Required: true + Images []*ImageReference `json:"images"` +} + +// Validate validates this images +func (m *Images) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateImages(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Images) validateImages(formats strfmt.Registry) error { + + if err := validate.Required("images", "body", m.Images); err != nil { + return err + } + + for i := 0; i < len(m.Images); i++ { + if swag.IsZero(m.Images[i]) { // not required + continue + } + + if m.Images[i] != nil { + if err := m.Images[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("images" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("images" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this images based on the context it is used +func (m *Images) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateImages(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Images) contextValidateImages(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Images); i++ { + + if m.Images[i] != nil { + if err := m.Images[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("images" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("images" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Images) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Images) UnmarshalBinary(b []byte) error { + var res Images + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_address_range.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_address_range.go new file mode 100644 index 00000000000..58cbfff9186 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_address_range.go @@ -0,0 +1,88 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// IPAddressRange IP address range +// +// swagger:model IPAddressRange +type IPAddressRange struct { + + // Ending IP Address + // Required: true + EndingIPAddress *string `json:"endingIPAddress"` + + // Starting IP Address + // Required: true + StartingIPAddress *string `json:"startingIPAddress"` +} + +// Validate validates this IP address range +func (m *IPAddressRange) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateEndingIPAddress(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStartingIPAddress(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *IPAddressRange) validateEndingIPAddress(formats strfmt.Registry) error { + + if err := validate.Required("endingIPAddress", "body", m.EndingIPAddress); err != nil { + return err + } + + return nil +} + +func (m *IPAddressRange) validateStartingIPAddress(formats strfmt.Registry) error { + + if err := validate.Required("startingIPAddress", "body", m.StartingIPAddress); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this IP address range based on context it is used +func (m *IPAddressRange) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *IPAddressRange) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *IPAddressRange) UnmarshalBinary(b []byte) error { + var res IPAddressRange + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_s_e_c_policy_authentication.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_s_e_c_policy_authentication.go new file mode 100644 index 00000000000..d3f704f02a5 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_s_e_c_policy_authentication.go @@ -0,0 +1,82 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// IPSECPolicyAuthentication authentication for IPSec policy +// Example: hmac-sha-256-128 +// +// swagger:model IPSECPolicyAuthentication +type IPSECPolicyAuthentication string + +func NewIPSECPolicyAuthentication(value IPSECPolicyAuthentication) *IPSECPolicyAuthentication { + return &value +} + +// Pointer returns a pointer to a freshly-allocated IPSECPolicyAuthentication. +func (m IPSECPolicyAuthentication) Pointer() *IPSECPolicyAuthentication { + return &m +} + +const ( + + // IPSECPolicyAuthenticationHmacDashShaDash256Dash128 captures enum value "hmac-sha-256-128" + IPSECPolicyAuthenticationHmacDashShaDash256Dash128 IPSECPolicyAuthentication = "hmac-sha-256-128" + + // IPSECPolicyAuthenticationHmacDashSha1Dash96 captures enum value "hmac-sha1-96" + IPSECPolicyAuthenticationHmacDashSha1Dash96 IPSECPolicyAuthentication = "hmac-sha1-96" + + // IPSECPolicyAuthenticationNone captures enum value "none" + IPSECPolicyAuthenticationNone IPSECPolicyAuthentication = "none" +) + +// for schema +var ipSECPolicyAuthenticationEnum []interface{} + +func init() { + var res []IPSECPolicyAuthentication + if err := json.Unmarshal([]byte(`["hmac-sha-256-128","hmac-sha1-96","none"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + ipSECPolicyAuthenticationEnum = append(ipSECPolicyAuthenticationEnum, v) + } +} + +func (m IPSECPolicyAuthentication) validateIPSECPolicyAuthenticationEnum(path, location string, value IPSECPolicyAuthentication) error { + if err := validate.EnumCase(path, location, value, ipSECPolicyAuthenticationEnum, true); err != nil { + return err + } + return nil +} + +// Validate validates this IP s e c policy authentication +func (m IPSECPolicyAuthentication) Validate(formats strfmt.Registry) error { + var res []error + + // value enum + if err := m.validateIPSECPolicyAuthenticationEnum("", "body", m); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validates this IP s e c policy authentication based on context it is used +func (m IPSECPolicyAuthentication) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_s_e_c_policy_authentications.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_s_e_c_policy_authentications.go new file mode 100644 index 00000000000..e7d49a6bfe4 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_s_e_c_policy_authentications.go @@ -0,0 +1,28 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" +) + +// IPSECPolicyAuthentications IP s e c policy authentications +// Example: ["hmac-sha-256-128","hmac-sha1-96","none"] +// +// swagger:model IPSECPolicyAuthentications +type IPSECPolicyAuthentications []string + +// Validate validates this IP s e c policy authentications +func (m IPSECPolicyAuthentications) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this IP s e c policy authentications based on context it is used +func (m IPSECPolicyAuthentications) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_s_e_c_policy_dh_groups.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_s_e_c_policy_dh_groups.go new file mode 100644 index 00000000000..3db313e56a4 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_s_e_c_policy_dh_groups.go @@ -0,0 +1,28 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" +) + +// IPSECPolicyDhGroups IP s e c policy dh groups +// Example: [1,2,5,14,19,20] +// +// swagger:model IPSECPolicyDhGroups +type IPSECPolicyDhGroups []float64 + +// Validate validates this IP s e c policy dh groups +func (m IPSECPolicyDhGroups) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this IP s e c policy dh groups based on context it is used +func (m IPSECPolicyDhGroups) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_s_e_c_policy_encryptions.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_s_e_c_policy_encryptions.go new file mode 100644 index 00000000000..be20e38f432 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_s_e_c_policy_encryptions.go @@ -0,0 +1,28 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" +) + +// IPSECPolicyEncryptions IP s e c policy encryptions +// Example: ["aes-256-cbc","aes-192-cbc","aes-128-cbc","aes-256-gcm","aes-128-gcm","3des-cbc"] +// +// swagger:model IPSECPolicyEncryptions +type IPSECPolicyEncryptions []string + +// Validate validates this IP s e c policy encryptions +func (m IPSECPolicyEncryptions) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this IP s e c policy encryptions based on context it is used +func (m IPSECPolicyEncryptions) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_sec_policies.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_sec_policies.go new file mode 100644 index 00000000000..6e0996a4a39 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_sec_policies.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// IPSecPolicies IP sec policies +// +// swagger:model IPSecPolicies +type IPSecPolicies struct { + + // IPSec Policies array + // Required: true + IPSecPolicies []*IPSecPolicy `json:"ipSecPolicies"` +} + +// Validate validates this IP sec policies +func (m *IPSecPolicies) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateIPSecPolicies(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *IPSecPolicies) validateIPSecPolicies(formats strfmt.Registry) error { + + if err := validate.Required("ipSecPolicies", "body", m.IPSecPolicies); err != nil { + return err + } + + for i := 0; i < len(m.IPSecPolicies); i++ { + if swag.IsZero(m.IPSecPolicies[i]) { // not required + continue + } + + if m.IPSecPolicies[i] != nil { + if err := m.IPSecPolicies[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ipSecPolicies" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ipSecPolicies" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this IP sec policies based on the context it is used +func (m *IPSecPolicies) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateIPSecPolicies(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *IPSecPolicies) contextValidateIPSecPolicies(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.IPSecPolicies); i++ { + + if m.IPSecPolicies[i] != nil { + if err := m.IPSecPolicies[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ipSecPolicies" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ipSecPolicies" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *IPSecPolicies) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *IPSecPolicies) UnmarshalBinary(b []byte) error { + var res IPSecPolicies + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_sec_policy.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_sec_policy.go new file mode 100644 index 00000000000..d13ba5a5631 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_sec_policy.go @@ -0,0 +1,330 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// IPSecPolicy IPSec Policy object +// +// swagger:model IPSecPolicy +type IPSecPolicy struct { + + // authentication + // Required: true + Authentication *IPSECPolicyAuthentication `json:"authentication"` + + // Diffie-Hellman group + // Example: 2 + // Required: true + // Enum: [1 2 5 14 19 20 24] + DhGroup *int64 `json:"dhGroup"` + + // connection encryption policy + // Example: aes-256-cbc + // Required: true + // Enum: [aes-256-cbc aes-192-cbc aes-128-cbc aes-256-gcm aes-192-gcm aes-128-gcm 3des-cbc] + Encryption *string `json:"encryption"` + + // unique identifier of the IPSec Policy + // Example: 6edc8988-eb18-4b5c-a594-0d73d8254463 + // Required: true + ID *string `json:"id"` + + // key lifetime + // Required: true + KeyLifetime *KeyLifetime `json:"keyLifetime"` + + // IPSec Policy name + // Example: ipSecPolicy2 + // Required: true + Name *string `json:"name"` + + // Perfect Forward Secrecy + // Example: true + // Required: true + Pfs *bool `json:"pfs"` +} + +// Validate validates this IP sec policy +func (m *IPSecPolicy) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAuthentication(formats); err != nil { + res = append(res, err) + } + + if err := m.validateDhGroup(formats); err != nil { + res = append(res, err) + } + + if err := m.validateEncryption(formats); err != nil { + res = append(res, err) + } + + if err := m.validateID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateKeyLifetime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePfs(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *IPSecPolicy) validateAuthentication(formats strfmt.Registry) error { + + if err := validate.Required("authentication", "body", m.Authentication); err != nil { + return err + } + + if err := validate.Required("authentication", "body", m.Authentication); err != nil { + return err + } + + if m.Authentication != nil { + if err := m.Authentication.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("authentication") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("authentication") + } + return err + } + } + + return nil +} + +var ipSecPolicyTypeDhGroupPropEnum []interface{} + +func init() { + var res []int64 + if err := json.Unmarshal([]byte(`[1,2,5,14,19,20,24]`), &res); err != nil { + panic(err) + } + for _, v := range res { + ipSecPolicyTypeDhGroupPropEnum = append(ipSecPolicyTypeDhGroupPropEnum, v) + } +} + +// prop value enum +func (m *IPSecPolicy) validateDhGroupEnum(path, location string, value int64) error { + if err := validate.EnumCase(path, location, value, ipSecPolicyTypeDhGroupPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *IPSecPolicy) validateDhGroup(formats strfmt.Registry) error { + + if err := validate.Required("dhGroup", "body", m.DhGroup); err != nil { + return err + } + + // value enum + if err := m.validateDhGroupEnum("dhGroup", "body", *m.DhGroup); err != nil { + return err + } + + return nil +} + +var ipSecPolicyTypeEncryptionPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["aes-256-cbc","aes-192-cbc","aes-128-cbc","aes-256-gcm","aes-192-gcm","aes-128-gcm","3des-cbc"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + ipSecPolicyTypeEncryptionPropEnum = append(ipSecPolicyTypeEncryptionPropEnum, v) + } +} + +const ( + + // IPSecPolicyEncryptionAesDash256DashCbc captures enum value "aes-256-cbc" + IPSecPolicyEncryptionAesDash256DashCbc string = "aes-256-cbc" + + // IPSecPolicyEncryptionAesDash192DashCbc captures enum value "aes-192-cbc" + IPSecPolicyEncryptionAesDash192DashCbc string = "aes-192-cbc" + + // IPSecPolicyEncryptionAesDash128DashCbc captures enum value "aes-128-cbc" + IPSecPolicyEncryptionAesDash128DashCbc string = "aes-128-cbc" + + // IPSecPolicyEncryptionAesDash256DashGcm captures enum value "aes-256-gcm" + IPSecPolicyEncryptionAesDash256DashGcm string = "aes-256-gcm" + + // IPSecPolicyEncryptionAesDash192DashGcm captures enum value "aes-192-gcm" + IPSecPolicyEncryptionAesDash192DashGcm string = "aes-192-gcm" + + // IPSecPolicyEncryptionAesDash128DashGcm captures enum value "aes-128-gcm" + IPSecPolicyEncryptionAesDash128DashGcm string = "aes-128-gcm" + + // IPSecPolicyEncryptionNr3desDashCbc captures enum value "3des-cbc" + IPSecPolicyEncryptionNr3desDashCbc string = "3des-cbc" +) + +// prop value enum +func (m *IPSecPolicy) validateEncryptionEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, ipSecPolicyTypeEncryptionPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *IPSecPolicy) validateEncryption(formats strfmt.Registry) error { + + if err := validate.Required("encryption", "body", m.Encryption); err != nil { + return err + } + + // value enum + if err := m.validateEncryptionEnum("encryption", "body", *m.Encryption); err != nil { + return err + } + + return nil +} + +func (m *IPSecPolicy) validateID(formats strfmt.Registry) error { + + if err := validate.Required("id", "body", m.ID); err != nil { + return err + } + + return nil +} + +func (m *IPSecPolicy) validateKeyLifetime(formats strfmt.Registry) error { + + if err := validate.Required("keyLifetime", "body", m.KeyLifetime); err != nil { + return err + } + + if err := validate.Required("keyLifetime", "body", m.KeyLifetime); err != nil { + return err + } + + if m.KeyLifetime != nil { + if err := m.KeyLifetime.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("keyLifetime") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("keyLifetime") + } + return err + } + } + + return nil +} + +func (m *IPSecPolicy) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *IPSecPolicy) validatePfs(formats strfmt.Registry) error { + + if err := validate.Required("pfs", "body", m.Pfs); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this IP sec policy based on the context it is used +func (m *IPSecPolicy) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateAuthentication(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateKeyLifetime(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *IPSecPolicy) contextValidateAuthentication(ctx context.Context, formats strfmt.Registry) error { + + if m.Authentication != nil { + if err := m.Authentication.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("authentication") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("authentication") + } + return err + } + } + + return nil +} + +func (m *IPSecPolicy) contextValidateKeyLifetime(ctx context.Context, formats strfmt.Registry) error { + + if m.KeyLifetime != nil { + if err := m.KeyLifetime.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("keyLifetime") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("keyLifetime") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *IPSecPolicy) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *IPSecPolicy) UnmarshalBinary(b []byte) error { + var res IPSecPolicy + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_sec_policy_create.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_sec_policy_create.go new file mode 100644 index 00000000000..2dbcb92c074 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_sec_policy_create.go @@ -0,0 +1,312 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// IPSecPolicyCreate IPSec Policy object used for creation +// +// swagger:model IPSecPolicyCreate +type IPSecPolicyCreate struct { + + // authentication + Authentication IPSECPolicyAuthentication `json:"authentication,omitempty"` + + // Diffie-Hellman group + // Example: 2 + // Required: true + // Enum: [1 2 5 14 19 20 24] + DhGroup *int64 `json:"dhGroup"` + + // connection encryption policy + // Example: aes-256-cbc + // Required: true + // Enum: [aes-256-cbc aes-192-cbc aes-128-cbc aes-256-gcm aes-192-gcm aes-128-gcm 3des-cbc] + Encryption *string `json:"encryption"` + + // key lifetime + // Required: true + KeyLifetime *KeyLifetime `json:"keyLifetime"` + + // IPSec Policy name + // Example: ipSecPolicy2 + // Required: true + // Max Length: 47 + // Min Length: 1 + Name *string `json:"name"` + + // Perfect Forward Secrecy + // Example: true + // Required: true + Pfs *bool `json:"pfs"` +} + +// Validate validates this IP sec policy create +func (m *IPSecPolicyCreate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAuthentication(formats); err != nil { + res = append(res, err) + } + + if err := m.validateDhGroup(formats); err != nil { + res = append(res, err) + } + + if err := m.validateEncryption(formats); err != nil { + res = append(res, err) + } + + if err := m.validateKeyLifetime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePfs(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *IPSecPolicyCreate) validateAuthentication(formats strfmt.Registry) error { + if swag.IsZero(m.Authentication) { // not required + return nil + } + + if err := m.Authentication.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("authentication") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("authentication") + } + return err + } + + return nil +} + +var ipSecPolicyCreateTypeDhGroupPropEnum []interface{} + +func init() { + var res []int64 + if err := json.Unmarshal([]byte(`[1,2,5,14,19,20,24]`), &res); err != nil { + panic(err) + } + for _, v := range res { + ipSecPolicyCreateTypeDhGroupPropEnum = append(ipSecPolicyCreateTypeDhGroupPropEnum, v) + } +} + +// prop value enum +func (m *IPSecPolicyCreate) validateDhGroupEnum(path, location string, value int64) error { + if err := validate.EnumCase(path, location, value, ipSecPolicyCreateTypeDhGroupPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *IPSecPolicyCreate) validateDhGroup(formats strfmt.Registry) error { + + if err := validate.Required("dhGroup", "body", m.DhGroup); err != nil { + return err + } + + // value enum + if err := m.validateDhGroupEnum("dhGroup", "body", *m.DhGroup); err != nil { + return err + } + + return nil +} + +var ipSecPolicyCreateTypeEncryptionPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["aes-256-cbc","aes-192-cbc","aes-128-cbc","aes-256-gcm","aes-192-gcm","aes-128-gcm","3des-cbc"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + ipSecPolicyCreateTypeEncryptionPropEnum = append(ipSecPolicyCreateTypeEncryptionPropEnum, v) + } +} + +const ( + + // IPSecPolicyCreateEncryptionAesDash256DashCbc captures enum value "aes-256-cbc" + IPSecPolicyCreateEncryptionAesDash256DashCbc string = "aes-256-cbc" + + // IPSecPolicyCreateEncryptionAesDash192DashCbc captures enum value "aes-192-cbc" + IPSecPolicyCreateEncryptionAesDash192DashCbc string = "aes-192-cbc" + + // IPSecPolicyCreateEncryptionAesDash128DashCbc captures enum value "aes-128-cbc" + IPSecPolicyCreateEncryptionAesDash128DashCbc string = "aes-128-cbc" + + // IPSecPolicyCreateEncryptionAesDash256DashGcm captures enum value "aes-256-gcm" + IPSecPolicyCreateEncryptionAesDash256DashGcm string = "aes-256-gcm" + + // IPSecPolicyCreateEncryptionAesDash192DashGcm captures enum value "aes-192-gcm" + IPSecPolicyCreateEncryptionAesDash192DashGcm string = "aes-192-gcm" + + // IPSecPolicyCreateEncryptionAesDash128DashGcm captures enum value "aes-128-gcm" + IPSecPolicyCreateEncryptionAesDash128DashGcm string = "aes-128-gcm" + + // IPSecPolicyCreateEncryptionNr3desDashCbc captures enum value "3des-cbc" + IPSecPolicyCreateEncryptionNr3desDashCbc string = "3des-cbc" +) + +// prop value enum +func (m *IPSecPolicyCreate) validateEncryptionEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, ipSecPolicyCreateTypeEncryptionPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *IPSecPolicyCreate) validateEncryption(formats strfmt.Registry) error { + + if err := validate.Required("encryption", "body", m.Encryption); err != nil { + return err + } + + // value enum + if err := m.validateEncryptionEnum("encryption", "body", *m.Encryption); err != nil { + return err + } + + return nil +} + +func (m *IPSecPolicyCreate) validateKeyLifetime(formats strfmt.Registry) error { + + if err := validate.Required("keyLifetime", "body", m.KeyLifetime); err != nil { + return err + } + + if err := validate.Required("keyLifetime", "body", m.KeyLifetime); err != nil { + return err + } + + if m.KeyLifetime != nil { + if err := m.KeyLifetime.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("keyLifetime") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("keyLifetime") + } + return err + } + } + + return nil +} + +func (m *IPSecPolicyCreate) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + if err := validate.MinLength("name", "body", *m.Name, 1); err != nil { + return err + } + + if err := validate.MaxLength("name", "body", *m.Name, 47); err != nil { + return err + } + + return nil +} + +func (m *IPSecPolicyCreate) validatePfs(formats strfmt.Registry) error { + + if err := validate.Required("pfs", "body", m.Pfs); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this IP sec policy create based on the context it is used +func (m *IPSecPolicyCreate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateAuthentication(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateKeyLifetime(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *IPSecPolicyCreate) contextValidateAuthentication(ctx context.Context, formats strfmt.Registry) error { + + if err := m.Authentication.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("authentication") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("authentication") + } + return err + } + + return nil +} + +func (m *IPSecPolicyCreate) contextValidateKeyLifetime(ctx context.Context, formats strfmt.Registry) error { + + if m.KeyLifetime != nil { + if err := m.KeyLifetime.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("keyLifetime") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("keyLifetime") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *IPSecPolicyCreate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *IPSecPolicyCreate) UnmarshalBinary(b []byte) error { + var res IPSecPolicyCreate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_sec_policy_options.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_sec_policy_options.go new file mode 100644 index 00000000000..07841dffc48 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_sec_policy_options.go @@ -0,0 +1,191 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// IPSecPolicyOptions IP sec policy options +// +// swagger:model IPSecPolicyOptions +type IPSecPolicyOptions struct { + + // authentications + // Required: true + Authentications IPSECPolicyAuthentications `json:"authentications"` + + // dh groups + // Required: true + DhGroups IPSECPolicyDhGroups `json:"dhGroups"` + + // encryptions + // Required: true + Encryptions IPSECPolicyEncryptions `json:"encryptions"` +} + +// Validate validates this IP sec policy options +func (m *IPSecPolicyOptions) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAuthentications(formats); err != nil { + res = append(res, err) + } + + if err := m.validateDhGroups(formats); err != nil { + res = append(res, err) + } + + if err := m.validateEncryptions(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *IPSecPolicyOptions) validateAuthentications(formats strfmt.Registry) error { + + if err := validate.Required("authentications", "body", m.Authentications); err != nil { + return err + } + + if err := m.Authentications.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("authentications") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("authentications") + } + return err + } + + return nil +} + +func (m *IPSecPolicyOptions) validateDhGroups(formats strfmt.Registry) error { + + if err := validate.Required("dhGroups", "body", m.DhGroups); err != nil { + return err + } + + if err := m.DhGroups.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("dhGroups") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("dhGroups") + } + return err + } + + return nil +} + +func (m *IPSecPolicyOptions) validateEncryptions(formats strfmt.Registry) error { + + if err := validate.Required("encryptions", "body", m.Encryptions); err != nil { + return err + } + + if err := m.Encryptions.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("encryptions") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("encryptions") + } + return err + } + + return nil +} + +// ContextValidate validate this IP sec policy options based on the context it is used +func (m *IPSecPolicyOptions) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateAuthentications(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateDhGroups(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateEncryptions(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *IPSecPolicyOptions) contextValidateAuthentications(ctx context.Context, formats strfmt.Registry) error { + + if err := m.Authentications.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("authentications") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("authentications") + } + return err + } + + return nil +} + +func (m *IPSecPolicyOptions) contextValidateDhGroups(ctx context.Context, formats strfmt.Registry) error { + + if err := m.DhGroups.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("dhGroups") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("dhGroups") + } + return err + } + + return nil +} + +func (m *IPSecPolicyOptions) contextValidateEncryptions(ctx context.Context, formats strfmt.Registry) error { + + if err := m.Encryptions.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("encryptions") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("encryptions") + } + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *IPSecPolicyOptions) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *IPSecPolicyOptions) UnmarshalBinary(b []byte) error { + var res IPSecPolicyOptions + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_sec_policy_ref.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_sec_policy_ref.go new file mode 100644 index 00000000000..4b5a384f235 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_sec_policy_ref.go @@ -0,0 +1,90 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// IPSecPolicyRef IPSec Policy reference object +// +// swagger:model IPSecPolicyRef +type IPSecPolicyRef struct { + + // unique identifier of IPSec Policy + // Example: 7abc1234-ab18-4b5c-b123-0d73e8254463 + // Required: true + ID *string `json:"id"` + + // name of IPSec Policy + // Example: IPSec Policy 1 + // Required: true + Name *string `json:"name"` +} + +// Validate validates this IP sec policy ref +func (m *IPSecPolicyRef) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *IPSecPolicyRef) validateID(formats strfmt.Registry) error { + + if err := validate.Required("id", "body", m.ID); err != nil { + return err + } + + return nil +} + +func (m *IPSecPolicyRef) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this IP sec policy ref based on context it is used +func (m *IPSecPolicyRef) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *IPSecPolicyRef) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *IPSecPolicyRef) UnmarshalBinary(b []byte) error { + var res IPSecPolicyRef + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_sec_policy_template.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_sec_policy_template.go new file mode 100644 index 00000000000..7f8c3413714 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_sec_policy_template.go @@ -0,0 +1,165 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// IPSecPolicyTemplate IP sec policy template +// +// swagger:model IPSecPolicyTemplate +type IPSecPolicyTemplate struct { + + // ipSecPolicy Authentication default value + // Example: sha256 + // Required: true + Authentication *string `json:"authentication"` + + // ipSecPolicy DHGroup default value + // Example: 2 + // Required: true + DhGroup *int64 `json:"dhGroup"` + + // ipSecPolicy Encryption default value + // Example: aes-256-cbc + // Required: true + Encryption *string `json:"encryption"` + + // key lifetime + // Required: true + KeyLifetime *KeyLifetime `json:"keyLifetime"` +} + +// Validate validates this IP sec policy template +func (m *IPSecPolicyTemplate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAuthentication(formats); err != nil { + res = append(res, err) + } + + if err := m.validateDhGroup(formats); err != nil { + res = append(res, err) + } + + if err := m.validateEncryption(formats); err != nil { + res = append(res, err) + } + + if err := m.validateKeyLifetime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *IPSecPolicyTemplate) validateAuthentication(formats strfmt.Registry) error { + + if err := validate.Required("authentication", "body", m.Authentication); err != nil { + return err + } + + return nil +} + +func (m *IPSecPolicyTemplate) validateDhGroup(formats strfmt.Registry) error { + + if err := validate.Required("dhGroup", "body", m.DhGroup); err != nil { + return err + } + + return nil +} + +func (m *IPSecPolicyTemplate) validateEncryption(formats strfmt.Registry) error { + + if err := validate.Required("encryption", "body", m.Encryption); err != nil { + return err + } + + return nil +} + +func (m *IPSecPolicyTemplate) validateKeyLifetime(formats strfmt.Registry) error { + + if err := validate.Required("keyLifetime", "body", m.KeyLifetime); err != nil { + return err + } + + if err := validate.Required("keyLifetime", "body", m.KeyLifetime); err != nil { + return err + } + + if m.KeyLifetime != nil { + if err := m.KeyLifetime.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("keyLifetime") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("keyLifetime") + } + return err + } + } + + return nil +} + +// ContextValidate validate this IP sec policy template based on the context it is used +func (m *IPSecPolicyTemplate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateKeyLifetime(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *IPSecPolicyTemplate) contextValidateKeyLifetime(ctx context.Context, formats strfmt.Registry) error { + + if m.KeyLifetime != nil { + if err := m.KeyLifetime.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("keyLifetime") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("keyLifetime") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *IPSecPolicyTemplate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *IPSecPolicyTemplate) UnmarshalBinary(b []byte) error { + var res IPSecPolicyTemplate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_sec_policy_update.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_sec_policy_update.go new file mode 100644 index 00000000000..7ec614b2ba3 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/ip_sec_policy_update.go @@ -0,0 +1,443 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// IPSecPolicyUpdate IPSEc Policy object used for update +// +// Min Properties: 1 +// +// swagger:model IPSecPolicyUpdate +type IPSecPolicyUpdate struct { + + // authentication + Authentication IPSECPolicyAuthentication `json:"authentication,omitempty"` + + // Diffie-Hellman group + // Example: 2 + // Enum: [1 2 5 14 19 20 24] + DhGroup int64 `json:"dhGroup,omitempty"` + + // connection encryption policy + // Example: aes-256-cbc + // Enum: [aes-256-cbc aes-192-cbc aes-128-cbc aes-256-gcm aes-192-gcm aes-128-gcm 3des-cbc] + Encryption string `json:"encryption,omitempty"` + + // key lifetime + KeyLifetime KeyLifetime `json:"keyLifetime,omitempty"` + + // IPSec Policy name + // Example: ipSecPolicy2 + // Max Length: 47 + // Min Length: 1 + Name string `json:"name,omitempty"` + + // Perfect Forward Secrecy + // Example: true + Pfs *bool `json:"pfs,omitempty"` + + // IP sec policy update additional properties + IPSecPolicyUpdateAdditionalProperties map[string]interface{} `json:"-"` +} + +// UnmarshalJSON unmarshals this object with additional properties from JSON +func (m *IPSecPolicyUpdate) UnmarshalJSON(data []byte) error { + // stage 1, bind the properties + var stage1 struct { + + // authentication + Authentication IPSECPolicyAuthentication `json:"authentication,omitempty"` + + // Diffie-Hellman group + // Example: 2 + // Enum: [1 2 5 14 19 20 24] + DhGroup int64 `json:"dhGroup,omitempty"` + + // connection encryption policy + // Example: aes-256-cbc + // Enum: [aes-256-cbc aes-192-cbc aes-128-cbc aes-256-gcm aes-192-gcm aes-128-gcm 3des-cbc] + Encryption string `json:"encryption,omitempty"` + + // key lifetime + KeyLifetime KeyLifetime `json:"keyLifetime,omitempty"` + + // IPSec Policy name + // Example: ipSecPolicy2 + // Max Length: 47 + // Min Length: 1 + Name string `json:"name,omitempty"` + + // Perfect Forward Secrecy + // Example: true + Pfs *bool `json:"pfs,omitempty"` + } + if err := json.Unmarshal(data, &stage1); err != nil { + return err + } + var rcv IPSecPolicyUpdate + + rcv.Authentication = stage1.Authentication + rcv.DhGroup = stage1.DhGroup + rcv.Encryption = stage1.Encryption + rcv.KeyLifetime = stage1.KeyLifetime + rcv.Name = stage1.Name + rcv.Pfs = stage1.Pfs + *m = rcv + + // stage 2, remove properties and add to map + stage2 := make(map[string]json.RawMessage) + if err := json.Unmarshal(data, &stage2); err != nil { + return err + } + + delete(stage2, "authentication") + delete(stage2, "dhGroup") + delete(stage2, "encryption") + delete(stage2, "keyLifetime") + delete(stage2, "name") + delete(stage2, "pfs") + // stage 3, add additional properties values + if len(stage2) > 0 { + result := make(map[string]interface{}) + for k, v := range stage2 { + var toadd interface{} + if err := json.Unmarshal(v, &toadd); err != nil { + return err + } + result[k] = toadd + } + m.IPSecPolicyUpdateAdditionalProperties = result + } + + return nil +} + +// MarshalJSON marshals this object with additional properties into a JSON object +func (m IPSecPolicyUpdate) MarshalJSON() ([]byte, error) { + var stage1 struct { + + // authentication + Authentication IPSECPolicyAuthentication `json:"authentication,omitempty"` + + // Diffie-Hellman group + // Example: 2 + // Enum: [1 2 5 14 19 20 24] + DhGroup int64 `json:"dhGroup,omitempty"` + + // connection encryption policy + // Example: aes-256-cbc + // Enum: [aes-256-cbc aes-192-cbc aes-128-cbc aes-256-gcm aes-192-gcm aes-128-gcm 3des-cbc] + Encryption string `json:"encryption,omitempty"` + + // key lifetime + KeyLifetime KeyLifetime `json:"keyLifetime,omitempty"` + + // IPSec Policy name + // Example: ipSecPolicy2 + // Max Length: 47 + // Min Length: 1 + Name string `json:"name,omitempty"` + + // Perfect Forward Secrecy + // Example: true + Pfs *bool `json:"pfs,omitempty"` + } + + stage1.Authentication = m.Authentication + stage1.DhGroup = m.DhGroup + stage1.Encryption = m.Encryption + stage1.KeyLifetime = m.KeyLifetime + stage1.Name = m.Name + stage1.Pfs = m.Pfs + + // make JSON object for known properties + props, err := json.Marshal(stage1) + if err != nil { + return nil, err + } + + if len(m.IPSecPolicyUpdateAdditionalProperties) == 0 { // no additional properties + return props, nil + } + + // make JSON object for the additional properties + additional, err := json.Marshal(m.IPSecPolicyUpdateAdditionalProperties) + if err != nil { + return nil, err + } + + if len(props) < 3 { // "{}": only additional properties + return additional, nil + } + + // concatenate the 2 objects + return swag.ConcatJSON(props, additional), nil +} + +// Validate validates this IP sec policy update +func (m *IPSecPolicyUpdate) Validate(formats strfmt.Registry) error { + var res []error + + // short circuits minProperties > 0 + if m == nil { + return errors.TooFewProperties("", "body", 1) + } + + props := make(map[string]json.RawMessage, 6+10) + j, err := swag.WriteJSON(m) + if err != nil { + return err + } + + if err = swag.ReadJSON(j, &props); err != nil { + return err + } + + nprops := len(props) + + // minProperties: 1 + if nprops < 1 { + return errors.TooFewProperties("", "body", 1) + } + + if err := m.validateAuthentication(formats); err != nil { + res = append(res, err) + } + + if err := m.validateDhGroup(formats); err != nil { + res = append(res, err) + } + + if err := m.validateEncryption(formats); err != nil { + res = append(res, err) + } + + if err := m.validateKeyLifetime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *IPSecPolicyUpdate) validateAuthentication(formats strfmt.Registry) error { + if swag.IsZero(m.Authentication) { // not required + return nil + } + + if err := m.Authentication.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("authentication") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("authentication") + } + return err + } + + return nil +} + +var ipSecPolicyUpdateTypeDhGroupPropEnum []interface{} + +func init() { + var res []int64 + if err := json.Unmarshal([]byte(`[1,2,5,14,19,20,24]`), &res); err != nil { + panic(err) + } + for _, v := range res { + ipSecPolicyUpdateTypeDhGroupPropEnum = append(ipSecPolicyUpdateTypeDhGroupPropEnum, v) + } +} + +// prop value enum +func (m *IPSecPolicyUpdate) validateDhGroupEnum(path, location string, value int64) error { + if err := validate.EnumCase(path, location, value, ipSecPolicyUpdateTypeDhGroupPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *IPSecPolicyUpdate) validateDhGroup(formats strfmt.Registry) error { + if swag.IsZero(m.DhGroup) { // not required + return nil + } + + // value enum + if err := m.validateDhGroupEnum("dhGroup", "body", m.DhGroup); err != nil { + return err + } + + return nil +} + +var ipSecPolicyUpdateTypeEncryptionPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["aes-256-cbc","aes-192-cbc","aes-128-cbc","aes-256-gcm","aes-192-gcm","aes-128-gcm","3des-cbc"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + ipSecPolicyUpdateTypeEncryptionPropEnum = append(ipSecPolicyUpdateTypeEncryptionPropEnum, v) + } +} + +const ( + + // IPSecPolicyUpdateEncryptionAesDash256DashCbc captures enum value "aes-256-cbc" + IPSecPolicyUpdateEncryptionAesDash256DashCbc string = "aes-256-cbc" + + // IPSecPolicyUpdateEncryptionAesDash192DashCbc captures enum value "aes-192-cbc" + IPSecPolicyUpdateEncryptionAesDash192DashCbc string = "aes-192-cbc" + + // IPSecPolicyUpdateEncryptionAesDash128DashCbc captures enum value "aes-128-cbc" + IPSecPolicyUpdateEncryptionAesDash128DashCbc string = "aes-128-cbc" + + // IPSecPolicyUpdateEncryptionAesDash256DashGcm captures enum value "aes-256-gcm" + IPSecPolicyUpdateEncryptionAesDash256DashGcm string = "aes-256-gcm" + + // IPSecPolicyUpdateEncryptionAesDash192DashGcm captures enum value "aes-192-gcm" + IPSecPolicyUpdateEncryptionAesDash192DashGcm string = "aes-192-gcm" + + // IPSecPolicyUpdateEncryptionAesDash128DashGcm captures enum value "aes-128-gcm" + IPSecPolicyUpdateEncryptionAesDash128DashGcm string = "aes-128-gcm" + + // IPSecPolicyUpdateEncryptionNr3desDashCbc captures enum value "3des-cbc" + IPSecPolicyUpdateEncryptionNr3desDashCbc string = "3des-cbc" +) + +// prop value enum +func (m *IPSecPolicyUpdate) validateEncryptionEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, ipSecPolicyUpdateTypeEncryptionPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *IPSecPolicyUpdate) validateEncryption(formats strfmt.Registry) error { + if swag.IsZero(m.Encryption) { // not required + return nil + } + + // value enum + if err := m.validateEncryptionEnum("encryption", "body", m.Encryption); err != nil { + return err + } + + return nil +} + +func (m *IPSecPolicyUpdate) validateKeyLifetime(formats strfmt.Registry) error { + if swag.IsZero(m.KeyLifetime) { // not required + return nil + } + + if err := m.KeyLifetime.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("keyLifetime") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("keyLifetime") + } + return err + } + + return nil +} + +func (m *IPSecPolicyUpdate) validateName(formats strfmt.Registry) error { + if swag.IsZero(m.Name) { // not required + return nil + } + + if err := validate.MinLength("name", "body", m.Name, 1); err != nil { + return err + } + + if err := validate.MaxLength("name", "body", m.Name, 47); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this IP sec policy update based on the context it is used +func (m *IPSecPolicyUpdate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateAuthentication(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateKeyLifetime(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *IPSecPolicyUpdate) contextValidateAuthentication(ctx context.Context, formats strfmt.Registry) error { + + if err := m.Authentication.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("authentication") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("authentication") + } + return err + } + + return nil +} + +func (m *IPSecPolicyUpdate) contextValidateKeyLifetime(ctx context.Context, formats strfmt.Registry) error { + + if err := m.KeyLifetime.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("keyLifetime") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("keyLifetime") + } + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *IPSecPolicyUpdate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *IPSecPolicyUpdate) UnmarshalBinary(b []byte) error { + var res IPSecPolicyUpdate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/job.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/job.go new file mode 100644 index 00000000000..fd59b76c97e --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/job.go @@ -0,0 +1,192 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Job job +// +// swagger:model Job +type Job struct { + + // create timestamp for the job + // Format: date-time + CreateTimestamp strfmt.DateTime `json:"createTimestamp,omitempty"` + + // id of a job + // Required: true + ID *string `json:"id"` + + // operation + // Required: true + Operation *Operation `json:"operation"` + + // status + // Required: true + Status *Status `json:"status"` +} + +// Validate validates this job +func (m *Job) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreateTimestamp(formats); err != nil { + res = append(res, err) + } + + if err := m.validateID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOperation(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStatus(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Job) validateCreateTimestamp(formats strfmt.Registry) error { + if swag.IsZero(m.CreateTimestamp) { // not required + return nil + } + + if err := validate.FormatOf("createTimestamp", "body", "date-time", m.CreateTimestamp.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *Job) validateID(formats strfmt.Registry) error { + + if err := validate.Required("id", "body", m.ID); err != nil { + return err + } + + return nil +} + +func (m *Job) validateOperation(formats strfmt.Registry) error { + + if err := validate.Required("operation", "body", m.Operation); err != nil { + return err + } + + if m.Operation != nil { + if err := m.Operation.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("operation") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("operation") + } + return err + } + } + + return nil +} + +func (m *Job) validateStatus(formats strfmt.Registry) error { + + if err := validate.Required("status", "body", m.Status); err != nil { + return err + } + + if m.Status != nil { + if err := m.Status.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("status") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("status") + } + return err + } + } + + return nil +} + +// ContextValidate validate this job based on the context it is used +func (m *Job) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateOperation(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateStatus(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Job) contextValidateOperation(ctx context.Context, formats strfmt.Registry) error { + + if m.Operation != nil { + if err := m.Operation.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("operation") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("operation") + } + return err + } + } + + return nil +} + +func (m *Job) contextValidateStatus(ctx context.Context, formats strfmt.Registry) error { + + if m.Status != nil { + if err := m.Status.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("status") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("status") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Job) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Job) UnmarshalBinary(b []byte) error { + var res Job + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/job_reference.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/job_reference.go new file mode 100644 index 00000000000..dc09f76fe84 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/job_reference.go @@ -0,0 +1,88 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// JobReference job reference +// +// swagger:model JobReference +type JobReference struct { + + // Link to job resource + // Required: true + Href *string `json:"href"` + + // id of a job used to get status of long running operation + // Required: true + ID *string `json:"id"` +} + +// Validate validates this job reference +func (m *JobReference) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateHref(formats); err != nil { + res = append(res, err) + } + + if err := m.validateID(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *JobReference) validateHref(formats strfmt.Registry) error { + + if err := validate.Required("href", "body", m.Href); err != nil { + return err + } + + return nil +} + +func (m *JobReference) validateID(formats strfmt.Registry) error { + + if err := validate.Required("id", "body", m.ID); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this job reference based on context it is used +func (m *JobReference) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *JobReference) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *JobReference) UnmarshalBinary(b []byte) error { + var res JobReference + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/jobs.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/jobs.go new file mode 100644 index 00000000000..99fd189bf69 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/jobs.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Jobs jobs +// +// swagger:model Jobs +type Jobs struct { + + // Jobs + // Required: true + Jobs []*Job `json:"jobs"` +} + +// Validate validates this jobs +func (m *Jobs) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateJobs(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Jobs) validateJobs(formats strfmt.Registry) error { + + if err := validate.Required("jobs", "body", m.Jobs); err != nil { + return err + } + + for i := 0; i < len(m.Jobs); i++ { + if swag.IsZero(m.Jobs[i]) { // not required + continue + } + + if m.Jobs[i] != nil { + if err := m.Jobs[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("jobs" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("jobs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this jobs based on the context it is used +func (m *Jobs) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateJobs(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Jobs) contextValidateJobs(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Jobs); i++ { + + if m.Jobs[i] != nil { + if err := m.Jobs[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("jobs" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("jobs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Jobs) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Jobs) UnmarshalBinary(b []byte) error { + var res Jobs + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/json_schema_object.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/json_schema_object.go new file mode 100644 index 00000000000..9fec438a573 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/json_schema_object.go @@ -0,0 +1,11 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +// JSONSchemaObject JSON schema object +// +// swagger:model JSONSchemaObject +type JSONSchemaObject interface{} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/key_lifetime.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/key_lifetime.go new file mode 100644 index 00000000000..053deebb2e3 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/key_lifetime.go @@ -0,0 +1,43 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// KeyLifetime Policy key lifetime +// Example: 28800 +// +// swagger:model KeyLifetime +type KeyLifetime int64 + +// Validate validates this key lifetime +func (m KeyLifetime) Validate(formats strfmt.Registry) error { + var res []error + + if err := validate.MinimumInt("", "body", int64(m), 180, false); err != nil { + return err + } + + if err := validate.MaximumInt("", "body", int64(m), 86400, false); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validates this key lifetime based on context it is used +func (m KeyLifetime) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/last_operation_resource.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/last_operation_resource.go new file mode 100644 index 00000000000..37596b72c29 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/last_operation_resource.go @@ -0,0 +1,113 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// LastOperationResource last operation resource +// +// swagger:model LastOperationResource +type LastOperationResource struct { + + // description + Description string `json:"description,omitempty"` + + // state + // Required: true + // Enum: [in progress succeeded failed] + State *string `json:"state"` +} + +// Validate validates this last operation resource +func (m *LastOperationResource) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateState(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +var lastOperationResourceTypeStatePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["in progress","succeeded","failed"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + lastOperationResourceTypeStatePropEnum = append(lastOperationResourceTypeStatePropEnum, v) + } +} + +const ( + + // LastOperationResourceStateInProgress captures enum value "in progress" + LastOperationResourceStateInProgress string = "in progress" + + // LastOperationResourceStateSucceeded captures enum value "succeeded" + LastOperationResourceStateSucceeded string = "succeeded" + + // LastOperationResourceStateFailed captures enum value "failed" + LastOperationResourceStateFailed string = "failed" +) + +// prop value enum +func (m *LastOperationResource) validateStateEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, lastOperationResourceTypeStatePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *LastOperationResource) validateState(formats strfmt.Registry) error { + + if err := validate.Required("state", "body", m.State); err != nil { + return err + } + + // value enum + if err := m.validateStateEnum("state", "body", *m.State); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this last operation resource based on context it is used +func (m *LastOperationResource) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *LastOperationResource) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *LastOperationResource) UnmarshalBinary(b []byte) error { + var res LastOperationResource + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/maximum_storage_allocation.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/maximum_storage_allocation.go new file mode 100644 index 00000000000..d33f36f3f56 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/maximum_storage_allocation.go @@ -0,0 +1,105 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// MaximumStorageAllocation Maximum storage allocation +// +// swagger:model MaximumStorageAllocation +type MaximumStorageAllocation struct { + + // Maximum allocation storage size (GB) + // Required: true + MaxAllocationSize *int64 `json:"maxAllocationSize"` + + // Storage pool + // Required: true + StoragePool *string `json:"storagePool"` + + // Storage type + // Required: true + StorageType *string `json:"storageType"` +} + +// Validate validates this maximum storage allocation +func (m *MaximumStorageAllocation) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateMaxAllocationSize(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStoragePool(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStorageType(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *MaximumStorageAllocation) validateMaxAllocationSize(formats strfmt.Registry) error { + + if err := validate.Required("maxAllocationSize", "body", m.MaxAllocationSize); err != nil { + return err + } + + return nil +} + +func (m *MaximumStorageAllocation) validateStoragePool(formats strfmt.Registry) error { + + if err := validate.Required("storagePool", "body", m.StoragePool); err != nil { + return err + } + + return nil +} + +func (m *MaximumStorageAllocation) validateStorageType(formats strfmt.Registry) error { + + if err := validate.Required("storageType", "body", m.StorageType); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this maximum storage allocation based on context it is used +func (m *MaximumStorageAllocation) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *MaximumStorageAllocation) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *MaximumStorageAllocation) UnmarshalBinary(b []byte) error { + var res MaximumStorageAllocation + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/metadata.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/metadata.go new file mode 100644 index 00000000000..fcebea3ace2 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/metadata.go @@ -0,0 +1,11 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +// Metadata See [Service Metadata Conventions](https://github.com/openservicebrokerapi/servicebroker/blob/master/profile.md#service-metadata) for more details. +// +// swagger:model Metadata +type Metadata interface{} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/min_max_default.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/min_max_default.go new file mode 100644 index 00000000000..1237d64c310 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/min_max_default.go @@ -0,0 +1,105 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// MinMaxDefault min max default +// +// swagger:model MinMaxDefault +type MinMaxDefault struct { + + // default value + // Required: true + Default *float64 `json:"default"` + + // max value + // Required: true + Max *float64 `json:"max"` + + // min value + // Required: true + Min *float64 `json:"min"` +} + +// Validate validates this min max default +func (m *MinMaxDefault) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateDefault(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMax(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMin(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *MinMaxDefault) validateDefault(formats strfmt.Registry) error { + + if err := validate.Required("default", "body", m.Default); err != nil { + return err + } + + return nil +} + +func (m *MinMaxDefault) validateMax(formats strfmt.Registry) error { + + if err := validate.Required("max", "body", m.Max); err != nil { + return err + } + + return nil +} + +func (m *MinMaxDefault) validateMin(formats strfmt.Registry) error { + + if err := validate.Required("min", "body", m.Min); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this min max default based on context it is used +func (m *MinMaxDefault) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *MinMaxDefault) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *MinMaxDefault) UnmarshalBinary(b []byte) error { + var res MinMaxDefault + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/multi_volumes_create.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/multi_volumes_create.go new file mode 100644 index 00000000000..46527787737 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/multi_volumes_create.go @@ -0,0 +1,166 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// MultiVolumesCreate multi volumes create +// +// swagger:model MultiVolumesCreate +type MultiVolumesCreate struct { + + // PVM Instance (ID or Name)to base volume affinity policy against; required if requesting affinity and affinityVolume is not provided + AffinityPVMInstance *string `json:"affinityPVMInstance,omitempty"` + + // Affinity policy for data volume being created; ignored if volumePool provided; for policy 'affinity' requires one of affinityPVMInstance or affinityVolume to be specified; for policy 'anti-affinity' requires one of antiAffinityPVMInstances or antiAffinityVolumes to be specified + // Enum: [affinity anti-affinity] + AffinityPolicy *string `json:"affinityPolicy,omitempty"` + + // Volume (ID or Name) to base volume affinity policy against; required if requesting affinity and affinityPVMInstance is not provided + AffinityVolume *string `json:"affinityVolume,omitempty"` + + // List of pvmInstances to base volume anti-affinity policy against; required if requesting anti-affinity and antiAffinityVolumes is not provided + AntiAffinityPVMInstances []string `json:"antiAffinityPVMInstances"` + + // List of volumes to base volume anti-affinity policy against; required if requesting anti-affinity and antiAffinityPVMInstances is not provided + AntiAffinityVolumes []string `json:"antiAffinityVolumes"` + + // Number of volumes to create + Count int64 `json:"count,omitempty"` + + // Type of Disk, required if affinityPolicy and volumePool not provided, otherwise ignored + DiskType string `json:"diskType,omitempty"` + + // Base name of the volume(s) + // Required: true + Name *string `json:"name"` + + // Indicates if the volume should be replication enabled or not + ReplicationEnabled *bool `json:"replicationEnabled,omitempty"` + + // Indicates if the volume is shareable between VMs + Shareable *bool `json:"shareable,omitempty"` + + // Volume Size (GB) + // Required: true + Size *int64 `json:"size"` + + // Volume pool where the volume will be created; if provided then diskType and affinityPolicy values will be ignored + VolumePool string `json:"volumePool,omitempty"` +} + +// Validate validates this multi volumes create +func (m *MultiVolumesCreate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAffinityPolicy(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSize(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +var multiVolumesCreateTypeAffinityPolicyPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["affinity","anti-affinity"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + multiVolumesCreateTypeAffinityPolicyPropEnum = append(multiVolumesCreateTypeAffinityPolicyPropEnum, v) + } +} + +const ( + + // MultiVolumesCreateAffinityPolicyAffinity captures enum value "affinity" + MultiVolumesCreateAffinityPolicyAffinity string = "affinity" + + // MultiVolumesCreateAffinityPolicyAntiDashAffinity captures enum value "anti-affinity" + MultiVolumesCreateAffinityPolicyAntiDashAffinity string = "anti-affinity" +) + +// prop value enum +func (m *MultiVolumesCreate) validateAffinityPolicyEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, multiVolumesCreateTypeAffinityPolicyPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *MultiVolumesCreate) validateAffinityPolicy(formats strfmt.Registry) error { + if swag.IsZero(m.AffinityPolicy) { // not required + return nil + } + + // value enum + if err := m.validateAffinityPolicyEnum("affinityPolicy", "body", *m.AffinityPolicy); err != nil { + return err + } + + return nil +} + +func (m *MultiVolumesCreate) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *MultiVolumesCreate) validateSize(formats strfmt.Registry) error { + + if err := validate.Required("size", "body", m.Size); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this multi volumes create based on context it is used +func (m *MultiVolumesCreate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *MultiVolumesCreate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *MultiVolumesCreate) UnmarshalBinary(b []byte) error { + var res MultiVolumesCreate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/network.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/network.go new file mode 100644 index 00000000000..0d008cd8111 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/network.go @@ -0,0 +1,589 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Network network +// +// swagger:model Network +type Network struct { + + // Network in CIDR notation (192.168.0.0/24) + // Required: true + Cidr *string `json:"cidr"` + + // (currently not available) cloud connections this network is attached + CloudConnections []*NetworkCloudConnectionsItems0 `json:"cloudConnections,omitempty"` + + // DHCP Managed Network + DhcpManaged bool `json:"dhcpManaged,omitempty"` + + // DNS Servers + // Required: true + DNSServers []string `json:"dnsServers"` + + // Gateway IP Address + Gateway string `json:"gateway,omitempty"` + + // ip address metrics + // Required: true + IPAddressMetrics *NetworkIPAddressMetrics `json:"ipAddressMetrics"` + + // IP Address Ranges + // Required: true + IPAddressRanges []*IPAddressRange `json:"ipAddressRanges"` + + // MTU Jumbo Network enabled + // Required: true + Jumbo *bool `json:"jumbo"` + + // Network Name + // Required: true + Name *string `json:"name"` + + // Unique Network ID + // Required: true + NetworkID *string `json:"networkID"` + + // Public IP Address Ranges (for pub-vlan networks) + PublicIPAddressRanges []*IPAddressRange `json:"publicIPAddressRanges,omitempty"` + + // Type of Network {vlan, pub-vlan} + // Required: true + // Enum: [vlan pub-vlan] + Type *string `json:"type"` + + // VLAN ID + // Required: true + VlanID *float64 `json:"vlanID"` +} + +// Validate validates this network +func (m *Network) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCidr(formats); err != nil { + res = append(res, err) + } + + if err := m.validateCloudConnections(formats); err != nil { + res = append(res, err) + } + + if err := m.validateDNSServers(formats); err != nil { + res = append(res, err) + } + + if err := m.validateIPAddressMetrics(formats); err != nil { + res = append(res, err) + } + + if err := m.validateIPAddressRanges(formats); err != nil { + res = append(res, err) + } + + if err := m.validateJumbo(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateNetworkID(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePublicIPAddressRanges(formats); err != nil { + res = append(res, err) + } + + if err := m.validateType(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVlanID(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Network) validateCidr(formats strfmt.Registry) error { + + if err := validate.Required("cidr", "body", m.Cidr); err != nil { + return err + } + + return nil +} + +func (m *Network) validateCloudConnections(formats strfmt.Registry) error { + if swag.IsZero(m.CloudConnections) { // not required + return nil + } + + for i := 0; i < len(m.CloudConnections); i++ { + if swag.IsZero(m.CloudConnections[i]) { // not required + continue + } + + if m.CloudConnections[i] != nil { + if err := m.CloudConnections[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("cloudConnections" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cloudConnections" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Network) validateDNSServers(formats strfmt.Registry) error { + + if err := validate.Required("dnsServers", "body", m.DNSServers); err != nil { + return err + } + + return nil +} + +func (m *Network) validateIPAddressMetrics(formats strfmt.Registry) error { + + if err := validate.Required("ipAddressMetrics", "body", m.IPAddressMetrics); err != nil { + return err + } + + if m.IPAddressMetrics != nil { + if err := m.IPAddressMetrics.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ipAddressMetrics") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ipAddressMetrics") + } + return err + } + } + + return nil +} + +func (m *Network) validateIPAddressRanges(formats strfmt.Registry) error { + + if err := validate.Required("ipAddressRanges", "body", m.IPAddressRanges); err != nil { + return err + } + + for i := 0; i < len(m.IPAddressRanges); i++ { + if swag.IsZero(m.IPAddressRanges[i]) { // not required + continue + } + + if m.IPAddressRanges[i] != nil { + if err := m.IPAddressRanges[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ipAddressRanges" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ipAddressRanges" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Network) validateJumbo(formats strfmt.Registry) error { + + if err := validate.Required("jumbo", "body", m.Jumbo); err != nil { + return err + } + + return nil +} + +func (m *Network) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *Network) validateNetworkID(formats strfmt.Registry) error { + + if err := validate.Required("networkID", "body", m.NetworkID); err != nil { + return err + } + + return nil +} + +func (m *Network) validatePublicIPAddressRanges(formats strfmt.Registry) error { + if swag.IsZero(m.PublicIPAddressRanges) { // not required + return nil + } + + for i := 0; i < len(m.PublicIPAddressRanges); i++ { + if swag.IsZero(m.PublicIPAddressRanges[i]) { // not required + continue + } + + if m.PublicIPAddressRanges[i] != nil { + if err := m.PublicIPAddressRanges[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("publicIPAddressRanges" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("publicIPAddressRanges" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +var networkTypeTypePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["vlan","pub-vlan"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + networkTypeTypePropEnum = append(networkTypeTypePropEnum, v) + } +} + +const ( + + // NetworkTypeVlan captures enum value "vlan" + NetworkTypeVlan string = "vlan" + + // NetworkTypePubDashVlan captures enum value "pub-vlan" + NetworkTypePubDashVlan string = "pub-vlan" +) + +// prop value enum +func (m *Network) validateTypeEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, networkTypeTypePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *Network) validateType(formats strfmt.Registry) error { + + if err := validate.Required("type", "body", m.Type); err != nil { + return err + } + + // value enum + if err := m.validateTypeEnum("type", "body", *m.Type); err != nil { + return err + } + + return nil +} + +func (m *Network) validateVlanID(formats strfmt.Registry) error { + + if err := validate.Required("vlanID", "body", m.VlanID); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this network based on the context it is used +func (m *Network) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateCloudConnections(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateIPAddressMetrics(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateIPAddressRanges(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidatePublicIPAddressRanges(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Network) contextValidateCloudConnections(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.CloudConnections); i++ { + + if m.CloudConnections[i] != nil { + if err := m.CloudConnections[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("cloudConnections" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cloudConnections" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Network) contextValidateIPAddressMetrics(ctx context.Context, formats strfmt.Registry) error { + + if m.IPAddressMetrics != nil { + if err := m.IPAddressMetrics.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ipAddressMetrics") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ipAddressMetrics") + } + return err + } + } + + return nil +} + +func (m *Network) contextValidateIPAddressRanges(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.IPAddressRanges); i++ { + + if m.IPAddressRanges[i] != nil { + if err := m.IPAddressRanges[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ipAddressRanges" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ipAddressRanges" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Network) contextValidatePublicIPAddressRanges(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.PublicIPAddressRanges); i++ { + + if m.PublicIPAddressRanges[i] != nil { + if err := m.PublicIPAddressRanges[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("publicIPAddressRanges" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("publicIPAddressRanges" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Network) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Network) UnmarshalBinary(b []byte) error { + var res Network + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// NetworkCloudConnectionsItems0 network cloud connections items0 +// +// swagger:model NetworkCloudConnectionsItems0 +type NetworkCloudConnectionsItems0 struct { + + // the cloud connection id + CloudConnectionID string `json:"cloudConnectionID,omitempty"` + + // link to the cloud connection resource + Href string `json:"href,omitempty"` +} + +// Validate validates this network cloud connections items0 +func (m *NetworkCloudConnectionsItems0) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this network cloud connections items0 based on context it is used +func (m *NetworkCloudConnectionsItems0) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *NetworkCloudConnectionsItems0) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *NetworkCloudConnectionsItems0) UnmarshalBinary(b []byte) error { + var res NetworkCloudConnectionsItems0 + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// NetworkIPAddressMetrics IP Address Metrics +// +// swagger:model NetworkIPAddressMetrics +type NetworkIPAddressMetrics struct { + + // Number of available IP addresses + // Required: true + Available *float64 `json:"available"` + + // Total number of all IP addresses in all ipAddressRanges + // Required: true + Total *float64 `json:"total"` + + // Number of IP addresses currently in use + // Required: true + Used *float64 `json:"used"` + + // Utilization of IP addresses in percent form (used / total) [0 - 100] + // Required: true + Utilization *float64 `json:"utilization"` +} + +// Validate validates this network IP address metrics +func (m *NetworkIPAddressMetrics) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAvailable(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTotal(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUsed(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUtilization(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *NetworkIPAddressMetrics) validateAvailable(formats strfmt.Registry) error { + + if err := validate.Required("ipAddressMetrics"+"."+"available", "body", m.Available); err != nil { + return err + } + + return nil +} + +func (m *NetworkIPAddressMetrics) validateTotal(formats strfmt.Registry) error { + + if err := validate.Required("ipAddressMetrics"+"."+"total", "body", m.Total); err != nil { + return err + } + + return nil +} + +func (m *NetworkIPAddressMetrics) validateUsed(formats strfmt.Registry) error { + + if err := validate.Required("ipAddressMetrics"+"."+"used", "body", m.Used); err != nil { + return err + } + + return nil +} + +func (m *NetworkIPAddressMetrics) validateUtilization(formats strfmt.Registry) error { + + if err := validate.Required("ipAddressMetrics"+"."+"utilization", "body", m.Utilization); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this network IP address metrics based on context it is used +func (m *NetworkIPAddressMetrics) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *NetworkIPAddressMetrics) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *NetworkIPAddressMetrics) UnmarshalBinary(b []byte) error { + var res NetworkIPAddressMetrics + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/network_create.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/network_create.go new file mode 100644 index 00000000000..c5a54d8f6fa --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/network_create.go @@ -0,0 +1,185 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NetworkCreate network create +// +// swagger:model NetworkCreate +type NetworkCreate struct { + + // Network in CIDR notation (192.168.0.0/24) + Cidr string `json:"cidr,omitempty"` + + // DNS Servers + DNSServers []string `json:"dnsServers"` + + // Gateway IP Address + Gateway string `json:"gateway,omitempty"` + + // IP Address Ranges + IPAddressRanges []*IPAddressRange `json:"ipAddressRanges"` + + // Enable MTU Jumbo Network + Jumbo bool `json:"jumbo,omitempty"` + + // Network Name + Name string `json:"name,omitempty"` + + // Type of Network - 'vlan' (private network) 'pub-vlan' (public network) + // Required: true + // Enum: [vlan pub-vlan] + Type *string `json:"type"` +} + +// Validate validates this network create +func (m *NetworkCreate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateIPAddressRanges(formats); err != nil { + res = append(res, err) + } + + if err := m.validateType(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *NetworkCreate) validateIPAddressRanges(formats strfmt.Registry) error { + if swag.IsZero(m.IPAddressRanges) { // not required + return nil + } + + for i := 0; i < len(m.IPAddressRanges); i++ { + if swag.IsZero(m.IPAddressRanges[i]) { // not required + continue + } + + if m.IPAddressRanges[i] != nil { + if err := m.IPAddressRanges[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ipAddressRanges" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ipAddressRanges" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +var networkCreateTypeTypePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["vlan","pub-vlan"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + networkCreateTypeTypePropEnum = append(networkCreateTypeTypePropEnum, v) + } +} + +const ( + + // NetworkCreateTypeVlan captures enum value "vlan" + NetworkCreateTypeVlan string = "vlan" + + // NetworkCreateTypePubDashVlan captures enum value "pub-vlan" + NetworkCreateTypePubDashVlan string = "pub-vlan" +) + +// prop value enum +func (m *NetworkCreate) validateTypeEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, networkCreateTypeTypePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *NetworkCreate) validateType(formats strfmt.Registry) error { + + if err := validate.Required("type", "body", m.Type); err != nil { + return err + } + + // value enum + if err := m.validateTypeEnum("type", "body", *m.Type); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this network create based on the context it is used +func (m *NetworkCreate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateIPAddressRanges(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *NetworkCreate) contextValidateIPAddressRanges(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.IPAddressRanges); i++ { + + if m.IPAddressRanges[i] != nil { + if err := m.IPAddressRanges[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ipAddressRanges" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ipAddressRanges" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *NetworkCreate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *NetworkCreate) UnmarshalBinary(b []byte) error { + var res NetworkCreate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/network_i_ds.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/network_i_ds.go new file mode 100644 index 00000000000..e2ceb6fca31 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/network_i_ds.go @@ -0,0 +1,51 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NetworkIDs network i ds +// +// swagger:model NetworkIDs +type NetworkIDs struct { + + // an array of network IDs + // Example: ["7f950c76-8582-11qeb-8dcd-0242ac143","7f950c76-8582-11veb-8dcd-0242ac153","7f950c76-8582-11deb-8dcd-0242ac163"] + NetworkIDs []string `json:"networkIDs"` +} + +// Validate validates this network i ds +func (m *NetworkIDs) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this network i ds based on context it is used +func (m *NetworkIDs) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *NetworkIDs) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *NetworkIDs) UnmarshalBinary(b []byte) error { + var res NetworkIDs + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/network_id.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/network_id.go new file mode 100644 index 00000000000..98ab9bddc15 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/network_id.go @@ -0,0 +1,72 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NetworkID unique identifier of a network +// +// swagger:model NetworkID +type NetworkID struct { + + // network ID + // Example: 7f950c76-8582-11qeb-8dcd-0242ac172 + // Required: true + NetworkID *string `json:"networkID"` +} + +// Validate validates this network ID +func (m *NetworkID) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateNetworkID(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *NetworkID) validateNetworkID(formats strfmt.Registry) error { + + if err := validate.Required("networkID", "body", m.NetworkID); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this network ID based on context it is used +func (m *NetworkID) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *NetworkID) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *NetworkID) UnmarshalBinary(b []byte) error { + var res NetworkID + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/network_port.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/network_port.go new file mode 100644 index 00000000000..360de77afd7 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/network_port.go @@ -0,0 +1,236 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NetworkPort network port +// +// swagger:model NetworkPort +type NetworkPort struct { + + // Description of the port (not unique or indexable) + // Required: true + Description *string `json:"description"` + + // The external ip address (for pub-vlan networks) + ExternalIP string `json:"externalIP,omitempty"` + + // Link to port resource + Href string `json:"href,omitempty"` + + // The ip address of this port + // Required: true + IPAddress *string `json:"ipAddress"` + + // The mac address of the network interface + // Required: true + MacAddress *string `json:"macAddress"` + + // The unique Port ID + // Required: true + PortID *string `json:"portID"` + + // pvm instance + PvmInstance *NetworkPortPvmInstance `json:"pvmInstance,omitempty"` + + // Te + // Required: true + Status *string `json:"status"` +} + +// Validate validates this network port +func (m *NetworkPort) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateDescription(formats); err != nil { + res = append(res, err) + } + + if err := m.validateIPAddress(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMacAddress(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePortID(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePvmInstance(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStatus(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *NetworkPort) validateDescription(formats strfmt.Registry) error { + + if err := validate.Required("description", "body", m.Description); err != nil { + return err + } + + return nil +} + +func (m *NetworkPort) validateIPAddress(formats strfmt.Registry) error { + + if err := validate.Required("ipAddress", "body", m.IPAddress); err != nil { + return err + } + + return nil +} + +func (m *NetworkPort) validateMacAddress(formats strfmt.Registry) error { + + if err := validate.Required("macAddress", "body", m.MacAddress); err != nil { + return err + } + + return nil +} + +func (m *NetworkPort) validatePortID(formats strfmt.Registry) error { + + if err := validate.Required("portID", "body", m.PortID); err != nil { + return err + } + + return nil +} + +func (m *NetworkPort) validatePvmInstance(formats strfmt.Registry) error { + if swag.IsZero(m.PvmInstance) { // not required + return nil + } + + if m.PvmInstance != nil { + if err := m.PvmInstance.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("pvmInstance") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("pvmInstance") + } + return err + } + } + + return nil +} + +func (m *NetworkPort) validateStatus(formats strfmt.Registry) error { + + if err := validate.Required("status", "body", m.Status); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this network port based on the context it is used +func (m *NetworkPort) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidatePvmInstance(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *NetworkPort) contextValidatePvmInstance(ctx context.Context, formats strfmt.Registry) error { + + if m.PvmInstance != nil { + if err := m.PvmInstance.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("pvmInstance") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("pvmInstance") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *NetworkPort) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *NetworkPort) UnmarshalBinary(b []byte) error { + var res NetworkPort + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// NetworkPortPvmInstance The attached pvm-instance to this port +// +// swagger:model NetworkPortPvmInstance +type NetworkPortPvmInstance struct { + + // Link to pvm-instance resource + Href string `json:"href,omitempty"` + + // The attahed pvm-instance ID + PvmInstanceID string `json:"pvmInstanceID,omitempty"` +} + +// Validate validates this network port pvm instance +func (m *NetworkPortPvmInstance) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this network port pvm instance based on context it is used +func (m *NetworkPortPvmInstance) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *NetworkPortPvmInstance) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *NetworkPortPvmInstance) UnmarshalBinary(b []byte) error { + var res NetworkPortPvmInstance + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/network_port_create.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/network_port_create.go new file mode 100644 index 00000000000..d9c99e85160 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/network_port_create.go @@ -0,0 +1,53 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NetworkPortCreate network port create +// +// swagger:model NetworkPortCreate +type NetworkPortCreate struct { + + // Description of the port (not unique or indexable) + Description string `json:"description,omitempty"` + + // The requested ip address of this port + IPAddress string `json:"ipAddress,omitempty"` +} + +// Validate validates this network port create +func (m *NetworkPortCreate) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this network port create based on context it is used +func (m *NetworkPortCreate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *NetworkPortCreate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *NetworkPortCreate) UnmarshalBinary(b []byte) error { + var res NetworkPortCreate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/network_port_update.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/network_port_update.go new file mode 100644 index 00000000000..6b438efb735 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/network_port_update.go @@ -0,0 +1,53 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NetworkPortUpdate network port update +// +// swagger:model NetworkPortUpdate +type NetworkPortUpdate struct { + + // Description of the port (not unique or indexable) + Description *string `json:"description,omitempty"` + + // If supplied populated it attaches to the PVMInstanceID, if empty detaches from PVMInstanceID + PvmInstanceID *string `json:"pvmInstanceID,omitempty"` +} + +// Validate validates this network port update +func (m *NetworkPortUpdate) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this network port update based on context it is used +func (m *NetworkPortUpdate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *NetworkPortUpdate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *NetworkPortUpdate) UnmarshalBinary(b []byte) error { + var res NetworkPortUpdate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/network_ports.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/network_ports.go new file mode 100644 index 00000000000..78f26b2249c --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/network_ports.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NetworkPorts network ports +// +// swagger:model NetworkPorts +type NetworkPorts struct { + + // Network Ports + // Required: true + Ports []*NetworkPort `json:"ports"` +} + +// Validate validates this network ports +func (m *NetworkPorts) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validatePorts(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *NetworkPorts) validatePorts(formats strfmt.Registry) error { + + if err := validate.Required("ports", "body", m.Ports); err != nil { + return err + } + + for i := 0; i < len(m.Ports); i++ { + if swag.IsZero(m.Ports[i]) { // not required + continue + } + + if m.Ports[i] != nil { + if err := m.Ports[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ports" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ports" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this network ports based on the context it is used +func (m *NetworkPorts) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidatePorts(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *NetworkPorts) contextValidatePorts(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Ports); i++ { + + if m.Ports[i] != nil { + if err := m.Ports[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ports" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ports" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *NetworkPorts) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *NetworkPorts) UnmarshalBinary(b []byte) error { + var res NetworkPorts + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/network_reference.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/network_reference.go new file mode 100644 index 00000000000..0398445e891 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/network_reference.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NetworkReference network reference +// +// swagger:model NetworkReference +type NetworkReference struct { + + // DHCP Managed Network + DhcpManaged bool `json:"dhcpManaged,omitempty"` + + // Link to Network resource + // Required: true + Href *string `json:"href"` + + // MTU Jumbo Network enabled + // Required: true + Jumbo *bool `json:"jumbo"` + + // Network Name + // Required: true + Name *string `json:"name"` + + // Unique Network ID + // Required: true + NetworkID *string `json:"networkID"` + + // Type of Network {vlan, pub-vlan} + // Required: true + // Enum: [vlan pub-vlan] + Type *string `json:"type"` + + // VLAN ID + // Required: true + VlanID *float64 `json:"vlanID"` +} + +// Validate validates this network reference +func (m *NetworkReference) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateHref(formats); err != nil { + res = append(res, err) + } + + if err := m.validateJumbo(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateNetworkID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateType(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVlanID(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *NetworkReference) validateHref(formats strfmt.Registry) error { + + if err := validate.Required("href", "body", m.Href); err != nil { + return err + } + + return nil +} + +func (m *NetworkReference) validateJumbo(formats strfmt.Registry) error { + + if err := validate.Required("jumbo", "body", m.Jumbo); err != nil { + return err + } + + return nil +} + +func (m *NetworkReference) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *NetworkReference) validateNetworkID(formats strfmt.Registry) error { + + if err := validate.Required("networkID", "body", m.NetworkID); err != nil { + return err + } + + return nil +} + +var networkReferenceTypeTypePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["vlan","pub-vlan"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + networkReferenceTypeTypePropEnum = append(networkReferenceTypeTypePropEnum, v) + } +} + +const ( + + // NetworkReferenceTypeVlan captures enum value "vlan" + NetworkReferenceTypeVlan string = "vlan" + + // NetworkReferenceTypePubDashVlan captures enum value "pub-vlan" + NetworkReferenceTypePubDashVlan string = "pub-vlan" +) + +// prop value enum +func (m *NetworkReference) validateTypeEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, networkReferenceTypeTypePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *NetworkReference) validateType(formats strfmt.Registry) error { + + if err := validate.Required("type", "body", m.Type); err != nil { + return err + } + + // value enum + if err := m.validateTypeEnum("type", "body", *m.Type); err != nil { + return err + } + + return nil +} + +func (m *NetworkReference) validateVlanID(formats strfmt.Registry) error { + + if err := validate.Required("vlanID", "body", m.VlanID); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this network reference based on context it is used +func (m *NetworkReference) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *NetworkReference) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *NetworkReference) UnmarshalBinary(b []byte) error { + var res NetworkReference + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/network_update.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/network_update.go new file mode 100644 index 00000000000..af849c48872 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/network_update.go @@ -0,0 +1,125 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NetworkUpdate network update +// +// swagger:model NetworkUpdate +type NetworkUpdate struct { + + // Replaces the current DNS Servers + DNSServers []string `json:"dnsServers"` + + // Replaces the current Gateway IP Address + Gateway *string `json:"gateway,omitempty"` + + // Replaces the current IP Address Ranges + IPAddressRanges []*IPAddressRange `json:"ipAddressRanges"` + + // Replaces the current Network Name + Name *string `json:"name,omitempty"` +} + +// Validate validates this network update +func (m *NetworkUpdate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateIPAddressRanges(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *NetworkUpdate) validateIPAddressRanges(formats strfmt.Registry) error { + if swag.IsZero(m.IPAddressRanges) { // not required + return nil + } + + for i := 0; i < len(m.IPAddressRanges); i++ { + if swag.IsZero(m.IPAddressRanges[i]) { // not required + continue + } + + if m.IPAddressRanges[i] != nil { + if err := m.IPAddressRanges[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ipAddressRanges" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ipAddressRanges" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this network update based on the context it is used +func (m *NetworkUpdate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateIPAddressRanges(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *NetworkUpdate) contextValidateIPAddressRanges(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.IPAddressRanges); i++ { + + if m.IPAddressRanges[i] != nil { + if err := m.IPAddressRanges[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ipAddressRanges" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ipAddressRanges" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *NetworkUpdate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *NetworkUpdate) UnmarshalBinary(b []byte) error { + var res NetworkUpdate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/networks.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/networks.go new file mode 100644 index 00000000000..42428ee31df --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/networks.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Networks networks +// +// swagger:model Networks +type Networks struct { + + // Network References + // Required: true + Networks []*NetworkReference `json:"networks"` +} + +// Validate validates this networks +func (m *Networks) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateNetworks(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Networks) validateNetworks(formats strfmt.Registry) error { + + if err := validate.Required("networks", "body", m.Networks); err != nil { + return err + } + + for i := 0; i < len(m.Networks); i++ { + if swag.IsZero(m.Networks[i]) { // not required + continue + } + + if m.Networks[i] != nil { + if err := m.Networks[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("networks" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("networks" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this networks based on the context it is used +func (m *Networks) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateNetworks(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Networks) contextValidateNetworks(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Networks); i++ { + + if m.Networks[i] != nil { + if err := m.Networks[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("networks" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("networks" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Networks) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Networks) UnmarshalBinary(b []byte) error { + var res Networks + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/object.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/object.go new file mode 100644 index 00000000000..cf28d25ee33 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/object.go @@ -0,0 +1,11 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +// Object object +// +// swagger:model Object +type Object interface{} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/open_stack.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/open_stack.go new file mode 100644 index 00000000000..6654773e098 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/open_stack.go @@ -0,0 +1,139 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// OpenStack open stack +// +// swagger:model OpenStack +type OpenStack struct { + + // Unique identifier for the OpenStack instance + // Required: true + ID *string `json:"id"` + + // Internal IP address of the OpenStack instance + // Required: true + IPAddress *string `json:"ipAddress"` + + // Shortname of the OpenStack instance + // Required: true + Name *string `json:"name"` + + // Next available VLAN ID to be used for a network creation + // Required: true + NextVLANID *float64 `json:"nextVLANID"` + + // The region where the open stack lives + // Required: true + Region *string `json:"region"` +} + +// Validate validates this open stack +func (m *OpenStack) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateIPAddress(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateNextVLANID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRegion(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *OpenStack) validateID(formats strfmt.Registry) error { + + if err := validate.Required("id", "body", m.ID); err != nil { + return err + } + + return nil +} + +func (m *OpenStack) validateIPAddress(formats strfmt.Registry) error { + + if err := validate.Required("ipAddress", "body", m.IPAddress); err != nil { + return err + } + + return nil +} + +func (m *OpenStack) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *OpenStack) validateNextVLANID(formats strfmt.Registry) error { + + if err := validate.Required("nextVLANID", "body", m.NextVLANID); err != nil { + return err + } + + return nil +} + +func (m *OpenStack) validateRegion(formats strfmt.Registry) error { + + if err := validate.Required("region", "body", m.Region); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this open stack based on context it is used +func (m *OpenStack) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *OpenStack) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *OpenStack) UnmarshalBinary(b []byte) error { + var res OpenStack + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/open_stack_create.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/open_stack_create.go new file mode 100644 index 00000000000..9c63f292e68 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/open_stack_create.go @@ -0,0 +1,105 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// OpenStackCreate open stack create +// +// swagger:model OpenStackCreate +type OpenStackCreate struct { + + // Internal IP address of the OpenStack instance + // Required: true + IPAddress *string `json:"ipAddress"` + + // Shortname of the OpenStack instance + // Required: true + Name *string `json:"name"` + + // The region where the open stack lives + // Required: true + Region *string `json:"region"` +} + +// Validate validates this open stack create +func (m *OpenStackCreate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateIPAddress(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRegion(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *OpenStackCreate) validateIPAddress(formats strfmt.Registry) error { + + if err := validate.Required("ipAddress", "body", m.IPAddress); err != nil { + return err + } + + return nil +} + +func (m *OpenStackCreate) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *OpenStackCreate) validateRegion(formats strfmt.Registry) error { + + if err := validate.Required("region", "body", m.Region); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this open stack create based on context it is used +func (m *OpenStackCreate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *OpenStackCreate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *OpenStackCreate) UnmarshalBinary(b []byte) error { + var res OpenStackCreate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/open_stack_info.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/open_stack_info.go new file mode 100644 index 00000000000..b98ee9762c7 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/open_stack_info.go @@ -0,0 +1,136 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// OpenStackInfo open stack info +// +// swagger:model OpenStackInfo +type OpenStackInfo struct { + + // Hosts on OpenStack + // Required: true + Hosts []*HostInfo `json:"hosts"` + + // Requested region + // Required: true + Region *string `json:"region"` +} + +// Validate validates this open stack info +func (m *OpenStackInfo) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateHosts(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRegion(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *OpenStackInfo) validateHosts(formats strfmt.Registry) error { + + if err := validate.Required("hosts", "body", m.Hosts); err != nil { + return err + } + + for i := 0; i < len(m.Hosts); i++ { + if swag.IsZero(m.Hosts[i]) { // not required + continue + } + + if m.Hosts[i] != nil { + if err := m.Hosts[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("hosts" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("hosts" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *OpenStackInfo) validateRegion(formats strfmt.Registry) error { + + if err := validate.Required("region", "body", m.Region); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this open stack info based on the context it is used +func (m *OpenStackInfo) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateHosts(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *OpenStackInfo) contextValidateHosts(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Hosts); i++ { + + if m.Hosts[i] != nil { + if err := m.Hosts[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("hosts" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("hosts" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *OpenStackInfo) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *OpenStackInfo) UnmarshalBinary(b []byte) error { + var res OpenStackInfo + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/open_stacks.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/open_stacks.go new file mode 100644 index 00000000000..3b4c526548c --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/open_stacks.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// OpenStacks open stacks +// +// swagger:model OpenStacks +type OpenStacks struct { + + // OpenStacks managed by Power IAAS + // Required: true + OpenStacks []*OpenStack `json:"openStacks"` +} + +// Validate validates this open stacks +func (m *OpenStacks) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateOpenStacks(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *OpenStacks) validateOpenStacks(formats strfmt.Registry) error { + + if err := validate.Required("openStacks", "body", m.OpenStacks); err != nil { + return err + } + + for i := 0; i < len(m.OpenStacks); i++ { + if swag.IsZero(m.OpenStacks[i]) { // not required + continue + } + + if m.OpenStacks[i] != nil { + if err := m.OpenStacks[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("openStacks" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("openStacks" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this open stacks based on the context it is used +func (m *OpenStacks) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateOpenStacks(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *OpenStacks) contextValidateOpenStacks(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.OpenStacks); i++ { + + if m.OpenStacks[i] != nil { + if err := m.OpenStacks[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("openStacks" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("openStacks" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *OpenStacks) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *OpenStacks) UnmarshalBinary(b []byte) error { + var res OpenStacks + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/operation.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/operation.go new file mode 100644 index 00000000000..3423d9e7b09 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/operation.go @@ -0,0 +1,105 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Operation operation +// +// swagger:model Operation +type Operation struct { + + // current action of the operation + // Required: true + Action *string `json:"action"` + + // ID of an operation + // Required: true + ID *string `json:"id"` + + // target resource of the operation + // Required: true + Target *string `json:"target"` +} + +// Validate validates this operation +func (m *Operation) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAction(formats); err != nil { + res = append(res, err) + } + + if err := m.validateID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTarget(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Operation) validateAction(formats strfmt.Registry) error { + + if err := validate.Required("action", "body", m.Action); err != nil { + return err + } + + return nil +} + +func (m *Operation) validateID(formats strfmt.Registry) error { + + if err := validate.Required("id", "body", m.ID); err != nil { + return err + } + + return nil +} + +func (m *Operation) validateTarget(formats strfmt.Registry) error { + + if err := validate.Required("target", "body", m.Target); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this operation based on context it is used +func (m *Operation) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Operation) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Operation) UnmarshalBinary(b []byte) error { + var res Operation + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/operations.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/operations.go new file mode 100644 index 00000000000..4c2d8b0808b --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/operations.go @@ -0,0 +1,229 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Operations operations +// +// swagger:model Operations +type Operations struct { + + // Name of the server boot mode a(Boot from disk using copy A), b(Boot from disk using copy B), c(Reserved for IBM lab use only), d(Boot from media/drives) + // Enum: [a b c d] + BootMode string `json:"bootMode,omitempty"` + + // Name of the server operating mode + // Enum: [normal manual] + OperatingMode string `json:"operatingMode,omitempty"` + + // Name of the job task to execute + // Enum: [dston retrydump consoleservice iopreset remotedstoff remotedston iopdump dumprestart] + Task string `json:"task,omitempty"` +} + +// Validate validates this operations +func (m *Operations) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateBootMode(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOperatingMode(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTask(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +var operationsTypeBootModePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["a","b","c","d"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + operationsTypeBootModePropEnum = append(operationsTypeBootModePropEnum, v) + } +} + +const ( + + // OperationsBootModeA captures enum value "a" + OperationsBootModeA string = "a" + + // OperationsBootModeB captures enum value "b" + OperationsBootModeB string = "b" + + // OperationsBootModeC captures enum value "c" + OperationsBootModeC string = "c" + + // OperationsBootModeD captures enum value "d" + OperationsBootModeD string = "d" +) + +// prop value enum +func (m *Operations) validateBootModeEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, operationsTypeBootModePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *Operations) validateBootMode(formats strfmt.Registry) error { + if swag.IsZero(m.BootMode) { // not required + return nil + } + + // value enum + if err := m.validateBootModeEnum("bootMode", "body", m.BootMode); err != nil { + return err + } + + return nil +} + +var operationsTypeOperatingModePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["normal","manual"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + operationsTypeOperatingModePropEnum = append(operationsTypeOperatingModePropEnum, v) + } +} + +const ( + + // OperationsOperatingModeNormal captures enum value "normal" + OperationsOperatingModeNormal string = "normal" + + // OperationsOperatingModeManual captures enum value "manual" + OperationsOperatingModeManual string = "manual" +) + +// prop value enum +func (m *Operations) validateOperatingModeEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, operationsTypeOperatingModePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *Operations) validateOperatingMode(formats strfmt.Registry) error { + if swag.IsZero(m.OperatingMode) { // not required + return nil + } + + // value enum + if err := m.validateOperatingModeEnum("operatingMode", "body", m.OperatingMode); err != nil { + return err + } + + return nil +} + +var operationsTypeTaskPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["dston","retrydump","consoleservice","iopreset","remotedstoff","remotedston","iopdump","dumprestart"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + operationsTypeTaskPropEnum = append(operationsTypeTaskPropEnum, v) + } +} + +const ( + + // OperationsTaskDston captures enum value "dston" + OperationsTaskDston string = "dston" + + // OperationsTaskRetrydump captures enum value "retrydump" + OperationsTaskRetrydump string = "retrydump" + + // OperationsTaskConsoleservice captures enum value "consoleservice" + OperationsTaskConsoleservice string = "consoleservice" + + // OperationsTaskIopreset captures enum value "iopreset" + OperationsTaskIopreset string = "iopreset" + + // OperationsTaskRemotedstoff captures enum value "remotedstoff" + OperationsTaskRemotedstoff string = "remotedstoff" + + // OperationsTaskRemotedston captures enum value "remotedston" + OperationsTaskRemotedston string = "remotedston" + + // OperationsTaskIopdump captures enum value "iopdump" + OperationsTaskIopdump string = "iopdump" + + // OperationsTaskDumprestart captures enum value "dumprestart" + OperationsTaskDumprestart string = "dumprestart" +) + +// prop value enum +func (m *Operations) validateTaskEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, operationsTypeTaskPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *Operations) validateTask(formats strfmt.Registry) error { + if swag.IsZero(m.Task) { // not required + return nil + } + + // value enum + if err := m.validateTaskEnum("task", "body", m.Task); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this operations based on context it is used +func (m *Operations) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Operations) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Operations) UnmarshalBinary(b []byte) error { + var res Operations + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/options.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/options.go new file mode 100644 index 00000000000..f0738536b33 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/options.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Options options +// +// swagger:model Options +type Options struct { + + // vpnaas options + // Required: true + VpnaasOptions *VPNaaSOptions `json:"vpnaasOptions"` +} + +// Validate validates this options +func (m *Options) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateVpnaasOptions(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Options) validateVpnaasOptions(formats strfmt.Registry) error { + + if err := validate.Required("vpnaasOptions", "body", m.VpnaasOptions); err != nil { + return err + } + + if m.VpnaasOptions != nil { + if err := m.VpnaasOptions.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("vpnaasOptions") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("vpnaasOptions") + } + return err + } + } + + return nil +} + +// ContextValidate validate this options based on the context it is used +func (m *Options) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateVpnaasOptions(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Options) contextValidateVpnaasOptions(ctx context.Context, formats strfmt.Registry) error { + + if m.VpnaasOptions != nil { + if err := m.VpnaasOptions.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("vpnaasOptions") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("vpnaasOptions") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Options) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Options) UnmarshalBinary(b []byte) error { + var res Options + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/owner_info.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/owner_info.go new file mode 100644 index 00000000000..3ed158c49e4 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/owner_info.go @@ -0,0 +1,241 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// OwnerInfo owner info +// +// swagger:model OwnerInfo +type OwnerInfo struct { + + // Country code of user + // Required: true + CountryCode *string `json:"countryCode"` + + // Currency code of user + // Required: true + CurrencyCode *string `json:"currencyCode"` + + // Email address of user + // Required: true + Email *string `json:"email"` + + // IAM id of user + // Required: true + IamID *string `json:"iamID"` + + // Indicates if user is an IBMer + // Required: true + IsIBMer *bool `json:"isIBMer"` + + // Name of user + // Required: true + Name *string `json:"name"` + + // (deprecated - replaced by softlayerSubscriptions) Array of Soft Layer IDs + SoftlayerIDs []string `json:"softlayerIDs"` + + // Array of softlayer subscriptions + // Required: true + SoftlayerSubscriptions []*SoftlayerSubscription `json:"softlayerSubscriptions"` + + // User id of user + // Required: true + UserID *string `json:"userID"` +} + +// Validate validates this owner info +func (m *OwnerInfo) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCountryCode(formats); err != nil { + res = append(res, err) + } + + if err := m.validateCurrencyCode(formats); err != nil { + res = append(res, err) + } + + if err := m.validateEmail(formats); err != nil { + res = append(res, err) + } + + if err := m.validateIamID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateIsIBMer(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSoftlayerSubscriptions(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUserID(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *OwnerInfo) validateCountryCode(formats strfmt.Registry) error { + + if err := validate.Required("countryCode", "body", m.CountryCode); err != nil { + return err + } + + return nil +} + +func (m *OwnerInfo) validateCurrencyCode(formats strfmt.Registry) error { + + if err := validate.Required("currencyCode", "body", m.CurrencyCode); err != nil { + return err + } + + return nil +} + +func (m *OwnerInfo) validateEmail(formats strfmt.Registry) error { + + if err := validate.Required("email", "body", m.Email); err != nil { + return err + } + + return nil +} + +func (m *OwnerInfo) validateIamID(formats strfmt.Registry) error { + + if err := validate.Required("iamID", "body", m.IamID); err != nil { + return err + } + + return nil +} + +func (m *OwnerInfo) validateIsIBMer(formats strfmt.Registry) error { + + if err := validate.Required("isIBMer", "body", m.IsIBMer); err != nil { + return err + } + + return nil +} + +func (m *OwnerInfo) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *OwnerInfo) validateSoftlayerSubscriptions(formats strfmt.Registry) error { + + if err := validate.Required("softlayerSubscriptions", "body", m.SoftlayerSubscriptions); err != nil { + return err + } + + for i := 0; i < len(m.SoftlayerSubscriptions); i++ { + if swag.IsZero(m.SoftlayerSubscriptions[i]) { // not required + continue + } + + if m.SoftlayerSubscriptions[i] != nil { + if err := m.SoftlayerSubscriptions[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("softlayerSubscriptions" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("softlayerSubscriptions" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *OwnerInfo) validateUserID(formats strfmt.Registry) error { + + if err := validate.Required("userID", "body", m.UserID); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this owner info based on the context it is used +func (m *OwnerInfo) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateSoftlayerSubscriptions(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *OwnerInfo) contextValidateSoftlayerSubscriptions(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.SoftlayerSubscriptions); i++ { + + if m.SoftlayerSubscriptions[i] != nil { + if err := m.SoftlayerSubscriptions[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("softlayerSubscriptions" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("softlayerSubscriptions" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *OwnerInfo) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *OwnerInfo) UnmarshalBinary(b []byte) error { + var res OwnerInfo + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance.go new file mode 100644 index 00000000000..5e0a9f10e3f --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance.go @@ -0,0 +1,843 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// PVMInstance p VM instance +// +// swagger:model PVMInstance +type PVMInstance struct { + + // (deprecated - replaced by networks) The list of addresses and their network information + Addresses []*PVMInstanceNetwork `json:"addresses"` + + // Console language and code + ConsoleLanguage *ConsoleLanguage `json:"consoleLanguage,omitempty"` + + // Date/Time of PVM creation + // Format: date-time + CreationDate strfmt.DateTime `json:"creationDate,omitempty"` + + // Size of allocated disk (in GB) + // Required: true + DiskSize *float64 `json:"diskSize"` + + // fault + Fault *PVMInstanceFault `json:"fault,omitempty"` + + // health + Health *PVMInstanceHealth `json:"health,omitempty"` + + // The PVM Instance Host ID (Internal Use Only) + HostID int64 `json:"hostID,omitempty"` + + // The ImageID used by the server + // Required: true + ImageID *string `json:"imageID"` + + // The VTL license repository capacity TB value + LicenseRepositoryCapacity int64 `json:"licenseRepositoryCapacity,omitempty"` + + // Maximum amount of memory that can be allocated (in GB, for resize) + Maxmem float64 `json:"maxmem,omitempty"` + + // Maximum number of processors that can be allocated (for resize) + Maxproc float64 `json:"maxproc,omitempty"` + + // Amount of memory allocated (in GB) + // Required: true + Memory *float64 `json:"memory"` + + // whether the instance can be migrated + Migratable *bool `json:"migratable,omitempty"` + + // Minimum amount of memory that can be allocated (in GB, for resize) + Minmem float64 `json:"minmem,omitempty"` + + // Minimum number of processors that can be allocated (for resize) + Minproc float64 `json:"minproc,omitempty"` + + // (deprecated - replaced by networks) List of Network IDs + // Required: true + NetworkIDs []string `json:"networkIDs"` + + // The pvm instance networks information + Networks []*PVMInstanceNetwork `json:"networks"` + + // OS system information (usually version and build) + OperatingSystem string `json:"operatingSystem,omitempty"` + + // Type of the OS [aix, ibmi, rhel, sles, vtl, rhcos] + // Required: true + OsType *string `json:"osType"` + + // VM pinning policy to use [none, soft, hard] + PinPolicy string `json:"pinPolicy,omitempty"` + + // The placement group of the server + PlacementGroup *string `json:"placementGroup,omitempty"` + + // Processor type (dedicated, shared, capped) + // Required: true + // Enum: [dedicated shared capped ] + ProcType *string `json:"procType"` + + // Number of processors allocated + // Required: true + Processors *float64 `json:"processors"` + + // The progress of an operation + Progress float64 `json:"progress,omitempty"` + + // PCloud PVM Instance ID + // Required: true + PvmInstanceID *string `json:"pvmInstanceID"` + + // If this is an SAP pvm-instance the profile reference will link to the SAP profile + SapProfile *SAPProfileReference `json:"sapProfile,omitempty"` + + // Name of the server + // Required: true + ServerName *string `json:"serverName"` + + // The pvm instance Software Licenses + SoftwareLicenses *SoftwareLicenses `json:"softwareLicenses,omitempty"` + + // The pvm instance SRC lists + Srcs [][]*SRC `json:"srcs"` + + // The status of the instance + // Required: true + Status *string `json:"status"` + + // Storage Pool where server is deployed + StoragePool string `json:"storagePool,omitempty"` + + // Indicates if all volumes attached to the server must reside in the same storage pool; Defaults to true when initially deploying a PVMInstance + StoragePoolAffinity *bool `json:"storagePoolAffinity,omitempty"` + + // Storage type where server is deployed + // Required: true + StorageType *string `json:"storageType"` + + // System type used to host the instance + SysType string `json:"sysType,omitempty"` + + // Date/Time of PVM last update + // Format: date-time + UpdatedDate strfmt.DateTime `json:"updatedDate,omitempty"` + + // The pvm instance virtual CPU information + VirtualCores *VirtualCores `json:"virtualCores,omitempty"` + + // List of volume IDs + // Required: true + VolumeIDs []string `json:"volumeIDs"` +} + +// Validate validates this p VM instance +func (m *PVMInstance) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAddresses(formats); err != nil { + res = append(res, err) + } + + if err := m.validateConsoleLanguage(formats); err != nil { + res = append(res, err) + } + + if err := m.validateCreationDate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateDiskSize(formats); err != nil { + res = append(res, err) + } + + if err := m.validateFault(formats); err != nil { + res = append(res, err) + } + + if err := m.validateHealth(formats); err != nil { + res = append(res, err) + } + + if err := m.validateImageID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMemory(formats); err != nil { + res = append(res, err) + } + + if err := m.validateNetworkIDs(formats); err != nil { + res = append(res, err) + } + + if err := m.validateNetworks(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOsType(formats); err != nil { + res = append(res, err) + } + + if err := m.validateProcType(formats); err != nil { + res = append(res, err) + } + + if err := m.validateProcessors(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePvmInstanceID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSapProfile(formats); err != nil { + res = append(res, err) + } + + if err := m.validateServerName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSoftwareLicenses(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSrcs(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStatus(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStorageType(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUpdatedDate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVirtualCores(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVolumeIDs(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PVMInstance) validateAddresses(formats strfmt.Registry) error { + if swag.IsZero(m.Addresses) { // not required + return nil + } + + for i := 0; i < len(m.Addresses); i++ { + if swag.IsZero(m.Addresses[i]) { // not required + continue + } + + if m.Addresses[i] != nil { + if err := m.Addresses[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("addresses" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("addresses" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *PVMInstance) validateConsoleLanguage(formats strfmt.Registry) error { + if swag.IsZero(m.ConsoleLanguage) { // not required + return nil + } + + if m.ConsoleLanguage != nil { + if err := m.ConsoleLanguage.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("consoleLanguage") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("consoleLanguage") + } + return err + } + } + + return nil +} + +func (m *PVMInstance) validateCreationDate(formats strfmt.Registry) error { + if swag.IsZero(m.CreationDate) { // not required + return nil + } + + if err := validate.FormatOf("creationDate", "body", "date-time", m.CreationDate.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *PVMInstance) validateDiskSize(formats strfmt.Registry) error { + + if err := validate.Required("diskSize", "body", m.DiskSize); err != nil { + return err + } + + return nil +} + +func (m *PVMInstance) validateFault(formats strfmt.Registry) error { + if swag.IsZero(m.Fault) { // not required + return nil + } + + if m.Fault != nil { + if err := m.Fault.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("fault") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("fault") + } + return err + } + } + + return nil +} + +func (m *PVMInstance) validateHealth(formats strfmt.Registry) error { + if swag.IsZero(m.Health) { // not required + return nil + } + + if m.Health != nil { + if err := m.Health.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("health") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("health") + } + return err + } + } + + return nil +} + +func (m *PVMInstance) validateImageID(formats strfmt.Registry) error { + + if err := validate.Required("imageID", "body", m.ImageID); err != nil { + return err + } + + return nil +} + +func (m *PVMInstance) validateMemory(formats strfmt.Registry) error { + + if err := validate.Required("memory", "body", m.Memory); err != nil { + return err + } + + return nil +} + +func (m *PVMInstance) validateNetworkIDs(formats strfmt.Registry) error { + + if err := validate.Required("networkIDs", "body", m.NetworkIDs); err != nil { + return err + } + + return nil +} + +func (m *PVMInstance) validateNetworks(formats strfmt.Registry) error { + if swag.IsZero(m.Networks) { // not required + return nil + } + + for i := 0; i < len(m.Networks); i++ { + if swag.IsZero(m.Networks[i]) { // not required + continue + } + + if m.Networks[i] != nil { + if err := m.Networks[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("networks" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("networks" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *PVMInstance) validateOsType(formats strfmt.Registry) error { + + if err := validate.Required("osType", "body", m.OsType); err != nil { + return err + } + + return nil +} + +var pVmInstanceTypeProcTypePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["dedicated","shared","capped",""]`), &res); err != nil { + panic(err) + } + for _, v := range res { + pVmInstanceTypeProcTypePropEnum = append(pVmInstanceTypeProcTypePropEnum, v) + } +} + +const ( + + // PVMInstanceProcTypeDedicated captures enum value "dedicated" + PVMInstanceProcTypeDedicated string = "dedicated" + + // PVMInstanceProcTypeShared captures enum value "shared" + PVMInstanceProcTypeShared string = "shared" + + // PVMInstanceProcTypeCapped captures enum value "capped" + PVMInstanceProcTypeCapped string = "capped" + + // PVMInstanceProcTypeEmpty captures enum value "" + PVMInstanceProcTypeEmpty string = "" +) + +// prop value enum +func (m *PVMInstance) validateProcTypeEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, pVmInstanceTypeProcTypePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *PVMInstance) validateProcType(formats strfmt.Registry) error { + + if err := validate.Required("procType", "body", m.ProcType); err != nil { + return err + } + + // value enum + if err := m.validateProcTypeEnum("procType", "body", *m.ProcType); err != nil { + return err + } + + return nil +} + +func (m *PVMInstance) validateProcessors(formats strfmt.Registry) error { + + if err := validate.Required("processors", "body", m.Processors); err != nil { + return err + } + + return nil +} + +func (m *PVMInstance) validatePvmInstanceID(formats strfmt.Registry) error { + + if err := validate.Required("pvmInstanceID", "body", m.PvmInstanceID); err != nil { + return err + } + + return nil +} + +func (m *PVMInstance) validateSapProfile(formats strfmt.Registry) error { + if swag.IsZero(m.SapProfile) { // not required + return nil + } + + if m.SapProfile != nil { + if err := m.SapProfile.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("sapProfile") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sapProfile") + } + return err + } + } + + return nil +} + +func (m *PVMInstance) validateServerName(formats strfmt.Registry) error { + + if err := validate.Required("serverName", "body", m.ServerName); err != nil { + return err + } + + return nil +} + +func (m *PVMInstance) validateSoftwareLicenses(formats strfmt.Registry) error { + if swag.IsZero(m.SoftwareLicenses) { // not required + return nil + } + + if m.SoftwareLicenses != nil { + if err := m.SoftwareLicenses.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("softwareLicenses") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("softwareLicenses") + } + return err + } + } + + return nil +} + +func (m *PVMInstance) validateSrcs(formats strfmt.Registry) error { + if swag.IsZero(m.Srcs) { // not required + return nil + } + + for i := 0; i < len(m.Srcs); i++ { + + for ii := 0; ii < len(m.Srcs[i]); ii++ { + if swag.IsZero(m.Srcs[i][ii]) { // not required + continue + } + + if m.Srcs[i][ii] != nil { + if err := m.Srcs[i][ii].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("srcs" + "." + strconv.Itoa(i) + "." + strconv.Itoa(ii)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("srcs" + "." + strconv.Itoa(i) + "." + strconv.Itoa(ii)) + } + return err + } + } + + } + + } + + return nil +} + +func (m *PVMInstance) validateStatus(formats strfmt.Registry) error { + + if err := validate.Required("status", "body", m.Status); err != nil { + return err + } + + return nil +} + +func (m *PVMInstance) validateStorageType(formats strfmt.Registry) error { + + if err := validate.Required("storageType", "body", m.StorageType); err != nil { + return err + } + + return nil +} + +func (m *PVMInstance) validateUpdatedDate(formats strfmt.Registry) error { + if swag.IsZero(m.UpdatedDate) { // not required + return nil + } + + if err := validate.FormatOf("updatedDate", "body", "date-time", m.UpdatedDate.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *PVMInstance) validateVirtualCores(formats strfmt.Registry) error { + if swag.IsZero(m.VirtualCores) { // not required + return nil + } + + if m.VirtualCores != nil { + if err := m.VirtualCores.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("virtualCores") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("virtualCores") + } + return err + } + } + + return nil +} + +func (m *PVMInstance) validateVolumeIDs(formats strfmt.Registry) error { + + if err := validate.Required("volumeIDs", "body", m.VolumeIDs); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this p VM instance based on the context it is used +func (m *PVMInstance) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateAddresses(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateConsoleLanguage(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateFault(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateHealth(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateNetworks(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSapProfile(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSoftwareLicenses(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSrcs(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateVirtualCores(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PVMInstance) contextValidateAddresses(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Addresses); i++ { + + if m.Addresses[i] != nil { + if err := m.Addresses[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("addresses" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("addresses" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *PVMInstance) contextValidateConsoleLanguage(ctx context.Context, formats strfmt.Registry) error { + + if m.ConsoleLanguage != nil { + if err := m.ConsoleLanguage.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("consoleLanguage") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("consoleLanguage") + } + return err + } + } + + return nil +} + +func (m *PVMInstance) contextValidateFault(ctx context.Context, formats strfmt.Registry) error { + + if m.Fault != nil { + if err := m.Fault.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("fault") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("fault") + } + return err + } + } + + return nil +} + +func (m *PVMInstance) contextValidateHealth(ctx context.Context, formats strfmt.Registry) error { + + if m.Health != nil { + if err := m.Health.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("health") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("health") + } + return err + } + } + + return nil +} + +func (m *PVMInstance) contextValidateNetworks(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Networks); i++ { + + if m.Networks[i] != nil { + if err := m.Networks[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("networks" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("networks" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *PVMInstance) contextValidateSapProfile(ctx context.Context, formats strfmt.Registry) error { + + if m.SapProfile != nil { + if err := m.SapProfile.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("sapProfile") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sapProfile") + } + return err + } + } + + return nil +} + +func (m *PVMInstance) contextValidateSoftwareLicenses(ctx context.Context, formats strfmt.Registry) error { + + if m.SoftwareLicenses != nil { + if err := m.SoftwareLicenses.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("softwareLicenses") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("softwareLicenses") + } + return err + } + } + + return nil +} + +func (m *PVMInstance) contextValidateSrcs(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Srcs); i++ { + + for ii := 0; ii < len(m.Srcs[i]); ii++ { + + if m.Srcs[i][ii] != nil { + if err := m.Srcs[i][ii].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("srcs" + "." + strconv.Itoa(i) + "." + strconv.Itoa(ii)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("srcs" + "." + strconv.Itoa(i) + "." + strconv.Itoa(ii)) + } + return err + } + } + + } + + } + + return nil +} + +func (m *PVMInstance) contextValidateVirtualCores(ctx context.Context, formats strfmt.Registry) error { + + if m.VirtualCores != nil { + if err := m.VirtualCores.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("virtualCores") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("virtualCores") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *PVMInstance) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PVMInstance) UnmarshalBinary(b []byte) error { + var res PVMInstance + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_action.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_action.go new file mode 100644 index 00000000000..3c927919d61 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_action.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// PVMInstanceAction p VM instance action +// +// swagger:model PVMInstanceAction +type PVMInstanceAction struct { + + // Name of the action to take; can be start, stop, hard-reboot, soft-reboot, immediate-shutdown, reset-state + // Required: true + // Enum: [start stop immediate-shutdown hard-reboot soft-reboot reset-state] + Action *string `json:"action"` +} + +// Validate validates this p VM instance action +func (m *PVMInstanceAction) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAction(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +var pVmInstanceActionTypeActionPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["start","stop","immediate-shutdown","hard-reboot","soft-reboot","reset-state"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + pVmInstanceActionTypeActionPropEnum = append(pVmInstanceActionTypeActionPropEnum, v) + } +} + +const ( + + // PVMInstanceActionActionStart captures enum value "start" + PVMInstanceActionActionStart string = "start" + + // PVMInstanceActionActionStop captures enum value "stop" + PVMInstanceActionActionStop string = "stop" + + // PVMInstanceActionActionImmediateDashShutdown captures enum value "immediate-shutdown" + PVMInstanceActionActionImmediateDashShutdown string = "immediate-shutdown" + + // PVMInstanceActionActionHardDashReboot captures enum value "hard-reboot" + PVMInstanceActionActionHardDashReboot string = "hard-reboot" + + // PVMInstanceActionActionSoftDashReboot captures enum value "soft-reboot" + PVMInstanceActionActionSoftDashReboot string = "soft-reboot" + + // PVMInstanceActionActionResetDashState captures enum value "reset-state" + PVMInstanceActionActionResetDashState string = "reset-state" +) + +// prop value enum +func (m *PVMInstanceAction) validateActionEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, pVmInstanceActionTypeActionPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *PVMInstanceAction) validateAction(formats strfmt.Registry) error { + + if err := validate.Required("action", "body", m.Action); err != nil { + return err + } + + // value enum + if err := m.validateActionEnum("action", "body", *m.Action); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this p VM instance action based on context it is used +func (m *PVMInstanceAction) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *PVMInstanceAction) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PVMInstanceAction) UnmarshalBinary(b []byte) error { + var res PVMInstanceAction + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_add_network.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_add_network.go new file mode 100644 index 00000000000..d0c9f7569e3 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_add_network.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// PVMInstanceAddNetwork p VM instance add network +// +// swagger:model PVMInstanceAddNetwork +type PVMInstanceAddNetwork struct { + + // The requested ip address of this network interface + IPAddress string `json:"ipAddress,omitempty"` + + // ID of the network + // Required: true + NetworkID *string `json:"networkID"` +} + +// Validate validates this p VM instance add network +func (m *PVMInstanceAddNetwork) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateNetworkID(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PVMInstanceAddNetwork) validateNetworkID(formats strfmt.Registry) error { + + if err := validate.Required("networkID", "body", m.NetworkID); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this p VM instance add network based on context it is used +func (m *PVMInstanceAddNetwork) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *PVMInstanceAddNetwork) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PVMInstanceAddNetwork) UnmarshalBinary(b []byte) error { + var res PVMInstanceAddNetwork + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_address.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_address.go new file mode 100644 index 00000000000..2e7ad6b98d8 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_address.go @@ -0,0 +1,65 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// PVMInstanceAddress deprecated - replaced by PVMInstanceNetwork +// +// swagger:model PVMInstanceAddress +type PVMInstanceAddress struct { + PVMInstanceNetwork +} + +// UnmarshalJSON unmarshals this object from a JSON structure +func (m *PVMInstanceAddress) UnmarshalJSON(raw []byte) error { + // AO0 + var aO0 PVMInstanceNetwork + if err := swag.ReadJSON(raw, &aO0); err != nil { + return err + } + m.PVMInstanceNetwork = aO0 + + return nil +} + +// MarshalJSON marshals this object to a JSON structure +func (m PVMInstanceAddress) MarshalJSON() ([]byte, error) { + _parts := make([][]byte, 0, 1) + + aO0, err := swag.WriteJSON(m.PVMInstanceNetwork) + if err != nil { + return nil, err + } + _parts = append(_parts, aO0) + return swag.ConcatJSON(_parts...), nil +} + +// Validate validates this p VM instance address +func (m *PVMInstanceAddress) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validate this p VM instance address based on the context it is used +func (m *PVMInstanceAddress) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + // validation for a type composition with PVMInstanceNetwork + if err := m.PVMInstanceNetwork.ContextValidate(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_capture.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_capture.go new file mode 100644 index 00000000000..7f925c28c09 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_capture.go @@ -0,0 +1,142 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// PVMInstanceCapture p VM instance capture +// +// swagger:model PVMInstanceCapture +type PVMInstanceCapture struct { + + // Destination for the deployable image + // Required: true + // Enum: [image-catalog cloud-storage both] + CaptureDestination *string `json:"captureDestination"` + + // Name of the deployable image created for the captured PVMInstance + // Required: true + CaptureName *string `json:"captureName"` + + // List of Data volume IDs to include in the captured PVMInstance + CaptureVolumeIDs []string `json:"captureVolumeIDs"` + + // Cloud Storage Access key + CloudStorageAccessKey string `json:"cloudStorageAccessKey,omitempty"` + + // Cloud Storage Image Path (bucket-name [/folder/../..]) + CloudStorageImagePath string `json:"cloudStorageImagePath,omitempty"` + + // Cloud Storage Region + CloudStorageRegion string `json:"cloudStorageRegion,omitempty"` + + // Cloud Storage Secret key + CloudStorageSecretKey string `json:"cloudStorageSecretKey,omitempty"` +} + +// Validate validates this p VM instance capture +func (m *PVMInstanceCapture) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCaptureDestination(formats); err != nil { + res = append(res, err) + } + + if err := m.validateCaptureName(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +var pVmInstanceCaptureTypeCaptureDestinationPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["image-catalog","cloud-storage","both"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + pVmInstanceCaptureTypeCaptureDestinationPropEnum = append(pVmInstanceCaptureTypeCaptureDestinationPropEnum, v) + } +} + +const ( + + // PVMInstanceCaptureCaptureDestinationImageDashCatalog captures enum value "image-catalog" + PVMInstanceCaptureCaptureDestinationImageDashCatalog string = "image-catalog" + + // PVMInstanceCaptureCaptureDestinationCloudDashStorage captures enum value "cloud-storage" + PVMInstanceCaptureCaptureDestinationCloudDashStorage string = "cloud-storage" + + // PVMInstanceCaptureCaptureDestinationBoth captures enum value "both" + PVMInstanceCaptureCaptureDestinationBoth string = "both" +) + +// prop value enum +func (m *PVMInstanceCapture) validateCaptureDestinationEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, pVmInstanceCaptureTypeCaptureDestinationPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *PVMInstanceCapture) validateCaptureDestination(formats strfmt.Registry) error { + + if err := validate.Required("captureDestination", "body", m.CaptureDestination); err != nil { + return err + } + + // value enum + if err := m.validateCaptureDestinationEnum("captureDestination", "body", *m.CaptureDestination); err != nil { + return err + } + + return nil +} + +func (m *PVMInstanceCapture) validateCaptureName(formats strfmt.Registry) error { + + if err := validate.Required("captureName", "body", m.CaptureName); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this p VM instance capture based on context it is used +func (m *PVMInstanceCapture) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *PVMInstanceCapture) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PVMInstanceCapture) UnmarshalBinary(b []byte) error { + var res PVMInstanceCapture + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_clone.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_clone.go new file mode 100644 index 00000000000..c517f97070f --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_clone.go @@ -0,0 +1,248 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// PVMInstanceClone p VM instance clone +// +// swagger:model PVMInstanceClone +type PVMInstanceClone struct { + + // The name of the SSH key pair provided to the server for authenticating users (looked up in the tenant's list of keys) + KeyPairName string `json:"keyPairName,omitempty"` + + // Amount of memory allocated (in GB) + Memory *float64 `json:"memory,omitempty"` + + // Name of the server to create + // Required: true + Name *string `json:"name"` + + // The pvm instance networks information + // Required: true + Networks []*PVMInstanceAddNetwork `json:"networks"` + + // Processor type (dedicated, shared, capped) + // Enum: [dedicated shared capped] + ProcType *string `json:"procType,omitempty"` + + // Number of processors allocated + Processors *float64 `json:"processors,omitempty"` + + // The pvm instance Software Licenses + SoftwareLicenses *SoftwareLicenses `json:"softwareLicenses,omitempty"` + + // List of volume IDs + VolumeIDs []string `json:"volumeIDs"` +} + +// Validate validates this p VM instance clone +func (m *PVMInstanceClone) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateNetworks(formats); err != nil { + res = append(res, err) + } + + if err := m.validateProcType(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSoftwareLicenses(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PVMInstanceClone) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *PVMInstanceClone) validateNetworks(formats strfmt.Registry) error { + + if err := validate.Required("networks", "body", m.Networks); err != nil { + return err + } + + for i := 0; i < len(m.Networks); i++ { + if swag.IsZero(m.Networks[i]) { // not required + continue + } + + if m.Networks[i] != nil { + if err := m.Networks[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("networks" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("networks" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +var pVmInstanceCloneTypeProcTypePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["dedicated","shared","capped"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + pVmInstanceCloneTypeProcTypePropEnum = append(pVmInstanceCloneTypeProcTypePropEnum, v) + } +} + +const ( + + // PVMInstanceCloneProcTypeDedicated captures enum value "dedicated" + PVMInstanceCloneProcTypeDedicated string = "dedicated" + + // PVMInstanceCloneProcTypeShared captures enum value "shared" + PVMInstanceCloneProcTypeShared string = "shared" + + // PVMInstanceCloneProcTypeCapped captures enum value "capped" + PVMInstanceCloneProcTypeCapped string = "capped" +) + +// prop value enum +func (m *PVMInstanceClone) validateProcTypeEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, pVmInstanceCloneTypeProcTypePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *PVMInstanceClone) validateProcType(formats strfmt.Registry) error { + if swag.IsZero(m.ProcType) { // not required + return nil + } + + // value enum + if err := m.validateProcTypeEnum("procType", "body", *m.ProcType); err != nil { + return err + } + + return nil +} + +func (m *PVMInstanceClone) validateSoftwareLicenses(formats strfmt.Registry) error { + if swag.IsZero(m.SoftwareLicenses) { // not required + return nil + } + + if m.SoftwareLicenses != nil { + if err := m.SoftwareLicenses.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("softwareLicenses") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("softwareLicenses") + } + return err + } + } + + return nil +} + +// ContextValidate validate this p VM instance clone based on the context it is used +func (m *PVMInstanceClone) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateNetworks(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSoftwareLicenses(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PVMInstanceClone) contextValidateNetworks(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Networks); i++ { + + if m.Networks[i] != nil { + if err := m.Networks[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("networks" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("networks" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *PVMInstanceClone) contextValidateSoftwareLicenses(ctx context.Context, formats strfmt.Registry) error { + + if m.SoftwareLicenses != nil { + if err := m.SoftwareLicenses.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("softwareLicenses") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("softwareLicenses") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *PVMInstanceClone) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PVMInstanceClone) UnmarshalBinary(b []byte) error { + var res PVMInstanceClone + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_console.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_console.go new file mode 100644 index 00000000000..0ed92109ad4 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_console.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// PVMInstanceConsole p VM instance console +// +// swagger:model PVMInstanceConsole +type PVMInstanceConsole struct { + + // The URL to the noVNC console for the PVM Instance + // Required: true + ConsoleURL *string `json:"consoleURL"` +} + +// Validate validates this p VM instance console +func (m *PVMInstanceConsole) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateConsoleURL(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PVMInstanceConsole) validateConsoleURL(formats strfmt.Registry) error { + + if err := validate.Required("consoleURL", "body", m.ConsoleURL); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this p VM instance console based on context it is used +func (m *PVMInstanceConsole) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *PVMInstanceConsole) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PVMInstanceConsole) UnmarshalBinary(b []byte) error { + var res PVMInstanceConsole + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_create.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_create.go new file mode 100644 index 00000000000..c5bcc1046d6 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_create.go @@ -0,0 +1,604 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// PVMInstanceCreate p VM instance create +// +// swagger:model PVMInstanceCreate +type PVMInstanceCreate struct { + + // Image ID of the image to use for the server + // Required: true + ImageID *string `json:"imageID"` + + // The name of the SSH key pair provided to the server for authenticating users (looked up in the tenant's list of keys) + KeyPairName string `json:"keyPairName,omitempty"` + + // The VTL license repository capacity TB value + LicenseRepositoryCapacity int64 `json:"licenseRepositoryCapacity,omitempty"` + + // Amount of memory allocated (in GB) + // Required: true + Memory *float64 `json:"memory"` + + // Indicates if the server is allowed to migrate between hosts + Migratable *bool `json:"migratable,omitempty"` + + // (deprecated - replaced by networks) List of Network IDs + NetworkIDs []string `json:"networkIDs"` + + // The pvm instance networks information + Networks []*PVMInstanceAddNetwork `json:"networks"` + + // pin policy + PinPolicy PinPolicy `json:"pinPolicy,omitempty"` + + // The placement group for the server + PlacementGroup string `json:"placementGroup,omitempty"` + + // Processor type (dedicated, shared, capped) + // Required: true + // Enum: [dedicated shared capped] + ProcType *string `json:"procType"` + + // Number of processors allocated + // Required: true + Processors *float64 `json:"processors"` + + // Affinity policy for replicants being created; affinity for the same host, anti-affinity for different hosts, none for no preference + // Enum: [affinity anti-affinity none] + ReplicantAffinityPolicy *string `json:"replicantAffinityPolicy,omitempty"` + + // How to name the created vms + // Enum: [prefix suffix] + ReplicantNamingScheme *string `json:"replicantNamingScheme,omitempty"` + + // Number of duplicate instances to create in this request + Replicants float64 `json:"replicants,omitempty"` + + // Name of the server to create + // Required: true + ServerName *string `json:"serverName"` + + // The pvm instance Software Licenses + SoftwareLicenses *SoftwareLicenses `json:"softwareLicenses,omitempty"` + + // The storage affinity data; ignored if storagePool is provided; Only valid when you deploy one of the IBM supplied stock images. Storage type and pool for a custom image (an imported image or an image that is created from a PVMInstance capture) defaults to the storage type and pool the image was created in + StorageAffinity *StorageAffinity `json:"storageAffinity,omitempty"` + + // The storage connection type + // Enum: [vSCSI] + StorageConnection string `json:"storageConnection,omitempty"` + + // Storage Pool for server deployment; if provided then storageAffinity and storageType will be ignored; Only valid when you deploy one of the IBM supplied stock images. Storage type and pool for a custom image (an imported image or an image that is created from a PVMInstance capture) defaults to the storage type and pool the image was created in + StoragePool string `json:"storagePool,omitempty"` + + // Storage type for server deployment; will be ignored if storagePool or storageAffinity is provided; Only valid when you deploy one of the IBM supplied stock images. Storage type and pool for a custom image (an imported image or an image that is created from a PVMInstance capture) defaults to the storage type and pool the image was created in + StorageType string `json:"storageType,omitempty"` + + // System type used to host the instance + SysType string `json:"sysType,omitempty"` + + // Cloud init user defined data + UserData string `json:"userData,omitempty"` + + // The pvm instance virtual CPU information + VirtualCores *VirtualCores `json:"virtualCores,omitempty"` + + // List of volume IDs + VolumeIDs []string `json:"volumeIDs"` +} + +// Validate validates this p VM instance create +func (m *PVMInstanceCreate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateImageID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMemory(formats); err != nil { + res = append(res, err) + } + + if err := m.validateNetworks(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePinPolicy(formats); err != nil { + res = append(res, err) + } + + if err := m.validateProcType(formats); err != nil { + res = append(res, err) + } + + if err := m.validateProcessors(formats); err != nil { + res = append(res, err) + } + + if err := m.validateReplicantAffinityPolicy(formats); err != nil { + res = append(res, err) + } + + if err := m.validateReplicantNamingScheme(formats); err != nil { + res = append(res, err) + } + + if err := m.validateServerName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSoftwareLicenses(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStorageAffinity(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStorageConnection(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVirtualCores(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PVMInstanceCreate) validateImageID(formats strfmt.Registry) error { + + if err := validate.Required("imageID", "body", m.ImageID); err != nil { + return err + } + + return nil +} + +func (m *PVMInstanceCreate) validateMemory(formats strfmt.Registry) error { + + if err := validate.Required("memory", "body", m.Memory); err != nil { + return err + } + + return nil +} + +func (m *PVMInstanceCreate) validateNetworks(formats strfmt.Registry) error { + if swag.IsZero(m.Networks) { // not required + return nil + } + + for i := 0; i < len(m.Networks); i++ { + if swag.IsZero(m.Networks[i]) { // not required + continue + } + + if m.Networks[i] != nil { + if err := m.Networks[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("networks" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("networks" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *PVMInstanceCreate) validatePinPolicy(formats strfmt.Registry) error { + if swag.IsZero(m.PinPolicy) { // not required + return nil + } + + if err := m.PinPolicy.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("pinPolicy") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("pinPolicy") + } + return err + } + + return nil +} + +var pVmInstanceCreateTypeProcTypePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["dedicated","shared","capped"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + pVmInstanceCreateTypeProcTypePropEnum = append(pVmInstanceCreateTypeProcTypePropEnum, v) + } +} + +const ( + + // PVMInstanceCreateProcTypeDedicated captures enum value "dedicated" + PVMInstanceCreateProcTypeDedicated string = "dedicated" + + // PVMInstanceCreateProcTypeShared captures enum value "shared" + PVMInstanceCreateProcTypeShared string = "shared" + + // PVMInstanceCreateProcTypeCapped captures enum value "capped" + PVMInstanceCreateProcTypeCapped string = "capped" +) + +// prop value enum +func (m *PVMInstanceCreate) validateProcTypeEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, pVmInstanceCreateTypeProcTypePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *PVMInstanceCreate) validateProcType(formats strfmt.Registry) error { + + if err := validate.Required("procType", "body", m.ProcType); err != nil { + return err + } + + // value enum + if err := m.validateProcTypeEnum("procType", "body", *m.ProcType); err != nil { + return err + } + + return nil +} + +func (m *PVMInstanceCreate) validateProcessors(formats strfmt.Registry) error { + + if err := validate.Required("processors", "body", m.Processors); err != nil { + return err + } + + return nil +} + +var pVmInstanceCreateTypeReplicantAffinityPolicyPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["affinity","anti-affinity","none"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + pVmInstanceCreateTypeReplicantAffinityPolicyPropEnum = append(pVmInstanceCreateTypeReplicantAffinityPolicyPropEnum, v) + } +} + +const ( + + // PVMInstanceCreateReplicantAffinityPolicyAffinity captures enum value "affinity" + PVMInstanceCreateReplicantAffinityPolicyAffinity string = "affinity" + + // PVMInstanceCreateReplicantAffinityPolicyAntiDashAffinity captures enum value "anti-affinity" + PVMInstanceCreateReplicantAffinityPolicyAntiDashAffinity string = "anti-affinity" + + // PVMInstanceCreateReplicantAffinityPolicyNone captures enum value "none" + PVMInstanceCreateReplicantAffinityPolicyNone string = "none" +) + +// prop value enum +func (m *PVMInstanceCreate) validateReplicantAffinityPolicyEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, pVmInstanceCreateTypeReplicantAffinityPolicyPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *PVMInstanceCreate) validateReplicantAffinityPolicy(formats strfmt.Registry) error { + if swag.IsZero(m.ReplicantAffinityPolicy) { // not required + return nil + } + + // value enum + if err := m.validateReplicantAffinityPolicyEnum("replicantAffinityPolicy", "body", *m.ReplicantAffinityPolicy); err != nil { + return err + } + + return nil +} + +var pVmInstanceCreateTypeReplicantNamingSchemePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["prefix","suffix"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + pVmInstanceCreateTypeReplicantNamingSchemePropEnum = append(pVmInstanceCreateTypeReplicantNamingSchemePropEnum, v) + } +} + +const ( + + // PVMInstanceCreateReplicantNamingSchemePrefix captures enum value "prefix" + PVMInstanceCreateReplicantNamingSchemePrefix string = "prefix" + + // PVMInstanceCreateReplicantNamingSchemeSuffix captures enum value "suffix" + PVMInstanceCreateReplicantNamingSchemeSuffix string = "suffix" +) + +// prop value enum +func (m *PVMInstanceCreate) validateReplicantNamingSchemeEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, pVmInstanceCreateTypeReplicantNamingSchemePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *PVMInstanceCreate) validateReplicantNamingScheme(formats strfmt.Registry) error { + if swag.IsZero(m.ReplicantNamingScheme) { // not required + return nil + } + + // value enum + if err := m.validateReplicantNamingSchemeEnum("replicantNamingScheme", "body", *m.ReplicantNamingScheme); err != nil { + return err + } + + return nil +} + +func (m *PVMInstanceCreate) validateServerName(formats strfmt.Registry) error { + + if err := validate.Required("serverName", "body", m.ServerName); err != nil { + return err + } + + return nil +} + +func (m *PVMInstanceCreate) validateSoftwareLicenses(formats strfmt.Registry) error { + if swag.IsZero(m.SoftwareLicenses) { // not required + return nil + } + + if m.SoftwareLicenses != nil { + if err := m.SoftwareLicenses.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("softwareLicenses") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("softwareLicenses") + } + return err + } + } + + return nil +} + +func (m *PVMInstanceCreate) validateStorageAffinity(formats strfmt.Registry) error { + if swag.IsZero(m.StorageAffinity) { // not required + return nil + } + + if m.StorageAffinity != nil { + if err := m.StorageAffinity.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("storageAffinity") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("storageAffinity") + } + return err + } + } + + return nil +} + +var pVmInstanceCreateTypeStorageConnectionPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["vSCSI"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + pVmInstanceCreateTypeStorageConnectionPropEnum = append(pVmInstanceCreateTypeStorageConnectionPropEnum, v) + } +} + +const ( + + // PVMInstanceCreateStorageConnectionVSCSI captures enum value "vSCSI" + PVMInstanceCreateStorageConnectionVSCSI string = "vSCSI" +) + +// prop value enum +func (m *PVMInstanceCreate) validateStorageConnectionEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, pVmInstanceCreateTypeStorageConnectionPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *PVMInstanceCreate) validateStorageConnection(formats strfmt.Registry) error { + if swag.IsZero(m.StorageConnection) { // not required + return nil + } + + // value enum + if err := m.validateStorageConnectionEnum("storageConnection", "body", m.StorageConnection); err != nil { + return err + } + + return nil +} + +func (m *PVMInstanceCreate) validateVirtualCores(formats strfmt.Registry) error { + if swag.IsZero(m.VirtualCores) { // not required + return nil + } + + if m.VirtualCores != nil { + if err := m.VirtualCores.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("virtualCores") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("virtualCores") + } + return err + } + } + + return nil +} + +// ContextValidate validate this p VM instance create based on the context it is used +func (m *PVMInstanceCreate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateNetworks(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidatePinPolicy(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSoftwareLicenses(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateStorageAffinity(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateVirtualCores(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PVMInstanceCreate) contextValidateNetworks(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Networks); i++ { + + if m.Networks[i] != nil { + if err := m.Networks[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("networks" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("networks" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *PVMInstanceCreate) contextValidatePinPolicy(ctx context.Context, formats strfmt.Registry) error { + + if err := m.PinPolicy.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("pinPolicy") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("pinPolicy") + } + return err + } + + return nil +} + +func (m *PVMInstanceCreate) contextValidateSoftwareLicenses(ctx context.Context, formats strfmt.Registry) error { + + if m.SoftwareLicenses != nil { + if err := m.SoftwareLicenses.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("softwareLicenses") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("softwareLicenses") + } + return err + } + } + + return nil +} + +func (m *PVMInstanceCreate) contextValidateStorageAffinity(ctx context.Context, formats strfmt.Registry) error { + + if m.StorageAffinity != nil { + if err := m.StorageAffinity.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("storageAffinity") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("storageAffinity") + } + return err + } + } + + return nil +} + +func (m *PVMInstanceCreate) contextValidateVirtualCores(ctx context.Context, formats strfmt.Registry) error { + + if m.VirtualCores != nil { + if err := m.VirtualCores.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("virtualCores") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("virtualCores") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *PVMInstanceCreate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PVMInstanceCreate) UnmarshalBinary(b []byte) error { + var res PVMInstanceCreate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_fault.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_fault.go new file mode 100644 index 00000000000..bc5133e8aad --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_fault.go @@ -0,0 +1,83 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// PVMInstanceFault Fault information (if occurred) +// +// swagger:model PVMInstanceFault +type PVMInstanceFault struct { + + // The fault status of the server, if any + Code float64 `json:"code,omitempty"` + + // The date and time the fault occurred + // Format: date-time + Created strfmt.DateTime `json:"created,omitempty"` + + // The fault details of the server, if any + Details string `json:"details,omitempty"` + + // The fault message of the server, if any + Message string `json:"message,omitempty"` +} + +// Validate validates this p VM instance fault +func (m *PVMInstanceFault) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreated(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PVMInstanceFault) validateCreated(formats strfmt.Registry) error { + if swag.IsZero(m.Created) { // not required + return nil + } + + if err := validate.FormatOf("created", "body", "date-time", m.Created.String(), formats); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this p VM instance fault based on context it is used +func (m *PVMInstanceFault) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *PVMInstanceFault) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PVMInstanceFault) UnmarshalBinary(b []byte) error { + var res PVMInstanceFault + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_health.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_health.go new file mode 100644 index 00000000000..11c21c9ab44 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_health.go @@ -0,0 +1,56 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// PVMInstanceHealth PVM's health status details +// +// swagger:model PVMInstanceHealth +type PVMInstanceHealth struct { + + // Date/Time of PVM last health status change + LastUpdate string `json:"lastUpdate,omitempty"` + + // The health status reason, if any + Reason string `json:"reason,omitempty"` + + // The PVM's health status value + Status string `json:"status,omitempty"` +} + +// Validate validates this p VM instance health +func (m *PVMInstanceHealth) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this p VM instance health based on context it is used +func (m *PVMInstanceHealth) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *PVMInstanceHealth) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PVMInstanceHealth) UnmarshalBinary(b []byte) error { + var res PVMInstanceHealth + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_list.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_list.go new file mode 100644 index 00000000000..2345d10dd6c --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_list.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// PVMInstanceList A list of PVMInstances +// +// swagger:model PVMInstanceList +type PVMInstanceList []*PVMInstance + +// Validate validates this p VM instance list +func (m PVMInstanceList) Validate(formats strfmt.Registry) error { + var res []error + + for i := 0; i < len(m); i++ { + if swag.IsZero(m[i]) { // not required + continue + } + + if m[i] != nil { + if err := m[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(strconv.Itoa(i)) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validate this p VM instance list based on the context it is used +func (m PVMInstanceList) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + for i := 0; i < len(m); i++ { + + if m[i] != nil { + if err := m[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(strconv.Itoa(i)) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_multi_create.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_multi_create.go new file mode 100644 index 00000000000..682af222cdc --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_multi_create.go @@ -0,0 +1,161 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// PVMInstanceMultiCreate p VM instance multi create +// +// swagger:model PVMInstanceMultiCreate +type PVMInstanceMultiCreate struct { + + // Affinity policy for pvm-instances being created; affinity for the same host, anti-affinity for different hosts, none for no preference + // Enum: [affinity anti-affinity none] + AffinityPolicy *string `json:"affinityPolicy,omitempty"` + + // Number of pvm-instances to create + Count int64 `json:"count,omitempty"` + + // Where to place the numerical number of the multi-created instance + // Enum: [prefix suffix] + Numerical *string `json:"numerical,omitempty"` +} + +// Validate validates this p VM instance multi create +func (m *PVMInstanceMultiCreate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAffinityPolicy(formats); err != nil { + res = append(res, err) + } + + if err := m.validateNumerical(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +var pVmInstanceMultiCreateTypeAffinityPolicyPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["affinity","anti-affinity","none"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + pVmInstanceMultiCreateTypeAffinityPolicyPropEnum = append(pVmInstanceMultiCreateTypeAffinityPolicyPropEnum, v) + } +} + +const ( + + // PVMInstanceMultiCreateAffinityPolicyAffinity captures enum value "affinity" + PVMInstanceMultiCreateAffinityPolicyAffinity string = "affinity" + + // PVMInstanceMultiCreateAffinityPolicyAntiDashAffinity captures enum value "anti-affinity" + PVMInstanceMultiCreateAffinityPolicyAntiDashAffinity string = "anti-affinity" + + // PVMInstanceMultiCreateAffinityPolicyNone captures enum value "none" + PVMInstanceMultiCreateAffinityPolicyNone string = "none" +) + +// prop value enum +func (m *PVMInstanceMultiCreate) validateAffinityPolicyEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, pVmInstanceMultiCreateTypeAffinityPolicyPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *PVMInstanceMultiCreate) validateAffinityPolicy(formats strfmt.Registry) error { + if swag.IsZero(m.AffinityPolicy) { // not required + return nil + } + + // value enum + if err := m.validateAffinityPolicyEnum("affinityPolicy", "body", *m.AffinityPolicy); err != nil { + return err + } + + return nil +} + +var pVmInstanceMultiCreateTypeNumericalPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["prefix","suffix"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + pVmInstanceMultiCreateTypeNumericalPropEnum = append(pVmInstanceMultiCreateTypeNumericalPropEnum, v) + } +} + +const ( + + // PVMInstanceMultiCreateNumericalPrefix captures enum value "prefix" + PVMInstanceMultiCreateNumericalPrefix string = "prefix" + + // PVMInstanceMultiCreateNumericalSuffix captures enum value "suffix" + PVMInstanceMultiCreateNumericalSuffix string = "suffix" +) + +// prop value enum +func (m *PVMInstanceMultiCreate) validateNumericalEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, pVmInstanceMultiCreateTypeNumericalPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *PVMInstanceMultiCreate) validateNumerical(formats strfmt.Registry) error { + if swag.IsZero(m.Numerical) { // not required + return nil + } + + // value enum + if err := m.validateNumericalEnum("numerical", "body", *m.Numerical); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this p VM instance multi create based on context it is used +func (m *PVMInstanceMultiCreate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *PVMInstanceMultiCreate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PVMInstanceMultiCreate) UnmarshalBinary(b []byte) error { + var res PVMInstanceMultiCreate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_network.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_network.go new file mode 100644 index 00000000000..94e6426411b --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_network.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// PVMInstanceNetwork A map containing information about a network address +// +// swagger:model PVMInstanceNetwork +type PVMInstanceNetwork struct { + + // The external ip address (for pub-vlan networks) + ExternalIP string `json:"externalIP,omitempty"` + + // Link to PVM Instance Network + Href string `json:"href,omitempty"` + + // (deprecated - replaced by ipAddress) + IP string `json:"ip,omitempty"` + + // The ip address of this network interface + IPAddress string `json:"ipAddress,omitempty"` + + // The mac address of the network interface + MacAddress string `json:"macAddress,omitempty"` + + // ID of the network + NetworkID string `json:"networkID,omitempty"` + + // The name of the network the address is on + NetworkName string `json:"networkName,omitempty"` + + // The address type (fixed or dynamic) + Type string `json:"type,omitempty"` + + // The version of the information provided + Version float64 `json:"version,omitempty"` +} + +// Validate validates this p VM instance network +func (m *PVMInstanceNetwork) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this p VM instance network based on context it is used +func (m *PVMInstanceNetwork) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *PVMInstanceNetwork) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PVMInstanceNetwork) UnmarshalBinary(b []byte) error { + var res PVMInstanceNetwork + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_networks.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_networks.go new file mode 100644 index 00000000000..e511b64dfc3 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_networks.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// PVMInstanceNetworks p VM instance networks +// +// swagger:model PVMInstanceNetworks +type PVMInstanceNetworks struct { + + // PVM Instance Networks + // Required: true + Networks []*PVMInstanceNetwork `json:"networks"` +} + +// Validate validates this p VM instance networks +func (m *PVMInstanceNetworks) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateNetworks(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PVMInstanceNetworks) validateNetworks(formats strfmt.Registry) error { + + if err := validate.Required("networks", "body", m.Networks); err != nil { + return err + } + + for i := 0; i < len(m.Networks); i++ { + if swag.IsZero(m.Networks[i]) { // not required + continue + } + + if m.Networks[i] != nil { + if err := m.Networks[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("networks" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("networks" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this p VM instance networks based on the context it is used +func (m *PVMInstanceNetworks) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateNetworks(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PVMInstanceNetworks) contextValidateNetworks(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Networks); i++ { + + if m.Networks[i] != nil { + if err := m.Networks[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("networks" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("networks" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *PVMInstanceNetworks) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PVMInstanceNetworks) UnmarshalBinary(b []byte) error { + var res PVMInstanceNetworks + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_operation.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_operation.go new file mode 100644 index 00000000000..f9c202e542a --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_operation.go @@ -0,0 +1,160 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// PVMInstanceOperation p VM instance operation +// +// swagger:model PVMInstanceOperation +type PVMInstanceOperation struct { + + // operation + // Required: true + Operation *Operations `json:"operation"` + + // Name of the operation to execute; can be job or boot + // Required: true + // Enum: [job boot] + OperationType *string `json:"operationType"` +} + +// Validate validates this p VM instance operation +func (m *PVMInstanceOperation) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateOperation(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOperationType(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PVMInstanceOperation) validateOperation(formats strfmt.Registry) error { + + if err := validate.Required("operation", "body", m.Operation); err != nil { + return err + } + + if m.Operation != nil { + if err := m.Operation.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("operation") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("operation") + } + return err + } + } + + return nil +} + +var pVmInstanceOperationTypeOperationTypePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["job","boot"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + pVmInstanceOperationTypeOperationTypePropEnum = append(pVmInstanceOperationTypeOperationTypePropEnum, v) + } +} + +const ( + + // PVMInstanceOperationOperationTypeJob captures enum value "job" + PVMInstanceOperationOperationTypeJob string = "job" + + // PVMInstanceOperationOperationTypeBoot captures enum value "boot" + PVMInstanceOperationOperationTypeBoot string = "boot" +) + +// prop value enum +func (m *PVMInstanceOperation) validateOperationTypeEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, pVmInstanceOperationTypeOperationTypePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *PVMInstanceOperation) validateOperationType(formats strfmt.Registry) error { + + if err := validate.Required("operationType", "body", m.OperationType); err != nil { + return err + } + + // value enum + if err := m.validateOperationTypeEnum("operationType", "body", *m.OperationType); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this p VM instance operation based on the context it is used +func (m *PVMInstanceOperation) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateOperation(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PVMInstanceOperation) contextValidateOperation(ctx context.Context, formats strfmt.Registry) error { + + if m.Operation != nil { + if err := m.Operation.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("operation") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("operation") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *PVMInstanceOperation) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PVMInstanceOperation) UnmarshalBinary(b []byte) error { + var res PVMInstanceOperation + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_reference.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_reference.go new file mode 100644 index 00000000000..33303e9d9c5 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_reference.go @@ -0,0 +1,806 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// PVMInstanceReference p VM instance reference +// +// swagger:model PVMInstanceReference +type PVMInstanceReference struct { + + // (deprecated - replaced by networks) The list of addresses and their network information + Addresses []*PVMInstanceNetwork `json:"addresses"` + + // Console language and code + ConsoleLanguage *ConsoleLanguage `json:"consoleLanguage,omitempty"` + + // Date/Time of PVM creation + // Format: date-time + CreationDate strfmt.DateTime `json:"creationDate,omitempty"` + + // Size of allocated disk (in GB) + // Required: true + DiskSize *float64 `json:"diskSize"` + + // fault + Fault *PVMInstanceFault `json:"fault,omitempty"` + + // health + Health *PVMInstanceHealth `json:"health,omitempty"` + + // The PVM Instance Host ID (Internal Use Only) + HostID int64 `json:"hostID,omitempty"` + + // Link to Cloud Instance resource + // Required: true + Href *string `json:"href"` + + // The ImageID used by the server + // Required: true + ImageID *string `json:"imageID"` + + // The VTL license repository capacity TB value + LicenseRepositoryCapacity int64 `json:"licenseRepositoryCapacity,omitempty"` + + // Maximum amount of memory that can be allocated (in GB, for resize) + Maxmem float64 `json:"maxmem,omitempty"` + + // Maximum number of processors that can be allocated (for resize) + Maxproc float64 `json:"maxproc,omitempty"` + + // Amount of memory allocated (in GB) + // Required: true + Memory *float64 `json:"memory"` + + // Minimum amount of memory that can be allocated (in GB, for resize) + Minmem float64 `json:"minmem,omitempty"` + + // Minimum number of processors that can be allocated (for resize) + Minproc float64 `json:"minproc,omitempty"` + + // The list of addresses and their network information + Networks []*PVMInstanceNetwork `json:"networks"` + + // OS system information (usually version and build) + OperatingSystem string `json:"operatingSystem,omitempty"` + + // Type of the OS [aix, ibmi, rhel, sles, vtl, rhcos] + // Required: true + OsType *string `json:"osType"` + + // VM pinning policy to use [none, soft, hard] + PinPolicy string `json:"pinPolicy,omitempty"` + + // The placement group of the server + PlacementGroup *string `json:"placementGroup,omitempty"` + + // Processor type (dedicated, shared, capped) + // Required: true + // Enum: [dedicated shared capped] + ProcType *string `json:"procType"` + + // Number of processors allocated + // Required: true + Processors *float64 `json:"processors"` + + // The progress of an operation + Progress float64 `json:"progress,omitempty"` + + // PCloud PVM Instance ID + // Required: true + PvmInstanceID *string `json:"pvmInstanceID"` + + // If this is an SAP pvm-instance the profile reference will link to the SAP profile + SapProfile *SAPProfileReference `json:"sapProfile,omitempty"` + + // Name of the server + // Required: true + ServerName *string `json:"serverName"` + + // The pvm instance Software Licenses + SoftwareLicenses *SoftwareLicenses `json:"softwareLicenses,omitempty"` + + // The pvm instance SRC lists + Srcs [][]*SRC `json:"srcs"` + + // The status of the instance + // Required: true + Status *string `json:"status"` + + // Storage Pool where server is deployed + StoragePool string `json:"storagePool,omitempty"` + + // Indicates if all volumes attached to the server must reside in the same storage pool + StoragePoolAffinity *bool `json:"storagePoolAffinity,omitempty"` + + // Storage type of the deployment storage pool + StorageType string `json:"storageType,omitempty"` + + // System type used to host the instance + SysType string `json:"sysType,omitempty"` + + // Date/Time of PVM last update + // Format: date-time + UpdatedDate strfmt.DateTime `json:"updatedDate,omitempty"` + + // The pvm instance virtual CPU information + VirtualCores *VirtualCores `json:"virtualCores,omitempty"` +} + +// Validate validates this p VM instance reference +func (m *PVMInstanceReference) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAddresses(formats); err != nil { + res = append(res, err) + } + + if err := m.validateConsoleLanguage(formats); err != nil { + res = append(res, err) + } + + if err := m.validateCreationDate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateDiskSize(formats); err != nil { + res = append(res, err) + } + + if err := m.validateFault(formats); err != nil { + res = append(res, err) + } + + if err := m.validateHealth(formats); err != nil { + res = append(res, err) + } + + if err := m.validateHref(formats); err != nil { + res = append(res, err) + } + + if err := m.validateImageID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMemory(formats); err != nil { + res = append(res, err) + } + + if err := m.validateNetworks(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOsType(formats); err != nil { + res = append(res, err) + } + + if err := m.validateProcType(formats); err != nil { + res = append(res, err) + } + + if err := m.validateProcessors(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePvmInstanceID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSapProfile(formats); err != nil { + res = append(res, err) + } + + if err := m.validateServerName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSoftwareLicenses(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSrcs(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStatus(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUpdatedDate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVirtualCores(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PVMInstanceReference) validateAddresses(formats strfmt.Registry) error { + if swag.IsZero(m.Addresses) { // not required + return nil + } + + for i := 0; i < len(m.Addresses); i++ { + if swag.IsZero(m.Addresses[i]) { // not required + continue + } + + if m.Addresses[i] != nil { + if err := m.Addresses[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("addresses" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("addresses" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *PVMInstanceReference) validateConsoleLanguage(formats strfmt.Registry) error { + if swag.IsZero(m.ConsoleLanguage) { // not required + return nil + } + + if m.ConsoleLanguage != nil { + if err := m.ConsoleLanguage.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("consoleLanguage") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("consoleLanguage") + } + return err + } + } + + return nil +} + +func (m *PVMInstanceReference) validateCreationDate(formats strfmt.Registry) error { + if swag.IsZero(m.CreationDate) { // not required + return nil + } + + if err := validate.FormatOf("creationDate", "body", "date-time", m.CreationDate.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *PVMInstanceReference) validateDiskSize(formats strfmt.Registry) error { + + if err := validate.Required("diskSize", "body", m.DiskSize); err != nil { + return err + } + + return nil +} + +func (m *PVMInstanceReference) validateFault(formats strfmt.Registry) error { + if swag.IsZero(m.Fault) { // not required + return nil + } + + if m.Fault != nil { + if err := m.Fault.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("fault") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("fault") + } + return err + } + } + + return nil +} + +func (m *PVMInstanceReference) validateHealth(formats strfmt.Registry) error { + if swag.IsZero(m.Health) { // not required + return nil + } + + if m.Health != nil { + if err := m.Health.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("health") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("health") + } + return err + } + } + + return nil +} + +func (m *PVMInstanceReference) validateHref(formats strfmt.Registry) error { + + if err := validate.Required("href", "body", m.Href); err != nil { + return err + } + + return nil +} + +func (m *PVMInstanceReference) validateImageID(formats strfmt.Registry) error { + + if err := validate.Required("imageID", "body", m.ImageID); err != nil { + return err + } + + return nil +} + +func (m *PVMInstanceReference) validateMemory(formats strfmt.Registry) error { + + if err := validate.Required("memory", "body", m.Memory); err != nil { + return err + } + + return nil +} + +func (m *PVMInstanceReference) validateNetworks(formats strfmt.Registry) error { + if swag.IsZero(m.Networks) { // not required + return nil + } + + for i := 0; i < len(m.Networks); i++ { + if swag.IsZero(m.Networks[i]) { // not required + continue + } + + if m.Networks[i] != nil { + if err := m.Networks[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("networks" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("networks" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *PVMInstanceReference) validateOsType(formats strfmt.Registry) error { + + if err := validate.Required("osType", "body", m.OsType); err != nil { + return err + } + + return nil +} + +var pVmInstanceReferenceTypeProcTypePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["dedicated","shared","capped"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + pVmInstanceReferenceTypeProcTypePropEnum = append(pVmInstanceReferenceTypeProcTypePropEnum, v) + } +} + +const ( + + // PVMInstanceReferenceProcTypeDedicated captures enum value "dedicated" + PVMInstanceReferenceProcTypeDedicated string = "dedicated" + + // PVMInstanceReferenceProcTypeShared captures enum value "shared" + PVMInstanceReferenceProcTypeShared string = "shared" + + // PVMInstanceReferenceProcTypeCapped captures enum value "capped" + PVMInstanceReferenceProcTypeCapped string = "capped" +) + +// prop value enum +func (m *PVMInstanceReference) validateProcTypeEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, pVmInstanceReferenceTypeProcTypePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *PVMInstanceReference) validateProcType(formats strfmt.Registry) error { + + if err := validate.Required("procType", "body", m.ProcType); err != nil { + return err + } + + // value enum + if err := m.validateProcTypeEnum("procType", "body", *m.ProcType); err != nil { + return err + } + + return nil +} + +func (m *PVMInstanceReference) validateProcessors(formats strfmt.Registry) error { + + if err := validate.Required("processors", "body", m.Processors); err != nil { + return err + } + + return nil +} + +func (m *PVMInstanceReference) validatePvmInstanceID(formats strfmt.Registry) error { + + if err := validate.Required("pvmInstanceID", "body", m.PvmInstanceID); err != nil { + return err + } + + return nil +} + +func (m *PVMInstanceReference) validateSapProfile(formats strfmt.Registry) error { + if swag.IsZero(m.SapProfile) { // not required + return nil + } + + if m.SapProfile != nil { + if err := m.SapProfile.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("sapProfile") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sapProfile") + } + return err + } + } + + return nil +} + +func (m *PVMInstanceReference) validateServerName(formats strfmt.Registry) error { + + if err := validate.Required("serverName", "body", m.ServerName); err != nil { + return err + } + + return nil +} + +func (m *PVMInstanceReference) validateSoftwareLicenses(formats strfmt.Registry) error { + if swag.IsZero(m.SoftwareLicenses) { // not required + return nil + } + + if m.SoftwareLicenses != nil { + if err := m.SoftwareLicenses.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("softwareLicenses") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("softwareLicenses") + } + return err + } + } + + return nil +} + +func (m *PVMInstanceReference) validateSrcs(formats strfmt.Registry) error { + if swag.IsZero(m.Srcs) { // not required + return nil + } + + for i := 0; i < len(m.Srcs); i++ { + + for ii := 0; ii < len(m.Srcs[i]); ii++ { + if swag.IsZero(m.Srcs[i][ii]) { // not required + continue + } + + if m.Srcs[i][ii] != nil { + if err := m.Srcs[i][ii].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("srcs" + "." + strconv.Itoa(i) + "." + strconv.Itoa(ii)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("srcs" + "." + strconv.Itoa(i) + "." + strconv.Itoa(ii)) + } + return err + } + } + + } + + } + + return nil +} + +func (m *PVMInstanceReference) validateStatus(formats strfmt.Registry) error { + + if err := validate.Required("status", "body", m.Status); err != nil { + return err + } + + return nil +} + +func (m *PVMInstanceReference) validateUpdatedDate(formats strfmt.Registry) error { + if swag.IsZero(m.UpdatedDate) { // not required + return nil + } + + if err := validate.FormatOf("updatedDate", "body", "date-time", m.UpdatedDate.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *PVMInstanceReference) validateVirtualCores(formats strfmt.Registry) error { + if swag.IsZero(m.VirtualCores) { // not required + return nil + } + + if m.VirtualCores != nil { + if err := m.VirtualCores.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("virtualCores") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("virtualCores") + } + return err + } + } + + return nil +} + +// ContextValidate validate this p VM instance reference based on the context it is used +func (m *PVMInstanceReference) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateAddresses(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateConsoleLanguage(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateFault(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateHealth(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateNetworks(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSapProfile(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSoftwareLicenses(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSrcs(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateVirtualCores(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PVMInstanceReference) contextValidateAddresses(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Addresses); i++ { + + if m.Addresses[i] != nil { + if err := m.Addresses[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("addresses" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("addresses" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *PVMInstanceReference) contextValidateConsoleLanguage(ctx context.Context, formats strfmt.Registry) error { + + if m.ConsoleLanguage != nil { + if err := m.ConsoleLanguage.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("consoleLanguage") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("consoleLanguage") + } + return err + } + } + + return nil +} + +func (m *PVMInstanceReference) contextValidateFault(ctx context.Context, formats strfmt.Registry) error { + + if m.Fault != nil { + if err := m.Fault.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("fault") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("fault") + } + return err + } + } + + return nil +} + +func (m *PVMInstanceReference) contextValidateHealth(ctx context.Context, formats strfmt.Registry) error { + + if m.Health != nil { + if err := m.Health.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("health") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("health") + } + return err + } + } + + return nil +} + +func (m *PVMInstanceReference) contextValidateNetworks(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Networks); i++ { + + if m.Networks[i] != nil { + if err := m.Networks[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("networks" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("networks" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *PVMInstanceReference) contextValidateSapProfile(ctx context.Context, formats strfmt.Registry) error { + + if m.SapProfile != nil { + if err := m.SapProfile.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("sapProfile") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sapProfile") + } + return err + } + } + + return nil +} + +func (m *PVMInstanceReference) contextValidateSoftwareLicenses(ctx context.Context, formats strfmt.Registry) error { + + if m.SoftwareLicenses != nil { + if err := m.SoftwareLicenses.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("softwareLicenses") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("softwareLicenses") + } + return err + } + } + + return nil +} + +func (m *PVMInstanceReference) contextValidateSrcs(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Srcs); i++ { + + for ii := 0; ii < len(m.Srcs[i]); ii++ { + + if m.Srcs[i][ii] != nil { + if err := m.Srcs[i][ii].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("srcs" + "." + strconv.Itoa(i) + "." + strconv.Itoa(ii)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("srcs" + "." + strconv.Itoa(i) + "." + strconv.Itoa(ii)) + } + return err + } + } + + } + + } + + return nil +} + +func (m *PVMInstanceReference) contextValidateVirtualCores(ctx context.Context, formats strfmt.Registry) error { + + if m.VirtualCores != nil { + if err := m.VirtualCores.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("virtualCores") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("virtualCores") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *PVMInstanceReference) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PVMInstanceReference) UnmarshalBinary(b []byte) error { + var res PVMInstanceReference + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_remove_network.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_remove_network.go new file mode 100644 index 00000000000..937e609decd --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_remove_network.go @@ -0,0 +1,50 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// PVMInstanceRemoveNetwork p VM instance remove network +// +// swagger:model PVMInstanceRemoveNetwork +type PVMInstanceRemoveNetwork struct { + + // The mac address of the network interface to be removed + MacAddress string `json:"macAddress,omitempty"` +} + +// Validate validates this p VM instance remove network +func (m *PVMInstanceRemoveNetwork) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this p VM instance remove network based on context it is used +func (m *PVMInstanceRemoveNetwork) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *PVMInstanceRemoveNetwork) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PVMInstanceRemoveNetwork) UnmarshalBinary(b []byte) error { + var res PVMInstanceRemoveNetwork + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_update.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_update.go new file mode 100644 index 00000000000..89cb7788825 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_update.go @@ -0,0 +1,268 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// PVMInstanceUpdate p VM instance update +// +// swagger:model PVMInstanceUpdate +type PVMInstanceUpdate struct { + + // The VTL license repository capacity TB value + LicenseRepositoryCapacity int64 `json:"licenseRepositoryCapacity,omitempty"` + + // Amount of memory allocated (in GB) + Memory float64 `json:"memory,omitempty"` + + // Indicates if the server is allowed to migrate between hosts + Migratable *bool `json:"migratable,omitempty"` + + // pin policy + PinPolicy PinPolicy `json:"pinPolicy,omitempty"` + + // Processor type (dedicated, shared, capped) + // Enum: [dedicated shared capped] + ProcType string `json:"procType,omitempty"` + + // Number of processors allocated + Processors float64 `json:"processors,omitempty"` + + // If an SAP pvm-instance, the SAP profile ID to switch to (only while shutdown) + SapProfileID string `json:"sapProfileID,omitempty"` + + // Name of the server to create + ServerName string `json:"serverName,omitempty"` + + // The pvm instance Software Licenses + SoftwareLicenses *SoftwareLicenses `json:"softwareLicenses,omitempty"` + + // Indicates if all volumes attached to the server must reside in the same storage pool; If set to false then volumes from any storage type and pool can be attached to the PVMInstance; Impacts PVMInstance snapshot, capture, and clone, for capture and clone - only data volumes that are of the same storage type and in the same storage pool of the PVMInstance's boot volume can be included; for snapshot - all data volumes to be included in the snapshot must reside in the same storage type and pool. Once set to false, cannot be set back to true unless all volumes attached reside in the same storage type and pool. + StoragePoolAffinity *bool `json:"storagePoolAffinity,omitempty"` + + // The pvm instance virtual CPU information + VirtualCores *VirtualCores `json:"virtualCores,omitempty"` +} + +// Validate validates this p VM instance update +func (m *PVMInstanceUpdate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validatePinPolicy(formats); err != nil { + res = append(res, err) + } + + if err := m.validateProcType(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSoftwareLicenses(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVirtualCores(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PVMInstanceUpdate) validatePinPolicy(formats strfmt.Registry) error { + if swag.IsZero(m.PinPolicy) { // not required + return nil + } + + if err := m.PinPolicy.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("pinPolicy") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("pinPolicy") + } + return err + } + + return nil +} + +var pVmInstanceUpdateTypeProcTypePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["dedicated","shared","capped"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + pVmInstanceUpdateTypeProcTypePropEnum = append(pVmInstanceUpdateTypeProcTypePropEnum, v) + } +} + +const ( + + // PVMInstanceUpdateProcTypeDedicated captures enum value "dedicated" + PVMInstanceUpdateProcTypeDedicated string = "dedicated" + + // PVMInstanceUpdateProcTypeShared captures enum value "shared" + PVMInstanceUpdateProcTypeShared string = "shared" + + // PVMInstanceUpdateProcTypeCapped captures enum value "capped" + PVMInstanceUpdateProcTypeCapped string = "capped" +) + +// prop value enum +func (m *PVMInstanceUpdate) validateProcTypeEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, pVmInstanceUpdateTypeProcTypePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *PVMInstanceUpdate) validateProcType(formats strfmt.Registry) error { + if swag.IsZero(m.ProcType) { // not required + return nil + } + + // value enum + if err := m.validateProcTypeEnum("procType", "body", m.ProcType); err != nil { + return err + } + + return nil +} + +func (m *PVMInstanceUpdate) validateSoftwareLicenses(formats strfmt.Registry) error { + if swag.IsZero(m.SoftwareLicenses) { // not required + return nil + } + + if m.SoftwareLicenses != nil { + if err := m.SoftwareLicenses.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("softwareLicenses") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("softwareLicenses") + } + return err + } + } + + return nil +} + +func (m *PVMInstanceUpdate) validateVirtualCores(formats strfmt.Registry) error { + if swag.IsZero(m.VirtualCores) { // not required + return nil + } + + if m.VirtualCores != nil { + if err := m.VirtualCores.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("virtualCores") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("virtualCores") + } + return err + } + } + + return nil +} + +// ContextValidate validate this p VM instance update based on the context it is used +func (m *PVMInstanceUpdate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidatePinPolicy(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSoftwareLicenses(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateVirtualCores(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PVMInstanceUpdate) contextValidatePinPolicy(ctx context.Context, formats strfmt.Registry) error { + + if err := m.PinPolicy.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("pinPolicy") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("pinPolicy") + } + return err + } + + return nil +} + +func (m *PVMInstanceUpdate) contextValidateSoftwareLicenses(ctx context.Context, formats strfmt.Registry) error { + + if m.SoftwareLicenses != nil { + if err := m.SoftwareLicenses.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("softwareLicenses") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("softwareLicenses") + } + return err + } + } + + return nil +} + +func (m *PVMInstanceUpdate) contextValidateVirtualCores(ctx context.Context, formats strfmt.Registry) error { + + if m.VirtualCores != nil { + if err := m.VirtualCores.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("virtualCores") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("virtualCores") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *PVMInstanceUpdate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PVMInstanceUpdate) UnmarshalBinary(b []byte) error { + var res PVMInstanceUpdate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_update_response.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_update_response.go new file mode 100644 index 00000000000..5f19935c501 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_update_response.go @@ -0,0 +1,170 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// PVMInstanceUpdateResponse p VM instance update response +// +// swagger:model PVMInstanceUpdateResponse +type PVMInstanceUpdateResponse struct { + + // The VTL license repository capacity TB value + LicenseRepositoryCapacity int64 `json:"licenseRepositoryCapacity,omitempty"` + + // Amount of memory allocated (in GB) + Memory float64 `json:"memory,omitempty"` + + // pin policy + PinPolicy PinPolicy `json:"pinPolicy,omitempty"` + + // Processor type (dedicated, shared, capped) + // Enum: [dedicated shared capped] + ProcType string `json:"procType,omitempty"` + + // Number of processors allocated + Processors float64 `json:"processors,omitempty"` + + // Name of the server to create + ServerName string `json:"serverName,omitempty"` + + // URL to check for status of the operation (for now, just the URL for the GET on the server, which has status information from powervc) + StatusURL string `json:"statusUrl,omitempty"` +} + +// Validate validates this p VM instance update response +func (m *PVMInstanceUpdateResponse) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validatePinPolicy(formats); err != nil { + res = append(res, err) + } + + if err := m.validateProcType(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PVMInstanceUpdateResponse) validatePinPolicy(formats strfmt.Registry) error { + if swag.IsZero(m.PinPolicy) { // not required + return nil + } + + if err := m.PinPolicy.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("pinPolicy") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("pinPolicy") + } + return err + } + + return nil +} + +var pVmInstanceUpdateResponseTypeProcTypePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["dedicated","shared","capped"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + pVmInstanceUpdateResponseTypeProcTypePropEnum = append(pVmInstanceUpdateResponseTypeProcTypePropEnum, v) + } +} + +const ( + + // PVMInstanceUpdateResponseProcTypeDedicated captures enum value "dedicated" + PVMInstanceUpdateResponseProcTypeDedicated string = "dedicated" + + // PVMInstanceUpdateResponseProcTypeShared captures enum value "shared" + PVMInstanceUpdateResponseProcTypeShared string = "shared" + + // PVMInstanceUpdateResponseProcTypeCapped captures enum value "capped" + PVMInstanceUpdateResponseProcTypeCapped string = "capped" +) + +// prop value enum +func (m *PVMInstanceUpdateResponse) validateProcTypeEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, pVmInstanceUpdateResponseTypeProcTypePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *PVMInstanceUpdateResponse) validateProcType(formats strfmt.Registry) error { + if swag.IsZero(m.ProcType) { // not required + return nil + } + + // value enum + if err := m.validateProcTypeEnum("procType", "body", m.ProcType); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this p VM instance update response based on the context it is used +func (m *PVMInstanceUpdateResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidatePinPolicy(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PVMInstanceUpdateResponse) contextValidatePinPolicy(ctx context.Context, formats strfmt.Registry) error { + + if err := m.PinPolicy.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("pinPolicy") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("pinPolicy") + } + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *PVMInstanceUpdateResponse) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PVMInstanceUpdateResponse) UnmarshalBinary(b []byte) error { + var res PVMInstanceUpdateResponse + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_volume_update.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_volume_update.go new file mode 100644 index 00000000000..d3ab5a7cc46 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instance_volume_update.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// PVMInstanceVolumeUpdate p VM instance volume update +// +// swagger:model PVMInstanceVolumeUpdate +type PVMInstanceVolumeUpdate struct { + + // Indicates if the volume should be deleted when the PVMInstance is terminated + // Required: true + DeleteOnTermination *bool `json:"deleteOnTermination"` +} + +// Validate validates this p VM instance volume update +func (m *PVMInstanceVolumeUpdate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateDeleteOnTermination(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PVMInstanceVolumeUpdate) validateDeleteOnTermination(formats strfmt.Registry) error { + + if err := validate.Required("deleteOnTermination", "body", m.DeleteOnTermination); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this p VM instance volume update based on context it is used +func (m *PVMInstanceVolumeUpdate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *PVMInstanceVolumeUpdate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PVMInstanceVolumeUpdate) UnmarshalBinary(b []byte) error { + var res PVMInstanceVolumeUpdate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instances.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instances.go new file mode 100644 index 00000000000..c535bc5fb0d --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/p_vm_instances.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// PVMInstances p VM instances +// +// swagger:model PVMInstances +type PVMInstances struct { + + // PVM Instance References + // Required: true + PvmInstances []*PVMInstanceReference `json:"pvmInstances"` +} + +// Validate validates this p VM instances +func (m *PVMInstances) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validatePvmInstances(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PVMInstances) validatePvmInstances(formats strfmt.Registry) error { + + if err := validate.Required("pvmInstances", "body", m.PvmInstances); err != nil { + return err + } + + for i := 0; i < len(m.PvmInstances); i++ { + if swag.IsZero(m.PvmInstances[i]) { // not required + continue + } + + if m.PvmInstances[i] != nil { + if err := m.PvmInstances[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("pvmInstances" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("pvmInstances" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this p VM instances based on the context it is used +func (m *PVMInstances) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidatePvmInstances(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PVMInstances) contextValidatePvmInstances(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.PvmInstances); i++ { + + if m.PvmInstances[i] != nil { + if err := m.PvmInstances[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("pvmInstances" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("pvmInstances" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *PVMInstances) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PVMInstances) UnmarshalBinary(b []byte) error { + var res PVMInstances + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/peer_gateway_address.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/peer_gateway_address.go new file mode 100644 index 00000000000..1a060a63659 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/peer_gateway_address.go @@ -0,0 +1,39 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// PeerGatewayAddress IP address of the Peer Gateway attached to this VPNConnection +// Example: 192.168.1.1 +// +// swagger:model PeerGatewayAddress +type PeerGatewayAddress strfmt.IPv4 + +// Validate validates this peer gateway address +func (m PeerGatewayAddress) Validate(formats strfmt.Registry) error { + var res []error + + if err := validate.FormatOf("", "body", "ipv4", strfmt.IPv4(m).String(), formats); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validates this peer gateway address based on context it is used +func (m PeerGatewayAddress) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/peer_subnet_update.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/peer_subnet_update.go new file mode 100644 index 00000000000..863dd974721 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/peer_subnet_update.go @@ -0,0 +1,72 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// PeerSubnetUpdate CIDR of peer subnet to attach/detach +// +// swagger:model PeerSubnetUpdate +type PeerSubnetUpdate struct { + + // cidr + // Example: 128.170.1.0/32 + // Required: true + Cidr *string `json:"cidr"` +} + +// Validate validates this peer subnet update +func (m *PeerSubnetUpdate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCidr(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PeerSubnetUpdate) validateCidr(formats strfmt.Registry) error { + + if err := validate.Required("cidr", "body", m.Cidr); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this peer subnet update based on context it is used +func (m *PeerSubnetUpdate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *PeerSubnetUpdate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PeerSubnetUpdate) UnmarshalBinary(b []byte) error { + var res PeerSubnetUpdate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/peer_subnets.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/peer_subnets.go new file mode 100644 index 00000000000..42c108d628a --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/peer_subnets.go @@ -0,0 +1,51 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// PeerSubnets peer subnets +// +// swagger:model PeerSubnets +type PeerSubnets struct { + + // an array of strings containing CIDR of peer subnets + // Example: ["128.170.1.0/20","128.169.1.0/24","128.168.1.0/27","128.170.1.0/32"] + PeerSubnets []string `json:"peerSubnets"` +} + +// Validate validates this peer subnets +func (m *PeerSubnets) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this peer subnets based on context it is used +func (m *PeerSubnets) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *PeerSubnets) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PeerSubnets) UnmarshalBinary(b []byte) error { + var res PeerSubnets + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/peering_network.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/peering_network.go new file mode 100644 index 00000000000..9530fe17486 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/peering_network.go @@ -0,0 +1,91 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// PeeringNetwork peering network +// +// swagger:model PeeringNetwork +type PeeringNetwork struct { + + // Network in CIDR notation (192.168.0.0/24) + // Required: true + Cidr *string `json:"cidr" datastore:"cidr"` + + // DNS Servers + DNSServers []string `json:"dnsServers,omitempty" datastore:"dnsServers"` + + // Name of project to be peered + // Required: true + ProjectName *string `json:"projectName" datastore:"projectName"` +} + +// Validate validates this peering network +func (m *PeeringNetwork) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCidr(formats); err != nil { + res = append(res, err) + } + + if err := m.validateProjectName(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PeeringNetwork) validateCidr(formats strfmt.Registry) error { + + if err := validate.Required("cidr", "body", m.Cidr); err != nil { + return err + } + + return nil +} + +func (m *PeeringNetwork) validateProjectName(formats strfmt.Registry) error { + + if err := validate.Required("projectName", "body", m.ProjectName); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this peering network based on context it is used +func (m *PeeringNetwork) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *PeeringNetwork) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PeeringNetwork) UnmarshalBinary(b []byte) error { + var res PeeringNetwork + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/pin_policy.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/pin_policy.go new file mode 100644 index 00000000000..9a1f4e45267 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/pin_policy.go @@ -0,0 +1,81 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// PinPolicy Specify PVM pin policy +// +// swagger:model PinPolicy +type PinPolicy string + +func NewPinPolicy(value PinPolicy) *PinPolicy { + return &value +} + +// Pointer returns a pointer to a freshly-allocated PinPolicy. +func (m PinPolicy) Pointer() *PinPolicy { + return &m +} + +const ( + + // PinPolicyNone captures enum value "none" + PinPolicyNone PinPolicy = "none" + + // PinPolicySoft captures enum value "soft" + PinPolicySoft PinPolicy = "soft" + + // PinPolicyHard captures enum value "hard" + PinPolicyHard PinPolicy = "hard" +) + +// for schema +var pinPolicyEnum []interface{} + +func init() { + var res []PinPolicy + if err := json.Unmarshal([]byte(`["none","soft","hard"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + pinPolicyEnum = append(pinPolicyEnum, v) + } +} + +func (m PinPolicy) validatePinPolicyEnum(path, location string, value PinPolicy) error { + if err := validate.EnumCase(path, location, value, pinPolicyEnum, true); err != nil { + return err + } + return nil +} + +// Validate validates this pin policy +func (m PinPolicy) Validate(formats strfmt.Registry) error { + var res []error + + // value enum + if err := m.validatePinPolicyEnum("", "body", m); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validates this pin policy based on context it is used +func (m PinPolicy) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/placement_group.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/placement_group.go new file mode 100644 index 00000000000..31661603fab --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/placement_group.go @@ -0,0 +1,158 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// PlacementGroup placement group +// +// swagger:model PlacementGroup +type PlacementGroup struct { + + // The id of the Placement Group + // Required: true + ID *string `json:"id"` + + // The List of PVM Instance IDs associated with the Placement Group + // Required: true + Members []string `json:"members"` + + // The name of the Placement Group + // Required: true + Name *string `json:"name"` + + // The Placement Group Policy + // Required: true + // Enum: [affinity anti-affinity] + Policy *string `json:"policy"` +} + +// Validate validates this placement group +func (m *PlacementGroup) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMembers(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePolicy(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PlacementGroup) validateID(formats strfmt.Registry) error { + + if err := validate.Required("id", "body", m.ID); err != nil { + return err + } + + return nil +} + +func (m *PlacementGroup) validateMembers(formats strfmt.Registry) error { + + if err := validate.Required("members", "body", m.Members); err != nil { + return err + } + + return nil +} + +func (m *PlacementGroup) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +var placementGroupTypePolicyPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["affinity","anti-affinity"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + placementGroupTypePolicyPropEnum = append(placementGroupTypePolicyPropEnum, v) + } +} + +const ( + + // PlacementGroupPolicyAffinity captures enum value "affinity" + PlacementGroupPolicyAffinity string = "affinity" + + // PlacementGroupPolicyAntiDashAffinity captures enum value "anti-affinity" + PlacementGroupPolicyAntiDashAffinity string = "anti-affinity" +) + +// prop value enum +func (m *PlacementGroup) validatePolicyEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, placementGroupTypePolicyPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *PlacementGroup) validatePolicy(formats strfmt.Registry) error { + + if err := validate.Required("policy", "body", m.Policy); err != nil { + return err + } + + // value enum + if err := m.validatePolicyEnum("policy", "body", *m.Policy); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this placement group based on context it is used +func (m *PlacementGroup) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *PlacementGroup) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PlacementGroup) UnmarshalBinary(b []byte) error { + var res PlacementGroup + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/placement_group_create.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/placement_group_create.go new file mode 100644 index 00000000000..2fd3d083d71 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/placement_group_create.go @@ -0,0 +1,124 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// PlacementGroupCreate placement group create +// +// swagger:model PlacementGroupCreate +type PlacementGroupCreate struct { + + // The name of the Placement Group + // Required: true + Name *string `json:"name"` + + // The Placement Group Policy + // Required: true + // Enum: [affinity anti-affinity] + Policy *string `json:"policy"` +} + +// Validate validates this placement group create +func (m *PlacementGroupCreate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePolicy(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PlacementGroupCreate) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +var placementGroupCreateTypePolicyPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["affinity","anti-affinity"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + placementGroupCreateTypePolicyPropEnum = append(placementGroupCreateTypePolicyPropEnum, v) + } +} + +const ( + + // PlacementGroupCreatePolicyAffinity captures enum value "affinity" + PlacementGroupCreatePolicyAffinity string = "affinity" + + // PlacementGroupCreatePolicyAntiDashAffinity captures enum value "anti-affinity" + PlacementGroupCreatePolicyAntiDashAffinity string = "anti-affinity" +) + +// prop value enum +func (m *PlacementGroupCreate) validatePolicyEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, placementGroupCreateTypePolicyPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *PlacementGroupCreate) validatePolicy(formats strfmt.Registry) error { + + if err := validate.Required("policy", "body", m.Policy); err != nil { + return err + } + + // value enum + if err := m.validatePolicyEnum("policy", "body", *m.Policy); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this placement group create based on context it is used +func (m *PlacementGroupCreate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *PlacementGroupCreate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PlacementGroupCreate) UnmarshalBinary(b []byte) error { + var res PlacementGroupCreate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/placement_group_server.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/placement_group_server.go new file mode 100644 index 00000000000..73d29188fd6 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/placement_group_server.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// PlacementGroupServer placement group server +// +// swagger:model PlacementGroupServer +type PlacementGroupServer struct { + + // The ID of the Server + // Required: true + ID *string `json:"id"` +} + +// Validate validates this placement group server +func (m *PlacementGroupServer) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateID(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PlacementGroupServer) validateID(formats strfmt.Registry) error { + + if err := validate.Required("id", "body", m.ID); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this placement group server based on context it is used +func (m *PlacementGroupServer) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *PlacementGroupServer) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PlacementGroupServer) UnmarshalBinary(b []byte) error { + var res PlacementGroupServer + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/placement_groups.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/placement_groups.go new file mode 100644 index 00000000000..9c033b6937a --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/placement_groups.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// PlacementGroups placement groups +// +// swagger:model PlacementGroups +type PlacementGroups struct { + + // List of Server Placement Groups + // Required: true + PlacementGroups []*PlacementGroup `json:"placementGroups"` +} + +// Validate validates this placement groups +func (m *PlacementGroups) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validatePlacementGroups(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PlacementGroups) validatePlacementGroups(formats strfmt.Registry) error { + + if err := validate.Required("placementGroups", "body", m.PlacementGroups); err != nil { + return err + } + + for i := 0; i < len(m.PlacementGroups); i++ { + if swag.IsZero(m.PlacementGroups[i]) { // not required + continue + } + + if m.PlacementGroups[i] != nil { + if err := m.PlacementGroups[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("placementGroups" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("placementGroups" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this placement groups based on the context it is used +func (m *PlacementGroups) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidatePlacementGroups(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PlacementGroups) contextValidatePlacementGroups(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.PlacementGroups); i++ { + + if m.PlacementGroups[i] != nil { + if err := m.PlacementGroups[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("placementGroups" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("placementGroups" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *PlacementGroups) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PlacementGroups) UnmarshalBinary(b []byte) error { + var res PlacementGroups + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/plan.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/plan.go new file mode 100644 index 00000000000..8a3eb9c4613 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/plan.go @@ -0,0 +1,165 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Plan plan +// +// swagger:model Plan +type Plan struct { + + // bindable + Bindable bool `json:"bindable,omitempty"` + + // description + // Required: true + Description *string `json:"description"` + + // free + Free *bool `json:"free,omitempty"` + + // id + // Required: true + ID *string `json:"id"` + + // metadata + Metadata Metadata `json:"metadata,omitempty"` + + // name + // Required: true + Name *string `json:"name"` + + // schemas + Schemas *SchemasObject `json:"schemas,omitempty"` +} + +// Validate validates this plan +func (m *Plan) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateDescription(formats); err != nil { + res = append(res, err) + } + + if err := m.validateID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSchemas(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Plan) validateDescription(formats strfmt.Registry) error { + + if err := validate.Required("description", "body", m.Description); err != nil { + return err + } + + return nil +} + +func (m *Plan) validateID(formats strfmt.Registry) error { + + if err := validate.Required("id", "body", m.ID); err != nil { + return err + } + + return nil +} + +func (m *Plan) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *Plan) validateSchemas(formats strfmt.Registry) error { + if swag.IsZero(m.Schemas) { // not required + return nil + } + + if m.Schemas != nil { + if err := m.Schemas.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("schemas") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("schemas") + } + return err + } + } + + return nil +} + +// ContextValidate validate this plan based on the context it is used +func (m *Plan) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateSchemas(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Plan) contextValidateSchemas(ctx context.Context, formats strfmt.Registry) error { + + if m.Schemas != nil { + if err := m.Schemas.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("schemas") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("schemas") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Plan) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Plan) UnmarshalBinary(b []byte) error { + var res Plan + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/policy_versions.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/policy_versions.go new file mode 100644 index 00000000000..fa426855a90 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/policy_versions.go @@ -0,0 +1,28 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" +) + +// PolicyVersions policy versions +// Example: [1,2] +// +// swagger:model PolicyVersions +type PolicyVersions []float64 + +// Validate validates this policy versions +func (m PolicyVersions) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this policy versions based on context it is used +func (m PolicyVersions) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/region_storage_types.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/region_storage_types.go new file mode 100644 index 00000000000..768bc4b51fa --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/region_storage_types.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RegionStorageTypes An array of of storage types supported in a region +// +// swagger:model RegionStorageTypes +type RegionStorageTypes []*StorageType + +// Validate validates this region storage types +func (m RegionStorageTypes) Validate(formats strfmt.Registry) error { + var res []error + + for i := 0; i < len(m); i++ { + if swag.IsZero(m[i]) { // not required + continue + } + + if m[i] != nil { + if err := m[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(strconv.Itoa(i)) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validate this region storage types based on the context it is used +func (m RegionStorageTypes) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + for i := 0; i < len(m); i++ { + + if m[i] != nil { + if err := m[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(strconv.Itoa(i)) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/s_a_p_create.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/s_a_p_create.go new file mode 100644 index 00000000000..b03b60f7d4d --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/s_a_p_create.go @@ -0,0 +1,325 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// SAPCreate s a p create +// +// swagger:model SAPCreate +type SAPCreate struct { + + // Image ID of the sap image to use for the server + // Required: true + ImageID *string `json:"imageID"` + + // instances + Instances *PVMInstanceMultiCreate `json:"instances,omitempty"` + + // Name of the sap pvm-instance + // Required: true + Name *string `json:"name"` + + // The pvm instance networks information + // Required: true + Networks []*PVMInstanceAddNetwork `json:"networks"` + + // pin policy + PinPolicy PinPolicy `json:"pinPolicy,omitempty"` + + // The placement group for the server + PlacementGroup string `json:"placementGroup,omitempty"` + + // SAP Profile ID for the amount of cores and memory + // Required: true + ProfileID *string `json:"profileID"` + + // The name of the SSH Key to provide to the server for authenticating + SSHKeyName string `json:"sshKeyName,omitempty"` + + // The storage affinity data; ignored if storagePool is provided; Only valid when you deploy one of the IBM supplied stock images. Storage type and pool for a custom image (an imported image or an image that is created from a PVMInstance capture) defaults to the storage type and pool the image was created in + StorageAffinity *StorageAffinity `json:"storageAffinity,omitempty"` + + // Storage Pool for server deployment; if provided then storageAffinity and storageType will be ignored; Only valid when you deploy one of the IBM supplied stock images. Storage type and pool for a custom image (an imported image or an image that is created from a PVMInstance capture) defaults to the storage type and pool the image was created in + StoragePool string `json:"storagePool,omitempty"` + + // Storage type for server deployment; will be ignored if storagePool or storageAffinity is provided; Only valid when you deploy one of the IBM supplied stock images. Storage type and pool for a custom image (an imported image or an image that is created from a PVMInstance capture) defaults to the storage type and pool the image was created in + StorageType string `json:"storageType,omitempty"` + + // System type used to host the instance. Only e880, e980, e1080 are supported + SysType string `json:"sysType,omitempty"` + + // Cloud init user defined data + UserData string `json:"userData,omitempty"` + + // List of Volume IDs to attach to the pvm-instance on creation + VolumeIDs []string `json:"volumeIDs"` +} + +// Validate validates this s a p create +func (m *SAPCreate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateImageID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateInstances(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateNetworks(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePinPolicy(formats); err != nil { + res = append(res, err) + } + + if err := m.validateProfileID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStorageAffinity(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SAPCreate) validateImageID(formats strfmt.Registry) error { + + if err := validate.Required("imageID", "body", m.ImageID); err != nil { + return err + } + + return nil +} + +func (m *SAPCreate) validateInstances(formats strfmt.Registry) error { + if swag.IsZero(m.Instances) { // not required + return nil + } + + if m.Instances != nil { + if err := m.Instances.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("instances") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("instances") + } + return err + } + } + + return nil +} + +func (m *SAPCreate) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *SAPCreate) validateNetworks(formats strfmt.Registry) error { + + if err := validate.Required("networks", "body", m.Networks); err != nil { + return err + } + + for i := 0; i < len(m.Networks); i++ { + if swag.IsZero(m.Networks[i]) { // not required + continue + } + + if m.Networks[i] != nil { + if err := m.Networks[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("networks" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("networks" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *SAPCreate) validatePinPolicy(formats strfmt.Registry) error { + if swag.IsZero(m.PinPolicy) { // not required + return nil + } + + if err := m.PinPolicy.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("pinPolicy") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("pinPolicy") + } + return err + } + + return nil +} + +func (m *SAPCreate) validateProfileID(formats strfmt.Registry) error { + + if err := validate.Required("profileID", "body", m.ProfileID); err != nil { + return err + } + + return nil +} + +func (m *SAPCreate) validateStorageAffinity(formats strfmt.Registry) error { + if swag.IsZero(m.StorageAffinity) { // not required + return nil + } + + if m.StorageAffinity != nil { + if err := m.StorageAffinity.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("storageAffinity") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("storageAffinity") + } + return err + } + } + + return nil +} + +// ContextValidate validate this s a p create based on the context it is used +func (m *SAPCreate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateInstances(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateNetworks(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidatePinPolicy(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateStorageAffinity(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SAPCreate) contextValidateInstances(ctx context.Context, formats strfmt.Registry) error { + + if m.Instances != nil { + if err := m.Instances.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("instances") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("instances") + } + return err + } + } + + return nil +} + +func (m *SAPCreate) contextValidateNetworks(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Networks); i++ { + + if m.Networks[i] != nil { + if err := m.Networks[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("networks" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("networks" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *SAPCreate) contextValidatePinPolicy(ctx context.Context, formats strfmt.Registry) error { + + if err := m.PinPolicy.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("pinPolicy") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("pinPolicy") + } + return err + } + + return nil +} + +func (m *SAPCreate) contextValidateStorageAffinity(ctx context.Context, formats strfmt.Registry) error { + + if m.StorageAffinity != nil { + if err := m.StorageAffinity.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("storageAffinity") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("storageAffinity") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *SAPCreate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SAPCreate) UnmarshalBinary(b []byte) error { + var res SAPCreate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/s_a_p_profile.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/s_a_p_profile.go new file mode 100644 index 00000000000..73096fa60ed --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/s_a_p_profile.go @@ -0,0 +1,184 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// SAPProfile s a p profile +// +// swagger:model SAPProfile +type SAPProfile struct { + + // Has certification been performed on profile + // Required: true + Certified *bool `json:"certified"` + + // Amount of cores + // Required: true + Cores *int64 `json:"cores"` + + // Amount of memory (in GB) + // Required: true + Memory *int64 `json:"memory"` + + // SAP Profile ID + // Required: true + ProfileID *string `json:"profileID"` + + // Type of profile + // Required: true + // Enum: [balanced compute memory non-production ultra-memory] + Type *string `json:"type"` +} + +// Validate validates this s a p profile +func (m *SAPProfile) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCertified(formats); err != nil { + res = append(res, err) + } + + if err := m.validateCores(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMemory(formats); err != nil { + res = append(res, err) + } + + if err := m.validateProfileID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateType(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SAPProfile) validateCertified(formats strfmt.Registry) error { + + if err := validate.Required("certified", "body", m.Certified); err != nil { + return err + } + + return nil +} + +func (m *SAPProfile) validateCores(formats strfmt.Registry) error { + + if err := validate.Required("cores", "body", m.Cores); err != nil { + return err + } + + return nil +} + +func (m *SAPProfile) validateMemory(formats strfmt.Registry) error { + + if err := validate.Required("memory", "body", m.Memory); err != nil { + return err + } + + return nil +} + +func (m *SAPProfile) validateProfileID(formats strfmt.Registry) error { + + if err := validate.Required("profileID", "body", m.ProfileID); err != nil { + return err + } + + return nil +} + +var sAPProfileTypeTypePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["balanced","compute","memory","non-production","ultra-memory"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + sAPProfileTypeTypePropEnum = append(sAPProfileTypeTypePropEnum, v) + } +} + +const ( + + // SAPProfileTypeBalanced captures enum value "balanced" + SAPProfileTypeBalanced string = "balanced" + + // SAPProfileTypeCompute captures enum value "compute" + SAPProfileTypeCompute string = "compute" + + // SAPProfileTypeMemory captures enum value "memory" + SAPProfileTypeMemory string = "memory" + + // SAPProfileTypeNonDashProduction captures enum value "non-production" + SAPProfileTypeNonDashProduction string = "non-production" + + // SAPProfileTypeUltraDashMemory captures enum value "ultra-memory" + SAPProfileTypeUltraDashMemory string = "ultra-memory" +) + +// prop value enum +func (m *SAPProfile) validateTypeEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, sAPProfileTypeTypePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *SAPProfile) validateType(formats strfmt.Registry) error { + + if err := validate.Required("type", "body", m.Type); err != nil { + return err + } + + // value enum + if err := m.validateTypeEnum("type", "body", *m.Type); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this s a p profile based on context it is used +func (m *SAPProfile) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *SAPProfile) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SAPProfile) UnmarshalBinary(b []byte) error { + var res SAPProfile + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/s_a_p_profile_reference.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/s_a_p_profile_reference.go new file mode 100644 index 00000000000..9f7cd91f548 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/s_a_p_profile_reference.go @@ -0,0 +1,88 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// SAPProfileReference s a p profile reference +// +// swagger:model SAPProfileReference +type SAPProfileReference struct { + + // Link to SAP profile resource + // Required: true + Href *string `json:"href"` + + // SAP Profile ID + // Required: true + ProfileID *string `json:"profileID"` +} + +// Validate validates this s a p profile reference +func (m *SAPProfileReference) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateHref(formats); err != nil { + res = append(res, err) + } + + if err := m.validateProfileID(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SAPProfileReference) validateHref(formats strfmt.Registry) error { + + if err := validate.Required("href", "body", m.Href); err != nil { + return err + } + + return nil +} + +func (m *SAPProfileReference) validateProfileID(formats strfmt.Registry) error { + + if err := validate.Required("profileID", "body", m.ProfileID); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this s a p profile reference based on context it is used +func (m *SAPProfileReference) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *SAPProfileReference) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SAPProfileReference) UnmarshalBinary(b []byte) error { + var res SAPProfileReference + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/s_a_p_profiles.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/s_a_p_profiles.go new file mode 100644 index 00000000000..02c67b962ed --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/s_a_p_profiles.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// SAPProfiles s a p profiles +// +// swagger:model SAPProfiles +type SAPProfiles struct { + + // SAP Profiles + // Required: true + Profiles []*SAPProfile `json:"profiles"` +} + +// Validate validates this s a p profiles +func (m *SAPProfiles) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateProfiles(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SAPProfiles) validateProfiles(formats strfmt.Registry) error { + + if err := validate.Required("profiles", "body", m.Profiles); err != nil { + return err + } + + for i := 0; i < len(m.Profiles); i++ { + if swag.IsZero(m.Profiles[i]) { // not required + continue + } + + if m.Profiles[i] != nil { + if err := m.Profiles[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("profiles" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("profiles" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this s a p profiles based on the context it is used +func (m *SAPProfiles) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateProfiles(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SAPProfiles) contextValidateProfiles(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Profiles); i++ { + + if m.Profiles[i] != nil { + if err := m.Profiles[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("profiles" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("profiles" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *SAPProfiles) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SAPProfiles) UnmarshalBinary(b []byte) error { + var res SAPProfiles + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/s_r_c.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/s_r_c.go new file mode 100644 index 00000000000..e9d191fa7a4 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/s_r_c.go @@ -0,0 +1,53 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// SRC s r c +// +// swagger:model SRC +type SRC struct { + + // The SRC reference code + Src string `json:"src,omitempty"` + + // The date stamp of the SRC + Timestamp string `json:"timestamp,omitempty"` +} + +// Validate validates this s r c +func (m *SRC) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this s r c based on context it is used +func (m *SRC) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *SRC) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SRC) UnmarshalBinary(b []byte) error { + var res SRC + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/schema_parameters.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/schema_parameters.go new file mode 100644 index 00000000000..118c6b0f975 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/schema_parameters.go @@ -0,0 +1,50 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// SchemaParameters schema parameters +// +// swagger:model SchemaParameters +type SchemaParameters struct { + + // parameters + Parameters JSONSchemaObject `json:"parameters,omitempty"` +} + +// Validate validates this schema parameters +func (m *SchemaParameters) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this schema parameters based on context it is used +func (m *SchemaParameters) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *SchemaParameters) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SchemaParameters) UnmarshalBinary(b []byte) error { + var res SchemaParameters + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/schemas_object.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/schemas_object.go new file mode 100644 index 00000000000..1f7ce4efe2d --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/schemas_object.go @@ -0,0 +1,150 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// SchemasObject schemas object +// +// swagger:model SchemasObject +type SchemasObject struct { + + // service binding + ServiceBinding *ServiceBindingSchemaObject `json:"service_binding,omitempty"` + + // service instance + ServiceInstance *ServiceInstanceSchemaObject `json:"service_instance,omitempty"` +} + +// Validate validates this schemas object +func (m *SchemasObject) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateServiceBinding(formats); err != nil { + res = append(res, err) + } + + if err := m.validateServiceInstance(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SchemasObject) validateServiceBinding(formats strfmt.Registry) error { + if swag.IsZero(m.ServiceBinding) { // not required + return nil + } + + if m.ServiceBinding != nil { + if err := m.ServiceBinding.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("service_binding") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("service_binding") + } + return err + } + } + + return nil +} + +func (m *SchemasObject) validateServiceInstance(formats strfmt.Registry) error { + if swag.IsZero(m.ServiceInstance) { // not required + return nil + } + + if m.ServiceInstance != nil { + if err := m.ServiceInstance.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("service_instance") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("service_instance") + } + return err + } + } + + return nil +} + +// ContextValidate validate this schemas object based on the context it is used +func (m *SchemasObject) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateServiceBinding(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateServiceInstance(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SchemasObject) contextValidateServiceBinding(ctx context.Context, formats strfmt.Registry) error { + + if m.ServiceBinding != nil { + if err := m.ServiceBinding.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("service_binding") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("service_binding") + } + return err + } + } + + return nil +} + +func (m *SchemasObject) contextValidateServiceInstance(ctx context.Context, formats strfmt.Registry) error { + + if m.ServiceInstance != nil { + if err := m.ServiceInstance.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("service_instance") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("service_instance") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *SchemasObject) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SchemasObject) UnmarshalBinary(b []byte) error { + var res SchemasObject + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/service.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service.go new file mode 100644 index 00000000000..8df437e38b6 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service.go @@ -0,0 +1,298 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Service service +// +// swagger:model Service +type Service struct { + + // bindable + // Required: true + Bindable *bool `json:"bindable"` + + // dashboard client + DashboardClient *DashboardClient `json:"dashboard_client,omitempty"` + + // description + // Required: true + Description *string `json:"description"` + + // iam compatible + IamCompatible bool `json:"iam_compatible,omitempty"` + + // id + // Required: true + ID *string `json:"id"` + + // metadata + Metadata Metadata `json:"metadata,omitempty"` + + // name + // Required: true + Name *string `json:"name"` + + // plan updateable + PlanUpdateable bool `json:"plan_updateable,omitempty"` + + // plans + // Required: true + Plans []*Plan `json:"plans"` + + // provisionable + Provisionable bool `json:"provisionable,omitempty"` + + // rc compatible + RcCompatible bool `json:"rc_compatible,omitempty"` + + // requires + Requires []string `json:"requires"` + + // tags + Tags []string `json:"tags"` + + // unique api key + UniqueAPIKey bool `json:"unique_api_key,omitempty"` +} + +// Validate validates this service +func (m *Service) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateBindable(formats); err != nil { + res = append(res, err) + } + + if err := m.validateDashboardClient(formats); err != nil { + res = append(res, err) + } + + if err := m.validateDescription(formats); err != nil { + res = append(res, err) + } + + if err := m.validateID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePlans(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRequires(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Service) validateBindable(formats strfmt.Registry) error { + + if err := validate.Required("bindable", "body", m.Bindable); err != nil { + return err + } + + return nil +} + +func (m *Service) validateDashboardClient(formats strfmt.Registry) error { + if swag.IsZero(m.DashboardClient) { // not required + return nil + } + + if m.DashboardClient != nil { + if err := m.DashboardClient.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("dashboard_client") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("dashboard_client") + } + return err + } + } + + return nil +} + +func (m *Service) validateDescription(formats strfmt.Registry) error { + + if err := validate.Required("description", "body", m.Description); err != nil { + return err + } + + return nil +} + +func (m *Service) validateID(formats strfmt.Registry) error { + + if err := validate.Required("id", "body", m.ID); err != nil { + return err + } + + return nil +} + +func (m *Service) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *Service) validatePlans(formats strfmt.Registry) error { + + if err := validate.Required("plans", "body", m.Plans); err != nil { + return err + } + + for i := 0; i < len(m.Plans); i++ { + if swag.IsZero(m.Plans[i]) { // not required + continue + } + + if m.Plans[i] != nil { + if err := m.Plans[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("plans" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("plans" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +var serviceRequiresItemsEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["syslog_drain","route_forwarding","volume_mount"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + serviceRequiresItemsEnum = append(serviceRequiresItemsEnum, v) + } +} + +func (m *Service) validateRequiresItemsEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, serviceRequiresItemsEnum, true); err != nil { + return err + } + return nil +} + +func (m *Service) validateRequires(formats strfmt.Registry) error { + if swag.IsZero(m.Requires) { // not required + return nil + } + + for i := 0; i < len(m.Requires); i++ { + + // value enum + if err := m.validateRequiresItemsEnum("requires"+"."+strconv.Itoa(i), "body", m.Requires[i]); err != nil { + return err + } + + } + + return nil +} + +// ContextValidate validate this service based on the context it is used +func (m *Service) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateDashboardClient(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidatePlans(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Service) contextValidateDashboardClient(ctx context.Context, formats strfmt.Registry) error { + + if m.DashboardClient != nil { + if err := m.DashboardClient.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("dashboard_client") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("dashboard_client") + } + return err + } + } + + return nil +} + +func (m *Service) contextValidatePlans(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Plans); i++ { + + if m.Plans[i] != nil { + if err := m.Plans[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("plans" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("plans" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Service) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Service) UnmarshalBinary(b []byte) error { + var res Service + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_binding.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_binding.go new file mode 100644 index 00000000000..a20665cc8d4 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_binding.go @@ -0,0 +1,125 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ServiceBinding service binding +// +// swagger:model ServiceBinding +type ServiceBinding struct { + + // credentials + Credentials Object `json:"credentials,omitempty"` + + // route service url + RouteServiceURL string `json:"route_service_url,omitempty"` + + // syslog drain url + SyslogDrainURL string `json:"syslog_drain_url,omitempty"` + + // volume mounts + VolumeMounts []*ServiceBindingVolumeMount `json:"volume_mounts"` +} + +// Validate validates this service binding +func (m *ServiceBinding) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateVolumeMounts(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ServiceBinding) validateVolumeMounts(formats strfmt.Registry) error { + if swag.IsZero(m.VolumeMounts) { // not required + return nil + } + + for i := 0; i < len(m.VolumeMounts); i++ { + if swag.IsZero(m.VolumeMounts[i]) { // not required + continue + } + + if m.VolumeMounts[i] != nil { + if err := m.VolumeMounts[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("volume_mounts" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("volume_mounts" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this service binding based on the context it is used +func (m *ServiceBinding) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateVolumeMounts(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ServiceBinding) contextValidateVolumeMounts(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.VolumeMounts); i++ { + + if m.VolumeMounts[i] != nil { + if err := m.VolumeMounts[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("volume_mounts" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("volume_mounts" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ServiceBinding) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ServiceBinding) UnmarshalBinary(b []byte) error { + var res ServiceBinding + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_binding_request.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_binding_request.go new file mode 100644 index 00000000000..dbadb948009 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_binding_request.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ServiceBindingRequest service binding request +// +// swagger:model ServiceBindingRequest +type ServiceBindingRequest struct { + + // app guid + AppGUID string `json:"app_guid,omitempty"` + + // bind resource + BindResource *ServiceBindingResourceObject `json:"bind_resource,omitempty"` + + // context + Context Context `json:"context,omitempty"` + + // parameters + Parameters Object `json:"parameters,omitempty"` + + // plan id + // Required: true + PlanID *string `json:"plan_id"` + + // service id + // Required: true + ServiceID *string `json:"service_id"` +} + +// Validate validates this service binding request +func (m *ServiceBindingRequest) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateBindResource(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePlanID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateServiceID(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ServiceBindingRequest) validateBindResource(formats strfmt.Registry) error { + if swag.IsZero(m.BindResource) { // not required + return nil + } + + if m.BindResource != nil { + if err := m.BindResource.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("bind_resource") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("bind_resource") + } + return err + } + } + + return nil +} + +func (m *ServiceBindingRequest) validatePlanID(formats strfmt.Registry) error { + + if err := validate.Required("plan_id", "body", m.PlanID); err != nil { + return err + } + + return nil +} + +func (m *ServiceBindingRequest) validateServiceID(formats strfmt.Registry) error { + + if err := validate.Required("service_id", "body", m.ServiceID); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this service binding request based on the context it is used +func (m *ServiceBindingRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateBindResource(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ServiceBindingRequest) contextValidateBindResource(ctx context.Context, formats strfmt.Registry) error { + + if m.BindResource != nil { + if err := m.BindResource.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("bind_resource") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("bind_resource") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ServiceBindingRequest) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ServiceBindingRequest) UnmarshalBinary(b []byte) error { + var res ServiceBindingRequest + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_binding_resource.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_binding_resource.go new file mode 100644 index 00000000000..4fcb7ce71c0 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_binding_resource.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ServiceBindingResource service binding resource +// +// swagger:model ServiceBindingResource +type ServiceBindingResource struct { + + // credentials + Credentials Object `json:"credentials,omitempty"` + + // parameters + Parameters Object `json:"parameters,omitempty"` + + // route service url + RouteServiceURL string `json:"route_service_url,omitempty"` + + // syslog drain url + SyslogDrainURL string `json:"syslog_drain_url,omitempty"` + + // volume mounts + VolumeMounts []*ServiceBindingVolumeMount `json:"volume_mounts"` +} + +// Validate validates this service binding resource +func (m *ServiceBindingResource) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateVolumeMounts(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ServiceBindingResource) validateVolumeMounts(formats strfmt.Registry) error { + if swag.IsZero(m.VolumeMounts) { // not required + return nil + } + + for i := 0; i < len(m.VolumeMounts); i++ { + if swag.IsZero(m.VolumeMounts[i]) { // not required + continue + } + + if m.VolumeMounts[i] != nil { + if err := m.VolumeMounts[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("volume_mounts" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("volume_mounts" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this service binding resource based on the context it is used +func (m *ServiceBindingResource) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateVolumeMounts(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ServiceBindingResource) contextValidateVolumeMounts(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.VolumeMounts); i++ { + + if m.VolumeMounts[i] != nil { + if err := m.VolumeMounts[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("volume_mounts" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("volume_mounts" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ServiceBindingResource) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ServiceBindingResource) UnmarshalBinary(b []byte) error { + var res ServiceBindingResource + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_binding_resource_object.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_binding_resource_object.go new file mode 100644 index 00000000000..dc89fff63e5 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_binding_resource_object.go @@ -0,0 +1,53 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ServiceBindingResourceObject service binding resource object +// +// swagger:model ServiceBindingResourceObject +type ServiceBindingResourceObject struct { + + // app guid + AppGUID string `json:"app_guid,omitempty"` + + // route + Route string `json:"route,omitempty"` +} + +// Validate validates this service binding resource object +func (m *ServiceBindingResourceObject) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this service binding resource object based on context it is used +func (m *ServiceBindingResourceObject) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ServiceBindingResourceObject) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ServiceBindingResourceObject) UnmarshalBinary(b []byte) error { + var res ServiceBindingResourceObject + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_binding_schema_object.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_binding_schema_object.go new file mode 100644 index 00000000000..bb3ba6acc09 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_binding_schema_object.go @@ -0,0 +1,104 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ServiceBindingSchemaObject service binding schema object +// +// swagger:model ServiceBindingSchemaObject +type ServiceBindingSchemaObject struct { + + // create + Create *SchemaParameters `json:"create,omitempty"` +} + +// Validate validates this service binding schema object +func (m *ServiceBindingSchemaObject) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreate(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ServiceBindingSchemaObject) validateCreate(formats strfmt.Registry) error { + if swag.IsZero(m.Create) { // not required + return nil + } + + if m.Create != nil { + if err := m.Create.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("create") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("create") + } + return err + } + } + + return nil +} + +// ContextValidate validate this service binding schema object based on the context it is used +func (m *ServiceBindingSchemaObject) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateCreate(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ServiceBindingSchemaObject) contextValidateCreate(ctx context.Context, formats strfmt.Registry) error { + + if m.Create != nil { + if err := m.Create.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("create") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("create") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ServiceBindingSchemaObject) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ServiceBindingSchemaObject) UnmarshalBinary(b []byte) error { + var res ServiceBindingSchemaObject + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_binding_volume_mount.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_binding_volume_mount.go new file mode 100644 index 00000000000..c077d6c0c45 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_binding_volume_mount.go @@ -0,0 +1,243 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ServiceBindingVolumeMount service binding volume mount +// +// swagger:model ServiceBindingVolumeMount +type ServiceBindingVolumeMount struct { + + // container dir + // Required: true + ContainerDir *string `json:"container_dir"` + + // device + // Required: true + Device *ServiceBindingVolumeMountDevice `json:"device"` + + // device type + // Required: true + // Enum: [shared] + DeviceType *string `json:"device_type"` + + // driver + // Required: true + Driver *string `json:"driver"` + + // mode + // Required: true + // Enum: [r rw] + Mode *string `json:"mode"` +} + +// Validate validates this service binding volume mount +func (m *ServiceBindingVolumeMount) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateContainerDir(formats); err != nil { + res = append(res, err) + } + + if err := m.validateDevice(formats); err != nil { + res = append(res, err) + } + + if err := m.validateDeviceType(formats); err != nil { + res = append(res, err) + } + + if err := m.validateDriver(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMode(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ServiceBindingVolumeMount) validateContainerDir(formats strfmt.Registry) error { + + if err := validate.Required("container_dir", "body", m.ContainerDir); err != nil { + return err + } + + return nil +} + +func (m *ServiceBindingVolumeMount) validateDevice(formats strfmt.Registry) error { + + if err := validate.Required("device", "body", m.Device); err != nil { + return err + } + + if m.Device != nil { + if err := m.Device.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("device") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("device") + } + return err + } + } + + return nil +} + +var serviceBindingVolumeMountTypeDeviceTypePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["shared"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + serviceBindingVolumeMountTypeDeviceTypePropEnum = append(serviceBindingVolumeMountTypeDeviceTypePropEnum, v) + } +} + +const ( + + // ServiceBindingVolumeMountDeviceTypeShared captures enum value "shared" + ServiceBindingVolumeMountDeviceTypeShared string = "shared" +) + +// prop value enum +func (m *ServiceBindingVolumeMount) validateDeviceTypeEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, serviceBindingVolumeMountTypeDeviceTypePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *ServiceBindingVolumeMount) validateDeviceType(formats strfmt.Registry) error { + + if err := validate.Required("device_type", "body", m.DeviceType); err != nil { + return err + } + + // value enum + if err := m.validateDeviceTypeEnum("device_type", "body", *m.DeviceType); err != nil { + return err + } + + return nil +} + +func (m *ServiceBindingVolumeMount) validateDriver(formats strfmt.Registry) error { + + if err := validate.Required("driver", "body", m.Driver); err != nil { + return err + } + + return nil +} + +var serviceBindingVolumeMountTypeModePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["r","rw"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + serviceBindingVolumeMountTypeModePropEnum = append(serviceBindingVolumeMountTypeModePropEnum, v) + } +} + +const ( + + // ServiceBindingVolumeMountModeR captures enum value "r" + ServiceBindingVolumeMountModeR string = "r" + + // ServiceBindingVolumeMountModeRw captures enum value "rw" + ServiceBindingVolumeMountModeRw string = "rw" +) + +// prop value enum +func (m *ServiceBindingVolumeMount) validateModeEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, serviceBindingVolumeMountTypeModePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *ServiceBindingVolumeMount) validateMode(formats strfmt.Registry) error { + + if err := validate.Required("mode", "body", m.Mode); err != nil { + return err + } + + // value enum + if err := m.validateModeEnum("mode", "body", *m.Mode); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this service binding volume mount based on the context it is used +func (m *ServiceBindingVolumeMount) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateDevice(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ServiceBindingVolumeMount) contextValidateDevice(ctx context.Context, formats strfmt.Registry) error { + + if m.Device != nil { + if err := m.Device.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("device") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("device") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ServiceBindingVolumeMount) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ServiceBindingVolumeMount) UnmarshalBinary(b []byte) error { + var res ServiceBindingVolumeMount + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_binding_volume_mount_device.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_binding_volume_mount_device.go new file mode 100644 index 00000000000..f95ff3f730a --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_binding_volume_mount_device.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ServiceBindingVolumeMountDevice service binding volume mount device +// +// swagger:model ServiceBindingVolumeMountDevice +type ServiceBindingVolumeMountDevice struct { + + // mount config + MountConfig Object `json:"mount_config,omitempty"` + + // volume id + // Required: true + VolumeID *string `json:"volume_id"` +} + +// Validate validates this service binding volume mount device +func (m *ServiceBindingVolumeMountDevice) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateVolumeID(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ServiceBindingVolumeMountDevice) validateVolumeID(formats strfmt.Registry) error { + + if err := validate.Required("volume_id", "body", m.VolumeID); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this service binding volume mount device based on context it is used +func (m *ServiceBindingVolumeMountDevice) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ServiceBindingVolumeMountDevice) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ServiceBindingVolumeMountDevice) UnmarshalBinary(b []byte) error { + var res ServiceBindingVolumeMountDevice + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_instance.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_instance.go new file mode 100644 index 00000000000..2c6ca23cdc2 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_instance.go @@ -0,0 +1,105 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ServiceInstance service instance +// +// swagger:model ServiceInstance +type ServiceInstance struct { + + // Indicates (from the viewpoint of the provider) whether the service instance is (perceived) active or not and is meaningful if enabled is true. The default value is true if not specified. + // Required: true + Active *bool `json:"active"` + + // Indicates the current state of the service instance. + // Required: true + Enable *bool `json:"enable"` + + // Indicates when the service instance was last accessed or modified, and is meaningful if enabled is true AND active is false. Represented as milliseconds since the epoch, but does not need to be accurate to the second/hour. + // Required: true + LastActive *float64 `json:"last_active"` +} + +// Validate validates this service instance +func (m *ServiceInstance) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateActive(formats); err != nil { + res = append(res, err) + } + + if err := m.validateEnable(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLastActive(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ServiceInstance) validateActive(formats strfmt.Registry) error { + + if err := validate.Required("active", "body", m.Active); err != nil { + return err + } + + return nil +} + +func (m *ServiceInstance) validateEnable(formats strfmt.Registry) error { + + if err := validate.Required("enable", "body", m.Enable); err != nil { + return err + } + + return nil +} + +func (m *ServiceInstance) validateLastActive(formats strfmt.Registry) error { + + if err := validate.Required("last_active", "body", m.LastActive); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this service instance based on context it is used +func (m *ServiceInstance) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ServiceInstance) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ServiceInstance) UnmarshalBinary(b []byte) error { + var res ServiceInstance + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_instance_async_operation.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_instance_async_operation.go new file mode 100644 index 00000000000..2711e66730d --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_instance_async_operation.go @@ -0,0 +1,53 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ServiceInstanceAsyncOperation service instance async operation +// +// swagger:model ServiceInstanceAsyncOperation +type ServiceInstanceAsyncOperation struct { + + // dashboard url + DashboardURL string `json:"dashboard_url,omitempty"` + + // operation + Operation string `json:"operation,omitempty"` +} + +// Validate validates this service instance async operation +func (m *ServiceInstanceAsyncOperation) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this service instance async operation based on context it is used +func (m *ServiceInstanceAsyncOperation) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ServiceInstanceAsyncOperation) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ServiceInstanceAsyncOperation) UnmarshalBinary(b []byte) error { + var res ServiceInstanceAsyncOperation + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_instance_previous_values.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_instance_previous_values.go new file mode 100644 index 00000000000..33c2f1c90bc --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_instance_previous_values.go @@ -0,0 +1,59 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ServiceInstancePreviousValues service instance previous values +// +// swagger:model ServiceInstancePreviousValues +type ServiceInstancePreviousValues struct { + + // organization id + OrganizationID string `json:"organization_id,omitempty"` + + // plan id + PlanID string `json:"plan_id,omitempty"` + + // service id + ServiceID string `json:"service_id,omitempty"` + + // space id + SpaceID string `json:"space_id,omitempty"` +} + +// Validate validates this service instance previous values +func (m *ServiceInstancePreviousValues) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this service instance previous values based on context it is used +func (m *ServiceInstancePreviousValues) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ServiceInstancePreviousValues) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ServiceInstancePreviousValues) UnmarshalBinary(b []byte) error { + var res ServiceInstancePreviousValues + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_instance_provision.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_instance_provision.go new file mode 100644 index 00000000000..7fb520f2ef2 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_instance_provision.go @@ -0,0 +1,50 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ServiceInstanceProvision service instance provision +// +// swagger:model ServiceInstanceProvision +type ServiceInstanceProvision struct { + + // dashboard url + DashboardURL string `json:"dashboard_url,omitempty"` +} + +// Validate validates this service instance provision +func (m *ServiceInstanceProvision) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this service instance provision based on context it is used +func (m *ServiceInstanceProvision) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ServiceInstanceProvision) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ServiceInstanceProvision) UnmarshalBinary(b []byte) error { + var res ServiceInstanceProvision + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_instance_provision_request.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_instance_provision_request.go new file mode 100644 index 00000000000..6e84dd46502 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_instance_provision_request.go @@ -0,0 +1,100 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ServiceInstanceProvisionRequest service instance provision request +// +// swagger:model ServiceInstanceProvisionRequest +type ServiceInstanceProvisionRequest struct { + + // context + Context Context `json:"context,omitempty"` + + // organization guid + OrganizationGUID string `json:"organization_guid,omitempty"` + + // parameters + Parameters Object `json:"parameters,omitempty"` + + // plan id + // Required: true + PlanID *string `json:"plan_id"` + + // service id + // Required: true + ServiceID *string `json:"service_id"` + + // space guid + SpaceGUID string `json:"space_guid,omitempty"` +} + +// Validate validates this service instance provision request +func (m *ServiceInstanceProvisionRequest) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validatePlanID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateServiceID(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ServiceInstanceProvisionRequest) validatePlanID(formats strfmt.Registry) error { + + if err := validate.Required("plan_id", "body", m.PlanID); err != nil { + return err + } + + return nil +} + +func (m *ServiceInstanceProvisionRequest) validateServiceID(formats strfmt.Registry) error { + + if err := validate.Required("service_id", "body", m.ServiceID); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this service instance provision request based on context it is used +func (m *ServiceInstanceProvisionRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ServiceInstanceProvisionRequest) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ServiceInstanceProvisionRequest) UnmarshalBinary(b []byte) error { + var res ServiceInstanceProvisionRequest + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_instance_request.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_instance_request.go new file mode 100644 index 00000000000..67afe7a14eb --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_instance_request.go @@ -0,0 +1,77 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ServiceInstanceRequest service instance request +// +// swagger:model ServiceInstanceRequest +type ServiceInstanceRequest struct { + + // Indicates the current state of the service instance. + // Required: true + Enabled *bool `json:"enabled"` + + // Optional string stating the reason code for the service instance state change. Valid values are BMX_ACCT_ACTIVATE, BMX_SERVICE_INSTANCE_BELOW_CAP for enable calls, and BMX_ACCT_SUSPEND, BMX_SERVICE_INSTANCE_ABOVE_CAP for disable calls. + InitiatorID string `json:"initiator_id,omitempty"` + + // Optional string showing the user id initiating the call + ReasonCode string `json:"reason_code,omitempty"` +} + +// Validate validates this service instance request +func (m *ServiceInstanceRequest) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateEnabled(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ServiceInstanceRequest) validateEnabled(formats strfmt.Registry) error { + + if err := validate.Required("enabled", "body", m.Enabled); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this service instance request based on context it is used +func (m *ServiceInstanceRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ServiceInstanceRequest) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ServiceInstanceRequest) UnmarshalBinary(b []byte) error { + var res ServiceInstanceRequest + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_instance_resource.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_instance_resource.go new file mode 100644 index 00000000000..1a7b2da7e78 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_instance_resource.go @@ -0,0 +1,59 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ServiceInstanceResource service instance resource +// +// swagger:model ServiceInstanceResource +type ServiceInstanceResource struct { + + // dashboard url + DashboardURL string `json:"dashboard_url,omitempty"` + + // parameters + Parameters Object `json:"parameters,omitempty"` + + // plan id + PlanID string `json:"plan_id,omitempty"` + + // service id + ServiceID string `json:"service_id,omitempty"` +} + +// Validate validates this service instance resource +func (m *ServiceInstanceResource) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this service instance resource based on context it is used +func (m *ServiceInstanceResource) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ServiceInstanceResource) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ServiceInstanceResource) UnmarshalBinary(b []byte) error { + var res ServiceInstanceResource + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_instance_schema_object.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_instance_schema_object.go new file mode 100644 index 00000000000..fb085f5fbea --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_instance_schema_object.go @@ -0,0 +1,150 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ServiceInstanceSchemaObject service instance schema object +// +// swagger:model ServiceInstanceSchemaObject +type ServiceInstanceSchemaObject struct { + + // create + Create *SchemaParameters `json:"create,omitempty"` + + // update + Update *SchemaParameters `json:"update,omitempty"` +} + +// Validate validates this service instance schema object +func (m *ServiceInstanceSchemaObject) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUpdate(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ServiceInstanceSchemaObject) validateCreate(formats strfmt.Registry) error { + if swag.IsZero(m.Create) { // not required + return nil + } + + if m.Create != nil { + if err := m.Create.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("create") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("create") + } + return err + } + } + + return nil +} + +func (m *ServiceInstanceSchemaObject) validateUpdate(formats strfmt.Registry) error { + if swag.IsZero(m.Update) { // not required + return nil + } + + if m.Update != nil { + if err := m.Update.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("update") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("update") + } + return err + } + } + + return nil +} + +// ContextValidate validate this service instance schema object based on the context it is used +func (m *ServiceInstanceSchemaObject) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateCreate(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateUpdate(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ServiceInstanceSchemaObject) contextValidateCreate(ctx context.Context, formats strfmt.Registry) error { + + if m.Create != nil { + if err := m.Create.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("create") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("create") + } + return err + } + } + + return nil +} + +func (m *ServiceInstanceSchemaObject) contextValidateUpdate(ctx context.Context, formats strfmt.Registry) error { + + if m.Update != nil { + if err := m.Update.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("update") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("update") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ServiceInstanceSchemaObject) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ServiceInstanceSchemaObject) UnmarshalBinary(b []byte) error { + var res ServiceInstanceSchemaObject + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_instance_update_request.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_instance_update_request.go new file mode 100644 index 00000000000..b4a4079544e --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/service_instance_update_request.go @@ -0,0 +1,131 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ServiceInstanceUpdateRequest service instance update request +// +// swagger:model ServiceInstanceUpdateRequest +type ServiceInstanceUpdateRequest struct { + + // context + Context Context `json:"context,omitempty"` + + // parameters + Parameters Object `json:"parameters,omitempty"` + + // plan id + PlanID string `json:"plan_id,omitempty"` + + // previous values + PreviousValues *ServiceInstancePreviousValues `json:"previous_values,omitempty"` + + // service id + // Required: true + ServiceID *string `json:"service_id"` +} + +// Validate validates this service instance update request +func (m *ServiceInstanceUpdateRequest) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validatePreviousValues(formats); err != nil { + res = append(res, err) + } + + if err := m.validateServiceID(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ServiceInstanceUpdateRequest) validatePreviousValues(formats strfmt.Registry) error { + if swag.IsZero(m.PreviousValues) { // not required + return nil + } + + if m.PreviousValues != nil { + if err := m.PreviousValues.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("previous_values") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("previous_values") + } + return err + } + } + + return nil +} + +func (m *ServiceInstanceUpdateRequest) validateServiceID(formats strfmt.Registry) error { + + if err := validate.Required("service_id", "body", m.ServiceID); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this service instance update request based on the context it is used +func (m *ServiceInstanceUpdateRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidatePreviousValues(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ServiceInstanceUpdateRequest) contextValidatePreviousValues(ctx context.Context, formats strfmt.Registry) error { + + if m.PreviousValues != nil { + if err := m.PreviousValues.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("previous_values") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("previous_values") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ServiceInstanceUpdateRequest) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ServiceInstanceUpdateRequest) UnmarshalBinary(b []byte) error { + var res ServiceInstanceUpdateRequest + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/snapshot.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/snapshot.go new file mode 100644 index 00000000000..c5d2fc31ea5 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/snapshot.go @@ -0,0 +1,174 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Snapshot snapshot +// +// swagger:model Snapshot +type Snapshot struct { + + // Action performed on the instance snapshot + Action string `json:"action,omitempty"` + + // Creation Date + // Format: date-time + CreationDate strfmt.DateTime `json:"creationDate,omitempty"` + + // Description of the PVM instance snapshot + Description string `json:"description,omitempty"` + + // Last Update Date + // Format: date-time + LastUpdateDate strfmt.DateTime `json:"lastUpdateDate,omitempty"` + + // Name of the PVM instance snapshot + // Required: true + Name *string `json:"name"` + + // Snapshot completion percentage + PercentComplete int64 `json:"percentComplete,omitempty"` + + // PCloud PVM Instance ID + // Required: true + PvmInstanceID *string `json:"pvmInstanceID"` + + // ID of the PVM instance snapshot + // Required: true + SnapshotID *string `json:"snapshotID"` + + // Status of the PVM instancesnapshot + Status string `json:"status,omitempty"` + + // A map of volume snapshots included in the PVM instance snapshot + // Required: true + VolumeSnapshots map[string]string `json:"volumeSnapshots"` +} + +// Validate validates this snapshot +func (m *Snapshot) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreationDate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLastUpdateDate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePvmInstanceID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSnapshotID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVolumeSnapshots(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Snapshot) validateCreationDate(formats strfmt.Registry) error { + if swag.IsZero(m.CreationDate) { // not required + return nil + } + + if err := validate.FormatOf("creationDate", "body", "date-time", m.CreationDate.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *Snapshot) validateLastUpdateDate(formats strfmt.Registry) error { + if swag.IsZero(m.LastUpdateDate) { // not required + return nil + } + + if err := validate.FormatOf("lastUpdateDate", "body", "date-time", m.LastUpdateDate.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *Snapshot) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *Snapshot) validatePvmInstanceID(formats strfmt.Registry) error { + + if err := validate.Required("pvmInstanceID", "body", m.PvmInstanceID); err != nil { + return err + } + + return nil +} + +func (m *Snapshot) validateSnapshotID(formats strfmt.Registry) error { + + if err := validate.Required("snapshotID", "body", m.SnapshotID); err != nil { + return err + } + + return nil +} + +func (m *Snapshot) validateVolumeSnapshots(formats strfmt.Registry) error { + + if err := validate.Required("volumeSnapshots", "body", m.VolumeSnapshots); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this snapshot based on context it is used +func (m *Snapshot) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Snapshot) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Snapshot) UnmarshalBinary(b []byte) error { + var res Snapshot + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/snapshot_create.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/snapshot_create.go new file mode 100644 index 00000000000..003771100e4 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/snapshot_create.go @@ -0,0 +1,77 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// SnapshotCreate snapshot create +// +// swagger:model SnapshotCreate +type SnapshotCreate struct { + + // Description of the PVM instance snapshot + Description string `json:"description,omitempty"` + + // Name of the PVM instance snapshot to create + // Required: true + Name *string `json:"name"` + + // List of volumes to include in the PVM instance snapshot + VolumeIDs []string `json:"volumeIDs"` +} + +// Validate validates this snapshot create +func (m *SnapshotCreate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SnapshotCreate) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this snapshot create based on context it is used +func (m *SnapshotCreate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *SnapshotCreate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SnapshotCreate) UnmarshalBinary(b []byte) error { + var res SnapshotCreate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/snapshot_create_response.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/snapshot_create_response.go new file mode 100644 index 00000000000..61214fb351e --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/snapshot_create_response.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// SnapshotCreateResponse snapshot create response +// +// swagger:model SnapshotCreateResponse +type SnapshotCreateResponse struct { + + // ID of the PVM instance snapshot + // Required: true + SnapshotID *string `json:"snapshotID"` +} + +// Validate validates this snapshot create response +func (m *SnapshotCreateResponse) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateSnapshotID(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SnapshotCreateResponse) validateSnapshotID(formats strfmt.Registry) error { + + if err := validate.Required("snapshotID", "body", m.SnapshotID); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this snapshot create response based on context it is used +func (m *SnapshotCreateResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *SnapshotCreateResponse) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SnapshotCreateResponse) UnmarshalBinary(b []byte) error { + var res SnapshotCreateResponse + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/snapshot_restore.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/snapshot_restore.go new file mode 100644 index 00000000000..b2effe1ffaa --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/snapshot_restore.go @@ -0,0 +1,50 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// SnapshotRestore snapshot restore +// +// swagger:model SnapshotRestore +type SnapshotRestore struct { + + // By default the VM must be shutoff during a snapshot restore, force set to true will relax the VM shutoff pre-condition. + Force *bool `json:"force,omitempty"` +} + +// Validate validates this snapshot restore +func (m *SnapshotRestore) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this snapshot restore based on context it is used +func (m *SnapshotRestore) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *SnapshotRestore) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SnapshotRestore) UnmarshalBinary(b []byte) error { + var res SnapshotRestore + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/snapshot_update.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/snapshot_update.go new file mode 100644 index 00000000000..162102e53d9 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/snapshot_update.go @@ -0,0 +1,53 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// SnapshotUpdate snapshot update +// +// swagger:model SnapshotUpdate +type SnapshotUpdate struct { + + // Description of the PVM instance snapshot + Description string `json:"description,omitempty"` + + // Name of the PVM instance snapshot + Name string `json:"name,omitempty"` +} + +// Validate validates this snapshot update +func (m *SnapshotUpdate) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this snapshot update based on context it is used +func (m *SnapshotUpdate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *SnapshotUpdate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SnapshotUpdate) UnmarshalBinary(b []byte) error { + var res SnapshotUpdate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/snapshots.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/snapshots.go new file mode 100644 index 00000000000..276c6119a8e --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/snapshots.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Snapshots snapshots +// +// swagger:model Snapshots +type Snapshots struct { + + // List of PVM instance snapshots + // Required: true + Snapshots []*Snapshot `json:"snapshots"` +} + +// Validate validates this snapshots +func (m *Snapshots) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateSnapshots(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Snapshots) validateSnapshots(formats strfmt.Registry) error { + + if err := validate.Required("snapshots", "body", m.Snapshots); err != nil { + return err + } + + for i := 0; i < len(m.Snapshots); i++ { + if swag.IsZero(m.Snapshots[i]) { // not required + continue + } + + if m.Snapshots[i] != nil { + if err := m.Snapshots[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("snapshots" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("snapshots" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this snapshots based on the context it is used +func (m *Snapshots) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateSnapshots(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Snapshots) contextValidateSnapshots(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Snapshots); i++ { + + if m.Snapshots[i] != nil { + if err := m.Snapshots[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("snapshots" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("snapshots" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Snapshots) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Snapshots) UnmarshalBinary(b []byte) error { + var res Snapshots + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/softlayer_subscription.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/softlayer_subscription.go new file mode 100644 index 00000000000..26941f4fcdb --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/softlayer_subscription.go @@ -0,0 +1,88 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// SoftlayerSubscription Softlayer subscription object +// +// swagger:model SoftlayerSubscription +type SoftlayerSubscription struct { + + // Softlayer ID + // Required: true + ID *string `json:"id"` + + // State of softlayer subscription + // Required: true + State *string `json:"state"` +} + +// Validate validates this softlayer subscription +func (m *SoftlayerSubscription) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateState(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SoftlayerSubscription) validateID(formats strfmt.Registry) error { + + if err := validate.Required("id", "body", m.ID); err != nil { + return err + } + + return nil +} + +func (m *SoftlayerSubscription) validateState(formats strfmt.Registry) error { + + if err := validate.Required("state", "body", m.State); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this softlayer subscription based on context it is used +func (m *SoftlayerSubscription) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *SoftlayerSubscription) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SoftlayerSubscription) UnmarshalBinary(b []byte) error { + var res SoftlayerSubscription + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/software_licenses.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/software_licenses.go new file mode 100644 index 00000000000..ae855dccaaf --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/software_licenses.go @@ -0,0 +1,62 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// SoftwareLicenses software licenses +// +// swagger:model SoftwareLicenses +type SoftwareLicenses struct { + + // IBMi Cloud Storage Solution + IbmiCSS *bool `json:"ibmiCSS,omitempty"` + + // IBMi Cloud Storage Solution + IbmiDBQ *bool `json:"ibmiDBQ,omitempty"` + + // IBMi Power High Availability + IbmiPHA *bool `json:"ibmiPHA,omitempty"` + + // IBMi Rational Dev Studio + IbmiRDS *bool `json:"ibmiRDS,omitempty"` + + // IBMi Rational Dev Studio Number of User Licenses + IbmiRDSUsers int64 `json:"ibmiRDSUsers,omitempty"` +} + +// Validate validates this software licenses +func (m *SoftwareLicenses) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this software licenses based on context it is used +func (m *SoftwareLicenses) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *SoftwareLicenses) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SoftwareLicenses) UnmarshalBinary(b []byte) error { + var res SoftwareLicenses + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/ssh_key.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/ssh_key.go new file mode 100644 index 00000000000..5112e6cd084 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/ssh_key.go @@ -0,0 +1,108 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// SSHKey SSH key +// +// swagger:model SSHKey +type SSHKey struct { + + // Date of sshkey creation + // Format: date-time + CreationDate *strfmt.DateTime `json:"creationDate,omitempty" datastore:"creationDate"` + + // User defined name for the SSH key + // Required: true + Name *string `json:"name" datastore:"name"` + + // SSH RSA key + // Required: true + SSHKey *string `json:"sshKey" datastore:"sshKey"` +} + +// Validate validates this SSH key +func (m *SSHKey) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreationDate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSSHKey(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SSHKey) validateCreationDate(formats strfmt.Registry) error { + if swag.IsZero(m.CreationDate) { // not required + return nil + } + + if err := validate.FormatOf("creationDate", "body", "date-time", m.CreationDate.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *SSHKey) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *SSHKey) validateSSHKey(formats strfmt.Registry) error { + + if err := validate.Required("sshKey", "body", m.SSHKey); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this SSH key based on context it is used +func (m *SSHKey) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *SSHKey) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SSHKey) UnmarshalBinary(b []byte) error { + var res SSHKey + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/ssh_keys.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/ssh_keys.go new file mode 100644 index 00000000000..ae4e4cd5f66 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/ssh_keys.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// SSHKeys SSH keys +// +// swagger:model SSHKeys +type SSHKeys struct { + + // SSH Keys + // Required: true + SSHKeys []*SSHKey `json:"sshKeys"` +} + +// Validate validates this SSH keys +func (m *SSHKeys) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateSSHKeys(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SSHKeys) validateSSHKeys(formats strfmt.Registry) error { + + if err := validate.Required("sshKeys", "body", m.SSHKeys); err != nil { + return err + } + + for i := 0; i < len(m.SSHKeys); i++ { + if swag.IsZero(m.SSHKeys[i]) { // not required + continue + } + + if m.SSHKeys[i] != nil { + if err := m.SSHKeys[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("sshKeys" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sshKeys" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this SSH keys based on the context it is used +func (m *SSHKeys) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateSSHKeys(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SSHKeys) contextValidateSSHKeys(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.SSHKeys); i++ { + + if m.SSHKeys[i] != nil { + if err := m.SSHKeys[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("sshKeys" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sshKeys" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *SSHKeys) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SSHKeys) UnmarshalBinary(b []byte) error { + var res SSHKeys + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/status.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/status.go new file mode 100644 index 00000000000..b62214580fd --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/status.go @@ -0,0 +1,91 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Status status +// +// swagger:model Status +type Status struct { + + // message detailing current state + Message string `json:"message,omitempty"` + + // progress of a job + // Required: true + Progress *string `json:"progress"` + + // state of a job + // Required: true + State *string `json:"state"` +} + +// Validate validates this status +func (m *Status) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateProgress(formats); err != nil { + res = append(res, err) + } + + if err := m.validateState(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Status) validateProgress(formats strfmt.Registry) error { + + if err := validate.Required("progress", "body", m.Progress); err != nil { + return err + } + + return nil +} + +func (m *Status) validateState(formats strfmt.Registry) error { + + if err := validate.Required("state", "body", m.State); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this status based on context it is used +func (m *Status) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Status) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Status) UnmarshalBinary(b []byte) error { + var res Status + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/stock_image.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/stock_image.go new file mode 100644 index 00000000000..5ec533e3177 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/stock_image.go @@ -0,0 +1,56 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// StockImage Stock image detail +// +// swagger:model StockImage +type StockImage struct { + + // Image ID + ID string `json:"id,omitempty"` + + // Storage pool for a stock image + StoragePool string `json:"storagePool,omitempty"` + + // Storage type for a stock image + StorageType string `json:"storageType,omitempty"` +} + +// Validate validates this stock image +func (m *StockImage) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this stock image based on context it is used +func (m *StockImage) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *StockImage) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *StockImage) UnmarshalBinary(b []byte) error { + var res StockImage + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/stock_images.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/stock_images.go new file mode 100644 index 00000000000..8ad0b319847 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/stock_images.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// StockImages List of stock images +// +// swagger:model StockImages +type StockImages []*StockImage + +// Validate validates this stock images +func (m StockImages) Validate(formats strfmt.Registry) error { + var res []error + + for i := 0; i < len(m); i++ { + if swag.IsZero(m[i]) { // not required + continue + } + + if m[i] != nil { + if err := m[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(strconv.Itoa(i)) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validate this stock images based on the context it is used +func (m StockImages) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + for i := 0; i < len(m); i++ { + + if m[i] != nil { + if err := m[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(strconv.Itoa(i)) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/storage_affinity.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/storage_affinity.go new file mode 100644 index 00000000000..071b9891ab8 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/storage_affinity.go @@ -0,0 +1,117 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// StorageAffinity storage affinity +// +// swagger:model StorageAffinity +type StorageAffinity struct { + + // PVM Instance (ID or Name) to base storage affinity policy against; required if requesting storage affinity and affinityVolume is not provided + AffinityPVMInstance *string `json:"affinityPVMInstance,omitempty"` + + // Affinity policy for storage pool selection; ignored if storagePool provided; for policy 'affinity' requires one of affinityPVMInstance or affinityVolume to be specified; for policy 'anti-affinity' requires one of antiAffinityPVMInstances or antiAffinityVolumes to be specified + // Enum: [affinity anti-affinity] + AffinityPolicy *string `json:"affinityPolicy,omitempty"` + + // Volume (ID or Name) to base storage affinity policy against; required if requesting storage affinity and affinityPVMInstance is not provided + AffinityVolume *string `json:"affinityVolume,omitempty"` + + // List of pvmInstances to base storage anti-affinity policy against; required if requesting storage anti-affinity and antiAffinityVolumes is not provided + AntiAffinityPVMInstances []string `json:"antiAffinityPVMInstances"` + + // List of volumes to base storage anti-affinity policy against; required if requesting storage anti-affinity and antiAffinityPVMInstances is not provided + AntiAffinityVolumes []string `json:"antiAffinityVolumes"` +} + +// Validate validates this storage affinity +func (m *StorageAffinity) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAffinityPolicy(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +var storageAffinityTypeAffinityPolicyPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["affinity","anti-affinity"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + storageAffinityTypeAffinityPolicyPropEnum = append(storageAffinityTypeAffinityPolicyPropEnum, v) + } +} + +const ( + + // StorageAffinityAffinityPolicyAffinity captures enum value "affinity" + StorageAffinityAffinityPolicyAffinity string = "affinity" + + // StorageAffinityAffinityPolicyAntiDashAffinity captures enum value "anti-affinity" + StorageAffinityAffinityPolicyAntiDashAffinity string = "anti-affinity" +) + +// prop value enum +func (m *StorageAffinity) validateAffinityPolicyEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, storageAffinityTypeAffinityPolicyPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *StorageAffinity) validateAffinityPolicy(formats strfmt.Registry) error { + if swag.IsZero(m.AffinityPolicy) { // not required + return nil + } + + // value enum + if err := m.validateAffinityPolicyEnum("affinityPolicy", "body", *m.AffinityPolicy); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this storage affinity based on context it is used +func (m *StorageAffinity) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *StorageAffinity) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *StorageAffinity) UnmarshalBinary(b []byte) error { + var res StorageAffinity + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/storage_entities.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/storage_entities.go new file mode 100644 index 00000000000..5f8c6e8f7cc --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/storage_entities.go @@ -0,0 +1,53 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// StorageEntities storage entities +// +// swagger:model StorageEntities +type StorageEntities struct { + + // threshold value to apply to an existing storage entity + ExistingEntity int64 `json:"existingEntity,omitempty"` + + // threshold value to apply to a new storage entity + NewEntity int64 `json:"newEntity,omitempty"` +} + +// Validate validates this storage entities +func (m *StorageEntities) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this storage entities based on context it is used +func (m *StorageEntities) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *StorageEntities) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *StorageEntities) UnmarshalBinary(b []byte) error { + var res StorageEntities + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/storage_pool.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/storage_pool.go new file mode 100644 index 00000000000..ab18cac6d00 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/storage_pool.go @@ -0,0 +1,226 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// StoragePool storage pool +// +// swagger:model StoragePool +type StoragePool struct { + + // display name of storage pool + // Required: true + DisplayName *string `json:"displayName"` + + // indicates if the storage pool is disaster recovery (dr) enabled + // Required: true + DrEnabled *bool `json:"drEnabled"` + + // name of storage pool + // Required: true + Name *string `json:"name"` + + // threshold override settings of a pool + OverrideThresholds *Thresholds `json:"overrideThresholds,omitempty"` + + // state of storage pool + // Required: true + // Enum: [closed opened] + State *string `json:"state"` + + // type of storage pool + // Required: true + Type *string `json:"type"` +} + +// Validate validates this storage pool +func (m *StoragePool) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateDisplayName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateDrEnabled(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOverrideThresholds(formats); err != nil { + res = append(res, err) + } + + if err := m.validateState(formats); err != nil { + res = append(res, err) + } + + if err := m.validateType(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *StoragePool) validateDisplayName(formats strfmt.Registry) error { + + if err := validate.Required("displayName", "body", m.DisplayName); err != nil { + return err + } + + return nil +} + +func (m *StoragePool) validateDrEnabled(formats strfmt.Registry) error { + + if err := validate.Required("drEnabled", "body", m.DrEnabled); err != nil { + return err + } + + return nil +} + +func (m *StoragePool) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *StoragePool) validateOverrideThresholds(formats strfmt.Registry) error { + if swag.IsZero(m.OverrideThresholds) { // not required + return nil + } + + if m.OverrideThresholds != nil { + if err := m.OverrideThresholds.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("overrideThresholds") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("overrideThresholds") + } + return err + } + } + + return nil +} + +var storagePoolTypeStatePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["closed","opened"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + storagePoolTypeStatePropEnum = append(storagePoolTypeStatePropEnum, v) + } +} + +const ( + + // StoragePoolStateClosed captures enum value "closed" + StoragePoolStateClosed string = "closed" + + // StoragePoolStateOpened captures enum value "opened" + StoragePoolStateOpened string = "opened" +) + +// prop value enum +func (m *StoragePool) validateStateEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, storagePoolTypeStatePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *StoragePool) validateState(formats strfmt.Registry) error { + + if err := validate.Required("state", "body", m.State); err != nil { + return err + } + + // value enum + if err := m.validateStateEnum("state", "body", *m.State); err != nil { + return err + } + + return nil +} + +func (m *StoragePool) validateType(formats strfmt.Registry) error { + + if err := validate.Required("type", "body", m.Type); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this storage pool based on the context it is used +func (m *StoragePool) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateOverrideThresholds(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *StoragePool) contextValidateOverrideThresholds(ctx context.Context, formats strfmt.Registry) error { + + if m.OverrideThresholds != nil { + if err := m.OverrideThresholds.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("overrideThresholds") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("overrideThresholds") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *StoragePool) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *StoragePool) UnmarshalBinary(b []byte) error { + var res StoragePool + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/storage_pool_capacity.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/storage_pool_capacity.go new file mode 100644 index 00000000000..6b233d6baf2 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/storage_pool_capacity.go @@ -0,0 +1,80 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// StoragePoolCapacity Storage pool capacity +// +// swagger:model StoragePoolCapacity +type StoragePoolCapacity struct { + + // Maximum allocation storage size (GB) + // Required: true + MaxAllocationSize *int64 `json:"maxAllocationSize"` + + // Pool name + PoolName string `json:"poolName,omitempty"` + + // Storage type of the storage pool + StorageType string `json:"storageType,omitempty"` + + // Total pool capacity (GB) + TotalCapacity int64 `json:"totalCapacity,omitempty"` +} + +// Validate validates this storage pool capacity +func (m *StoragePoolCapacity) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateMaxAllocationSize(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *StoragePoolCapacity) validateMaxAllocationSize(formats strfmt.Registry) error { + + if err := validate.Required("maxAllocationSize", "body", m.MaxAllocationSize); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this storage pool capacity based on context it is used +func (m *StoragePoolCapacity) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *StoragePoolCapacity) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *StoragePoolCapacity) UnmarshalBinary(b []byte) error { + var res StoragePoolCapacity + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/storage_pools.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/storage_pools.go new file mode 100644 index 00000000000..622e1e19fb5 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/storage_pools.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// StoragePools list of storage pools for a region-zone +// +// swagger:model StoragePools +type StoragePools []*StoragePool + +// Validate validates this storage pools +func (m StoragePools) Validate(formats strfmt.Registry) error { + var res []error + + for i := 0; i < len(m); i++ { + if swag.IsZero(m[i]) { // not required + continue + } + + if m[i] != nil { + if err := m[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(strconv.Itoa(i)) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validate this storage pools based on the context it is used +func (m StoragePools) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + for i := 0; i < len(m); i++ { + + if m[i] != nil { + if err := m[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(strconv.Itoa(i)) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/storage_pools_capacity.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/storage_pools_capacity.go new file mode 100644 index 00000000000..ad6c04653b1 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/storage_pools_capacity.go @@ -0,0 +1,162 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// StoragePoolsCapacity Storage capacity for all storage pools +// +// swagger:model StoragePoolsCapacity +type StoragePoolsCapacity struct { + + // maximum storage allocation + MaximumStorageAllocation *MaximumStorageAllocation `json:"maximumStorageAllocation,omitempty"` + + // storage pools capacity + StoragePoolsCapacity []*StoragePoolCapacity `json:"storagePoolsCapacity"` +} + +// Validate validates this storage pools capacity +func (m *StoragePoolsCapacity) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateMaximumStorageAllocation(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStoragePoolsCapacity(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *StoragePoolsCapacity) validateMaximumStorageAllocation(formats strfmt.Registry) error { + if swag.IsZero(m.MaximumStorageAllocation) { // not required + return nil + } + + if m.MaximumStorageAllocation != nil { + if err := m.MaximumStorageAllocation.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("maximumStorageAllocation") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("maximumStorageAllocation") + } + return err + } + } + + return nil +} + +func (m *StoragePoolsCapacity) validateStoragePoolsCapacity(formats strfmt.Registry) error { + if swag.IsZero(m.StoragePoolsCapacity) { // not required + return nil + } + + for i := 0; i < len(m.StoragePoolsCapacity); i++ { + if swag.IsZero(m.StoragePoolsCapacity[i]) { // not required + continue + } + + if m.StoragePoolsCapacity[i] != nil { + if err := m.StoragePoolsCapacity[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("storagePoolsCapacity" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("storagePoolsCapacity" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this storage pools capacity based on the context it is used +func (m *StoragePoolsCapacity) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateMaximumStorageAllocation(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateStoragePoolsCapacity(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *StoragePoolsCapacity) contextValidateMaximumStorageAllocation(ctx context.Context, formats strfmt.Registry) error { + + if m.MaximumStorageAllocation != nil { + if err := m.MaximumStorageAllocation.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("maximumStorageAllocation") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("maximumStorageAllocation") + } + return err + } + } + + return nil +} + +func (m *StoragePoolsCapacity) contextValidateStoragePoolsCapacity(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.StoragePoolsCapacity); i++ { + + if m.StoragePoolsCapacity[i] != nil { + if err := m.StoragePoolsCapacity[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("storagePoolsCapacity" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("storagePoolsCapacity" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *StoragePoolsCapacity) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *StoragePoolsCapacity) UnmarshalBinary(b []byte) error { + var res StoragePoolsCapacity + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/storage_type.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/storage_type.go new file mode 100644 index 00000000000..4af1f8954aa --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/storage_type.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// StorageType Storage type detail +// +// swagger:model StorageType +type StorageType struct { + + // Identifies if the storage type is the default for a region + Default bool `json:"default,omitempty"` + + // Description, storage type label + Description string `json:"description,omitempty"` + + // State of the storage type (active or inactive) + // Enum: [active inactive] + State *string `json:"state,omitempty"` + + // Storage type + Type string `json:"type,omitempty"` +} + +// Validate validates this storage type +func (m *StorageType) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateState(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +var storageTypeTypeStatePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["active","inactive"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + storageTypeTypeStatePropEnum = append(storageTypeTypeStatePropEnum, v) + } +} + +const ( + + // StorageTypeStateActive captures enum value "active" + StorageTypeStateActive string = "active" + + // StorageTypeStateInactive captures enum value "inactive" + StorageTypeStateInactive string = "inactive" +) + +// prop value enum +func (m *StorageType) validateStateEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, storageTypeTypeStatePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *StorageType) validateState(formats strfmt.Registry) error { + if swag.IsZero(m.State) { // not required + return nil + } + + // value enum + if err := m.validateStateEnum("state", "body", *m.State); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this storage type based on context it is used +func (m *StorageType) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *StorageType) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *StorageType) UnmarshalBinary(b []byte) error { + var res StorageType + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/storage_type_capacity.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/storage_type_capacity.go new file mode 100644 index 00000000000..4ac3bf6dee4 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/storage_type_capacity.go @@ -0,0 +1,165 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// StorageTypeCapacity Storage type capacity +// +// swagger:model StorageTypeCapacity +type StorageTypeCapacity struct { + + // maximum storage allocation + MaximumStorageAllocation *MaximumStorageAllocation `json:"maximumStorageAllocation,omitempty"` + + // List of storage pool capacity for storage type + StoragePoolsCapacity []*StoragePoolCapacity `json:"storagePoolsCapacity"` + + // Storage type + StorageType string `json:"storageType,omitempty"` +} + +// Validate validates this storage type capacity +func (m *StorageTypeCapacity) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateMaximumStorageAllocation(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStoragePoolsCapacity(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *StorageTypeCapacity) validateMaximumStorageAllocation(formats strfmt.Registry) error { + if swag.IsZero(m.MaximumStorageAllocation) { // not required + return nil + } + + if m.MaximumStorageAllocation != nil { + if err := m.MaximumStorageAllocation.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("maximumStorageAllocation") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("maximumStorageAllocation") + } + return err + } + } + + return nil +} + +func (m *StorageTypeCapacity) validateStoragePoolsCapacity(formats strfmt.Registry) error { + if swag.IsZero(m.StoragePoolsCapacity) { // not required + return nil + } + + for i := 0; i < len(m.StoragePoolsCapacity); i++ { + if swag.IsZero(m.StoragePoolsCapacity[i]) { // not required + continue + } + + if m.StoragePoolsCapacity[i] != nil { + if err := m.StoragePoolsCapacity[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("storagePoolsCapacity" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("storagePoolsCapacity" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this storage type capacity based on the context it is used +func (m *StorageTypeCapacity) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateMaximumStorageAllocation(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateStoragePoolsCapacity(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *StorageTypeCapacity) contextValidateMaximumStorageAllocation(ctx context.Context, formats strfmt.Registry) error { + + if m.MaximumStorageAllocation != nil { + if err := m.MaximumStorageAllocation.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("maximumStorageAllocation") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("maximumStorageAllocation") + } + return err + } + } + + return nil +} + +func (m *StorageTypeCapacity) contextValidateStoragePoolsCapacity(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.StoragePoolsCapacity); i++ { + + if m.StoragePoolsCapacity[i] != nil { + if err := m.StoragePoolsCapacity[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("storagePoolsCapacity" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("storagePoolsCapacity" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *StorageTypeCapacity) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *StorageTypeCapacity) UnmarshalBinary(b []byte) error { + var res StorageTypeCapacity + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/storage_types.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/storage_types.go new file mode 100644 index 00000000000..d00c9cd4e4e --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/storage_types.go @@ -0,0 +1,69 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// StorageTypes A map of an array of storage types supported in a region +// +// swagger:model StorageTypes +type StorageTypes map[string]RegionStorageTypes + +// Validate validates this storage types +func (m StorageTypes) Validate(formats strfmt.Registry) error { + var res []error + + for k := range m { + + if err := validate.Required(k, "body", m[k]); err != nil { + return err + } + + if err := m[k].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(k) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(k) + } + return err + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validate this storage types based on the context it is used +func (m StorageTypes) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + for k := range m { + + if err := m[k].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(k) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(k) + } + return err + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/storage_types_capacity.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/storage_types_capacity.go new file mode 100644 index 00000000000..de163af979e --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/storage_types_capacity.go @@ -0,0 +1,162 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// StorageTypesCapacity Storage types capacity +// +// swagger:model StorageTypesCapacity +type StorageTypesCapacity struct { + + // maximum storage allocation + MaximumStorageAllocation *MaximumStorageAllocation `json:"maximumStorageAllocation,omitempty"` + + // storage types capacity + StorageTypesCapacity []*StorageTypeCapacity `json:"storageTypesCapacity"` +} + +// Validate validates this storage types capacity +func (m *StorageTypesCapacity) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateMaximumStorageAllocation(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStorageTypesCapacity(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *StorageTypesCapacity) validateMaximumStorageAllocation(formats strfmt.Registry) error { + if swag.IsZero(m.MaximumStorageAllocation) { // not required + return nil + } + + if m.MaximumStorageAllocation != nil { + if err := m.MaximumStorageAllocation.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("maximumStorageAllocation") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("maximumStorageAllocation") + } + return err + } + } + + return nil +} + +func (m *StorageTypesCapacity) validateStorageTypesCapacity(formats strfmt.Registry) error { + if swag.IsZero(m.StorageTypesCapacity) { // not required + return nil + } + + for i := 0; i < len(m.StorageTypesCapacity); i++ { + if swag.IsZero(m.StorageTypesCapacity[i]) { // not required + continue + } + + if m.StorageTypesCapacity[i] != nil { + if err := m.StorageTypesCapacity[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("storageTypesCapacity" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("storageTypesCapacity" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this storage types capacity based on the context it is used +func (m *StorageTypesCapacity) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateMaximumStorageAllocation(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateStorageTypesCapacity(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *StorageTypesCapacity) contextValidateMaximumStorageAllocation(ctx context.Context, formats strfmt.Registry) error { + + if m.MaximumStorageAllocation != nil { + if err := m.MaximumStorageAllocation.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("maximumStorageAllocation") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("maximumStorageAllocation") + } + return err + } + } + + return nil +} + +func (m *StorageTypesCapacity) contextValidateStorageTypesCapacity(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.StorageTypesCapacity); i++ { + + if m.StorageTypesCapacity[i] != nil { + if err := m.StorageTypesCapacity[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("storageTypesCapacity" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("storageTypesCapacity" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *StorageTypesCapacity) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *StorageTypesCapacity) UnmarshalBinary(b []byte) error { + var res StorageTypesCapacity + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/system.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/system.go new file mode 100644 index 00000000000..7e09b8ba43f --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/system.go @@ -0,0 +1,91 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// System system +// +// swagger:model System +type System struct { + + // The host available Processor units + // Required: true + Cores *float64 `json:"cores"` + + // The host identifier + ID int64 `json:"id,omitempty"` + + // The host available RAM memory in GiB + // Required: true + Memory *int64 `json:"memory"` +} + +// Validate validates this system +func (m *System) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCores(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMemory(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *System) validateCores(formats strfmt.Registry) error { + + if err := validate.Required("cores", "body", m.Cores); err != nil { + return err + } + + return nil +} + +func (m *System) validateMemory(formats strfmt.Registry) error { + + if err := validate.Required("memory", "body", m.Memory); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this system based on context it is used +func (m *System) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *System) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *System) UnmarshalBinary(b []byte) error { + var res System + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/system_pool.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/system_pool.go new file mode 100644 index 00000000000..59da690a53e --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/system_pool.go @@ -0,0 +1,352 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// SystemPool Hardware platform detailing its limits and statistics +// +// swagger:model SystemPool +type SystemPool struct { + + // Advertised capacity cores and memory (GB) + Capacity *System `json:"capacity,omitempty"` + + // Processor to Memory (GB) Ratio + CoreMemoryRatio float64 `json:"coreMemoryRatio,omitempty"` + + // Maximum configurable cores and memory (GB) (aggregated from all hosts) + MaxAvailable *System `json:"maxAvailable,omitempty"` + + // Maximum configurable cores available combined with available memory of that host + MaxCoresAvailable *System `json:"maxCoresAvailable,omitempty"` + + // Maximum configurable memory available combined with available cores of that host + MaxMemoryAvailable *System `json:"maxMemoryAvailable,omitempty"` + + // min-max-default allocation percentage of shared core per vCPU + SharedCoreRatio *MinMaxDefault `json:"sharedCoreRatio,omitempty"` + + // The DataCenter list of servers and their available resources + Systems []*System `json:"systems"` + + // Type of system hardware + Type string `json:"type,omitempty"` +} + +// Validate validates this system pool +func (m *SystemPool) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCapacity(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMaxAvailable(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMaxCoresAvailable(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMaxMemoryAvailable(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSharedCoreRatio(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSystems(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SystemPool) validateCapacity(formats strfmt.Registry) error { + if swag.IsZero(m.Capacity) { // not required + return nil + } + + if m.Capacity != nil { + if err := m.Capacity.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("capacity") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("capacity") + } + return err + } + } + + return nil +} + +func (m *SystemPool) validateMaxAvailable(formats strfmt.Registry) error { + if swag.IsZero(m.MaxAvailable) { // not required + return nil + } + + if m.MaxAvailable != nil { + if err := m.MaxAvailable.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("maxAvailable") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("maxAvailable") + } + return err + } + } + + return nil +} + +func (m *SystemPool) validateMaxCoresAvailable(formats strfmt.Registry) error { + if swag.IsZero(m.MaxCoresAvailable) { // not required + return nil + } + + if m.MaxCoresAvailable != nil { + if err := m.MaxCoresAvailable.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("maxCoresAvailable") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("maxCoresAvailable") + } + return err + } + } + + return nil +} + +func (m *SystemPool) validateMaxMemoryAvailable(formats strfmt.Registry) error { + if swag.IsZero(m.MaxMemoryAvailable) { // not required + return nil + } + + if m.MaxMemoryAvailable != nil { + if err := m.MaxMemoryAvailable.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("maxMemoryAvailable") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("maxMemoryAvailable") + } + return err + } + } + + return nil +} + +func (m *SystemPool) validateSharedCoreRatio(formats strfmt.Registry) error { + if swag.IsZero(m.SharedCoreRatio) { // not required + return nil + } + + if m.SharedCoreRatio != nil { + if err := m.SharedCoreRatio.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("sharedCoreRatio") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sharedCoreRatio") + } + return err + } + } + + return nil +} + +func (m *SystemPool) validateSystems(formats strfmt.Registry) error { + if swag.IsZero(m.Systems) { // not required + return nil + } + + for i := 0; i < len(m.Systems); i++ { + if swag.IsZero(m.Systems[i]) { // not required + continue + } + + if m.Systems[i] != nil { + if err := m.Systems[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("systems" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("systems" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this system pool based on the context it is used +func (m *SystemPool) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateCapacity(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMaxAvailable(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMaxCoresAvailable(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMaxMemoryAvailable(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSharedCoreRatio(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSystems(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SystemPool) contextValidateCapacity(ctx context.Context, formats strfmt.Registry) error { + + if m.Capacity != nil { + if err := m.Capacity.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("capacity") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("capacity") + } + return err + } + } + + return nil +} + +func (m *SystemPool) contextValidateMaxAvailable(ctx context.Context, formats strfmt.Registry) error { + + if m.MaxAvailable != nil { + if err := m.MaxAvailable.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("maxAvailable") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("maxAvailable") + } + return err + } + } + + return nil +} + +func (m *SystemPool) contextValidateMaxCoresAvailable(ctx context.Context, formats strfmt.Registry) error { + + if m.MaxCoresAvailable != nil { + if err := m.MaxCoresAvailable.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("maxCoresAvailable") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("maxCoresAvailable") + } + return err + } + } + + return nil +} + +func (m *SystemPool) contextValidateMaxMemoryAvailable(ctx context.Context, formats strfmt.Registry) error { + + if m.MaxMemoryAvailable != nil { + if err := m.MaxMemoryAvailable.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("maxMemoryAvailable") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("maxMemoryAvailable") + } + return err + } + } + + return nil +} + +func (m *SystemPool) contextValidateSharedCoreRatio(ctx context.Context, formats strfmt.Registry) error { + + if m.SharedCoreRatio != nil { + if err := m.SharedCoreRatio.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("sharedCoreRatio") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sharedCoreRatio") + } + return err + } + } + + return nil +} + +func (m *SystemPool) contextValidateSystems(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Systems); i++ { + + if m.Systems[i] != nil { + if err := m.Systems[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("systems" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("systems" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *SystemPool) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SystemPool) UnmarshalBinary(b []byte) error { + var res SystemPool + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/system_pools.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/system_pools.go new file mode 100644 index 00000000000..afae9a2f15a --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/system_pools.go @@ -0,0 +1,67 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// SystemPools List of available system pools within a particular DataCenter +// +// swagger:model SystemPools +type SystemPools map[string]SystemPool + +// Validate validates this system pools +func (m SystemPools) Validate(formats strfmt.Registry) error { + var res []error + + for k := range m { + + if err := validate.Required(k, "body", m[k]); err != nil { + return err + } + if val, ok := m[k]; ok { + if err := val.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(k) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(k) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validate this system pools based on the context it is used +func (m SystemPools) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + for k := range m { + + if val, ok := m[k]; ok { + if err := val.ContextValidate(ctx, formats); err != nil { + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/task.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/task.go new file mode 100644 index 00000000000..ccaf515ab29 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/task.go @@ -0,0 +1,217 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Task task +// +// swagger:model Task +type Task struct { + + // Cloud Instance ID of task owner + // Required: true + CloudInstanceID *string `json:"cloudInstanceID"` + + // the component id of the task + // Required: true + ComponentID *string `json:"componentID"` + + // the component type of the task + // Required: true + ComponentType *string `json:"componentType"` + + // Creation Date + // Required: true + // Format: date-time + CreationDate *strfmt.DateTime `json:"creationDate"` + + // Last Update Date + // Required: true + // Format: date-time + LastUpdateDate *strfmt.DateTime `json:"lastUpdateDate"` + + // Task Operation + // Required: true + Operation *string `json:"operation"` + + // status code of the task + // Required: true + Status *string `json:"status"` + + // status detail of the task + // Required: true + StatusDetail *string `json:"statusDetail"` + + // Pcloud Task ID + // Required: true + TaskID *string `json:"taskID"` +} + +// Validate validates this task +func (m *Task) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCloudInstanceID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateComponentID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateComponentType(formats); err != nil { + res = append(res, err) + } + + if err := m.validateCreationDate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLastUpdateDate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOperation(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStatus(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStatusDetail(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTaskID(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Task) validateCloudInstanceID(formats strfmt.Registry) error { + + if err := validate.Required("cloudInstanceID", "body", m.CloudInstanceID); err != nil { + return err + } + + return nil +} + +func (m *Task) validateComponentID(formats strfmt.Registry) error { + + if err := validate.Required("componentID", "body", m.ComponentID); err != nil { + return err + } + + return nil +} + +func (m *Task) validateComponentType(formats strfmt.Registry) error { + + if err := validate.Required("componentType", "body", m.ComponentType); err != nil { + return err + } + + return nil +} + +func (m *Task) validateCreationDate(formats strfmt.Registry) error { + + if err := validate.Required("creationDate", "body", m.CreationDate); err != nil { + return err + } + + if err := validate.FormatOf("creationDate", "body", "date-time", m.CreationDate.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *Task) validateLastUpdateDate(formats strfmt.Registry) error { + + if err := validate.Required("lastUpdateDate", "body", m.LastUpdateDate); err != nil { + return err + } + + if err := validate.FormatOf("lastUpdateDate", "body", "date-time", m.LastUpdateDate.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *Task) validateOperation(formats strfmt.Registry) error { + + if err := validate.Required("operation", "body", m.Operation); err != nil { + return err + } + + return nil +} + +func (m *Task) validateStatus(formats strfmt.Registry) error { + + if err := validate.Required("status", "body", m.Status); err != nil { + return err + } + + return nil +} + +func (m *Task) validateStatusDetail(formats strfmt.Registry) error { + + if err := validate.Required("statusDetail", "body", m.StatusDetail); err != nil { + return err + } + + return nil +} + +func (m *Task) validateTaskID(formats strfmt.Registry) error { + + if err := validate.Required("taskID", "body", m.TaskID); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this task based on context it is used +func (m *Task) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Task) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Task) UnmarshalBinary(b []byte) error { + var res Task + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/task_reference.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/task_reference.go new file mode 100644 index 00000000000..aca4c6d20d2 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/task_reference.go @@ -0,0 +1,88 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// TaskReference task reference +// +// swagger:model TaskReference +type TaskReference struct { + + // Link to Task resource + // Required: true + Href *string `json:"href"` + + // ID of Task used to get status of long running operation + // Required: true + TaskID *string `json:"taskID"` +} + +// Validate validates this task reference +func (m *TaskReference) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateHref(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTaskID(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *TaskReference) validateHref(formats strfmt.Registry) error { + + if err := validate.Required("href", "body", m.Href); err != nil { + return err + } + + return nil +} + +func (m *TaskReference) validateTaskID(formats strfmt.Registry) error { + + if err := validate.Required("taskID", "body", m.TaskID); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this task reference based on context it is used +func (m *TaskReference) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *TaskReference) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *TaskReference) UnmarshalBinary(b []byte) error { + var res TaskReference + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/tenant.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/tenant.go new file mode 100644 index 00000000000..60dcec1ba27 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/tenant.go @@ -0,0 +1,292 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Tenant tenant +// +// swagger:model Tenant +type Tenant struct { + + // Cloud Instances owned by the Tenant + // Required: true + CloudInstances []*CloudInstanceReference `json:"cloudInstances"` + + // Date of Tenant creation + // Required: true + // Format: date-time + CreationDate *strfmt.DateTime `json:"creationDate"` + + // Indicates if the tenant is enabled + // Required: true + Enabled *bool `json:"enabled"` + + // IBM Customer Number + Icn string `json:"icn,omitempty"` + + // Peering Network Information (optional) + PeeringNetworks []*PeeringNetwork `json:"peeringNetworks,omitempty"` + + // Tenant SSH Keys + SSHKeys []*SSHKey `json:"sshKeys"` + + // Tenant ID + // Required: true + TenantID *string `json:"tenantID"` +} + +// Validate validates this tenant +func (m *Tenant) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCloudInstances(formats); err != nil { + res = append(res, err) + } + + if err := m.validateCreationDate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateEnabled(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePeeringNetworks(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSSHKeys(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTenantID(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Tenant) validateCloudInstances(formats strfmt.Registry) error { + + if err := validate.Required("cloudInstances", "body", m.CloudInstances); err != nil { + return err + } + + for i := 0; i < len(m.CloudInstances); i++ { + if swag.IsZero(m.CloudInstances[i]) { // not required + continue + } + + if m.CloudInstances[i] != nil { + if err := m.CloudInstances[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("cloudInstances" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cloudInstances" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Tenant) validateCreationDate(formats strfmt.Registry) error { + + if err := validate.Required("creationDate", "body", m.CreationDate); err != nil { + return err + } + + if err := validate.FormatOf("creationDate", "body", "date-time", m.CreationDate.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *Tenant) validateEnabled(formats strfmt.Registry) error { + + if err := validate.Required("enabled", "body", m.Enabled); err != nil { + return err + } + + return nil +} + +func (m *Tenant) validatePeeringNetworks(formats strfmt.Registry) error { + if swag.IsZero(m.PeeringNetworks) { // not required + return nil + } + + for i := 0; i < len(m.PeeringNetworks); i++ { + if swag.IsZero(m.PeeringNetworks[i]) { // not required + continue + } + + if m.PeeringNetworks[i] != nil { + if err := m.PeeringNetworks[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("peeringNetworks" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("peeringNetworks" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Tenant) validateSSHKeys(formats strfmt.Registry) error { + if swag.IsZero(m.SSHKeys) { // not required + return nil + } + + for i := 0; i < len(m.SSHKeys); i++ { + if swag.IsZero(m.SSHKeys[i]) { // not required + continue + } + + if m.SSHKeys[i] != nil { + if err := m.SSHKeys[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("sshKeys" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sshKeys" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Tenant) validateTenantID(formats strfmt.Registry) error { + + if err := validate.Required("tenantID", "body", m.TenantID); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this tenant based on the context it is used +func (m *Tenant) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateCloudInstances(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidatePeeringNetworks(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSSHKeys(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Tenant) contextValidateCloudInstances(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.CloudInstances); i++ { + + if m.CloudInstances[i] != nil { + if err := m.CloudInstances[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("cloudInstances" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cloudInstances" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Tenant) contextValidatePeeringNetworks(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.PeeringNetworks); i++ { + + if m.PeeringNetworks[i] != nil { + if err := m.PeeringNetworks[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("peeringNetworks" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("peeringNetworks" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Tenant) contextValidateSSHKeys(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.SSHKeys); i++ { + + if m.SSHKeys[i] != nil { + if err := m.SSHKeys[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("sshKeys" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sshKeys" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Tenant) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Tenant) UnmarshalBinary(b []byte) error { + var res Tenant + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/tenant_update.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/tenant_update.go new file mode 100644 index 00000000000..a1a9e439a07 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/tenant_update.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// TenantUpdate tenant update +// +// swagger:model TenantUpdate +type TenantUpdate struct { + + // IBM Customer Number + Icn *string `json:"icn,omitempty"` + + // Peering Network Information (optional) + PeeringNetworks []*PeeringNetwork `json:"peeringNetworks"` +} + +// Validate validates this tenant update +func (m *TenantUpdate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validatePeeringNetworks(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *TenantUpdate) validatePeeringNetworks(formats strfmt.Registry) error { + if swag.IsZero(m.PeeringNetworks) { // not required + return nil + } + + for i := 0; i < len(m.PeeringNetworks); i++ { + if swag.IsZero(m.PeeringNetworks[i]) { // not required + continue + } + + if m.PeeringNetworks[i] != nil { + if err := m.PeeringNetworks[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("peeringNetworks" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("peeringNetworks" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this tenant update based on the context it is used +func (m *TenantUpdate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidatePeeringNetworks(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *TenantUpdate) contextValidatePeeringNetworks(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.PeeringNetworks); i++ { + + if m.PeeringNetworks[i] != nil { + if err := m.PeeringNetworks[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("peeringNetworks" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("peeringNetworks" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *TenantUpdate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *TenantUpdate) UnmarshalBinary(b []byte) error { + var res TenantUpdate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/thresholds.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/thresholds.go new file mode 100644 index 00000000000..9d142d57feb --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/thresholds.go @@ -0,0 +1,288 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Thresholds storage threshold settings +// +// swagger:model Thresholds +type Thresholds struct { + + // capacity threshold + Capacity *StorageEntities `json:"capacity,omitempty"` + + // overcommt threshold + Overcommit *StorageEntities `json:"overcommit,omitempty"` + + // physical capacity threshold + PhysicalCapacity *StorageEntities `json:"physicalCapacity,omitempty"` + + // vdisk capacity threshold + VdiskCapacity *StorageEntities `json:"vdiskCapacity,omitempty"` + + // vdisk limit threshold + VdiskLimit *StorageEntities `json:"vdiskLimit,omitempty"` +} + +// Validate validates this thresholds +func (m *Thresholds) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCapacity(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOvercommit(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePhysicalCapacity(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVdiskCapacity(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVdiskLimit(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Thresholds) validateCapacity(formats strfmt.Registry) error { + if swag.IsZero(m.Capacity) { // not required + return nil + } + + if m.Capacity != nil { + if err := m.Capacity.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("capacity") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("capacity") + } + return err + } + } + + return nil +} + +func (m *Thresholds) validateOvercommit(formats strfmt.Registry) error { + if swag.IsZero(m.Overcommit) { // not required + return nil + } + + if m.Overcommit != nil { + if err := m.Overcommit.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("overcommit") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("overcommit") + } + return err + } + } + + return nil +} + +func (m *Thresholds) validatePhysicalCapacity(formats strfmt.Registry) error { + if swag.IsZero(m.PhysicalCapacity) { // not required + return nil + } + + if m.PhysicalCapacity != nil { + if err := m.PhysicalCapacity.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("physicalCapacity") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("physicalCapacity") + } + return err + } + } + + return nil +} + +func (m *Thresholds) validateVdiskCapacity(formats strfmt.Registry) error { + if swag.IsZero(m.VdiskCapacity) { // not required + return nil + } + + if m.VdiskCapacity != nil { + if err := m.VdiskCapacity.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("vdiskCapacity") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("vdiskCapacity") + } + return err + } + } + + return nil +} + +func (m *Thresholds) validateVdiskLimit(formats strfmt.Registry) error { + if swag.IsZero(m.VdiskLimit) { // not required + return nil + } + + if m.VdiskLimit != nil { + if err := m.VdiskLimit.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("vdiskLimit") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("vdiskLimit") + } + return err + } + } + + return nil +} + +// ContextValidate validate this thresholds based on the context it is used +func (m *Thresholds) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateCapacity(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateOvercommit(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidatePhysicalCapacity(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateVdiskCapacity(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateVdiskLimit(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Thresholds) contextValidateCapacity(ctx context.Context, formats strfmt.Registry) error { + + if m.Capacity != nil { + if err := m.Capacity.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("capacity") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("capacity") + } + return err + } + } + + return nil +} + +func (m *Thresholds) contextValidateOvercommit(ctx context.Context, formats strfmt.Registry) error { + + if m.Overcommit != nil { + if err := m.Overcommit.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("overcommit") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("overcommit") + } + return err + } + } + + return nil +} + +func (m *Thresholds) contextValidatePhysicalCapacity(ctx context.Context, formats strfmt.Registry) error { + + if m.PhysicalCapacity != nil { + if err := m.PhysicalCapacity.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("physicalCapacity") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("physicalCapacity") + } + return err + } + } + + return nil +} + +func (m *Thresholds) contextValidateVdiskCapacity(ctx context.Context, formats strfmt.Registry) error { + + if m.VdiskCapacity != nil { + if err := m.VdiskCapacity.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("vdiskCapacity") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("vdiskCapacity") + } + return err + } + } + + return nil +} + +func (m *Thresholds) contextValidateVdiskLimit(ctx context.Context, formats strfmt.Registry) error { + + if m.VdiskLimit != nil { + if err := m.VdiskLimit.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("vdiskLimit") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("vdiskLimit") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Thresholds) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Thresholds) UnmarshalBinary(b []byte) error { + var res Thresholds + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/token.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/token.go new file mode 100644 index 00000000000..7dcf3634658 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/token.go @@ -0,0 +1,127 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Token token +// +// swagger:model Token +type Token struct { + + // AccessToken + // Required: true + AccessToken *string `json:"accessToken"` + + // Token Expires + // Required: true + // Format: date-time + Expires *strfmt.DateTime `json:"expires"` + + // Refresh Token + // Required: true + RefreshToken *string `json:"refreshToken"` + + // Token Type + // Required: true + Type *string `json:"type"` +} + +// Validate validates this token +func (m *Token) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAccessToken(formats); err != nil { + res = append(res, err) + } + + if err := m.validateExpires(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRefreshToken(formats); err != nil { + res = append(res, err) + } + + if err := m.validateType(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Token) validateAccessToken(formats strfmt.Registry) error { + + if err := validate.Required("accessToken", "body", m.AccessToken); err != nil { + return err + } + + return nil +} + +func (m *Token) validateExpires(formats strfmt.Registry) error { + + if err := validate.Required("expires", "body", m.Expires); err != nil { + return err + } + + if err := validate.FormatOf("expires", "body", "date-time", m.Expires.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *Token) validateRefreshToken(formats strfmt.Registry) error { + + if err := validate.Required("refreshToken", "body", m.RefreshToken); err != nil { + return err + } + + return nil +} + +func (m *Token) validateType(formats strfmt.Registry) error { + + if err := validate.Required("type", "body", m.Type); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this token based on context it is used +func (m *Token) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Token) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Token) UnmarshalBinary(b []byte) error { + var res Token + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/token_extra.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/token_extra.go new file mode 100644 index 00000000000..a37a8bc217e --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/token_extra.go @@ -0,0 +1,163 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// TokenExtra token extra +// +// swagger:model TokenExtra +type TokenExtra struct { + + // Number of seconds token will expire + // Required: true + ExpiresIn *float64 `json:"expiresIn"` + + // Time on the service broker + // Required: true + // Format: date-time + ServerTime *strfmt.DateTime `json:"serverTime"` + + // OAuth Token + // Required: true + Token *Token `json:"token"` + + // Is this token valid + // Required: true + Valid *bool `json:"valid"` +} + +// Validate validates this token extra +func (m *TokenExtra) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateExpiresIn(formats); err != nil { + res = append(res, err) + } + + if err := m.validateServerTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateToken(formats); err != nil { + res = append(res, err) + } + + if err := m.validateValid(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *TokenExtra) validateExpiresIn(formats strfmt.Registry) error { + + if err := validate.Required("expiresIn", "body", m.ExpiresIn); err != nil { + return err + } + + return nil +} + +func (m *TokenExtra) validateServerTime(formats strfmt.Registry) error { + + if err := validate.Required("serverTime", "body", m.ServerTime); err != nil { + return err + } + + if err := validate.FormatOf("serverTime", "body", "date-time", m.ServerTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *TokenExtra) validateToken(formats strfmt.Registry) error { + + if err := validate.Required("token", "body", m.Token); err != nil { + return err + } + + if m.Token != nil { + if err := m.Token.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("token") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("token") + } + return err + } + } + + return nil +} + +func (m *TokenExtra) validateValid(formats strfmt.Registry) error { + + if err := validate.Required("valid", "body", m.Valid); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this token extra based on the context it is used +func (m *TokenExtra) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateToken(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *TokenExtra) contextValidateToken(ctx context.Context, formats strfmt.Registry) error { + + if m.Token != nil { + if err := m.Token.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("token") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("token") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *TokenExtra) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *TokenExtra) UnmarshalBinary(b []byte) error { + var res TokenExtra + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/token_request.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/token_request.go new file mode 100644 index 00000000000..a136c5cec15 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/token_request.go @@ -0,0 +1,124 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// TokenRequest token request +// +// swagger:model TokenRequest +type TokenRequest struct { + + // The refresh token to request the new Access Token + // Required: true + RefreshToken *string `json:"refreshToken"` + + // Source type of the token request (web or cli) + // Required: true + // Enum: [web cli] + Source *string `json:"source"` +} + +// Validate validates this token request +func (m *TokenRequest) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateRefreshToken(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSource(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *TokenRequest) validateRefreshToken(formats strfmt.Registry) error { + + if err := validate.Required("refreshToken", "body", m.RefreshToken); err != nil { + return err + } + + return nil +} + +var tokenRequestTypeSourcePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["web","cli"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + tokenRequestTypeSourcePropEnum = append(tokenRequestTypeSourcePropEnum, v) + } +} + +const ( + + // TokenRequestSourceWeb captures enum value "web" + TokenRequestSourceWeb string = "web" + + // TokenRequestSourceCli captures enum value "cli" + TokenRequestSourceCli string = "cli" +) + +// prop value enum +func (m *TokenRequest) validateSourceEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, tokenRequestTypeSourcePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *TokenRequest) validateSource(formats strfmt.Registry) error { + + if err := validate.Required("source", "body", m.Source); err != nil { + return err + } + + // value enum + if err := m.validateSourceEnum("source", "body", *m.Source); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this token request based on context it is used +func (m *TokenRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *TokenRequest) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *TokenRequest) UnmarshalBinary(b []byte) error { + var res TokenRequest + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/update_storage_pool.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/update_storage_pool.go new file mode 100644 index 00000000000..b186a57ba94 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/update_storage_pool.go @@ -0,0 +1,162 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// UpdateStoragePool update storage pool +// +// swagger:model UpdateStoragePool +type UpdateStoragePool struct { + + // display name of storage pool + DisplayName *string `json:"displayName,omitempty"` + + // indicates if the storage pool is disaster recovery (dr) enabled + DrEnabled *bool `json:"drEnabled,omitempty"` + + // threshold override settings of a pool + OverrideThresholds *Thresholds `json:"overrideThresholds,omitempty"` + + // state of storage pool + // Enum: [closed opened] + State *string `json:"state,omitempty"` +} + +// Validate validates this update storage pool +func (m *UpdateStoragePool) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateOverrideThresholds(formats); err != nil { + res = append(res, err) + } + + if err := m.validateState(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *UpdateStoragePool) validateOverrideThresholds(formats strfmt.Registry) error { + if swag.IsZero(m.OverrideThresholds) { // not required + return nil + } + + if m.OverrideThresholds != nil { + if err := m.OverrideThresholds.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("overrideThresholds") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("overrideThresholds") + } + return err + } + } + + return nil +} + +var updateStoragePoolTypeStatePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["closed","opened"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + updateStoragePoolTypeStatePropEnum = append(updateStoragePoolTypeStatePropEnum, v) + } +} + +const ( + + // UpdateStoragePoolStateClosed captures enum value "closed" + UpdateStoragePoolStateClosed string = "closed" + + // UpdateStoragePoolStateOpened captures enum value "opened" + UpdateStoragePoolStateOpened string = "opened" +) + +// prop value enum +func (m *UpdateStoragePool) validateStateEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, updateStoragePoolTypeStatePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *UpdateStoragePool) validateState(formats strfmt.Registry) error { + if swag.IsZero(m.State) { // not required + return nil + } + + // value enum + if err := m.validateStateEnum("state", "body", *m.State); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this update storage pool based on the context it is used +func (m *UpdateStoragePool) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateOverrideThresholds(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *UpdateStoragePool) contextValidateOverrideThresholds(ctx context.Context, formats strfmt.Registry) error { + + if m.OverrideThresholds != nil { + if err := m.OverrideThresholds.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("overrideThresholds") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("overrideThresholds") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *UpdateStoragePool) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *UpdateStoragePool) UnmarshalBinary(b []byte) error { + var res UpdateStoragePool + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/update_volume.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/update_volume.go new file mode 100644 index 00000000000..630668b1000 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/update_volume.go @@ -0,0 +1,59 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// UpdateVolume update volume +// +// swagger:model UpdateVolume +type UpdateVolume struct { + + // Indicates if the volume is boot capable + Bootable *bool `json:"bootable,omitempty"` + + // Name + Name *string `json:"name,omitempty"` + + // Indicates if the volume is shareable between VMs + Shareable *bool `json:"shareable,omitempty"` + + // New Volume size + Size float64 `json:"size,omitempty"` +} + +// Validate validates this update volume +func (m *UpdateVolume) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this update volume based on context it is used +func (m *UpdateVolume) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *UpdateVolume) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *UpdateVolume) UnmarshalBinary(b []byte) error { + var res UpdateVolume + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/user_info.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/user_info.go new file mode 100644 index 00000000000..95978214893 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/user_info.go @@ -0,0 +1,111 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// UserInfo user info +// +// swagger:model UserInfo +type UserInfo struct { + + // User Email + // Required: true + Email *string `json:"email"` + + // User ID + // Required: true + ID *string `json:"id"` + + // User Image URL + ImageURL string `json:"imageURL,omitempty"` + + // Member of the following tenants + MemberOf []string `json:"memberOf"` + + // User Name + // Required: true + Name *string `json:"name"` +} + +// Validate validates this user info +func (m *UserInfo) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateEmail(formats); err != nil { + res = append(res, err) + } + + if err := m.validateID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *UserInfo) validateEmail(formats strfmt.Registry) error { + + if err := validate.Required("email", "body", m.Email); err != nil { + return err + } + + return nil +} + +func (m *UserInfo) validateID(formats strfmt.Registry) error { + + if err := validate.Required("id", "body", m.ID); err != nil { + return err + } + + return nil +} + +func (m *UserInfo) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this user info based on context it is used +func (m *UserInfo) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *UserInfo) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *UserInfo) UnmarshalBinary(b []byte) error { + var res UserInfo + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/v_p_n_connection.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/v_p_n_connection.go new file mode 100644 index 00000000000..368b9814dd4 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/v_p_n_connection.go @@ -0,0 +1,472 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// VPNConnection v p n connection +// +// swagger:model VPNConnection +type VPNConnection struct { + + // dead peer detection + // Required: true + DeadPeerDetection *DeadPeerDetection `json:"deadPeerDetection"` + + // unique identifier for VPN Connection + // Example: 123e4567-e89b-12d3-a456-42661475 + // Required: true + ID *string `json:"id"` + + // ike policy + // Required: true + IkePolicy *IKEPolicyRef `json:"ikePolicy"` + + // ip sec policy + // Required: true + IPSecPolicy *IPSecPolicyRef `json:"ipSecPolicy"` + + // local Gateway address, only in 'route' mode. + // Example: 192.168.1.1 + // Required: true + LocalGatewayAddress *string `json:"localGatewayAddress"` + + // Mode used by this VPNConnection, either policy-based, or route-based, this attribute is set at the creation and cannot be updated later. + // Example: policy + // Required: true + // Enum: [policy route] + Mode *string `json:"mode"` + + // VPN Connection name + // Example: VPN-Connection-1 + // Required: true + Name *string `json:"name"` + + // an array of network IDs + // Required: true + NetworkIDs []string `json:"networkIDs"` + + // peer gateway address + // Required: true + // Format: ipv4 + PeerGatewayAddress *PeerGatewayAddress `json:"peerGatewayAddress"` + + // an array of strings containing CIDR of peer subnets + // Example: ["128.170.1.0/20","128.169.1.0/24","128.168.1.0/27","128.170.1.0/32"] + // Required: true + PeerSubnets []string `json:"peerSubnets"` + + // status of the VPN connection + // Required: true + // Enum: [active warning disabled] + Status *string `json:"status"` + + // public IP address of the VPN Gateway (vSRX) attached to this VPNConnection + // Example: 192.168.204.1 + // Required: true + VpnGatewayAddress *string `json:"vpnGatewayAddress"` +} + +// Validate validates this v p n connection +func (m *VPNConnection) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateDeadPeerDetection(formats); err != nil { + res = append(res, err) + } + + if err := m.validateID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateIkePolicy(formats); err != nil { + res = append(res, err) + } + + if err := m.validateIPSecPolicy(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLocalGatewayAddress(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMode(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateNetworkIDs(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePeerGatewayAddress(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePeerSubnets(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStatus(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVpnGatewayAddress(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *VPNConnection) validateDeadPeerDetection(formats strfmt.Registry) error { + + if err := validate.Required("deadPeerDetection", "body", m.DeadPeerDetection); err != nil { + return err + } + + if m.DeadPeerDetection != nil { + if err := m.DeadPeerDetection.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("deadPeerDetection") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("deadPeerDetection") + } + return err + } + } + + return nil +} + +func (m *VPNConnection) validateID(formats strfmt.Registry) error { + + if err := validate.Required("id", "body", m.ID); err != nil { + return err + } + + return nil +} + +func (m *VPNConnection) validateIkePolicy(formats strfmt.Registry) error { + + if err := validate.Required("ikePolicy", "body", m.IkePolicy); err != nil { + return err + } + + if m.IkePolicy != nil { + if err := m.IkePolicy.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ikePolicy") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ikePolicy") + } + return err + } + } + + return nil +} + +func (m *VPNConnection) validateIPSecPolicy(formats strfmt.Registry) error { + + if err := validate.Required("ipSecPolicy", "body", m.IPSecPolicy); err != nil { + return err + } + + if m.IPSecPolicy != nil { + if err := m.IPSecPolicy.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ipSecPolicy") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ipSecPolicy") + } + return err + } + } + + return nil +} + +func (m *VPNConnection) validateLocalGatewayAddress(formats strfmt.Registry) error { + + if err := validate.Required("localGatewayAddress", "body", m.LocalGatewayAddress); err != nil { + return err + } + + return nil +} + +var vPNConnectionTypeModePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["policy","route"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + vPNConnectionTypeModePropEnum = append(vPNConnectionTypeModePropEnum, v) + } +} + +const ( + + // VPNConnectionModePolicy captures enum value "policy" + VPNConnectionModePolicy string = "policy" + + // VPNConnectionModeRoute captures enum value "route" + VPNConnectionModeRoute string = "route" +) + +// prop value enum +func (m *VPNConnection) validateModeEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, vPNConnectionTypeModePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *VPNConnection) validateMode(formats strfmt.Registry) error { + + if err := validate.Required("mode", "body", m.Mode); err != nil { + return err + } + + // value enum + if err := m.validateModeEnum("mode", "body", *m.Mode); err != nil { + return err + } + + return nil +} + +func (m *VPNConnection) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *VPNConnection) validateNetworkIDs(formats strfmt.Registry) error { + + if err := validate.Required("networkIDs", "body", m.NetworkIDs); err != nil { + return err + } + + return nil +} + +func (m *VPNConnection) validatePeerGatewayAddress(formats strfmt.Registry) error { + + if err := validate.Required("peerGatewayAddress", "body", m.PeerGatewayAddress); err != nil { + return err + } + + if err := validate.Required("peerGatewayAddress", "body", m.PeerGatewayAddress); err != nil { + return err + } + + if m.PeerGatewayAddress != nil { + if err := m.PeerGatewayAddress.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("peerGatewayAddress") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("peerGatewayAddress") + } + return err + } + } + + return nil +} + +func (m *VPNConnection) validatePeerSubnets(formats strfmt.Registry) error { + + if err := validate.Required("peerSubnets", "body", m.PeerSubnets); err != nil { + return err + } + + return nil +} + +var vPNConnectionTypeStatusPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["active","warning","disabled"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + vPNConnectionTypeStatusPropEnum = append(vPNConnectionTypeStatusPropEnum, v) + } +} + +const ( + + // VPNConnectionStatusActive captures enum value "active" + VPNConnectionStatusActive string = "active" + + // VPNConnectionStatusWarning captures enum value "warning" + VPNConnectionStatusWarning string = "warning" + + // VPNConnectionStatusDisabled captures enum value "disabled" + VPNConnectionStatusDisabled string = "disabled" +) + +// prop value enum +func (m *VPNConnection) validateStatusEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, vPNConnectionTypeStatusPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *VPNConnection) validateStatus(formats strfmt.Registry) error { + + if err := validate.Required("status", "body", m.Status); err != nil { + return err + } + + // value enum + if err := m.validateStatusEnum("status", "body", *m.Status); err != nil { + return err + } + + return nil +} + +func (m *VPNConnection) validateVpnGatewayAddress(formats strfmt.Registry) error { + + if err := validate.Required("vpnGatewayAddress", "body", m.VpnGatewayAddress); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this v p n connection based on the context it is used +func (m *VPNConnection) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateDeadPeerDetection(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateIkePolicy(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateIPSecPolicy(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidatePeerGatewayAddress(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *VPNConnection) contextValidateDeadPeerDetection(ctx context.Context, formats strfmt.Registry) error { + + if m.DeadPeerDetection != nil { + if err := m.DeadPeerDetection.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("deadPeerDetection") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("deadPeerDetection") + } + return err + } + } + + return nil +} + +func (m *VPNConnection) contextValidateIkePolicy(ctx context.Context, formats strfmt.Registry) error { + + if m.IkePolicy != nil { + if err := m.IkePolicy.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ikePolicy") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ikePolicy") + } + return err + } + } + + return nil +} + +func (m *VPNConnection) contextValidateIPSecPolicy(ctx context.Context, formats strfmt.Registry) error { + + if m.IPSecPolicy != nil { + if err := m.IPSecPolicy.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ipSecPolicy") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ipSecPolicy") + } + return err + } + } + + return nil +} + +func (m *VPNConnection) contextValidatePeerGatewayAddress(ctx context.Context, formats strfmt.Registry) error { + + if m.PeerGatewayAddress != nil { + if err := m.PeerGatewayAddress.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("peerGatewayAddress") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("peerGatewayAddress") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *VPNConnection) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *VPNConnection) UnmarshalBinary(b []byte) error { + var res VPNConnection + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/v_p_n_connection_create.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/v_p_n_connection_create.go new file mode 100644 index 00000000000..a98a8db474d --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/v_p_n_connection_create.go @@ -0,0 +1,256 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// VPNConnectionCreate v p n connection create +// +// swagger:model VPNConnectionCreate +type VPNConnectionCreate struct { + + // unique identifier of IKEPolicy selected for this VPNConnection + // Example: c36723ec-8593-11eb-8dcd-0242ac133853 + // Required: true + IkePolicy *string `json:"ikePolicy"` + + // unique identifier of IPSecPolicy selected for this VPNConnection + // Example: c12345d-8593-11eb-8dcd-0242ac134573 + // Required: true + IPSecPolicy *string `json:"ipSecPolicy"` + + // Mode used by this VPNConnection, either policy-based, or route-based, this attribute is set at the creation and cannot be updated later. + // Example: policy + // Required: true + // Enum: [policy route] + Mode *string `json:"mode"` + + // VPN Connection name + // Example: VPN-Connection-1 + // Required: true + Name *string `json:"name"` + + // an array of network IDs to attach to this VPNConnection + // Example: ["7f950c76-8582-11veb-8dcd-0242ac153","7f950c76-8582-11veb-8dcd-0242ac144","7f950c76-8582-11veb-8dcd-0242ac199"] + // Required: true + Networks []string `json:"networks"` + + // peer gateway address + // Required: true + // Format: ipv4 + PeerGatewayAddress *PeerGatewayAddress `json:"peerGatewayAddress"` + + // an array of strings containing CIDR of peer subnets + // Example: ["128.170.1.0/20","128.169.1.0/24","128.168.1.0/27","128.170.1.0/32"] + // Required: true + PeerSubnets []string `json:"peerSubnets"` +} + +// Validate validates this v p n connection create +func (m *VPNConnectionCreate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateIkePolicy(formats); err != nil { + res = append(res, err) + } + + if err := m.validateIPSecPolicy(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMode(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateNetworks(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePeerGatewayAddress(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePeerSubnets(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *VPNConnectionCreate) validateIkePolicy(formats strfmt.Registry) error { + + if err := validate.Required("ikePolicy", "body", m.IkePolicy); err != nil { + return err + } + + return nil +} + +func (m *VPNConnectionCreate) validateIPSecPolicy(formats strfmt.Registry) error { + + if err := validate.Required("ipSecPolicy", "body", m.IPSecPolicy); err != nil { + return err + } + + return nil +} + +var vPNConnectionCreateTypeModePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["policy","route"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + vPNConnectionCreateTypeModePropEnum = append(vPNConnectionCreateTypeModePropEnum, v) + } +} + +const ( + + // VPNConnectionCreateModePolicy captures enum value "policy" + VPNConnectionCreateModePolicy string = "policy" + + // VPNConnectionCreateModeRoute captures enum value "route" + VPNConnectionCreateModeRoute string = "route" +) + +// prop value enum +func (m *VPNConnectionCreate) validateModeEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, vPNConnectionCreateTypeModePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *VPNConnectionCreate) validateMode(formats strfmt.Registry) error { + + if err := validate.Required("mode", "body", m.Mode); err != nil { + return err + } + + // value enum + if err := m.validateModeEnum("mode", "body", *m.Mode); err != nil { + return err + } + + return nil +} + +func (m *VPNConnectionCreate) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *VPNConnectionCreate) validateNetworks(formats strfmt.Registry) error { + + if err := validate.Required("networks", "body", m.Networks); err != nil { + return err + } + + return nil +} + +func (m *VPNConnectionCreate) validatePeerGatewayAddress(formats strfmt.Registry) error { + + if err := validate.Required("peerGatewayAddress", "body", m.PeerGatewayAddress); err != nil { + return err + } + + if err := validate.Required("peerGatewayAddress", "body", m.PeerGatewayAddress); err != nil { + return err + } + + if m.PeerGatewayAddress != nil { + if err := m.PeerGatewayAddress.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("peerGatewayAddress") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("peerGatewayAddress") + } + return err + } + } + + return nil +} + +func (m *VPNConnectionCreate) validatePeerSubnets(formats strfmt.Registry) error { + + if err := validate.Required("peerSubnets", "body", m.PeerSubnets); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this v p n connection create based on the context it is used +func (m *VPNConnectionCreate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidatePeerGatewayAddress(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *VPNConnectionCreate) contextValidatePeerGatewayAddress(ctx context.Context, formats strfmt.Registry) error { + + if m.PeerGatewayAddress != nil { + if err := m.PeerGatewayAddress.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("peerGatewayAddress") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("peerGatewayAddress") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *VPNConnectionCreate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *VPNConnectionCreate) UnmarshalBinary(b []byte) error { + var res VPNConnectionCreate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/v_p_n_connection_create_response.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/v_p_n_connection_create_response.go new file mode 100644 index 00000000000..fc9c60ef94e --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/v_p_n_connection_create_response.go @@ -0,0 +1,160 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// VPNConnectionCreateResponse v p n connection create response +// +// swagger:model VPNConnectionCreateResponse +type VPNConnectionCreateResponse struct { + VPNConnection + + // job ref + JobRef *JobReference `json:"jobRef,omitempty"` +} + +// UnmarshalJSON unmarshals this object from a JSON structure +func (m *VPNConnectionCreateResponse) UnmarshalJSON(raw []byte) error { + // AO0 + var aO0 VPNConnection + if err := swag.ReadJSON(raw, &aO0); err != nil { + return err + } + m.VPNConnection = aO0 + + // now for regular properties + var propsVPNConnectionCreateResponse struct { + JobRef *JobReference `json:"jobRef,omitempty"` + } + if err := swag.ReadJSON(raw, &propsVPNConnectionCreateResponse); err != nil { + return err + } + m.JobRef = propsVPNConnectionCreateResponse.JobRef + + return nil +} + +// MarshalJSON marshals this object to a JSON structure +func (m VPNConnectionCreateResponse) MarshalJSON() ([]byte, error) { + _parts := make([][]byte, 0, 1) + + aO0, err := swag.WriteJSON(m.VPNConnection) + if err != nil { + return nil, err + } + _parts = append(_parts, aO0) + + // now for regular properties + var propsVPNConnectionCreateResponse struct { + JobRef *JobReference `json:"jobRef,omitempty"` + } + propsVPNConnectionCreateResponse.JobRef = m.JobRef + + jsonDataPropsVPNConnectionCreateResponse, errVPNConnectionCreateResponse := swag.WriteJSON(propsVPNConnectionCreateResponse) + if errVPNConnectionCreateResponse != nil { + return nil, errVPNConnectionCreateResponse + } + _parts = append(_parts, jsonDataPropsVPNConnectionCreateResponse) + return swag.ConcatJSON(_parts...), nil +} + +// Validate validates this v p n connection create response +func (m *VPNConnectionCreateResponse) Validate(formats strfmt.Registry) error { + var res []error + + // validation for a type composition with VPNConnection + if err := m.VPNConnection.Validate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateJobRef(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *VPNConnectionCreateResponse) validateJobRef(formats strfmt.Registry) error { + if swag.IsZero(m.JobRef) { // not required + return nil + } + + if m.JobRef != nil { + if err := m.JobRef.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("jobRef") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("jobRef") + } + return err + } + } + + return nil +} + +// ContextValidate validate this v p n connection create response based on the context it is used +func (m *VPNConnectionCreateResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + // validation for a type composition with VPNConnection + if err := m.VPNConnection.ContextValidate(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateJobRef(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *VPNConnectionCreateResponse) contextValidateJobRef(ctx context.Context, formats strfmt.Registry) error { + + if m.JobRef != nil { + if err := m.JobRef.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("jobRef") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("jobRef") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *VPNConnectionCreateResponse) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *VPNConnectionCreateResponse) UnmarshalBinary(b []byte) error { + var res VPNConnectionCreateResponse + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/v_p_n_connection_update.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/v_p_n_connection_update.go new file mode 100644 index 00000000000..a771e5c2678 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/v_p_n_connection_update.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// VPNConnectionUpdate VPN Connection object to send during the update +// +// Min Properties: 1 +// +// swagger:model VPNConnectionUpdate +type VPNConnectionUpdate struct { + + // unique identifier of IKEPolicy selected for this VPNConnection + // Example: c36723ec-8593-11eb-8dcd-0242ac133853 + IkePolicy string `json:"ikePolicy,omitempty"` + + // unique identifier of IPSecPolicy selected for this VPNConnection + // Example: c12345d-8593-11eb-8dcd-0242ac134573 + IPSecPolicy string `json:"ipSecPolicy,omitempty"` + + // VPN Connection name + // Example: VPN-Connection-1 + Name string `json:"name,omitempty"` + + // peer gateway address + // Format: ipv4 + PeerGatewayAddress PeerGatewayAddress `json:"peerGatewayAddress,omitempty"` + + // v p n connection update additional properties + VPNConnectionUpdateAdditionalProperties map[string]interface{} `json:"-"` +} + +// UnmarshalJSON unmarshals this object with additional properties from JSON +func (m *VPNConnectionUpdate) UnmarshalJSON(data []byte) error { + // stage 1, bind the properties + var stage1 struct { + + // unique identifier of IKEPolicy selected for this VPNConnection + // Example: c36723ec-8593-11eb-8dcd-0242ac133853 + IkePolicy string `json:"ikePolicy,omitempty"` + + // unique identifier of IPSecPolicy selected for this VPNConnection + // Example: c12345d-8593-11eb-8dcd-0242ac134573 + IPSecPolicy string `json:"ipSecPolicy,omitempty"` + + // VPN Connection name + // Example: VPN-Connection-1 + Name string `json:"name,omitempty"` + + // peer gateway address + // Format: ipv4 + PeerGatewayAddress PeerGatewayAddress `json:"peerGatewayAddress,omitempty"` + } + if err := json.Unmarshal(data, &stage1); err != nil { + return err + } + var rcv VPNConnectionUpdate + + rcv.IkePolicy = stage1.IkePolicy + rcv.IPSecPolicy = stage1.IPSecPolicy + rcv.Name = stage1.Name + rcv.PeerGatewayAddress = stage1.PeerGatewayAddress + *m = rcv + + // stage 2, remove properties and add to map + stage2 := make(map[string]json.RawMessage) + if err := json.Unmarshal(data, &stage2); err != nil { + return err + } + + delete(stage2, "ikePolicy") + delete(stage2, "ipSecPolicy") + delete(stage2, "name") + delete(stage2, "peerGatewayAddress") + // stage 3, add additional properties values + if len(stage2) > 0 { + result := make(map[string]interface{}) + for k, v := range stage2 { + var toadd interface{} + if err := json.Unmarshal(v, &toadd); err != nil { + return err + } + result[k] = toadd + } + m.VPNConnectionUpdateAdditionalProperties = result + } + + return nil +} + +// MarshalJSON marshals this object with additional properties into a JSON object +func (m VPNConnectionUpdate) MarshalJSON() ([]byte, error) { + var stage1 struct { + + // unique identifier of IKEPolicy selected for this VPNConnection + // Example: c36723ec-8593-11eb-8dcd-0242ac133853 + IkePolicy string `json:"ikePolicy,omitempty"` + + // unique identifier of IPSecPolicy selected for this VPNConnection + // Example: c12345d-8593-11eb-8dcd-0242ac134573 + IPSecPolicy string `json:"ipSecPolicy,omitempty"` + + // VPN Connection name + // Example: VPN-Connection-1 + Name string `json:"name,omitempty"` + + // peer gateway address + // Format: ipv4 + PeerGatewayAddress PeerGatewayAddress `json:"peerGatewayAddress,omitempty"` + } + + stage1.IkePolicy = m.IkePolicy + stage1.IPSecPolicy = m.IPSecPolicy + stage1.Name = m.Name + stage1.PeerGatewayAddress = m.PeerGatewayAddress + + // make JSON object for known properties + props, err := json.Marshal(stage1) + if err != nil { + return nil, err + } + + if len(m.VPNConnectionUpdateAdditionalProperties) == 0 { // no additional properties + return props, nil + } + + // make JSON object for the additional properties + additional, err := json.Marshal(m.VPNConnectionUpdateAdditionalProperties) + if err != nil { + return nil, err + } + + if len(props) < 3 { // "{}": only additional properties + return additional, nil + } + + // concatenate the 2 objects + return swag.ConcatJSON(props, additional), nil +} + +// Validate validates this v p n connection update +func (m *VPNConnectionUpdate) Validate(formats strfmt.Registry) error { + var res []error + + // short circuits minProperties > 0 + if m == nil { + return errors.TooFewProperties("", "body", 1) + } + + props := make(map[string]json.RawMessage, 4+10) + j, err := swag.WriteJSON(m) + if err != nil { + return err + } + + if err = swag.ReadJSON(j, &props); err != nil { + return err + } + + nprops := len(props) + + // minProperties: 1 + if nprops < 1 { + return errors.TooFewProperties("", "body", 1) + } + + if err := m.validatePeerGatewayAddress(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *VPNConnectionUpdate) validatePeerGatewayAddress(formats strfmt.Registry) error { + if swag.IsZero(m.PeerGatewayAddress) { // not required + return nil + } + + if err := m.PeerGatewayAddress.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("peerGatewayAddress") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("peerGatewayAddress") + } + return err + } + + return nil +} + +// ContextValidate validate this v p n connection update based on the context it is used +func (m *VPNConnectionUpdate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidatePeerGatewayAddress(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *VPNConnectionUpdate) contextValidatePeerGatewayAddress(ctx context.Context, formats strfmt.Registry) error { + + if err := m.PeerGatewayAddress.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("peerGatewayAddress") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("peerGatewayAddress") + } + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *VPNConnectionUpdate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *VPNConnectionUpdate) UnmarshalBinary(b []byte) error { + var res VPNConnectionUpdate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/v_p_n_connections.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/v_p_n_connections.go new file mode 100644 index 00000000000..789c36571bd --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/v_p_n_connections.go @@ -0,0 +1,117 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// VPNConnections v p n connections +// +// swagger:model VPNConnections +type VPNConnections struct { + + // an array of VPN Connections + // Example: [{"deadPeerDetection":{"action":"restart","interval":10,"threshold":5},"id":"123e4567-e89b-12d3-a456-42661475","ikePolicy":{"id":"7654e321-e89b-12d3-a456-4566447","name":"IKE Policy 3"},"ipSecPolicy":{"id":"456f7890-e89b-12d3-a456-4569934","name":"IPSec Policy 2"},"localGatewayAddress":"192.168.1.1","mode":"route","name":"VPN Connection 2","peerGatewayAddress":"192.168.44.1","peerSubnets":["128.169.1.0/24","128.168.1.0/27"],"status":"Active","vpnGatewayAddress":"192.168.24.1"}] + VpnConnections []*VPNConnection `json:"vpnConnections"` +} + +// Validate validates this v p n connections +func (m *VPNConnections) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateVpnConnections(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *VPNConnections) validateVpnConnections(formats strfmt.Registry) error { + if swag.IsZero(m.VpnConnections) { // not required + return nil + } + + for i := 0; i < len(m.VpnConnections); i++ { + if swag.IsZero(m.VpnConnections[i]) { // not required + continue + } + + if m.VpnConnections[i] != nil { + if err := m.VpnConnections[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("vpnConnections" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("vpnConnections" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this v p n connections based on the context it is used +func (m *VPNConnections) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateVpnConnections(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *VPNConnections) contextValidateVpnConnections(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.VpnConnections); i++ { + + if m.VpnConnections[i] != nil { + if err := m.VpnConnections[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("vpnConnections" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("vpnConnections" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *VPNConnections) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *VPNConnections) UnmarshalBinary(b []byte) error { + var res VPNConnections + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/v_p_naa_s_options.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/v_p_naa_s_options.go new file mode 100644 index 00000000000..ca802f90275 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/v_p_naa_s_options.go @@ -0,0 +1,299 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// VPNaaSOptions v p naa s options +// +// swagger:model VPNaaSOptions +type VPNaaSOptions struct { + + // dead peer detection + // Required: true + DeadPeerDetection *DeadPeerDetection `json:"deadPeerDetection"` + + // ike policy options + // Required: true + IkePolicyOptions *IKEPolicyOptions `json:"ikePolicyOptions"` + + // ike policy template + // Required: true + IkePolicyTemplate *IKEPolicyTemplate `json:"ikePolicyTemplate"` + + // ip sec policy options + // Required: true + IPSecPolicyOptions *IPSecPolicyOptions `json:"ipSecPolicyOptions"` + + // ip sec policy template + // Required: true + IPSecPolicyTemplate *IPSecPolicyTemplate `json:"ipSecPolicyTemplate"` +} + +// Validate validates this v p naa s options +func (m *VPNaaSOptions) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateDeadPeerDetection(formats); err != nil { + res = append(res, err) + } + + if err := m.validateIkePolicyOptions(formats); err != nil { + res = append(res, err) + } + + if err := m.validateIkePolicyTemplate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateIPSecPolicyOptions(formats); err != nil { + res = append(res, err) + } + + if err := m.validateIPSecPolicyTemplate(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *VPNaaSOptions) validateDeadPeerDetection(formats strfmt.Registry) error { + + if err := validate.Required("deadPeerDetection", "body", m.DeadPeerDetection); err != nil { + return err + } + + if m.DeadPeerDetection != nil { + if err := m.DeadPeerDetection.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("deadPeerDetection") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("deadPeerDetection") + } + return err + } + } + + return nil +} + +func (m *VPNaaSOptions) validateIkePolicyOptions(formats strfmt.Registry) error { + + if err := validate.Required("ikePolicyOptions", "body", m.IkePolicyOptions); err != nil { + return err + } + + if m.IkePolicyOptions != nil { + if err := m.IkePolicyOptions.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ikePolicyOptions") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ikePolicyOptions") + } + return err + } + } + + return nil +} + +func (m *VPNaaSOptions) validateIkePolicyTemplate(formats strfmt.Registry) error { + + if err := validate.Required("ikePolicyTemplate", "body", m.IkePolicyTemplate); err != nil { + return err + } + + if m.IkePolicyTemplate != nil { + if err := m.IkePolicyTemplate.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ikePolicyTemplate") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ikePolicyTemplate") + } + return err + } + } + + return nil +} + +func (m *VPNaaSOptions) validateIPSecPolicyOptions(formats strfmt.Registry) error { + + if err := validate.Required("ipSecPolicyOptions", "body", m.IPSecPolicyOptions); err != nil { + return err + } + + if m.IPSecPolicyOptions != nil { + if err := m.IPSecPolicyOptions.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ipSecPolicyOptions") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ipSecPolicyOptions") + } + return err + } + } + + return nil +} + +func (m *VPNaaSOptions) validateIPSecPolicyTemplate(formats strfmt.Registry) error { + + if err := validate.Required("ipSecPolicyTemplate", "body", m.IPSecPolicyTemplate); err != nil { + return err + } + + if m.IPSecPolicyTemplate != nil { + if err := m.IPSecPolicyTemplate.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ipSecPolicyTemplate") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ipSecPolicyTemplate") + } + return err + } + } + + return nil +} + +// ContextValidate validate this v p naa s options based on the context it is used +func (m *VPNaaSOptions) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateDeadPeerDetection(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateIkePolicyOptions(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateIkePolicyTemplate(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateIPSecPolicyOptions(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateIPSecPolicyTemplate(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *VPNaaSOptions) contextValidateDeadPeerDetection(ctx context.Context, formats strfmt.Registry) error { + + if m.DeadPeerDetection != nil { + if err := m.DeadPeerDetection.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("deadPeerDetection") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("deadPeerDetection") + } + return err + } + } + + return nil +} + +func (m *VPNaaSOptions) contextValidateIkePolicyOptions(ctx context.Context, formats strfmt.Registry) error { + + if m.IkePolicyOptions != nil { + if err := m.IkePolicyOptions.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ikePolicyOptions") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ikePolicyOptions") + } + return err + } + } + + return nil +} + +func (m *VPNaaSOptions) contextValidateIkePolicyTemplate(ctx context.Context, formats strfmt.Registry) error { + + if m.IkePolicyTemplate != nil { + if err := m.IkePolicyTemplate.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ikePolicyTemplate") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ikePolicyTemplate") + } + return err + } + } + + return nil +} + +func (m *VPNaaSOptions) contextValidateIPSecPolicyOptions(ctx context.Context, formats strfmt.Registry) error { + + if m.IPSecPolicyOptions != nil { + if err := m.IPSecPolicyOptions.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ipSecPolicyOptions") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ipSecPolicyOptions") + } + return err + } + } + + return nil +} + +func (m *VPNaaSOptions) contextValidateIPSecPolicyTemplate(ctx context.Context, formats strfmt.Registry) error { + + if m.IPSecPolicyTemplate != nil { + if err := m.IPSecPolicyTemplate.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ipSecPolicyTemplate") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ipSecPolicyTemplate") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *VPNaaSOptions) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *VPNaaSOptions) UnmarshalBinary(b []byte) error { + var res VPNaaSOptions + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/version.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/version.go new file mode 100644 index 00000000000..8432df2334f --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/version.go @@ -0,0 +1,59 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Version version +// +// swagger:model Version +type Version struct { + + // Returns the build time + BuildDate string `json:"buildDate,omitempty"` + + // Returns the current go runtime version + GoVersion string `json:"goVersion,omitempty"` + + // Hostname of the responding system + Hostname string `json:"hostname,omitempty"` + + // Returns the git versioning information + Version string `json:"version,omitempty"` +} + +// Validate validates this version +func (m *Version) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this version based on context it is used +func (m *Version) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Version) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Version) UnmarshalBinary(b []byte) error { + var res Version + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/virtual_cores.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/virtual_cores.go new file mode 100644 index 00000000000..5d1330783f3 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/virtual_cores.go @@ -0,0 +1,82 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// VirtualCores virtual cores +// +// swagger:model VirtualCores +type VirtualCores struct { + + // The active virtual Cores + // Required: true + // Minimum: 1 + Assigned *int64 `json:"assigned"` + + // The maximum DLPAR range for virtual Cores (Display only support) + Max int64 `json:"max,omitempty"` + + // The minimum DLPAR range for virtual Cores (Display only support) + Min int64 `json:"min,omitempty"` +} + +// Validate validates this virtual cores +func (m *VirtualCores) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAssigned(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *VirtualCores) validateAssigned(formats strfmt.Registry) error { + + if err := validate.Required("assigned", "body", m.Assigned); err != nil { + return err + } + + if err := validate.MinimumInt("assigned", "body", *m.Assigned, 1, false); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this virtual cores based on context it is used +func (m *VirtualCores) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *VirtualCores) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *VirtualCores) UnmarshalBinary(b []byte) error { + var res VirtualCores + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/volume.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volume.go new file mode 100644 index 00000000000..167869c331a --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volume.go @@ -0,0 +1,191 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Volume volume +// +// swagger:model Volume +type Volume struct { + + // Indicates if the volume is the server's boot volume + BootVolume *bool `json:"bootVolume,omitempty"` + + // Indicates if the volume is boot capable + Bootable *bool `json:"bootable,omitempty"` + + // Consistency Group Name if volume is a part of volume group + ConsistencyGroupName string `json:"consistencyGroupName,omitempty"` + + // Creation Date + // Required: true + // Format: date-time + CreationDate *strfmt.DateTime `json:"creationDate"` + + // Indicates if the volume should be deleted when the server terminates + DeleteOnTermination *bool `json:"deleteOnTermination,omitempty"` + + // Type of Disk + DiskType string `json:"diskType,omitempty"` + + // Volume Group ID + GroupID string `json:"groupID,omitempty"` + + // Last Update Date + // Required: true + // Format: date-time + LastUpdateDate *strfmt.DateTime `json:"lastUpdateDate"` + + // mirroring state for replication enabled volume + MirroringState string `json:"mirroringState,omitempty"` + + // Volume Name + // Required: true + Name *string `json:"name"` + + // List of PCloud PVM Instance attached to the volume + PvmInstanceIDs []string `json:"pvmInstanceIDs"` + + // shows the replication status of a volume + ReplicationStatus string `json:"replicationStatus,omitempty"` + + // Indicates if the volume is shareable between VMs + Shareable *bool `json:"shareable,omitempty"` + + // Volume Size + // Required: true + Size *float64 `json:"size"` + + // Volume State + State string `json:"state,omitempty"` + + // Volume ID + // Required: true + VolumeID *string `json:"volumeID"` + + // Volume pool, name of storage pool where the volume is located + VolumePool string `json:"volumePool,omitempty"` + + // Volume type, name of storage template used to create the volume + VolumeType string `json:"volumeType,omitempty"` + + // Volume world wide name + Wwn string `json:"wwn,omitempty"` +} + +// Validate validates this volume +func (m *Volume) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreationDate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLastUpdateDate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSize(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVolumeID(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Volume) validateCreationDate(formats strfmt.Registry) error { + + if err := validate.Required("creationDate", "body", m.CreationDate); err != nil { + return err + } + + if err := validate.FormatOf("creationDate", "body", "date-time", m.CreationDate.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *Volume) validateLastUpdateDate(formats strfmt.Registry) error { + + if err := validate.Required("lastUpdateDate", "body", m.LastUpdateDate); err != nil { + return err + } + + if err := validate.FormatOf("lastUpdateDate", "body", "date-time", m.LastUpdateDate.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *Volume) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *Volume) validateSize(formats strfmt.Registry) error { + + if err := validate.Required("size", "body", m.Size); err != nil { + return err + } + + return nil +} + +func (m *Volume) validateVolumeID(formats strfmt.Registry) error { + + if err := validate.Required("volumeID", "body", m.VolumeID); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this volume based on context it is used +func (m *Volume) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Volume) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Volume) UnmarshalBinary(b []byte) error { + var res Volume + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/volume_action.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volume_action.go new file mode 100644 index 00000000000..b0c8b5eb443 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volume_action.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// VolumeAction volume action +// +// swagger:model VolumeAction +type VolumeAction struct { + + // Indicates if the volume should be replication enabled or not + // Required: true + ReplicationEnabled *bool `json:"replicationEnabled"` +} + +// Validate validates this volume action +func (m *VolumeAction) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateReplicationEnabled(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *VolumeAction) validateReplicationEnabled(formats strfmt.Registry) error { + + if err := validate.Required("replicationEnabled", "body", m.ReplicationEnabled); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this volume action based on context it is used +func (m *VolumeAction) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *VolumeAction) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *VolumeAction) UnmarshalBinary(b []byte) error { + var res VolumeAction + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/volume_info.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volume_info.go new file mode 100644 index 00000000000..26f5b3f2a67 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volume_info.go @@ -0,0 +1,53 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// VolumeInfo volume info +// +// swagger:model VolumeInfo +type VolumeInfo struct { + + // Name of the volume + Name string `json:"name,omitempty"` + + // ID of the volume + VolumeID string `json:"volumeID,omitempty"` +} + +// Validate validates this volume info +func (m *VolumeInfo) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this volume info based on context it is used +func (m *VolumeInfo) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *VolumeInfo) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *VolumeInfo) UnmarshalBinary(b []byte) error { + var res VolumeInfo + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/volume_reference.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volume_reference.go new file mode 100644 index 00000000000..95783127e87 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volume_reference.go @@ -0,0 +1,278 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// VolumeReference volume reference +// +// swagger:model VolumeReference +type VolumeReference struct { + + // Indicates if the volume is the server's boot volume + BootVolume *bool `json:"bootVolume,omitempty"` + + // Indicates if the volume is boot capable + // Required: true + Bootable *bool `json:"bootable"` + + // Consistency Group Name if volume is a part of volume group + ConsistencyGroupName string `json:"consistencyGroupName,omitempty"` + + // Creation Date + // Required: true + // Format: date-time + CreationDate *strfmt.DateTime `json:"creationDate"` + + // Indicates if the volume should be deleted when the server terminates + DeleteOnTermination *bool `json:"deleteOnTermination,omitempty"` + + // Type of Disk + // Required: true + DiskType *string `json:"diskType"` + + // Volume Group ID + GroupID string `json:"groupID,omitempty"` + + // Link to Volume resource + // Required: true + Href *string `json:"href"` + + // Last Update Date + // Required: true + // Format: date-time + LastUpdateDate *strfmt.DateTime `json:"lastUpdateDate"` + + // mirroring state for replication enabled volume + MirroringState string `json:"mirroringState,omitempty"` + + // Volume Name + // Required: true + Name *string `json:"name"` + + // List of PCloud PVM Instance attached to the volume + PvmInstanceIDs []string `json:"pvmInstanceIDs"` + + // shows the replication status of a volume + ReplicationStatus string `json:"replicationStatus,omitempty"` + + // Indicates if the volume is shareable between VMs + // Required: true + Shareable *bool `json:"shareable"` + + // Volume Size + // Required: true + Size *float64 `json:"size"` + + // Volume State + // Required: true + State *string `json:"state"` + + // Volume ID + // Required: true + VolumeID *string `json:"volumeID"` + + // Volume pool, name of storage pool where the volume is located + VolumePool string `json:"volumePool,omitempty"` + + // Volume type, name of storage template used to create the volume + VolumeType string `json:"volumeType,omitempty"` + + // Volume world wide name + // Required: true + Wwn *string `json:"wwn"` +} + +// Validate validates this volume reference +func (m *VolumeReference) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateBootable(formats); err != nil { + res = append(res, err) + } + + if err := m.validateCreationDate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateDiskType(formats); err != nil { + res = append(res, err) + } + + if err := m.validateHref(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLastUpdateDate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateShareable(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSize(formats); err != nil { + res = append(res, err) + } + + if err := m.validateState(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVolumeID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateWwn(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *VolumeReference) validateBootable(formats strfmt.Registry) error { + + if err := validate.Required("bootable", "body", m.Bootable); err != nil { + return err + } + + return nil +} + +func (m *VolumeReference) validateCreationDate(formats strfmt.Registry) error { + + if err := validate.Required("creationDate", "body", m.CreationDate); err != nil { + return err + } + + if err := validate.FormatOf("creationDate", "body", "date-time", m.CreationDate.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *VolumeReference) validateDiskType(formats strfmt.Registry) error { + + if err := validate.Required("diskType", "body", m.DiskType); err != nil { + return err + } + + return nil +} + +func (m *VolumeReference) validateHref(formats strfmt.Registry) error { + + if err := validate.Required("href", "body", m.Href); err != nil { + return err + } + + return nil +} + +func (m *VolumeReference) validateLastUpdateDate(formats strfmt.Registry) error { + + if err := validate.Required("lastUpdateDate", "body", m.LastUpdateDate); err != nil { + return err + } + + if err := validate.FormatOf("lastUpdateDate", "body", "date-time", m.LastUpdateDate.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *VolumeReference) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *VolumeReference) validateShareable(formats strfmt.Registry) error { + + if err := validate.Required("shareable", "body", m.Shareable); err != nil { + return err + } + + return nil +} + +func (m *VolumeReference) validateSize(formats strfmt.Registry) error { + + if err := validate.Required("size", "body", m.Size); err != nil { + return err + } + + return nil +} + +func (m *VolumeReference) validateState(formats strfmt.Registry) error { + + if err := validate.Required("state", "body", m.State); err != nil { + return err + } + + return nil +} + +func (m *VolumeReference) validateVolumeID(formats strfmt.Registry) error { + + if err := validate.Required("volumeID", "body", m.VolumeID); err != nil { + return err + } + + return nil +} + +func (m *VolumeReference) validateWwn(formats strfmt.Registry) error { + + if err := validate.Required("wwn", "body", m.Wwn); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this volume reference based on context it is used +func (m *VolumeReference) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *VolumeReference) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *VolumeReference) UnmarshalBinary(b []byte) error { + var res VolumeReference + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes.go new file mode 100644 index 00000000000..b701d4837ee --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Volumes volumes +// +// swagger:model Volumes +type Volumes struct { + + // Volumes + // Required: true + Volumes []*VolumeReference `json:"volumes"` +} + +// Validate validates this volumes +func (m *Volumes) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateVolumes(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Volumes) validateVolumes(formats strfmt.Registry) error { + + if err := validate.Required("volumes", "body", m.Volumes); err != nil { + return err + } + + for i := 0; i < len(m.Volumes); i++ { + if swag.IsZero(m.Volumes[i]) { // not required + continue + } + + if m.Volumes[i] != nil { + if err := m.Volumes[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("volumes" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("volumes" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this volumes based on the context it is used +func (m *Volumes) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateVolumes(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Volumes) contextValidateVolumes(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Volumes); i++ { + + if m.Volumes[i] != nil { + if err := m.Volumes[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("volumes" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("volumes" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Volumes) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Volumes) UnmarshalBinary(b []byte) error { + var res Volumes + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_attach.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_attach.go new file mode 100644 index 00000000000..5e5b69b0891 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_attach.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// VolumesAttach volumes attach +// +// swagger:model volumesAttach +type VolumesAttach struct { + + // List of volumes to be attached to a PVM instance + // Required: true + VolumeIDs []string `json:"volumeIDs"` +} + +// Validate validates this volumes attach +func (m *VolumesAttach) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateVolumeIDs(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *VolumesAttach) validateVolumeIDs(formats strfmt.Registry) error { + + if err := validate.Required("volumeIDs", "body", m.VolumeIDs); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this volumes attach based on context it is used +func (m *VolumesAttach) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *VolumesAttach) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *VolumesAttach) UnmarshalBinary(b []byte) error { + var res VolumesAttach + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_attachment_response.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_attachment_response.go new file mode 100644 index 00000000000..a8d453d27ef --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_attachment_response.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// VolumesAttachmentResponse volumes attachment response +// +// swagger:model VolumesAttachmentResponse +type VolumesAttachmentResponse struct { + + // status summary for volume attachment to a PVM Instance + // Required: true + Summary *string `json:"summary"` +} + +// Validate validates this volumes attachment response +func (m *VolumesAttachmentResponse) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateSummary(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *VolumesAttachmentResponse) validateSummary(formats strfmt.Registry) error { + + if err := validate.Required("summary", "body", m.Summary); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this volumes attachment response based on context it is used +func (m *VolumesAttachmentResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *VolumesAttachmentResponse) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *VolumesAttachmentResponse) UnmarshalBinary(b []byte) error { + var res VolumesAttachmentResponse + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_clone.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_clone.go new file mode 100644 index 00000000000..38cd8e679db --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_clone.go @@ -0,0 +1,126 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// VolumesClone volumes clone +// +// swagger:model VolumesClone +type VolumesClone struct { + + // Current action performed for the volumes-clone request + Action string `json:"action,omitempty"` + + // Creation Date + // Format: date-time + CreationDate strfmt.DateTime `json:"creationDate,omitempty"` + + // Failure reason for a failed volumes-clone request + FailureMessage string `json:"failureMessage,omitempty"` + + // Last Update Date + // Format: date-time + LastUpdateDate strfmt.DateTime `json:"lastUpdateDate,omitempty"` + + // Name assigned to a volumes-clone request + Name string `json:"name,omitempty"` + + // The percent completion for the current action + // Required: true + PercentComplete *int64 `json:"percentComplete"` + + // Current status of the volumes-clone request + Status string `json:"status,omitempty"` + + // ID assigned to a volumes-clone request + VolumesCloneID string `json:"volumesCloneID,omitempty"` +} + +// Validate validates this volumes clone +func (m *VolumesClone) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreationDate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLastUpdateDate(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePercentComplete(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *VolumesClone) validateCreationDate(formats strfmt.Registry) error { + if swag.IsZero(m.CreationDate) { // not required + return nil + } + + if err := validate.FormatOf("creationDate", "body", "date-time", m.CreationDate.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *VolumesClone) validateLastUpdateDate(formats strfmt.Registry) error { + if swag.IsZero(m.LastUpdateDate) { // not required + return nil + } + + if err := validate.FormatOf("lastUpdateDate", "body", "date-time", m.LastUpdateDate.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *VolumesClone) validatePercentComplete(formats strfmt.Registry) error { + + if err := validate.Required("percentComplete", "body", m.PercentComplete); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this volumes clone based on context it is used +func (m *VolumesClone) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *VolumesClone) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *VolumesClone) UnmarshalBinary(b []byte) error { + var res VolumesClone + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_clone_async_request.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_clone_async_request.go new file mode 100644 index 00000000000..4ec6f73cd32 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_clone_async_request.go @@ -0,0 +1,95 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// VolumesCloneAsyncRequest volumes clone async request +// +// swagger:model VolumesCloneAsyncRequest +type VolumesCloneAsyncRequest struct { + + // Base name of the new cloned volume(s). + // Cloned Volume names will be prefixed with 'clone-' + // and suffixed with '-#####' (where ##### is a 5 digit random number) + // If multiple volumes cloned they will be further suffixed with an incremental number starting with 1. + // Example volume names using name="volume-abcdef" + // single volume clone will be named "clone-volume-abcdef-83081" + // multi volume clone will be named "clone-volume-abcdef-73721-1", "clone-volume-abcdef-73721-2", ... + // + // Required: true + Name *string `json:"name"` + + // List of volumes to be cloned + // Required: true + VolumeIDs []string `json:"volumeIDs"` +} + +// Validate validates this volumes clone async request +func (m *VolumesCloneAsyncRequest) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVolumeIDs(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *VolumesCloneAsyncRequest) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *VolumesCloneAsyncRequest) validateVolumeIDs(formats strfmt.Registry) error { + + if err := validate.Required("volumeIDs", "body", m.VolumeIDs); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this volumes clone async request based on context it is used +func (m *VolumesCloneAsyncRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *VolumesCloneAsyncRequest) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *VolumesCloneAsyncRequest) UnmarshalBinary(b []byte) error { + var res VolumesCloneAsyncRequest + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_clone_cancel.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_clone_cancel.go new file mode 100644 index 00000000000..44bf4c720c9 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_clone_cancel.go @@ -0,0 +1,52 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// VolumesCloneCancel volumes clone cancel +// +// swagger:model VolumesCloneCancel +type VolumesCloneCancel struct { + + // default False, Cancel will only be allowed if the status is 'prepared', or 'available' + // True, Cancel will be allowed when the status is NOT completed, cancelling, cancelled, or failed + // + Force bool `json:"force,omitempty"` +} + +// Validate validates this volumes clone cancel +func (m *VolumesCloneCancel) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this volumes clone cancel based on context it is used +func (m *VolumesCloneCancel) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *VolumesCloneCancel) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *VolumesCloneCancel) UnmarshalBinary(b []byte) error { + var res VolumesCloneCancel + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_clone_create.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_clone_create.go new file mode 100644 index 00000000000..77b38ab9b77 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_clone_create.go @@ -0,0 +1,90 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// VolumesCloneCreate volumes clone create +// +// swagger:model VolumesCloneCreate +type VolumesCloneCreate struct { + + // Unique name within a cloud instance used to identify a volumes-clone request + // name can be used in replace of a volumesCloneID when used as a URL path parameter + // + // Required: true + Name *string `json:"name"` + + // List of volumes to be cloned + // Required: true + VolumeIDs []string `json:"volumeIDs"` +} + +// Validate validates this volumes clone create +func (m *VolumesCloneCreate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVolumeIDs(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *VolumesCloneCreate) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *VolumesCloneCreate) validateVolumeIDs(formats strfmt.Registry) error { + + if err := validate.Required("volumeIDs", "body", m.VolumeIDs); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this volumes clone create based on context it is used +func (m *VolumesCloneCreate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *VolumesCloneCreate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *VolumesCloneCreate) UnmarshalBinary(b []byte) error { + var res VolumesCloneCreate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_clone_detail.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_clone_detail.go new file mode 100644 index 00000000000..24a51c91d8c --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_clone_detail.go @@ -0,0 +1,189 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// VolumesCloneDetail volumes clone detail +// +// swagger:model VolumesCloneDetail +type VolumesCloneDetail struct { + + // Current action performed for the volumes-clone request + Action string `json:"action,omitempty"` + + // List of cloned volumes created from the volumes-clone request + ClonedVolumes []*ClonedVolumeDetail `json:"clonedVolumes"` + + // Creation Date + // Format: date-time + CreationDate strfmt.DateTime `json:"creationDate,omitempty"` + + // Failure reason for a failed volumes-clone request + FailureMessage string `json:"failureMessage,omitempty"` + + // Last Update Date + // Format: date-time + LastUpdateDate strfmt.DateTime `json:"lastUpdateDate,omitempty"` + + // Name assigned to a volumes-clone request + Name string `json:"name,omitempty"` + + // The percent completion for the current action + // Required: true + PercentComplete *int64 `json:"percentComplete"` + + // Current status of the volumes-clone request + Status string `json:"status,omitempty"` + + // ID assigned to a volumes-clone request + VolumesCloneID string `json:"volumesCloneID,omitempty"` +} + +// Validate validates this volumes clone detail +func (m *VolumesCloneDetail) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateClonedVolumes(formats); err != nil { + res = append(res, err) + } + + if err := m.validateCreationDate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLastUpdateDate(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePercentComplete(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *VolumesCloneDetail) validateClonedVolumes(formats strfmt.Registry) error { + if swag.IsZero(m.ClonedVolumes) { // not required + return nil + } + + for i := 0; i < len(m.ClonedVolumes); i++ { + if swag.IsZero(m.ClonedVolumes[i]) { // not required + continue + } + + if m.ClonedVolumes[i] != nil { + if err := m.ClonedVolumes[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("clonedVolumes" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("clonedVolumes" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *VolumesCloneDetail) validateCreationDate(formats strfmt.Registry) error { + if swag.IsZero(m.CreationDate) { // not required + return nil + } + + if err := validate.FormatOf("creationDate", "body", "date-time", m.CreationDate.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *VolumesCloneDetail) validateLastUpdateDate(formats strfmt.Registry) error { + if swag.IsZero(m.LastUpdateDate) { // not required + return nil + } + + if err := validate.FormatOf("lastUpdateDate", "body", "date-time", m.LastUpdateDate.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *VolumesCloneDetail) validatePercentComplete(formats strfmt.Registry) error { + + if err := validate.Required("percentComplete", "body", m.PercentComplete); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this volumes clone detail based on the context it is used +func (m *VolumesCloneDetail) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateClonedVolumes(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *VolumesCloneDetail) contextValidateClonedVolumes(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.ClonedVolumes); i++ { + + if m.ClonedVolumes[i] != nil { + if err := m.ClonedVolumes[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("clonedVolumes" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("clonedVolumes" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *VolumesCloneDetail) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *VolumesCloneDetail) UnmarshalBinary(b []byte) error { + var res VolumesCloneDetail + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_clone_execute.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_clone_execute.go new file mode 100644 index 00000000000..1e10ae5d359 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_clone_execute.go @@ -0,0 +1,83 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// VolumesCloneExecute volumes clone execute +// +// swagger:model VolumesCloneExecute +type VolumesCloneExecute struct { + + // Base name of the new cloned volume(s). + // Cloned Volume names will be prefixed with 'clone-' + // and suffixed with '-#####' (where ##### is a 5 digit random number) + // If multiple volumes cloned they will be further suffixed with an incremental number starting with 1. + // Example volume names using name="volume-abcdef" + // single volume clone will be named "clone-volume-abcdef-83081" + // multi volume clone will be named "clone-volume-abcdef-73721-1", "clone-volume-abcdef-73721-2", ... + // + // Required: true + Name *string `json:"name"` + + // default False, Execute failure rolls back clone activity but leaves prepared snapshot + // True, Execute failure rolls back clone activity and removes the prepared snapshot + // + RollbackPrepare bool `json:"rollbackPrepare,omitempty"` +} + +// Validate validates this volumes clone execute +func (m *VolumesCloneExecute) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *VolumesCloneExecute) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this volumes clone execute based on context it is used +func (m *VolumesCloneExecute) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *VolumesCloneExecute) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *VolumesCloneExecute) UnmarshalBinary(b []byte) error { + var res VolumesCloneExecute + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_clone_request.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_clone_request.go new file mode 100644 index 00000000000..7ed5f8c5cd1 --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_clone_request.go @@ -0,0 +1,94 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// VolumesCloneRequest volumes clone request +// +// swagger:model VolumesCloneRequest +type VolumesCloneRequest struct { + + // Display name for the new cloned volumes. + // Cloned Volume names will be prefixed with 'clone-'. + // If multiple volumes cloned they will be suffix with a '-' and an incremental number starting with 1. + // Example volume names using displayName="volume-abcdef" + // single volume clone will be named "clone-volume-abcdef" + // multi volume clone will be named "clone-volume-abcdef-1", "clone-volume-abcdef-2", ... + // + // Required: true + DisplayName *string `json:"displayName"` + + // List of volumes to be cloned + // Required: true + VolumeIDs []string `json:"volumeIDs"` +} + +// Validate validates this volumes clone request +func (m *VolumesCloneRequest) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateDisplayName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVolumeIDs(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *VolumesCloneRequest) validateDisplayName(formats strfmt.Registry) error { + + if err := validate.Required("displayName", "body", m.DisplayName); err != nil { + return err + } + + return nil +} + +func (m *VolumesCloneRequest) validateVolumeIDs(formats strfmt.Registry) error { + + if err := validate.Required("volumeIDs", "body", m.VolumeIDs); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this volumes clone request based on context it is used +func (m *VolumesCloneRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *VolumesCloneRequest) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *VolumesCloneRequest) UnmarshalBinary(b []byte) error { + var res VolumesCloneRequest + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_clone_response.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_clone_response.go new file mode 100644 index 00000000000..09ecf72c26f --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_clone_response.go @@ -0,0 +1,53 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// VolumesCloneResponse volumes clone response +// +// swagger:model VolumesCloneResponse +type VolumesCloneResponse struct { + + // ID of the new cloned volume + AdditionalProperties string `json:"additionalProperties,omitempty"` + + // A map of volume IDs to cloned volume IDs + ClonedVolumes interface{} `json:"clonedVolumes,omitempty"` +} + +// Validate validates this volumes clone response +func (m *VolumesCloneResponse) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this volumes clone response based on context it is used +func (m *VolumesCloneResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *VolumesCloneResponse) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *VolumesCloneResponse) UnmarshalBinary(b []byte) error { + var res VolumesCloneResponse + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_clones.go b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_clones.go new file mode 100644 index 00000000000..33bcab36fbf --- /dev/null +++ b/vendor/github.com/IBM-Cloud/power-go-client/power/models/volumes_clones.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// VolumesClones volumes clones +// +// swagger:model VolumesClones +type VolumesClones struct { + + // list of volumes-clone requests + VolumesClone []*VolumesClone `json:"volumesClone"` +} + +// Validate validates this volumes clones +func (m *VolumesClones) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateVolumesClone(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *VolumesClones) validateVolumesClone(formats strfmt.Registry) error { + if swag.IsZero(m.VolumesClone) { // not required + return nil + } + + for i := 0; i < len(m.VolumesClone); i++ { + if swag.IsZero(m.VolumesClone[i]) { // not required + continue + } + + if m.VolumesClone[i] != nil { + if err := m.VolumesClone[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("volumesClone" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("volumesClone" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this volumes clones based on the context it is used +func (m *VolumesClones) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateVolumesClone(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *VolumesClones) contextValidateVolumesClone(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.VolumesClone); i++ { + + if m.VolumesClone[i] != nil { + if err := m.VolumesClone[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("volumesClone" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("volumesClone" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *VolumesClones) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *VolumesClones) UnmarshalBinary(b []byte) error { + var res VolumesClones + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/vendor/github.com/IBM/go-sdk-core/v5/core/authenticator_factory.go b/vendor/github.com/IBM/go-sdk-core/v5/core/authenticator_factory.go index fba1de6e815..b02bc1efcc7 100644 --- a/vendor/github.com/IBM/go-sdk-core/v5/core/authenticator_factory.go +++ b/vendor/github.com/IBM/go-sdk-core/v5/core/authenticator_factory.go @@ -1,6 +1,6 @@ package core -// (C) Copyright IBM Corp. 2019. +// (C) Copyright IBM Corp. 2019, 2021. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -27,10 +27,22 @@ func GetAuthenticatorFromEnvironment(credentialKey string) (authenticator Authen return } - // Default the authentication type to IAM if not specified. + // Determine the authentication type if not specified explicitly. authType := properties[PROPNAME_AUTH_TYPE] + + // Support alternate "AUTHTYPE" property. + if authType == "" { + authType = properties["AUTHTYPE"] + } + + // Determine a default auth type if one wasn't specified. if authType == "" { - authType = AUTHTYPE_IAM + // If the APIKEY property is specified, then we'll guess IAM... otherwise CR Auth. + if properties[PROPNAME_APIKEY] != "" { + authType = AUTHTYPE_IAM + } else { + authType = AUTHTYPE_CONTAINER + } } // Create the authenticator appropriate for the auth type. @@ -40,6 +52,10 @@ func GetAuthenticatorFromEnvironment(credentialKey string) (authenticator Authen authenticator, err = newBearerTokenAuthenticatorFromMap(properties) } else if strings.EqualFold(authType, AUTHTYPE_IAM) { authenticator, err = newIamAuthenticatorFromMap(properties) + } else if strings.EqualFold(authType, AUTHTYPE_CONTAINER) { + authenticator, err = newContainerAuthenticatorFromMap(properties) + } else if strings.EqualFold(authType, AUTHTYPE_VPC) { + authenticator, err = newVpcInstanceAuthenticatorFromMap(properties) } else if strings.EqualFold(authType, AUTHTYPE_CP4D) { authenticator, err = newCloudPakForDataAuthenticatorFromMap(properties) } else if strings.EqualFold(authType, AUTHTYPE_NOAUTH) { diff --git a/vendor/github.com/IBM/go-sdk-core/v5/core/base_service.go b/vendor/github.com/IBM/go-sdk-core/v5/core/base_service.go index e4b8b1bb780..c124c12d544 100644 --- a/vendor/github.com/IBM/go-sdk-core/v5/core/base_service.go +++ b/vendor/github.com/IBM/go-sdk-core/v5/core/base_service.go @@ -241,8 +241,7 @@ func (service *BaseService) DisableSSLVerification() { client := DefaultHTTPClient() tr, ok := client.Transport.(*http.Transport) if tr != nil && ok { - /* #nosec G402 */ - tr.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} + tr.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} // #nosec G402 } service.SetHTTPClient(client) @@ -306,6 +305,15 @@ func (service *BaseService) Request(req *http.Request, result interface{}) (deta for k, v := range service.DefaultHeaders { req.Header.Add(k, strings.Join(v, "")) } + + // After adding the default headers, make one final check to see if the user + // specified the "Host" header within the default headers. + // This needs to be handled separately because it will be ignored by + // the Request.Write() method. + host := service.DefaultHeaders.Get("Host") + if host != "" { + req.Host = host + } } // Add the default User-Agent header if not already present. @@ -334,9 +342,9 @@ func (service *BaseService) Request(req *http.Request, result interface{}) (deta if GetLogger().IsLogLevelEnabled(LevelDebug) { buf, dumpErr := httputil.DumpRequestOut(req, req.Body != nil) if dumpErr == nil { - GetLogger().Debug(fmt.Sprintf("Request:\n%s\n", string(buf))) + GetLogger().Debug("Request:\n%s\n", RedactSecrets(string(buf))) } else { - GetLogger().Debug(fmt.Sprintf("error while attempting to log outbound request: %s", dumpErr.Error())) + GetLogger().Debug("error while attempting to log outbound request: %s", dumpErr.Error()) } } @@ -370,9 +378,9 @@ func (service *BaseService) Request(req *http.Request, result interface{}) (deta if GetLogger().IsLogLevelEnabled(LevelDebug) { buf, dumpErr := httputil.DumpResponse(httpResponse, httpResponse.Body != nil) if err == nil { - GetLogger().Debug(fmt.Sprintf("Response:\n%s\n", string(buf))) + GetLogger().Debug("Response:\n%s\n", RedactSecrets(string(buf))) } else { - GetLogger().Debug(fmt.Sprintf("error while attempting to log inbound response: %s", dumpErr.Error())) + GetLogger().Debug("error while attempting to log inbound response: %s", dumpErr.Error()) } } @@ -430,10 +438,11 @@ func (service *BaseService) Request(req *http.Request, result interface{}) (deta // Operation was successful and we are expecting a response, so process the response. if !IsNil(result) { + resultType := reflect.TypeOf(result).String() // If 'result' is a io.ReadCloser, then pass the response body back reflectively via 'result' // and bypass any further unmarshalling of the response. - if reflect.TypeOf(result).String() == "*io.ReadCloser" { + if resultType == "*io.ReadCloser" { rResult := reflect.ValueOf(result).Elem() rResult.Set(reflect.ValueOf(httpResponse.Body)) detailedResponse.Result = httpResponse.Body @@ -472,24 +481,24 @@ func (service *BaseService) Request(req *http.Request, result interface{}) (deta // Check to see if the caller wanted the response body as a string. // If the caller passed in 'result' as the address of *string, // then we'll reflectively set result to point to it. - if reflect.TypeOf(result).String() == "**string" { + if resultType == "**string" { responseString := string(responseBody) rResult := reflect.ValueOf(result).Elem() rResult.Set(reflect.ValueOf(&responseString)) // And set the string in the Result field. detailedResponse.Result = &responseString - } else if reflect.TypeOf(result).String() == "*[]uint8" { // byte is an alias for uint8 + } else if resultType == "*[]uint8" { // byte is an alias for uint8 rResult := reflect.ValueOf(result).Elem() rResult.Set(reflect.ValueOf(responseBody)) // And set the byte slice in the Result field. detailedResponse.Result = responseBody } else { - // At this point, we don't know how to set the result field, so we have to return an error + // At this point, we don't know how to set the result field, so we have to return an error. // But make sure we save the bytes we read in the DetailedResponse for debugging purposes detailedResponse.Result = responseBody - err = fmt.Errorf(ERRORMSG_UNEXPECTED_RESPONSE) + err = fmt.Errorf(ERRORMSG_UNEXPECTED_RESPONSE, contentType, resultType) return } } @@ -600,7 +609,10 @@ type httpLogger struct { } func (l *httpLogger) Printf(format string, inserts ...interface{}) { - GetLogger().Log(LevelDebug, format, inserts...) + if GetLogger().IsLogLevelEnabled(LevelDebug) { + msg := fmt.Sprintf(format, inserts...) + GetLogger().Log(LevelDebug, RedactSecrets(msg)) + } } // NewRetryableHTTPClient returns a new instance of go-retryablehttp.Client @@ -678,18 +690,11 @@ func IBMCloudSDKRetryPolicy(ctx context.Context, resp *http.Response, err error) // Now check the status code. // A 429 should be retryable. - if resp.StatusCode == 429 { + // All codes in the 500's range except for 501 (Not Implemented) should be retryable. + if resp.StatusCode == 429 || (resp.StatusCode >= 500 && resp.StatusCode <= 599 && resp.StatusCode != 501) { return true, nil } - // Check the response code. We retry on 500-range responses to allow - // the server time to recover, as 500's are typically not permanent - // errors and may relate to outages on the server side. This will catch - // invalid response codes as well, like 0 and 999. - if resp.StatusCode == 0 || (resp.StatusCode >= 500 && resp.StatusCode != 501) { - return true, fmt.Errorf(ERRORMSG_UNEXPECTED_STATUS_CODE, resp.StatusCode, resp.Status) - } - return false, nil } diff --git a/vendor/github.com/IBM/go-sdk-core/v5/core/config_utils.go b/vendor/github.com/IBM/go-sdk-core/v5/core/config_utils.go index a4861080b87..8268cdd3956 100644 --- a/vendor/github.com/IBM/go-sdk-core/v5/core/config_utils.go +++ b/vendor/github.com/IBM/go-sdk-core/v5/core/config_utils.go @@ -113,13 +113,11 @@ func getServicePropertiesFromCredentialFile(credentialKey string) map[string]str // If we found a file to load, then load it. if credentialFilePath != "" { - /* #nosec G304 */ - file, err := os.Open(credentialFilePath) + file, err := os.Open(credentialFilePath) // #nosec G304 if err != nil { return nil } - /* #nosec G307 */ - defer file.Close() + defer file.Close() // #nosec G307 // Collect the contents of the credential file in a string array. lines := make([]string, 0) diff --git a/vendor/github.com/IBM/go-sdk-core/v5/core/constants.go b/vendor/github.com/IBM/go-sdk-core/v5/core/constants.go index 1d83d2f2b61..b02274edfd5 100644 --- a/vendor/github.com/IBM/go-sdk-core/v5/core/constants.go +++ b/vendor/github.com/IBM/go-sdk-core/v5/core/constants.go @@ -21,6 +21,8 @@ const ( AUTHTYPE_NOAUTH = "noAuth" AUTHTYPE_IAM = "iam" AUTHTYPE_CP4D = "cp4d" + AUTHTYPE_CONTAINER = "container" + AUTHTYPE_VPC = "vpc" // Names of properties that can be defined as part of an external configuration (credential file, env vars, etc.). // Example: export MYSERVICE_URL=https://myurl @@ -41,9 +43,14 @@ const ( PROPNAME_AUTH_URL = "AUTH_URL" PROPNAME_AUTH_DISABLE_SSL = "AUTH_DISABLE_SSL" PROPNAME_APIKEY = "APIKEY" + PROPNAME_REFRESH_TOKEN = "REFRESH_TOKEN" // #nosec G101 PROPNAME_CLIENT_ID = "CLIENT_ID" PROPNAME_CLIENT_SECRET = "CLIENT_SECRET" PROPNAME_SCOPE = "SCOPE" + PROPNAME_CRTOKEN_FILENAME = "CR_TOKEN_FILENAME" // #nosec G101 + PROPNAME_IAM_PROFILE_CRN = "IAM_PROFILE_CRN" + PROPNAME_IAM_PROFILE_NAME = "IAM_PROFILE_NAME" + PROPNAME_IAM_PROFILE_ID = "IAM_PROFILE_ID" // SSL error SSL_CERTIFICATION_ERROR = "x509: certificate" @@ -52,6 +59,8 @@ const ( ERRORMSG_PROP_MISSING = "The %s property is required but was not specified." ERRORMSG_PROP_INVALID = "The %s property is invalid. Please remove any surrounding {, }, or \" characters." ERRORMSG_EXCLUSIVE_PROPS_ERROR = "Exactly one of %s or %s must be specified." + ERRORMSG_ATLEAST_ONE_PROP_ERROR = "At least one of %s or %s must be specified." + ERRORMSG_ATMOST_ONE_PROP_ERROR = "At most one of %s or %s may be specified." ERRORMSG_NO_AUTHENTICATOR = "Authentication information was not properly configured." ERRORMSG_AUTHTYPE_UNKNOWN = "Unrecognized authentication type: %s" ERRORMSG_PROPS_MAP_NIL = "The 'properties' map cannot be nil." @@ -61,7 +70,7 @@ const ( "and/or use the DisableSSLVerification option of the authenticator." ERRORMSG_AUTHENTICATE_ERROR = "An error occurred while performing the 'authenticate' step: %s" ERRORMSG_READ_RESPONSE_BODY = "An error occurred while reading the response body: %s" - ERRORMSG_UNEXPECTED_RESPONSE = "The response contained unexpected content" + ERRORMSG_UNEXPECTED_RESPONSE = "The response contained unexpected content, Content-Type=%s, operation resultType=%s" ERRORMSG_UNMARSHAL_RESPONSE_BODY = "An error occurred while unmarshalling the response body: %s" ERRORMSG_NIL_SLICE = "The 'slice' parameter cannot be nil" ERRORMSG_PARAM_NOT_SLICE = "The 'slice' parameter must be a slice" @@ -70,4 +79,8 @@ const ( ERRORMSG_CREATE_RETRYABLE_REQ = "An error occurred while creating a retryable http Request: %s" ERRORMSG_UNEXPECTED_STATUS_CODE = "Unexpected HTTP status code %d (%s)" ERRORMSG_UNMARSHAL_AUTH_RESPONSE = "error unmarshalling authentication response: %s" + ERRORMSG_UNABLE_RETRIEVE_CRTOKEN = "unable to retrieve compute resource token value: %s" // #nosec G101 + ERRORMSG_IAM_GETTOKEN_ERROR = "IAM 'get token' error, status code %d received from '%s': %s" // #nosec G101 + ERRORMSG_UNABLE_RETRIEVE_IITOKEN = "unable to retrieve instance identity token value: %s" // #nosec G101 + ERRORMSG_VPCMDS_OPERATION_ERROR = "VPC metadata service error, status code %d received from '%s': %s" ) diff --git a/vendor/github.com/IBM/go-sdk-core/v5/core/container_authenticator.go b/vendor/github.com/IBM/go-sdk-core/v5/core/container_authenticator.go new file mode 100644 index 00000000000..ff732837599 --- /dev/null +++ b/vendor/github.com/IBM/go-sdk-core/v5/core/container_authenticator.go @@ -0,0 +1,494 @@ +package core + +// (C) Copyright IBM Corp. 2021. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import ( + "bytes" + "crypto/tls" + "encoding/json" + "fmt" + "io/ioutil" + "net/http" + "net/http/httputil" + "strconv" + "strings" + "sync" + "time" +) + +// ContainerAuthenticator implements an IAM-based authentication schema whereby it +// retrieves a "compute resource token" from the local compute resource (VM) +// and uses that to obtain an IAM access token by invoking the IAM "get token" operation with grant-type=cr-token. +// The resulting IAM access token is then added to outbound requests in an Authorization header +// of the form: +// Authorization: Bearer +// +type ContainerAuthenticator struct { + + // [optional] The name of the file containing the injected CR token value (applies to + // IKS-managed compute resources). + // Default value: "/var/run/secrets/tokens/vault-token" + CRTokenFilename string + + // [optional] The name of the linked trusted IAM profile to be used when obtaining the IAM access token. + // One of IAMProfileName or IAMProfileID must be specified. + // Default value: "" + IAMProfileName string + + // [optional] The id of the linked trusted IAM profile to be used when obtaining the IAM access token. + // One of IAMProfileName or IAMProfileID must be specified. + // Default value: "" + IAMProfileID string + + // [optional] The IAM token server's base endpoint URL. + // Default value: "https://iam.cloud.ibm.com" + URL string + + // [optional] The ClientID and ClientSecret fields are used to form a "basic auth" + // Authorization header for interactions with the IAM token server. + // If neither field is specified, then no Authorization header will be sent + // with token server requests. + // These fields are both optional, but must be specified together. + // Default value: "" + ClientID string + ClientSecret string + + // [optional] A flag that indicates whether verification of the server's SSL certificate + // should be disabled. + // Default value: false + DisableSSLVerification bool + + // [optional] The "scope" to use when fetching the access token from the IAM token server. + // This can be used to obtain an access token with a specific scope. + // Default value: "" + Scope string + + // [optional] A set of key/value pairs that will be sent as HTTP headers in requests + // made to the IAM token server. + // Default value: nil + Headers map[string]string + + // [optional] The http.Client object used in interacts with the IAM token server. + // If not specified by the user, a suitable default Client will be constructed. + Client *http.Client + + // The cached IAM access token and its expiration time. + tokenData *iamTokenData + + // Mutex to synchronize access to the tokenData field. + tokenDataMutex sync.Mutex +} + +const ( + defaultCRTokenFilename = "/var/run/secrets/tokens/vault-token" // #nosec G101 + iamGrantTypeCRToken = "urn:ibm:params:oauth:grant-type:cr-token" // #nosec G101 +) + +var craRequestTokenMutex sync.Mutex + +// ContainerAuthenticatorBuilder is used to construct an instance of the ContainerAuthenticator +type ContainerAuthenticatorBuilder struct { + ContainerAuthenticator +} + +// NewContainerAuthenticatorBuilder returns a new builder struct that +// can be used to construct a ContainerAuthenticator instance. +func NewContainerAuthenticatorBuilder() *ContainerAuthenticatorBuilder { + return &ContainerAuthenticatorBuilder{} +} + +// SetCRTokenFilename sets the CRTokenFilename field in the builder. +func (builder *ContainerAuthenticatorBuilder) SetCRTokenFilename(s string) *ContainerAuthenticatorBuilder { + builder.ContainerAuthenticator.CRTokenFilename = s + return builder +} + +// SetIAMProfileName sets the IAMProfileName field in the builder. +func (builder *ContainerAuthenticatorBuilder) SetIAMProfileName(s string) *ContainerAuthenticatorBuilder { + builder.ContainerAuthenticator.IAMProfileName = s + return builder +} + +// SetIAMProfileID sets the IAMProfileID field in the builder. +func (builder *ContainerAuthenticatorBuilder) SetIAMProfileID(s string) *ContainerAuthenticatorBuilder { + builder.ContainerAuthenticator.IAMProfileID = s + return builder +} + +// SetURL sets the URL field in the builder. +func (builder *ContainerAuthenticatorBuilder) SetURL(s string) *ContainerAuthenticatorBuilder { + builder.ContainerAuthenticator.URL = s + return builder +} + +// SetClientIDSecret sets the ClientID and ClientSecret fields in the builder. +func (builder *ContainerAuthenticatorBuilder) SetClientIDSecret(clientID, clientSecret string) *ContainerAuthenticatorBuilder { + builder.ContainerAuthenticator.ClientID = clientID + builder.ContainerAuthenticator.ClientSecret = clientSecret + return builder +} + +// SetDisableSSLVerification sets the DisableSSLVerification field in the builder. +func (builder *ContainerAuthenticatorBuilder) SetDisableSSLVerification(b bool) *ContainerAuthenticatorBuilder { + builder.ContainerAuthenticator.DisableSSLVerification = b + return builder +} + +// SetScope sets the Scope field in the builder. +func (builder *ContainerAuthenticatorBuilder) SetScope(s string) *ContainerAuthenticatorBuilder { + builder.ContainerAuthenticator.Scope = s + return builder +} + +// SetHeaders sets the Headers field in the builder. +func (builder *ContainerAuthenticatorBuilder) SetHeaders(headers map[string]string) *ContainerAuthenticatorBuilder { + builder.ContainerAuthenticator.Headers = headers + return builder +} + +// SetClient sets the Client field in the builder. +func (builder *ContainerAuthenticatorBuilder) SetClient(client *http.Client) *ContainerAuthenticatorBuilder { + builder.ContainerAuthenticator.Client = client + return builder +} + +// Build() returns a validated instance of the ContainerAuthenticator with the config that was set in the builder. +func (builder *ContainerAuthenticatorBuilder) Build() (*ContainerAuthenticator, error) { + + // Make sure the config is valid. + err := builder.ContainerAuthenticator.Validate() + if err != nil { + return nil, err + } + + return &builder.ContainerAuthenticator, nil +} + +// newContainerAuthenticatorFromMap constructs a new ContainerAuthenticator instance from a map containing +// configuration properties. +func newContainerAuthenticatorFromMap(properties map[string]string) (authenticator *ContainerAuthenticator, err error) { + if properties == nil { + return nil, fmt.Errorf(ERRORMSG_PROPS_MAP_NIL) + } + + // Grab the AUTH_DISABLE_SSL string property and convert to a boolean value. + disableSSL, err := strconv.ParseBool(properties[PROPNAME_AUTH_DISABLE_SSL]) + if err != nil { + disableSSL = false + } + + authenticator, err = NewContainerAuthenticatorBuilder(). + SetCRTokenFilename(properties[PROPNAME_CRTOKEN_FILENAME]). + SetIAMProfileName(properties[PROPNAME_IAM_PROFILE_NAME]). + SetIAMProfileID(properties[PROPNAME_IAM_PROFILE_ID]). + SetURL(properties[PROPNAME_AUTH_URL]). + SetClientIDSecret(properties[PROPNAME_CLIENT_ID], properties[PROPNAME_CLIENT_SECRET]). + SetDisableSSLVerification(disableSSL). + SetScope(properties[PROPNAME_SCOPE]). + Build() + + return +} + +// AuthenticationType returns the authentication type for this authenticator. +func (*ContainerAuthenticator) AuthenticationType() string { + return AUTHTYPE_CONTAINER +} + +// Authenticate adds IAM authentication information to the request. +// +// The IAM access token will be added to the request's headers in the form: +// +// Authorization: Bearer +// +func (authenticator *ContainerAuthenticator) Authenticate(request *http.Request) error { + token, err := authenticator.GetToken() + if err != nil { + return err + } + + request.Header.Set("Authorization", "Bearer "+token) + return nil +} + +// getTokenData returns the tokenData field from the authenticator with synchronization. +func (authenticator *ContainerAuthenticator) getTokenData() *iamTokenData { + authenticator.tokenDataMutex.Lock() + defer authenticator.tokenDataMutex.Unlock() + + return authenticator.tokenData +} + +// setTokenData sets the 'tokenData' field in the authenticator with synchronization. +func (authenticator *ContainerAuthenticator) setTokenData(tokenData *iamTokenData) { + authenticator.tokenDataMutex.Lock() + defer authenticator.tokenDataMutex.Unlock() + + authenticator.tokenData = tokenData +} + +// Validate the authenticator's configuration. +// +// Ensures that one of IAMProfileName or IAMProfileID are specified, and the ClientId and ClientSecret pair are +// mutually inclusive. +func (authenticator *ContainerAuthenticator) Validate() error { + + // Check to make sure that one of IAMProfileName or IAMProfileID are specified. + if authenticator.IAMProfileName == "" && authenticator.IAMProfileID == "" { + return fmt.Errorf(ERRORMSG_ATLEAST_ONE_PROP_ERROR, "IAMProfileName", "IAMProfileID") + } + + // Validate ClientId and ClientSecret. They must both be specified togther or neither should be specified. + if authenticator.ClientID == "" && authenticator.ClientSecret == "" { + // Do nothing as this is the valid scenario + } else { + // Since it is NOT the case that both properties are empty, make sure BOTH are specified. + if authenticator.ClientID == "" { + return fmt.Errorf(ERRORMSG_PROP_MISSING, "ClientID") + } + + if authenticator.ClientSecret == "" { + return fmt.Errorf(ERRORMSG_PROP_MISSING, "ClientSecret") + } + } + + return nil +} + +// GetToken returns an access token to be used in an Authorization header. +// Whenever a new token is needed (when a token doesn't yet exist or the existing token has expired), +// a new access token is fetched from the token server. +func (authenticator *ContainerAuthenticator) GetToken() (string, error) { + if authenticator.getTokenData() == nil || !authenticator.getTokenData().isTokenValid() { + GetLogger().Debug("Performing synchronous token fetch...") + // synchronously request the token + err := authenticator.synchronizedRequestToken() + if err != nil { + return "", err + } + } else if authenticator.getTokenData().needsRefresh() { + GetLogger().Debug("Performing background asynchronous token fetch...") + // If refresh needed, kick off a go routine in the background to get a new token + //nolint: errcheck + go authenticator.invokeRequestTokenData() + } else { + GetLogger().Debug("Using cached access token...") + } + + // return an error if the access token is not valid or was not fetched + if authenticator.getTokenData() == nil || authenticator.getTokenData().AccessToken == "" { + return "", fmt.Errorf("Error while trying to get access token") + } + + return authenticator.getTokenData().AccessToken, nil +} + +// synchronizedRequestToken will check if the authenticator currently has +// a valid cached access token. +// If yes, then nothing else needs to be done. +// If no, then a blocking request is made to obtain a new IAM access token. +func (authenticator *ContainerAuthenticator) synchronizedRequestToken() error { + craRequestTokenMutex.Lock() + defer craRequestTokenMutex.Unlock() + // if cached token is still valid, then just continue to use it + if authenticator.getTokenData() != nil && authenticator.getTokenData().isTokenValid() { + return nil + } + + return authenticator.invokeRequestTokenData() +} + +// invokeRequestTokenData requests a new token from the IAM token server and +// unmarshals the response to produce the authenticator's 'tokenData' field (cache). +// Returns an error if the token was unable to be fetched, otherwise returns nil. +func (authenticator *ContainerAuthenticator) invokeRequestTokenData() error { + tokenResponse, err := authenticator.RequestToken() + if err != nil { + return err + } + + if tokenData, err := newIamTokenData(tokenResponse); err != nil { + return err + } else { + authenticator.setTokenData(tokenData) + } + + return nil +} + +// RequestToken first retrieves a CR token value from the current compute resource, then uses +// that to obtain a new IAM access token from the IAM token server. +func (authenticator *ContainerAuthenticator) RequestToken() (*IamTokenServerResponse, error) { + var err error + var operationPath string = "/identity/token" + + // First, retrieve the CR token value for this compute resource. + crToken, err := authenticator.retrieveCRToken() + if crToken == "" { + if err == nil { + err = fmt.Errorf(ERRORMSG_UNABLE_RETRIEVE_CRTOKEN, "reason unknown") + } + return nil, NewAuthenticationError(&DetailedResponse{}, err) + } + + // Use the default IAM URL if one was not specified by the user. + url := authenticator.URL + if url == "" { + url = defaultIamTokenServerEndpoint + } else { + // Canonicalize the URL by removing the operation path if it was specified by the user. + url = strings.TrimSuffix(url, operationPath) + } + + // Set up the request for the IAM "get token" invocation. + builder := NewRequestBuilder(POST) + _, err = builder.ResolveRequestURL(url, operationPath, nil) + if err != nil { + return nil, NewAuthenticationError(&DetailedResponse{}, err) + } + + builder.AddHeader(CONTENT_TYPE, FORM_URL_ENCODED_HEADER) + builder.AddHeader(Accept, APPLICATION_JSON) + builder.AddFormData("grant_type", "", "", iamGrantTypeCRToken) // #nosec G101 + builder.AddFormData("cr_token", "", "", crToken) + + // We previously verified that one of IBMProfileID or IAMProfileName are specified, + // so just process them individually here. + // If both are specified, that's ok too (they must map to the same profile though). + if authenticator.IAMProfileID != "" { + builder.AddFormData("profile_id", "", "", authenticator.IAMProfileID) + } + if authenticator.IAMProfileName != "" { + builder.AddFormData("profile_name", "", "", authenticator.IAMProfileName) + } + + // If the scope was specified, add that form param to the request. + if authenticator.Scope != "" { + builder.AddFormData("scope", "", "", authenticator.Scope) + } + + // Add user-defined headers to request. + for headerName, headerValue := range authenticator.Headers { + builder.AddHeader(headerName, headerValue) + } + + req, err := builder.Build() + if err != nil { + return nil, NewAuthenticationError(&DetailedResponse{}, err) + } + + // If client id and secret were configured by the user, then set them on the request + // as a basic auth header. + if authenticator.ClientID != "" && authenticator.ClientSecret != "" { + req.SetBasicAuth(authenticator.ClientID, authenticator.ClientSecret) + } + + // If the authenticator does not have a Client, create one now. + if authenticator.Client == nil { + authenticator.Client = &http.Client{ + Timeout: time.Second * 30, + } + + // If the user told us to disable SSL verification, then do it now. + if authenticator.DisableSSLVerification { + transport := &http.Transport{ + // #nosec G402 + TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, + } + authenticator.Client.Transport = transport + } + } + + // If debug is enabled, then dump the request. + if GetLogger().IsLogLevelEnabled(LevelDebug) { + buf, dumpErr := httputil.DumpRequestOut(req, req.Body != nil) + if dumpErr == nil { + GetLogger().Debug("Request:\n%s\n", RedactSecrets(string(buf))) + } else { + GetLogger().Debug(fmt.Sprintf("error while attempting to log outbound request: %s", dumpErr.Error())) + } + } + + GetLogger().Debug("Invoking IAM 'get token' operation: %s", builder.URL) + resp, err := authenticator.Client.Do(req) + if err != nil { + return nil, NewAuthenticationError(&DetailedResponse{}, err) + } + GetLogger().Debug("Returned from IAM 'get token' operation, received status code %d", resp.StatusCode) + + // If debug is enabled, then dump the response. + if GetLogger().IsLogLevelEnabled(LevelDebug) { + buf, dumpErr := httputil.DumpResponse(resp, req.Body != nil) + if dumpErr == nil { + GetLogger().Debug("Response:\n%s\n", RedactSecrets(string(buf))) + } else { + GetLogger().Debug(fmt.Sprintf("error while attempting to log inbound response: %s", dumpErr.Error())) + } + } + + // Check for a bad status code and handle an operation error. + if resp.StatusCode < 200 || resp.StatusCode >= 300 { + buff := new(bytes.Buffer) + _, _ = buff.ReadFrom(resp.Body) + resp.Body.Close() // #nosec G104 + + // Create a DetailedResponse to be included in the error below. + detailedResponse := &DetailedResponse{ + StatusCode: resp.StatusCode, + Headers: resp.Header, + RawResult: buff.Bytes(), + } + + iamErrorMsg := string(detailedResponse.RawResult) + if iamErrorMsg == "" { + iamErrorMsg = "IAM error response not available" + } + err = fmt.Errorf(ERRORMSG_IAM_GETTOKEN_ERROR, detailedResponse.StatusCode, builder.URL, iamErrorMsg) + return nil, NewAuthenticationError(detailedResponse, err) + } + + // Good response, so unmarshal the response body into an IamTokenServerResponse instance. + tokenResponse := &IamTokenServerResponse{} + _ = json.NewDecoder(resp.Body).Decode(tokenResponse) + defer resp.Body.Close() + + return tokenResponse, nil +} + +// retrieveCRToken tries to read the CR token value from the local file system. +func (authenticator *ContainerAuthenticator) retrieveCRToken() (crToken string, err error) { + + // Use the default filename if one wasn't supplied by the user. + crTokenFilename := authenticator.CRTokenFilename + if crTokenFilename == "" { + crTokenFilename = defaultCRTokenFilename + } + + GetLogger().Debug("Attempting to read CR token from file: %s\n", crTokenFilename) + + // Read the entire file into a byte slice, then convert to string. + var bytes []byte + bytes, err = ioutil.ReadFile(crTokenFilename) // #nosec G304 + if err != nil { + err = fmt.Errorf(ERRORMSG_UNABLE_RETRIEVE_CRTOKEN, err.Error()) + GetLogger().Debug(err.Error()) + return + } + + crToken = string(bytes) + GetLogger().Debug("Successfully read CR token from file: %s\n", crTokenFilename) + + return +} diff --git a/vendor/github.com/IBM/go-sdk-core/v5/core/cp4d_authenticator.go b/vendor/github.com/IBM/go-sdk-core/v5/core/cp4d_authenticator.go index bd2b46b09f7..3b0d5aacf71 100644 --- a/vendor/github.com/IBM/go-sdk-core/v5/core/cp4d_authenticator.go +++ b/vendor/github.com/IBM/go-sdk-core/v5/core/cp4d_authenticator.go @@ -20,6 +20,7 @@ import ( "encoding/json" "fmt" "net/http" + "net/http/httputil" "strconv" "sync" "time" @@ -164,7 +165,7 @@ func (authenticator *CloudPakForDataAuthenticator) Validate() error { // Authorization: Bearer // func (authenticator *CloudPakForDataAuthenticator) Authenticate(request *http.Request) error { - token, err := authenticator.getToken() + token, err := authenticator.GetToken() if err != nil { return err } @@ -189,10 +190,10 @@ func (authenticator *CloudPakForDataAuthenticator) setTokenData(tokenData *cp4dT authenticator.tokenData = tokenData } -// getToken: returns an access token to be used in an Authorization header. +// GetToken: returns an access token to be used in an Authorization header. // Whenever a new token is needed (when a token doesn't yet exist, needs to be refreshed, // or the existing token has expired), a new access token is fetched from the token server. -func (authenticator *CloudPakForDataAuthenticator) getToken() (string, error) { +func (authenticator *CloudPakForDataAuthenticator) GetToken() (string, error) { if authenticator.getTokenData() == nil || !authenticator.getTokenData().isTokenValid() { // synchronously request the token err := authenticator.synchronizedRequestToken() @@ -302,17 +303,39 @@ func (authenticator *CloudPakForDataAuthenticator) requestToken() (tokenResponse // If the user told us to disable SSL verification, then do it now. if authenticator.DisableSSLVerification { transport := &http.Transport{ - /* #nosec G402 */ + // #nosec G402 TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, } authenticator.Client.Transport = transport } } + // If debug is enabled, then dump the request. + if GetLogger().IsLogLevelEnabled(LevelDebug) { + buf, dumpErr := httputil.DumpRequestOut(req, req.Body != nil) + if dumpErr == nil { + GetLogger().Debug("Request:\n%s\n", RedactSecrets(string(buf))) + } else { + GetLogger().Debug(fmt.Sprintf("error while attempting to log outbound request: %s", dumpErr.Error())) + } + } + + GetLogger().Debug("Invoking CP4D token service operation: %s", builder.URL) resp, err := authenticator.Client.Do(req) if err != nil { return } + GetLogger().Debug("Returned from CP4D token service operation, received status code %d", resp.StatusCode) + + // If debug is enabled, then dump the response. + if GetLogger().IsLogLevelEnabled(LevelDebug) { + buf, dumpErr := httputil.DumpResponse(resp, req.Body != nil) + if dumpErr == nil { + GetLogger().Debug("Response:\n%s\n", RedactSecrets(string(buf))) + } else { + GetLogger().Debug(fmt.Sprintf("error while attempting to log inbound response: %s", dumpErr.Error())) + } + } if resp.StatusCode < 200 || resp.StatusCode >= 300 { buff := new(bytes.Buffer) diff --git a/vendor/github.com/IBM/go-sdk-core/v5/core/datetime.go b/vendor/github.com/IBM/go-sdk-core/v5/core/datetime.go index 11bd6799240..0a8bcf839d0 100644 --- a/vendor/github.com/IBM/go-sdk-core/v5/core/datetime.go +++ b/vendor/github.com/IBM/go-sdk-core/v5/core/datetime.go @@ -73,7 +73,12 @@ func NormalizeDateTimeUTC(t time.Time) time.Time { } // ParseDate parses the specified RFC3339 full-date string (YYYY-MM-DD) and returns a strfmt.Date instance. +// If the string is empty the return value will be the unix epoch (1970-01-01). func ParseDate(dateString string) (fmtDate strfmt.Date, err error) { + if dateString == "" { + return strfmt.Date(time.Unix(0, 0).UTC()), nil + } + formattedTime, err := time.Parse(strfmt.RFC3339FullDate, dateString) if err == nil { fmtDate = strfmt.Date(formattedTime) @@ -82,6 +87,7 @@ func ParseDate(dateString string) (fmtDate strfmt.Date, err error) { } // ParseDateTime parses the specified date-time string and returns a strfmt.DateTime instance. +// If the string is empty the return value will be the unix epoch (1970-01-01T00:00:00.000Z). func ParseDateTime(dateString string) (strfmt.DateTime, error) { return strfmt.ParseDateTime(dateString) } diff --git a/vendor/github.com/IBM/go-sdk-core/v5/core/file_with_metadata.go b/vendor/github.com/IBM/go-sdk-core/v5/core/file_with_metadata.go index d0a3f8d59f3..578c59bec97 100644 --- a/vendor/github.com/IBM/go-sdk-core/v5/core/file_with_metadata.go +++ b/vendor/github.com/IBM/go-sdk-core/v5/core/file_with_metadata.go @@ -56,8 +56,7 @@ func UnmarshalFileWithMetadata(m map[string]json.RawMessage, result interface{}) if err != nil { return } - /* #nosec G304 */ - data, err = os.Open(pathToData) + data, err = os.Open(pathToData) // #nosec G304 if err != nil { return } diff --git a/vendor/github.com/IBM/go-sdk-core/v5/core/gzip.go b/vendor/github.com/IBM/go-sdk-core/v5/core/gzip.go index 9121129f4c0..1a834736511 100644 --- a/vendor/github.com/IBM/go-sdk-core/v5/core/gzip.go +++ b/vendor/github.com/IBM/go-sdk-core/v5/core/gzip.go @@ -41,7 +41,7 @@ func NewGzipCompressionReader(uncompressedReader io.Reader) (io.Reader, error) { // to the pipe only when the pipe reader is called to retrieve more bytes. _, err := io.Copy(compressedWriter, uncompressedReader) if err != nil { - panic(err) + _ = pipeWriter.CloseWithError(err) } }() return pipeReader, nil diff --git a/vendor/github.com/IBM/go-sdk-core/v5/core/iam_authenticator.go b/vendor/github.com/IBM/go-sdk-core/v5/core/iam_authenticator.go index 307e9e904a6..6a3247e45e0 100644 --- a/vendor/github.com/IBM/go-sdk-core/v5/core/iam_authenticator.go +++ b/vendor/github.com/IBM/go-sdk-core/v5/core/iam_authenticator.go @@ -1,6 +1,6 @@ package core -// (C) Copyright IBM Corp. 2019. +// (C) Copyright IBM Corp. 2019, 2021. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -20,49 +20,43 @@ import ( "encoding/json" "fmt" "net/http" + "net/http/httputil" "strconv" "strings" "sync" "time" ) -// IamAuthenticator-related constants. -const ( - DEFAULT_IAM_URL = "https://iam.cloud.ibm.com" - OPERATION_PATH = "/identity/token" - DEFAULT_CONTENT_TYPE = "application/x-www-form-urlencoded" - /* #nosec G101 */ - REQUEST_TOKEN_GRANT_TYPE = "urn:ibm:params:oauth:grant-type:apikey" - REQUEST_TOKEN_RESPONSE_TYPE = "cloud_iam" -) - -// IamAuthenticator uses an apikey to obtain a suitable bearer token value, -// and adds the bearer token to requests via an Authorization header +// IamAuthenticator uses an apikey to obtain an IAM access token, +// and adds the access token to requests via an Authorization header // of the form: // -// Authorization: Bearer +// Authorization: Bearer // type IamAuthenticator struct { - // The apikey used to fetch the bearer token from the IAM token server - // [required]. + // The apikey used to fetch the bearer token from the IAM token server. + // You must specify either ApiKey or RefreshToken. ApiKey string + // The refresh token used to fetch the bearer token from the IAM token server. + // You must specify either ApiKey or RefreshToken. + // If this property is specified, then you also must supply appropriate values + // for the ClientId and ClientSecret properties (i.e. they must be the same + // values that were used to obtain the refresh token). + RefreshToken string + // The URL representing the IAM token server's endpoint; If not specified, // a suitable default value will be used [optional]. URL string // The ClientId and ClientSecret fields are used to form a "basic auth" - // Authorization header for interactions with the IAM token server - - // If neither field is specified, then no Authorization header will be sent - // with token server requests [optional]. These fields are optional, but must - // be specified together. - ClientId string + // Authorization header for interactions with the IAM token server. // If neither field is specified, then no Authorization header will be sent // with token server requests [optional]. These fields are optional, but must // be specified together. + ClientId string ClientSecret string // A flag that indicates whether verification of the server's SSL certificate @@ -92,29 +86,103 @@ type IamAuthenticator struct { var iamRequestTokenMutex sync.Mutex var iamNeedsRefreshMutex sync.Mutex -// NewIamAuthenticator constructs a new IamAuthenticator instance. -func NewIamAuthenticator(apikey string, url string, clientId string, clientSecret string, - disableSSLVerification bool, headers map[string]string) (*IamAuthenticator, error) { - authenticator := &IamAuthenticator{ - ApiKey: apikey, - URL: url, - ClientId: clientId, - ClientSecret: clientSecret, - DisableSSLVerification: disableSSLVerification, - Headers: headers, - } +const ( + // The default (prod) IAM token server base endpoint address. + defaultIamTokenServerEndpoint = "https://iam.cloud.ibm.com" // #nosec G101 + iamAuthOperationPathGetToken = "/identity/token" + iamAuthGrantTypeApiKey = "urn:ibm:params:oauth:grant-type:apikey" // #nosec G101 + iamAuthGrantTypeRefreshToken = "refresh_token" // #nosec G101 +) + +// IamAuthenticatorBuilder is used to construct an IamAuthenticator instance. +type IamAuthenticatorBuilder struct { + IamAuthenticator +} + +// NewIamAuthenticatorBuilder returns a new builder struct that +// can be used to construct an IamAuthenticator instance. +func NewIamAuthenticatorBuilder() *IamAuthenticatorBuilder { + return &IamAuthenticatorBuilder{} +} + +// SetApiKey sets the ApiKey field in the builder. +func (builder *IamAuthenticatorBuilder) SetApiKey(s string) *IamAuthenticatorBuilder { + builder.IamAuthenticator.ApiKey = s + return builder +} + +// SetRefreshToken sets the RefreshToken field in the builder. +func (builder *IamAuthenticatorBuilder) SetRefreshToken(s string) *IamAuthenticatorBuilder { + builder.IamAuthenticator.RefreshToken = s + return builder +} + +// SetURL sets the URL field in the builder. +func (builder *IamAuthenticatorBuilder) SetURL(s string) *IamAuthenticatorBuilder { + builder.IamAuthenticator.URL = s + return builder +} + +// SetClientIDSecret sets the ClientId and ClientSecret fields in the builder. +func (builder *IamAuthenticatorBuilder) SetClientIDSecret(clientID, clientSecret string) *IamAuthenticatorBuilder { + builder.IamAuthenticator.ClientId = clientID + builder.IamAuthenticator.ClientSecret = clientSecret + return builder +} + +// SetDisableSSLVerification sets the DisableSSLVerification field in the builder. +func (builder *IamAuthenticatorBuilder) SetDisableSSLVerification(b bool) *IamAuthenticatorBuilder { + builder.IamAuthenticator.DisableSSLVerification = b + return builder +} + +// SetScope sets the Scope field in the builder. +func (builder *IamAuthenticatorBuilder) SetScope(s string) *IamAuthenticatorBuilder { + builder.IamAuthenticator.Scope = s + return builder +} + +// SetHeaders sets the Headers field in the builder. +func (builder *IamAuthenticatorBuilder) SetHeaders(headers map[string]string) *IamAuthenticatorBuilder { + builder.IamAuthenticator.Headers = headers + return builder +} + +// SetClient sets the Client field in the builder. +func (builder *IamAuthenticatorBuilder) SetClient(client *http.Client) *IamAuthenticatorBuilder { + builder.IamAuthenticator.Client = client + return builder +} + +// Build() returns a validated instance of the IamAuthenticator with the config that was set in the builder. +func (builder *IamAuthenticatorBuilder) Build() (*IamAuthenticator, error) { // Make sure the config is valid. - err := authenticator.Validate() + err := builder.IamAuthenticator.Validate() if err != nil { return nil, err } - return authenticator, nil + return &builder.IamAuthenticator, nil } -// NewIamAuthenticatorFromMap constructs a new IamAuthenticator instance from a -// map. +// NewIamAuthenticator constructs a new IamAuthenticator instance. +// Deprecated - use the IamAuthenticatorBuilder instead. +func NewIamAuthenticator(apiKey string, url string, clientId string, clientSecret string, + disableSSLVerification bool, headers map[string]string) (*IamAuthenticator, error) { + + authenticator, err := NewIamAuthenticatorBuilder(). + SetApiKey(apiKey). + SetURL(url). + SetClientIDSecret(clientId, clientSecret). + SetDisableSSLVerification(disableSSLVerification). + SetHeaders(headers). + Build() + + return authenticator, err +} + +// newIamAuthenticatorFromMap constructs a new IamAuthenticator instance from a map. func newIamAuthenticatorFromMap(properties map[string]string) (authenticator *IamAuthenticator, err error) { if properties == nil { return nil, fmt.Errorf(ERRORMSG_PROPS_MAP_NIL) @@ -125,12 +193,15 @@ func newIamAuthenticatorFromMap(properties map[string]string) (authenticator *Ia disableSSL = false } - authenticator, err = NewIamAuthenticator(properties[PROPNAME_APIKEY], properties[PROPNAME_AUTH_URL], - properties[PROPNAME_CLIENT_ID], properties[PROPNAME_CLIENT_SECRET], - disableSSL, nil) - if authenticator != nil { - authenticator.Scope = properties[PROPNAME_SCOPE] - } + authenticator, err = NewIamAuthenticatorBuilder(). + SetApiKey(properties[PROPNAME_APIKEY]). + SetRefreshToken(properties[PROPNAME_REFRESH_TOKEN]). + SetURL(properties[PROPNAME_AUTH_URL]). + SetClientIDSecret(properties[PROPNAME_CLIENT_ID], properties[PROPNAME_CLIENT_SECRET]). + SetDisableSSLVerification(disableSSL). + SetScope(properties[PROPNAME_SCOPE]). + Build() + return } @@ -146,12 +217,12 @@ func (*IamAuthenticator) AuthenticationType() string { // Authorization: Bearer // func (authenticator *IamAuthenticator) Authenticate(request *http.Request) error { - token, err := authenticator.getToken() + token, err := authenticator.GetToken() if err != nil { return err } - request.Header.Set("Authorization", fmt.Sprintf(`Bearer %s`, token)) + request.Header.Set("Authorization", "Bearer "+token) return nil } @@ -169,23 +240,40 @@ func (authenticator *IamAuthenticator) setTokenData(tokenData *iamTokenData) { defer authenticator.tokenDataMutex.Unlock() authenticator.tokenData = tokenData + + // Next, we should save the just-returned refresh token back to the main + // authenticator struct. + // This is done so that if we were originally configured with + // a refresh token, then we'll be sure to use a "fresh" + // refresh token next time we invoke the "get token" operation. + // This was recommended by the IAM team to avoid problems in the future + // if the token service is changed to invalidate an existing refresh token + // when a new one is generated and returned in the response. + if tokenData != nil { + authenticator.RefreshToken = tokenData.RefreshToken + } } // Validate the authenticator's configuration. // -// Ensures the ApiKey is valid, and the ClientId and ClientSecret pair are -// mutually inclusive. +// Ensures that the ApiKey and RefreshToken properties are mutually exclusive, +// and that the ClientId and ClientSecret properties are mutually inclusive. func (this *IamAuthenticator) Validate() error { - if this.ApiKey == "" { - return fmt.Errorf(ERRORMSG_PROP_MISSING, "ApiKey") + + // The user should specify exactly one of ApiKey or RefreshToken. + if this.ApiKey == "" && this.RefreshToken == "" || + this.ApiKey != "" && this.RefreshToken != "" { + return fmt.Errorf(ERRORMSG_EXCLUSIVE_PROPS_ERROR, "ApiKey", "RefreshToken") } - if HasBadFirstOrLastChar(this.ApiKey) { + if this.ApiKey != "" && HasBadFirstOrLastChar(this.ApiKey) { return fmt.Errorf(ERRORMSG_PROP_INVALID, "ApiKey") } - // Validate ClientId and ClientSecret. They must both be specified togther or neither should be specified. - if this.ClientId == "" && this.ClientSecret == "" { + // Validate ClientId and ClientSecret. + // If RefreshToken is not specified, then both or neither should be specified. + // If RefreshToken is specified, then both must be specified. + if this.ClientId == "" && this.ClientSecret == "" && this.RefreshToken == "" { // Do nothing as this is the valid scenario } else { // Since it is NOT the case that both properties are empty, make sure BOTH are specified. @@ -201,10 +289,10 @@ func (this *IamAuthenticator) Validate() error { return nil } -// getToken: returns an access token to be used in an Authorization header. +// GetToken: returns an access token to be used in an Authorization header. // Whenever a new token is needed (when a token doesn't yet exist, needs to be refreshed, // or the existing token has expired), a new access token is fetched from the token server. -func (authenticator *IamAuthenticator) getToken() (string, error) { +func (authenticator *IamAuthenticator) GetToken() (string, error) { if authenticator.getTokenData() == nil || !authenticator.getTokenData().isTokenValid() { // synchronously request the token err := authenticator.synchronizedRequestToken() @@ -259,26 +347,38 @@ func (authenticator *IamAuthenticator) invokeRequestTokenData() error { // RequestToken fetches a new access token from the token server. func (authenticator *IamAuthenticator) RequestToken() (*IamTokenServerResponse, error) { + // Use the default IAM URL if one was not specified by the user. url := authenticator.URL if url == "" { - url = DEFAULT_IAM_URL + url = defaultIamTokenServerEndpoint } else { // Canonicalize the URL by removing the operation path if it was specified by the user. - url = strings.TrimSuffix(url, OPERATION_PATH) + url = strings.TrimSuffix(url, iamAuthOperationPathGetToken) } builder := NewRequestBuilder(POST) - _, err := builder.ResolveRequestURL(url, OPERATION_PATH, nil) + _, err := builder.ResolveRequestURL(url, iamAuthOperationPathGetToken, nil) if err != nil { return nil, err } - builder.AddHeader(CONTENT_TYPE, DEFAULT_CONTENT_TYPE). - AddHeader(Accept, APPLICATION_JSON). - AddFormData("grant_type", "", "", REQUEST_TOKEN_GRANT_TYPE). - AddFormData("apikey", "", "", authenticator.ApiKey). - AddFormData("response_type", "", "", REQUEST_TOKEN_RESPONSE_TYPE) + builder.AddHeader(CONTENT_TYPE, "application/x-www-form-urlencoded") + builder.AddHeader(Accept, APPLICATION_JSON) + builder.AddFormData("response_type", "", "", "cloud_iam") + + if authenticator.ApiKey != "" { + // If ApiKey was configured, then use grant_type "apikey" to obtain an access token. + builder.AddFormData("grant_type", "", "", iamAuthGrantTypeApiKey) + builder.AddFormData("apikey", "", "", authenticator.ApiKey) + } else if authenticator.RefreshToken != "" { + // Otherwise, if RefreshToken was configured then use grant_type "refresh_token". + builder.AddFormData("grant_type", "", "", iamAuthGrantTypeRefreshToken) + builder.AddFormData("refresh_token", "", "", authenticator.RefreshToken) + } else { + // We shouldn't ever get here due to prior validations, but just in case, let's log an error. + return nil, fmt.Errorf(ERRORMSG_EXCLUSIVE_PROPS_ERROR, "ApiKey", "RefreshToken") + } // Add any optional parameters to the request. if authenticator.Scope != "" { @@ -297,6 +397,8 @@ func (authenticator *IamAuthenticator) RequestToken() (*IamTokenServerResponse, // If client id and secret were configured by the user, then set them on the request // as a basic auth header. + // Our previous validation step would have made sure that both values are specified + // if the RefreshToken property was specified. if authenticator.ClientId != "" && authenticator.ClientSecret != "" { req.SetBasicAuth(authenticator.ClientId, authenticator.ClientSecret) } @@ -310,17 +412,39 @@ func (authenticator *IamAuthenticator) RequestToken() (*IamTokenServerResponse, // If the user told us to disable SSL verification, then do it now. if authenticator.DisableSSLVerification { transport := &http.Transport{ - /* #nosec G402 */ + // #nosec G402 TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, } authenticator.Client.Transport = transport } } + // If debug is enabled, then dump the request. + if GetLogger().IsLogLevelEnabled(LevelDebug) { + buf, dumpErr := httputil.DumpRequestOut(req, req.Body != nil) + if dumpErr == nil { + GetLogger().Debug("Request:\n%s\n", RedactSecrets(string(buf))) + } else { + GetLogger().Debug(fmt.Sprintf("error while attempting to log outbound request: %s", dumpErr.Error())) + } + } + + GetLogger().Debug("Invoking IAM 'get token' operation: %s", builder.URL) resp, err := authenticator.Client.Do(req) if err != nil { return nil, err } + GetLogger().Debug("Returned from IAM 'get token' operation, received status code %d", resp.StatusCode) + + // If debug is enabled, then dump the response. + if GetLogger().IsLogLevelEnabled(LevelDebug) { + buf, dumpErr := httputil.DumpResponse(resp, req.Body != nil) + if dumpErr == nil { + GetLogger().Debug("Response:\n%s\n", RedactSecrets(string(buf))) + } else { + GetLogger().Debug(fmt.Sprintf("error while attempting to log inbound response: %s", dumpErr.Error())) + } + } if resp.StatusCode < 200 || resp.StatusCode >= 300 { buff := new(bytes.Buffer) @@ -358,9 +482,10 @@ type IamTokenServerResponse struct { // iamTokenData : This struct represents the cached information related to a fetched access token. type iamTokenData struct { - AccessToken string - RefreshTime int64 - Expiration int64 + AccessToken string + RefreshToken string + RefreshTime int64 + Expiration int64 } // newIamTokenData: constructs a new IamTokenData instance from the specified IamTokenServerResponse instance. @@ -375,9 +500,10 @@ func newIamTokenData(tokenResponse *IamTokenServerResponse) (*iamTokenData, erro refreshTime := expireTime - int64(float64(timeToLive)*0.2) tokenData := &iamTokenData{ - AccessToken: tokenResponse.AccessToken, - Expiration: expireTime, - RefreshTime: refreshTime, + AccessToken: tokenResponse.AccessToken, + RefreshToken: tokenResponse.RefreshToken, + Expiration: expireTime, + RefreshTime: refreshTime, } return tokenData, nil @@ -405,5 +531,4 @@ func (this *iamTokenData) needsRefresh() bool { } return false - } diff --git a/vendor/github.com/IBM/go-sdk-core/v5/core/jwt_utils.go b/vendor/github.com/IBM/go-sdk-core/v5/core/jwt_utils.go index 7916c964bff..117669eb9e0 100644 --- a/vendor/github.com/IBM/go-sdk-core/v5/core/jwt_utils.go +++ b/vendor/github.com/IBM/go-sdk-core/v5/core/jwt_utils.go @@ -15,11 +15,10 @@ package core // limitations under the License. import ( + "encoding/base64" "encoding/json" "fmt" "strings" - - jwt "github.com/form3tech-oss/jwt-go" ) // coreJWTClaims are the fields within a JWT's "claims" segment that we're interested in. @@ -39,7 +38,7 @@ func parseJWT(tokenString string) (claims *coreJWTClaims, err error) { // Parse Claims segment. var claimBytes []byte - claimBytes, err = jwt.DecodeSegment(segments[1]) + claimBytes, err = decodeSegment(segments[1]) if err != nil { err = fmt.Errorf("error decoding claims segment: %s", err.Error()) return @@ -55,3 +54,13 @@ func parseJWT(tokenString string) (claims *coreJWTClaims, err error) { return } + +// Decode JWT specific base64url encoding with padding stripped +// Copied from https://github.com/golang-jwt/jwt/blob/main/token.go +func decodeSegment(seg string) ([]byte, error) { + if l := len(seg) % 4; l > 0 { + seg += strings.Repeat("=", 4-l) + } + + return base64.URLEncoding.DecodeString(seg) +} diff --git a/vendor/github.com/IBM/go-sdk-core/v5/core/parameterized_url.go b/vendor/github.com/IBM/go-sdk-core/v5/core/parameterized_url.go new file mode 100644 index 00000000000..a2c672b7d6c --- /dev/null +++ b/vendor/github.com/IBM/go-sdk-core/v5/core/parameterized_url.go @@ -0,0 +1,74 @@ +package core + +// (C) Copyright IBM Corp. 2021. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import ( + "fmt" + "sort" + "strings" +) + +// +// ConstructServiceURL returns a service URL that is constructed by formatting a parameterized URL. +// +// Parameters: +// +// parameterizedUrl: URL that contains variable placeholders, e.g. "{scheme}://ibm.com". +// +// defaultUrlVariables: map from variable names to default values. +// Each variable in the parameterized URL must have a default value specified in this map. +// +// providedUrlVariables: map from variable names to desired values. +// If a variable is not provided in this map, +// the default variable value will be used instead. +// +func ConstructServiceURL( + parameterizedUrl string, + defaultUrlVariables map[string]string, + providedUrlVariables map[string]string, +) (string, error) { + + // Verify the provided variable names. + for providedName := range providedUrlVariables { + if _, ok := defaultUrlVariables[providedName]; !ok { + // Get all accepted variable names (the keys of the default variables map). + var acceptedNames []string + for name := range defaultUrlVariables { + acceptedNames = append(acceptedNames, name) + } + sort.Strings(acceptedNames) + + return "", fmt.Errorf( + "'%s' is an invalid variable name.\nValid variable names: %s.", + providedName, + acceptedNames, + ) + } + } + + // Format the URL with provided or default variable values. + formattedUrl := parameterizedUrl + + for name, defaultValue := range defaultUrlVariables { + providedValue, ok := providedUrlVariables[name] + + // Use the default variable value if none was provided. + if !ok { + providedValue = defaultValue + } + formattedUrl = strings.Replace(formattedUrl, "{"+name+"}", providedValue, 1) + } + return formattedUrl, nil +} diff --git a/vendor/github.com/IBM/go-sdk-core/v5/core/request_builder.go b/vendor/github.com/IBM/go-sdk-core/v5/core/request_builder.go index 249d41abdcc..bdd549cdbed 100644 --- a/vendor/github.com/IBM/go-sdk-core/v5/core/request_builder.go +++ b/vendor/github.com/IBM/go-sdk-core/v5/core/request_builder.go @@ -348,6 +348,13 @@ func (requestBuilder *RequestBuilder) Build() (req *http.Request, err error) { // Headers req.Header = requestBuilder.Header + // If "Host" was specified as a header, we need to explicitly copy it + // to the request's Host field since the "Host" header will be ignored by Request.Write(). + host := req.Header.Get("Host") + if host != "" { + req.Host = host + } + // Query query := req.URL.Query() for k, l := range requestBuilder.Query { diff --git a/vendor/github.com/IBM/go-sdk-core/v5/core/utils.go b/vendor/github.com/IBM/go-sdk-core/v5/core/utils.go index 7f34192a6c1..43645ad596e 100644 --- a/vendor/github.com/IBM/go-sdk-core/v5/core/utils.go +++ b/vendor/github.com/IBM/go-sdk-core/v5/core/utils.go @@ -33,14 +33,13 @@ import ( // Validate is a shared validator instance used to perform validation of structs. var Validate *validator.Validate -var re = regexp.MustCompile(`(?s)\[(\S*)\]`) func init() { Validate = validator.New() } const ( - jsonMimePattern = "(?i)^application\\/((json)|(merge\\-patch\\+json))(;.*)?$" + jsonMimePattern = "(?i)^application\\/((json)|(merge\\-patch\\+json)|(vnd\\..*\\+json))(;.*)?$" jsonPatchMimePattern = "(?i)^application\\/json\\-patch\\+json(;.*)?$" ) @@ -189,7 +188,11 @@ func GetCurrentTime() int64 { return time.Now().Unix() } -// ConvertSlice Marshals 'slice' to a json string, performs +// Pre-compiled regular expression used to remove the surrounding +// [] characters from a JSON string containing a slice (e.g. `["str1", "str2", "str3"]`). +var reJsonSlice = regexp.MustCompile(`(?s)\[(\S*)\]`) + +// ConvertSlice marshals 'slice' to a json string, performs // string manipulation on the resulting string, and converts // the string to a '[]string'. If 'slice' is nil, not a 'slice' type, // or an error occurred during conversion, an error will be returned @@ -228,7 +231,7 @@ func ConvertSlice(slice interface{}) (s []string, err error) { jsonString := string(jsonBuffer) // Use regex to convert the json string to a string slice - match := re.FindStringSubmatch(jsonString) + match := reJsonSlice.FindStringSubmatch(jsonString) if match != nil && match[1] != "" { newString := match[1] s = strings.Split(newString, ",") @@ -263,8 +266,8 @@ func SliceContains(slice []string, contains string) bool { return false } -// return a pointer to the value of query parameter `param` from url, -// or nil when not found +// GetQueryParam() returns a pointer to the value of query parameter `param` from urlStr, +// or nil if not found. func GetQueryParam(urlStr *string, param string) (*string, error) { if urlStr == nil || *urlStr == "" { return nil, nil @@ -286,3 +289,20 @@ func GetQueryParam(urlStr *string, param string) (*string, error) { } return &v, nil } + +// Pre-compiled regular expressions used by RedactSecrets(). +var reAuthHeader = regexp.MustCompile(`(?m)^(Authorization|X-Auth\S*): .*`) +var rePassword1 = regexp.MustCompile(`(?i)(password|token|apikey|api_key|passcode)=[^&]*(&|$)`) +var rePassword2 = regexp.MustCompile(`(?i)"([^"]*(password|token|apikey|api_key)[^"_]*)":\s*"[^\,]*"`) + +// RedactSecrets() returns the input string with secrets redacted. +func RedactSecrets(input string) string { + var redacted = "[redacted]" + + redactedString := input + redactedString = reAuthHeader.ReplaceAllString(redactedString, "$1: "+redacted) + redactedString = rePassword1.ReplaceAllString(redactedString, "$1="+redacted+"$2") + redactedString = rePassword2.ReplaceAllString(redactedString, fmt.Sprintf(`"$1":"%s"`, redacted)) + + return redactedString +} diff --git a/vendor/github.com/IBM/go-sdk-core/v5/core/version.go b/vendor/github.com/IBM/go-sdk-core/v5/core/version.go index 09cb161bb81..9f8c0a039a9 100644 --- a/vendor/github.com/IBM/go-sdk-core/v5/core/version.go +++ b/vendor/github.com/IBM/go-sdk-core/v5/core/version.go @@ -15,4 +15,4 @@ package core // limitations under the License. // Version of the SDK -const __VERSION__ = "5.4.3" +const __VERSION__ = "5.9.1" diff --git a/vendor/github.com/IBM/go-sdk-core/v5/core/vpc_instance_authenticator.go b/vendor/github.com/IBM/go-sdk-core/v5/core/vpc_instance_authenticator.go new file mode 100644 index 00000000000..e0130d7ee20 --- /dev/null +++ b/vendor/github.com/IBM/go-sdk-core/v5/core/vpc_instance_authenticator.go @@ -0,0 +1,515 @@ +package core + +// (C) Copyright IBM Corp. 2021. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import ( + "bytes" + "encoding/json" + "fmt" + "net/http" + "net/http/httputil" + "sync" + "time" + + "github.com/go-openapi/strfmt" +) + +// VpcInstanceAuthenticator implements an authentication scheme in which it +// retrieves an "instance identity token" and exchanges that for an IAM access token using the +// VPC Instance Metadata Service API which is available on the local compute resource (VM). +// The instance identity token is similar to an IAM apikey, except that it is managed +// automatically by the compute resource provider (VPC). +// The resulting IAM access token is then added to outbound requests in an Authorization header +// of the form: +// Authorization: Bearer +// +type VpcInstanceAuthenticator struct { + + // [optional] The CRN of the linked trusted IAM profile to be used as the identity of the compute resource. + // At most one of IAMProfileCRN or IAMProfileID may be specified. If neither one is specified, then + // the default IAM profile defined for the compute resource will be used. + // Default value: "" + IAMProfileCRN string + + // [optional] The ID of the linked trusted IAM profile to be used when obtaining the IAM access token. + // At most one of IAMProfileCRN or IAMProfileID may be specified. If neither one is specified, then + // the default IAM profile defined for the compute resource will be used. + // Default value: "" + IAMProfileID string + + // [optional] The VPC Instance Metadata Service's base endpoint URL. + // Default value: "http://169.254.169.254" + URL string + urlInit sync.Once + + // [optional] The http.Client object used to interact with the VPC Instance Metadata Service API. + // If not specified by the user, a suitable default Client will be constructed. + Client *http.Client + clientInit sync.Once + + // The cached IAM access token and its expiration time. + tokenData *iamTokenData + + // Mutex to synchronize access to the tokenData field. + tokenDataMutex sync.Mutex +} + +const ( + vpcauthDefaultIMSEndpoint = "http://169.254.169.254" + vpcauthOperationPathCreateAccessToken = "/instance_identity/v1/token" + vpcauthOperationPathCreateIamToken = "/instance_identity/v1/iam_token" + vpcauthMetadataFlavor = "ibm" + vpcauthMetadataServiceVersion = "2021-09-20" + vpcauthInstanceIdentityTokenLifetime = 300 + vpcauthDefaultTimeout = time.Second * 30 +) + +// VpcInstanceAuthenticatorBuilder is used to construct an instance of the VpcInstanceAuthenticator +type VpcInstanceAuthenticatorBuilder struct { + VpcInstanceAuthenticator +} + +// NewVpcInstanceAuthenticatorBuilder returns a new builder struct that +// can be used to construct a VpcInstanceAuthenticator instance. +func NewVpcInstanceAuthenticatorBuilder() *VpcInstanceAuthenticatorBuilder { + return &VpcInstanceAuthenticatorBuilder{} +} + +// SetIAMProfileCRN sets the IAMProfileCRN field in the builder. +func (builder *VpcInstanceAuthenticatorBuilder) SetIAMProfileCRN(s string) *VpcInstanceAuthenticatorBuilder { + builder.VpcInstanceAuthenticator.IAMProfileCRN = s + return builder +} + +// SetIAMProfileID sets the IAMProfileID field in the builder. +func (builder *VpcInstanceAuthenticatorBuilder) SetIAMProfileID(s string) *VpcInstanceAuthenticatorBuilder { + builder.VpcInstanceAuthenticator.IAMProfileID = s + return builder +} + +// SetURL sets the URL field in the builder. +func (builder *VpcInstanceAuthenticatorBuilder) SetURL(s string) *VpcInstanceAuthenticatorBuilder { + builder.VpcInstanceAuthenticator.URL = s + return builder +} + +// SetClient sets the Client field in the builder. +func (builder *VpcInstanceAuthenticatorBuilder) SetClient(client *http.Client) *VpcInstanceAuthenticatorBuilder { + builder.VpcInstanceAuthenticator.Client = client + return builder +} + +// Build() returns a validated instance of the VpcInstanceAuthenticator with the config that was set in the builder. +func (builder *VpcInstanceAuthenticatorBuilder) Build() (*VpcInstanceAuthenticator, error) { + + // Make sure the config is valid. + err := builder.VpcInstanceAuthenticator.Validate() + if err != nil { + return nil, err + } + + return &builder.VpcInstanceAuthenticator, nil +} + +// client returns the authenticator's http client after potentially initializing it. +func (authenticator *VpcInstanceAuthenticator) client() *http.Client { + authenticator.clientInit.Do(func() { + if authenticator.Client == nil { + authenticator.Client = &http.Client{ + Timeout: vpcauthDefaultTimeout, + } + } + }) + return authenticator.Client +} + +// url returns the authenticator's URL property after potentially initializing it. +func (authenticator *VpcInstanceAuthenticator) url() string { + authenticator.urlInit.Do(func() { + if authenticator.URL == "" { + authenticator.URL = vpcauthDefaultIMSEndpoint + } + }) + return authenticator.URL +} + +// newVpcInstanceAuthenticatorFromMap constructs a new VpcInstanceAuthenticator instance from a map containing +// configuration properties. +func newVpcInstanceAuthenticatorFromMap(properties map[string]string) (authenticator *VpcInstanceAuthenticator, err error) { + if properties == nil { + return nil, fmt.Errorf(ERRORMSG_PROPS_MAP_NIL) + } + + authenticator, err = NewVpcInstanceAuthenticatorBuilder(). + SetIAMProfileCRN(properties[PROPNAME_IAM_PROFILE_CRN]). + SetIAMProfileID(properties[PROPNAME_IAM_PROFILE_ID]). + SetURL(properties[PROPNAME_AUTH_URL]). + Build() + + return +} + +// AuthenticationType returns the authentication type for this authenticator. +func (*VpcInstanceAuthenticator) AuthenticationType() string { + return AUTHTYPE_VPC +} + +// Authenticate adds IAM authentication information to the request. +// +// The IAM access token will be added to the request's headers in the form: +// +// Authorization: Bearer +// +func (authenticator *VpcInstanceAuthenticator) Authenticate(request *http.Request) error { + token, err := authenticator.GetToken() + if err != nil { + return err + } + + request.Header.Set("Authorization", "Bearer "+token) + return nil +} + +// getTokenData returns the tokenData field from the authenticator with synchronization. +func (authenticator *VpcInstanceAuthenticator) getTokenData() *iamTokenData { + authenticator.tokenDataMutex.Lock() + defer authenticator.tokenDataMutex.Unlock() + + return authenticator.tokenData +} + +// setTokenData sets the 'tokenData' field in the authenticator with synchronization. +func (authenticator *VpcInstanceAuthenticator) setTokenData(tokenData *iamTokenData) { + authenticator.tokenDataMutex.Lock() + defer authenticator.tokenDataMutex.Unlock() + + authenticator.tokenData = tokenData +} + +// Validate the authenticator's configuration. +// +// Ensures that one of IAMProfileName or IAMProfileID are specified, and the ClientId and ClientSecret pair are +// mutually inclusive. +func (authenticator *VpcInstanceAuthenticator) Validate() error { + + // Check to make sure that at most one of IAMProfileCRN or IAMProfileID are specified. + if authenticator.IAMProfileCRN != "" && authenticator.IAMProfileID != "" { + return fmt.Errorf(ERRORMSG_ATMOST_ONE_PROP_ERROR, "IAMProfileCRN", "IAMProfileID") + } + + return nil +} + +// GetToken returns an IAM access token to be used in an Authorization header. +// Whenever a new IAM access token is needed (when a token doesn't yet exist or the existing token has expired), +// a new IAM access token is fetched from the token server. +func (authenticator *VpcInstanceAuthenticator) GetToken() (string, error) { + if authenticator.getTokenData() == nil || !authenticator.getTokenData().isTokenValid() { + GetLogger().Debug("Performing synchronous token fetch...") + // synchronously request the token + err := authenticator.synchronizedRequestToken() + if err != nil { + return "", err + } + } else if authenticator.getTokenData().needsRefresh() { + GetLogger().Debug("Performing background asynchronous token fetch...") + // If refresh needed, kick off a go routine in the background to get a new token + //nolint: errcheck + go authenticator.invokeRequestTokenData() + } else { + GetLogger().Debug("Using cached access token...") + } + + // return an error if the access token is not valid or was not fetched + if authenticator.getTokenData() == nil || authenticator.getTokenData().AccessToken == "" { + return "", fmt.Errorf("Error while trying to get access token") + } + + return authenticator.getTokenData().AccessToken, nil +} + +// vpcRequestTokenMutex is used to synchronize access to requesting a new IAM access token. +var vpcRequestTokenMutex sync.Mutex + +// synchronizedRequestToken will check if the authenticator currently has +// a valid cached access token. +// If yes, then nothing else needs to be done. +// If no, then a blocking request is made to obtain a new IAM access token. +func (authenticator *VpcInstanceAuthenticator) synchronizedRequestToken() error { + vpcRequestTokenMutex.Lock() + defer vpcRequestTokenMutex.Unlock() + // if cached token is still valid, then just continue to use it + if authenticator.getTokenData() != nil && authenticator.getTokenData().isTokenValid() { + return nil + } + + return authenticator.invokeRequestTokenData() +} + +// invokeRequestTokenData will invoke RequestToken() to obtain a new IAM access token, +// then caches the resulting "tokenData" on the authenticator. +// Returns nil if successful, or non-nil if an error occurred. +func (authenticator *VpcInstanceAuthenticator) invokeRequestTokenData() error { + tokenResponse, err := authenticator.RequestToken() + if err != nil { + return err + } + + if tokenData, err := newIamTokenData(tokenResponse); err != nil { + return err + } else { + authenticator.setTokenData(tokenData) + } + + return nil +} + +// RequestToken will use the VPC Instance Metadata Service to (1) retrieve a fresh instance identity token +// and then (2) exchange that for an IAM access token. +func (authenticator *VpcInstanceAuthenticator) RequestToken() (iamTokenResponse *IamTokenServerResponse, err error) { + + // Use the default VPC base endpoint if user didn't specifiy the URL property. + if authenticator.URL == "" { + authenticator.URL = vpcauthDefaultIMSEndpoint + } + + // Retrieve the instance identity token from the VPC Instance Metadata Service. + instanceIdentityToken, err := authenticator.retrieveInstanceIdentityToken() + if err != nil { + return + } + + // Next, exchange the instance identity token for an IAM access token. + iamTokenResponse, err = authenticator.retrieveIamAccessToken(instanceIdentityToken) + if err != nil { + return + } + + return +} + +// vpcTokenResponse describes the response body for both the 'create_access_token' and 'create_iam_token' +// operations (i.e. the response body has the same structure for both operations). +// Note: this struct was generated from the VPC metadata service API definition. +type vpcTokenResponse struct { + // The access token. + AccessToken *string `json:"access_token" validate:"required"` + + // The date and time that the access token was created. + CreatedAt *strfmt.DateTime `json:"created_at" validate:"required"` + + // The date and time that the access token will expire. + ExpiresAt *strfmt.DateTime `json:"expires_at" validate:"required"` + + // Time in seconds before the access token expires. + ExpiresIn *int64 `json:"expires_in" validate:"required"` +} + +// retrieveIamAccessToken will use the VPC "create_iam_token" operation to exchange the +// compute resource's instance identity token for an IAM access token that can be used +// to authenticate outbound REST requests targeting IAM-secured services. +func (authenticator *VpcInstanceAuthenticator) retrieveIamAccessToken( + instanceIdentityToken string) (iamTokenResponse *IamTokenServerResponse, err error) { + + // Set up the request for the VPC "create_iam_token" operation. + builder := NewRequestBuilder(POST) + _, err = builder.ResolveRequestURL(authenticator.url(), vpcauthOperationPathCreateIamToken, nil) + if err != nil { + err = NewAuthenticationError(&DetailedResponse{}, err) + return + } + + // Set the params and request body. + builder.AddQuery("version", vpcauthMetadataServiceVersion) + builder.AddHeader(CONTENT_TYPE, APPLICATION_JSON) + builder.AddHeader(Accept, APPLICATION_JSON) + builder.AddHeader("Authorization", "Bearer "+instanceIdentityToken) + + // Next, construct the optional request body to specify the linked IAM profile. + // We previously verified that at most one of IBMProfileCRN or IAMProfileID was specified by the user, + // so just process them individually here and create the appropriate request body if needed. + // If neither property was specified by the user, then no request body is sent with the request. + var requestBody string + if authenticator.IAMProfileCRN != "" { + requestBody = fmt.Sprintf(`{"trusted_profile": {"crn": "%s"}}`, authenticator.IAMProfileCRN) + } + if authenticator.IAMProfileID != "" { + requestBody = fmt.Sprintf(`{"trusted_profile": {"id": "%s"}}`, authenticator.IAMProfileID) + } + if requestBody != "" { + _, _ = builder.SetBodyContentString(requestBody) + } + + // Build the request. + req, err := builder.Build() + if err != nil { + return nil, NewAuthenticationError(&DetailedResponse{}, err) + } + + // If debug is enabled, then dump the request. + if GetLogger().IsLogLevelEnabled(LevelDebug) { + buf, dumpErr := httputil.DumpRequestOut(req, req.Body != nil) + if dumpErr == nil { + GetLogger().Debug("Request:\n%s\n", string(buf)) + } else { + GetLogger().Debug(fmt.Sprintf("error while attempting to log outbound request: %s", dumpErr.Error())) + } + } + + GetLogger().Debug("Invoking VPC 'create_iam_token' operation: %s", builder.URL) + resp, err := authenticator.client().Do(req) + if err != nil { + return nil, NewAuthenticationError(&DetailedResponse{}, err) + } + GetLogger().Debug("Returned from VPC 'create_iam_token' operation, received status code %d", resp.StatusCode) + + // If debug is enabled, then dump the response. + if GetLogger().IsLogLevelEnabled(LevelDebug) { + buf, dumpErr := httputil.DumpResponse(resp, resp.Body != nil) + if dumpErr == nil { + GetLogger().Debug("Response:\n%s\n", string(buf)) + } else { + GetLogger().Debug(fmt.Sprintf("error while attempting to log inbound response: %s", dumpErr.Error())) + } + } + + // Check for a bad status code and handle an operation error. + if resp.StatusCode < 200 || resp.StatusCode >= 300 { + buff := new(bytes.Buffer) + _, _ = buff.ReadFrom(resp.Body) + resp.Body.Close() // #nosec G104 + + // Create a DetailedResponse to be included in the error below. + detailedResponse := &DetailedResponse{ + StatusCode: resp.StatusCode, + Headers: resp.Header, + RawResult: buff.Bytes(), + } + + vpcErrorMsg := string(detailedResponse.RawResult) + if vpcErrorMsg == "" { + vpcErrorMsg = "Operation 'create_iam_token' error response not available" + } + err = fmt.Errorf(ERRORMSG_VPCMDS_OPERATION_ERROR, detailedResponse.StatusCode, builder.URL, vpcErrorMsg) + return nil, NewAuthenticationError(detailedResponse, err) + } + + // Good response, so unmarshal the response body into a vpcTokenResponse instance. + tokenResponse := &vpcTokenResponse{} + _ = json.NewDecoder(resp.Body).Decode(tokenResponse) + defer resp.Body.Close() + + // Finally, convert the vpcTokenResponse instance into an IamTokenServerResponse to maintain + // consistency with other IAM-based authenticators. + iamTokenResponse = &IamTokenServerResponse{ + AccessToken: *tokenResponse.AccessToken, + ExpiresIn: *tokenResponse.ExpiresIn, + Expiration: time.Time(*tokenResponse.ExpiresAt).Unix(), + } + + return +} + +// retrieveInstanceIdentityToken retrieves the local compute resource's instance identity token using +// the "create_access_token" operation of the local VPC Instance Metadata Service API. +func (authenticator *VpcInstanceAuthenticator) retrieveInstanceIdentityToken() (instanceIdentityToken string, err error) { + + // Set up the request to invoke the "create_access_token" operation. + builder := NewRequestBuilder(PUT) + _, err = builder.ResolveRequestURL(authenticator.url(), vpcauthOperationPathCreateAccessToken, nil) + if err != nil { + err = NewAuthenticationError(&DetailedResponse{}, err) + return + } + + // Set the params and request body. + builder.AddQuery("version", vpcauthMetadataServiceVersion) + builder.AddHeader(CONTENT_TYPE, APPLICATION_JSON) + builder.AddHeader(Accept, APPLICATION_JSON) + builder.AddHeader("Metadata-Flavor", vpcauthMetadataFlavor) + + requestBody := fmt.Sprintf(`{"expires_in": %d}`, vpcauthInstanceIdentityTokenLifetime) + _, _ = builder.SetBodyContentString(requestBody) + + // Build the request. + req, err := builder.Build() + if err != nil { + err = NewAuthenticationError(&DetailedResponse{}, err) + return + } + + // If debug is enabled, then dump the request. + if GetLogger().IsLogLevelEnabled(LevelDebug) { + buf, dumpErr := httputil.DumpRequestOut(req, req.Body != nil) + if dumpErr == nil { + GetLogger().Debug("Request:\n%s\n", string(buf)) + } else { + GetLogger().Debug(fmt.Sprintf("error while attempting to log outbound request: %s", dumpErr.Error())) + } + } + + // Invoke the request. + GetLogger().Debug("Invoking VPC 'create_access_token' operation: %s", builder.URL) + resp, err := authenticator.client().Do(req) + if err != nil { + err = NewAuthenticationError(&DetailedResponse{}, err) + return + } + GetLogger().Debug("Returned from VPC 'create_access_token' operation, received status code %d", resp.StatusCode) + + // If debug is enabled, then dump the response. + if GetLogger().IsLogLevelEnabled(LevelDebug) { + buf, dumpErr := httputil.DumpResponse(resp, resp.Body != nil) + if dumpErr == nil { + GetLogger().Debug("Response:\n%s\n", string(buf)) + } else { + GetLogger().Debug(fmt.Sprintf("error while attempting to log inbound response: %s", dumpErr.Error())) + } + } + + // Check for a bad status code and handle the operation error. + if resp.StatusCode < 200 || resp.StatusCode >= 300 { + buff := new(bytes.Buffer) + _, _ = buff.ReadFrom(resp.Body) + resp.Body.Close() // #nosec G104 + + // Create a DetailedResponse to be included in the error below. + detailedResponse := &DetailedResponse{ + StatusCode: resp.StatusCode, + Headers: resp.Header, + RawResult: buff.Bytes(), + } + + vpcErrorMsg := string(detailedResponse.RawResult) + if vpcErrorMsg == "" { + vpcErrorMsg = "Operation 'create_access_token' error response not available" + } + + err = NewAuthenticationError(detailedResponse, + fmt.Errorf(ERRORMSG_VPCMDS_OPERATION_ERROR, detailedResponse.StatusCode, builder.URL, vpcErrorMsg)) + return + } + + // VPC "create_access_token" operation must have worked, so unmarshal the operation response body + // and retrieve the instance identity token value. + operationResponse := &vpcTokenResponse{} + _ = json.NewDecoder(resp.Body).Decode(operationResponse) + defer resp.Body.Close() + + // The instance identity token is returned in the "access_token" field of the response object. + instanceIdentityToken = *operationResponse.AccessToken + + return +} diff --git a/vendor/github.com/PuerkitoBio/purell/.gitignore b/vendor/github.com/PuerkitoBio/purell/.gitignore new file mode 100644 index 00000000000..748e4c8073c --- /dev/null +++ b/vendor/github.com/PuerkitoBio/purell/.gitignore @@ -0,0 +1,5 @@ +*.sublime-* +.DS_Store +*.swp +*.swo +tags diff --git a/vendor/github.com/PuerkitoBio/purell/.travis.yml b/vendor/github.com/PuerkitoBio/purell/.travis.yml new file mode 100644 index 00000000000..cf31e6af6d5 --- /dev/null +++ b/vendor/github.com/PuerkitoBio/purell/.travis.yml @@ -0,0 +1,12 @@ +language: go + +go: + - 1.4.x + - 1.5.x + - 1.6.x + - 1.7.x + - 1.8.x + - 1.9.x + - "1.10.x" + - "1.11.x" + - tip diff --git a/vendor/github.com/PuerkitoBio/purell/LICENSE b/vendor/github.com/PuerkitoBio/purell/LICENSE new file mode 100644 index 00000000000..4b9986dea71 --- /dev/null +++ b/vendor/github.com/PuerkitoBio/purell/LICENSE @@ -0,0 +1,12 @@ +Copyright (c) 2012, Martin Angers +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +* Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/PuerkitoBio/purell/README.md b/vendor/github.com/PuerkitoBio/purell/README.md new file mode 100644 index 00000000000..07de0c49866 --- /dev/null +++ b/vendor/github.com/PuerkitoBio/purell/README.md @@ -0,0 +1,188 @@ +# Purell + +Purell is a tiny Go library to normalize URLs. It returns a pure URL. Pure-ell. Sanitizer and all. Yeah, I know... + +Based on the [wikipedia paper][wiki] and the [RFC 3986 document][rfc]. + +[![build status](https://travis-ci.org/PuerkitoBio/purell.svg?branch=master)](http://travis-ci.org/PuerkitoBio/purell) + +## Install + +`go get github.com/PuerkitoBio/purell` + +## Changelog + +* **v1.1.1** : Fix failing test due to Go1.12 changes (thanks to @ianlancetaylor). +* **2016-11-14 (v1.1.0)** : IDN: Conform to RFC 5895: Fold character width (thanks to @beeker1121). +* **2016-07-27 (v1.0.0)** : Normalize IDN to ASCII (thanks to @zenovich). +* **2015-02-08** : Add fix for relative paths issue ([PR #5][pr5]) and add fix for unnecessary encoding of reserved characters ([see issue #7][iss7]). +* **v0.2.0** : Add benchmarks, Attempt IDN support. +* **v0.1.0** : Initial release. + +## Examples + +From `example_test.go` (note that in your code, you would import "github.com/PuerkitoBio/purell", and would prefix references to its methods and constants with "purell."): + +```go +package purell + +import ( + "fmt" + "net/url" +) + +func ExampleNormalizeURLString() { + if normalized, err := NormalizeURLString("hTTp://someWEBsite.com:80/Amazing%3f/url/", + FlagLowercaseScheme|FlagLowercaseHost|FlagUppercaseEscapes); err != nil { + panic(err) + } else { + fmt.Print(normalized) + } + // Output: http://somewebsite.com:80/Amazing%3F/url/ +} + +func ExampleMustNormalizeURLString() { + normalized := MustNormalizeURLString("hTTpS://someWEBsite.com:443/Amazing%fa/url/", + FlagsUnsafeGreedy) + fmt.Print(normalized) + + // Output: http://somewebsite.com/Amazing%FA/url +} + +func ExampleNormalizeURL() { + if u, err := url.Parse("Http://SomeUrl.com:8080/a/b/.././c///g?c=3&a=1&b=9&c=0#target"); err != nil { + panic(err) + } else { + normalized := NormalizeURL(u, FlagsUsuallySafeGreedy|FlagRemoveDuplicateSlashes|FlagRemoveFragment) + fmt.Print(normalized) + } + + // Output: http://someurl.com:8080/a/c/g?c=3&a=1&b=9&c=0 +} +``` + +## API + +As seen in the examples above, purell offers three methods, `NormalizeURLString(string, NormalizationFlags) (string, error)`, `MustNormalizeURLString(string, NormalizationFlags) (string)` and `NormalizeURL(*url.URL, NormalizationFlags) (string)`. They all normalize the provided URL based on the specified flags. Here are the available flags: + +```go +const ( + // Safe normalizations + FlagLowercaseScheme NormalizationFlags = 1 << iota // HTTP://host -> http://host, applied by default in Go1.1 + FlagLowercaseHost // http://HOST -> http://host + FlagUppercaseEscapes // http://host/t%ef -> http://host/t%EF + FlagDecodeUnnecessaryEscapes // http://host/t%41 -> http://host/tA + FlagEncodeNecessaryEscapes // http://host/!"#$ -> http://host/%21%22#$ + FlagRemoveDefaultPort // http://host:80 -> http://host + FlagRemoveEmptyQuerySeparator // http://host/path? -> http://host/path + + // Usually safe normalizations + FlagRemoveTrailingSlash // http://host/path/ -> http://host/path + FlagAddTrailingSlash // http://host/path -> http://host/path/ (should choose only one of these add/remove trailing slash flags) + FlagRemoveDotSegments // http://host/path/./a/b/../c -> http://host/path/a/c + + // Unsafe normalizations + FlagRemoveDirectoryIndex // http://host/path/index.html -> http://host/path/ + FlagRemoveFragment // http://host/path#fragment -> http://host/path + FlagForceHTTP // https://host -> http://host + FlagRemoveDuplicateSlashes // http://host/path//a///b -> http://host/path/a/b + FlagRemoveWWW // http://www.host/ -> http://host/ + FlagAddWWW // http://host/ -> http://www.host/ (should choose only one of these add/remove WWW flags) + FlagSortQuery // http://host/path?c=3&b=2&a=1&b=1 -> http://host/path?a=1&b=1&b=2&c=3 + + // Normalizations not in the wikipedia article, required to cover tests cases + // submitted by jehiah + FlagDecodeDWORDHost // http://1113982867 -> http://66.102.7.147 + FlagDecodeOctalHost // http://0102.0146.07.0223 -> http://66.102.7.147 + FlagDecodeHexHost // http://0x42660793 -> http://66.102.7.147 + FlagRemoveUnnecessaryHostDots // http://.host../path -> http://host/path + FlagRemoveEmptyPortSeparator // http://host:/path -> http://host/path + + // Convenience set of safe normalizations + FlagsSafe NormalizationFlags = FlagLowercaseHost | FlagLowercaseScheme | FlagUppercaseEscapes | FlagDecodeUnnecessaryEscapes | FlagEncodeNecessaryEscapes | FlagRemoveDefaultPort | FlagRemoveEmptyQuerySeparator + + // For convenience sets, "greedy" uses the "remove trailing slash" and "remove www. prefix" flags, + // while "non-greedy" uses the "add (or keep) the trailing slash" and "add www. prefix". + + // Convenience set of usually safe normalizations (includes FlagsSafe) + FlagsUsuallySafeGreedy NormalizationFlags = FlagsSafe | FlagRemoveTrailingSlash | FlagRemoveDotSegments + FlagsUsuallySafeNonGreedy NormalizationFlags = FlagsSafe | FlagAddTrailingSlash | FlagRemoveDotSegments + + // Convenience set of unsafe normalizations (includes FlagsUsuallySafe) + FlagsUnsafeGreedy NormalizationFlags = FlagsUsuallySafeGreedy | FlagRemoveDirectoryIndex | FlagRemoveFragment | FlagForceHTTP | FlagRemoveDuplicateSlashes | FlagRemoveWWW | FlagSortQuery + FlagsUnsafeNonGreedy NormalizationFlags = FlagsUsuallySafeNonGreedy | FlagRemoveDirectoryIndex | FlagRemoveFragment | FlagForceHTTP | FlagRemoveDuplicateSlashes | FlagAddWWW | FlagSortQuery + + // Convenience set of all available flags + FlagsAllGreedy = FlagsUnsafeGreedy | FlagDecodeDWORDHost | FlagDecodeOctalHost | FlagDecodeHexHost | FlagRemoveUnnecessaryHostDots | FlagRemoveEmptyPortSeparator + FlagsAllNonGreedy = FlagsUnsafeNonGreedy | FlagDecodeDWORDHost | FlagDecodeOctalHost | FlagDecodeHexHost | FlagRemoveUnnecessaryHostDots | FlagRemoveEmptyPortSeparator +) +``` + +For convenience, the set of flags `FlagsSafe`, `FlagsUsuallySafe[Greedy|NonGreedy]`, `FlagsUnsafe[Greedy|NonGreedy]` and `FlagsAll[Greedy|NonGreedy]` are provided for the similarly grouped normalizations on [wikipedia's URL normalization page][wiki]. You can add (using the bitwise OR `|` operator) or remove (using the bitwise AND NOT `&^` operator) individual flags from the sets if required, to build your own custom set. + +The [full godoc reference is available on gopkgdoc][godoc]. + +Some things to note: + +* `FlagDecodeUnnecessaryEscapes`, `FlagEncodeNecessaryEscapes`, `FlagUppercaseEscapes` and `FlagRemoveEmptyQuerySeparator` are always implicitly set, because internally, the URL string is parsed as an URL object, which automatically decodes unnecessary escapes, uppercases and encodes necessary ones, and removes empty query separators (an unnecessary `?` at the end of the url). So this operation cannot **not** be done. For this reason, `FlagRemoveEmptyQuerySeparator` (as well as the other three) has been included in the `FlagsSafe` convenience set, instead of `FlagsUnsafe`, where Wikipedia puts it. + +* The `FlagDecodeUnnecessaryEscapes` decodes the following escapes (*from -> to*): + - %24 -> $ + - %26 -> & + - %2B-%3B -> +,-./0123456789:; + - %3D -> = + - %40-%5A -> @ABCDEFGHIJKLMNOPQRSTUVWXYZ + - %5F -> _ + - %61-%7A -> abcdefghijklmnopqrstuvwxyz + - %7E -> ~ + + +* When the `NormalizeURL` function is used (passing an URL object), this source URL object is modified (that is, after the call, the URL object will be modified to reflect the normalization). + +* The *replace IP with domain name* normalization (`http://208.77.188.166/ → http://www.example.com/`) is obviously not possible for a library without making some network requests. This is not implemented in purell. + +* The *remove unused query string parameters* and *remove default query parameters* are also not implemented, since this is a very case-specific normalization, and it is quite trivial to do with an URL object. + +### Safe vs Usually Safe vs Unsafe + +Purell allows you to control the level of risk you take while normalizing an URL. You can aggressively normalize, play it totally safe, or anything in between. + +Consider the following URL: + +`HTTPS://www.RooT.com/toto/t%45%1f///a/./b/../c/?z=3&w=2&a=4&w=1#invalid` + +Normalizing with the `FlagsSafe` gives: + +`https://www.root.com/toto/tE%1F///a/./b/../c/?z=3&w=2&a=4&w=1#invalid` + +With the `FlagsUsuallySafeGreedy`: + +`https://www.root.com/toto/tE%1F///a/c?z=3&w=2&a=4&w=1#invalid` + +And with `FlagsUnsafeGreedy`: + +`http://root.com/toto/tE%1F/a/c?a=4&w=1&w=2&z=3` + +## TODOs + +* Add a class/default instance to allow specifying custom directory index names? At the moment, removing directory index removes `(^|/)((?:default|index)\.\w{1,4})$`. + +## Thanks / Contributions + +@rogpeppe +@jehiah +@opennota +@pchristopher1275 +@zenovich +@beeker1121 + +## License + +The [BSD 3-Clause license][bsd]. + +[bsd]: http://opensource.org/licenses/BSD-3-Clause +[wiki]: http://en.wikipedia.org/wiki/URL_normalization +[rfc]: http://tools.ietf.org/html/rfc3986#section-6 +[godoc]: http://go.pkgdoc.org/github.com/PuerkitoBio/purell +[pr5]: https://github.com/PuerkitoBio/purell/pull/5 +[iss7]: https://github.com/PuerkitoBio/purell/issues/7 diff --git a/vendor/github.com/PuerkitoBio/purell/purell.go b/vendor/github.com/PuerkitoBio/purell/purell.go new file mode 100644 index 00000000000..6d0fc190a18 --- /dev/null +++ b/vendor/github.com/PuerkitoBio/purell/purell.go @@ -0,0 +1,379 @@ +/* +Package purell offers URL normalization as described on the wikipedia page: +http://en.wikipedia.org/wiki/URL_normalization +*/ +package purell + +import ( + "bytes" + "fmt" + "net/url" + "regexp" + "sort" + "strconv" + "strings" + + "github.com/PuerkitoBio/urlesc" + "golang.org/x/net/idna" + "golang.org/x/text/unicode/norm" + "golang.org/x/text/width" +) + +// A set of normalization flags determines how a URL will +// be normalized. +type NormalizationFlags uint + +const ( + // Safe normalizations + FlagLowercaseScheme NormalizationFlags = 1 << iota // HTTP://host -> http://host, applied by default in Go1.1 + FlagLowercaseHost // http://HOST -> http://host + FlagUppercaseEscapes // http://host/t%ef -> http://host/t%EF + FlagDecodeUnnecessaryEscapes // http://host/t%41 -> http://host/tA + FlagEncodeNecessaryEscapes // http://host/!"#$ -> http://host/%21%22#$ + FlagRemoveDefaultPort // http://host:80 -> http://host + FlagRemoveEmptyQuerySeparator // http://host/path? -> http://host/path + + // Usually safe normalizations + FlagRemoveTrailingSlash // http://host/path/ -> http://host/path + FlagAddTrailingSlash // http://host/path -> http://host/path/ (should choose only one of these add/remove trailing slash flags) + FlagRemoveDotSegments // http://host/path/./a/b/../c -> http://host/path/a/c + + // Unsafe normalizations + FlagRemoveDirectoryIndex // http://host/path/index.html -> http://host/path/ + FlagRemoveFragment // http://host/path#fragment -> http://host/path + FlagForceHTTP // https://host -> http://host + FlagRemoveDuplicateSlashes // http://host/path//a///b -> http://host/path/a/b + FlagRemoveWWW // http://www.host/ -> http://host/ + FlagAddWWW // http://host/ -> http://www.host/ (should choose only one of these add/remove WWW flags) + FlagSortQuery // http://host/path?c=3&b=2&a=1&b=1 -> http://host/path?a=1&b=1&b=2&c=3 + + // Normalizations not in the wikipedia article, required to cover tests cases + // submitted by jehiah + FlagDecodeDWORDHost // http://1113982867 -> http://66.102.7.147 + FlagDecodeOctalHost // http://0102.0146.07.0223 -> http://66.102.7.147 + FlagDecodeHexHost // http://0x42660793 -> http://66.102.7.147 + FlagRemoveUnnecessaryHostDots // http://.host../path -> http://host/path + FlagRemoveEmptyPortSeparator // http://host:/path -> http://host/path + + // Convenience set of safe normalizations + FlagsSafe NormalizationFlags = FlagLowercaseHost | FlagLowercaseScheme | FlagUppercaseEscapes | FlagDecodeUnnecessaryEscapes | FlagEncodeNecessaryEscapes | FlagRemoveDefaultPort | FlagRemoveEmptyQuerySeparator + + // For convenience sets, "greedy" uses the "remove trailing slash" and "remove www. prefix" flags, + // while "non-greedy" uses the "add (or keep) the trailing slash" and "add www. prefix". + + // Convenience set of usually safe normalizations (includes FlagsSafe) + FlagsUsuallySafeGreedy NormalizationFlags = FlagsSafe | FlagRemoveTrailingSlash | FlagRemoveDotSegments + FlagsUsuallySafeNonGreedy NormalizationFlags = FlagsSafe | FlagAddTrailingSlash | FlagRemoveDotSegments + + // Convenience set of unsafe normalizations (includes FlagsUsuallySafe) + FlagsUnsafeGreedy NormalizationFlags = FlagsUsuallySafeGreedy | FlagRemoveDirectoryIndex | FlagRemoveFragment | FlagForceHTTP | FlagRemoveDuplicateSlashes | FlagRemoveWWW | FlagSortQuery + FlagsUnsafeNonGreedy NormalizationFlags = FlagsUsuallySafeNonGreedy | FlagRemoveDirectoryIndex | FlagRemoveFragment | FlagForceHTTP | FlagRemoveDuplicateSlashes | FlagAddWWW | FlagSortQuery + + // Convenience set of all available flags + FlagsAllGreedy = FlagsUnsafeGreedy | FlagDecodeDWORDHost | FlagDecodeOctalHost | FlagDecodeHexHost | FlagRemoveUnnecessaryHostDots | FlagRemoveEmptyPortSeparator + FlagsAllNonGreedy = FlagsUnsafeNonGreedy | FlagDecodeDWORDHost | FlagDecodeOctalHost | FlagDecodeHexHost | FlagRemoveUnnecessaryHostDots | FlagRemoveEmptyPortSeparator +) + +const ( + defaultHttpPort = ":80" + defaultHttpsPort = ":443" +) + +// Regular expressions used by the normalizations +var rxPort = regexp.MustCompile(`(:\d+)/?$`) +var rxDirIndex = regexp.MustCompile(`(^|/)((?:default|index)\.\w{1,4})$`) +var rxDupSlashes = regexp.MustCompile(`/{2,}`) +var rxDWORDHost = regexp.MustCompile(`^(\d+)((?:\.+)?(?:\:\d*)?)$`) +var rxOctalHost = regexp.MustCompile(`^(0\d*)\.(0\d*)\.(0\d*)\.(0\d*)((?:\.+)?(?:\:\d*)?)$`) +var rxHexHost = regexp.MustCompile(`^0x([0-9A-Fa-f]+)((?:\.+)?(?:\:\d*)?)$`) +var rxHostDots = regexp.MustCompile(`^(.+?)(:\d+)?$`) +var rxEmptyPort = regexp.MustCompile(`:+$`) + +// Map of flags to implementation function. +// FlagDecodeUnnecessaryEscapes has no action, since it is done automatically +// by parsing the string as an URL. Same for FlagUppercaseEscapes and FlagRemoveEmptyQuerySeparator. + +// Since maps have undefined traversing order, make a slice of ordered keys +var flagsOrder = []NormalizationFlags{ + FlagLowercaseScheme, + FlagLowercaseHost, + FlagRemoveDefaultPort, + FlagRemoveDirectoryIndex, + FlagRemoveDotSegments, + FlagRemoveFragment, + FlagForceHTTP, // Must be after remove default port (because https=443/http=80) + FlagRemoveDuplicateSlashes, + FlagRemoveWWW, + FlagAddWWW, + FlagSortQuery, + FlagDecodeDWORDHost, + FlagDecodeOctalHost, + FlagDecodeHexHost, + FlagRemoveUnnecessaryHostDots, + FlagRemoveEmptyPortSeparator, + FlagRemoveTrailingSlash, // These two (add/remove trailing slash) must be last + FlagAddTrailingSlash, +} + +// ... and then the map, where order is unimportant +var flags = map[NormalizationFlags]func(*url.URL){ + FlagLowercaseScheme: lowercaseScheme, + FlagLowercaseHost: lowercaseHost, + FlagRemoveDefaultPort: removeDefaultPort, + FlagRemoveDirectoryIndex: removeDirectoryIndex, + FlagRemoveDotSegments: removeDotSegments, + FlagRemoveFragment: removeFragment, + FlagForceHTTP: forceHTTP, + FlagRemoveDuplicateSlashes: removeDuplicateSlashes, + FlagRemoveWWW: removeWWW, + FlagAddWWW: addWWW, + FlagSortQuery: sortQuery, + FlagDecodeDWORDHost: decodeDWORDHost, + FlagDecodeOctalHost: decodeOctalHost, + FlagDecodeHexHost: decodeHexHost, + FlagRemoveUnnecessaryHostDots: removeUnncessaryHostDots, + FlagRemoveEmptyPortSeparator: removeEmptyPortSeparator, + FlagRemoveTrailingSlash: removeTrailingSlash, + FlagAddTrailingSlash: addTrailingSlash, +} + +// MustNormalizeURLString returns the normalized string, and panics if an error occurs. +// It takes an URL string as input, as well as the normalization flags. +func MustNormalizeURLString(u string, f NormalizationFlags) string { + result, e := NormalizeURLString(u, f) + if e != nil { + panic(e) + } + return result +} + +// NormalizeURLString returns the normalized string, or an error if it can't be parsed into an URL object. +// It takes an URL string as input, as well as the normalization flags. +func NormalizeURLString(u string, f NormalizationFlags) (string, error) { + parsed, err := url.Parse(u) + if err != nil { + return "", err + } + + if f&FlagLowercaseHost == FlagLowercaseHost { + parsed.Host = strings.ToLower(parsed.Host) + } + + // The idna package doesn't fully conform to RFC 5895 + // (https://tools.ietf.org/html/rfc5895), so we do it here. + // Taken from Go 1.8 cycle source, courtesy of bradfitz. + // TODO: Remove when (if?) idna package conforms to RFC 5895. + parsed.Host = width.Fold.String(parsed.Host) + parsed.Host = norm.NFC.String(parsed.Host) + if parsed.Host, err = idna.ToASCII(parsed.Host); err != nil { + return "", err + } + + return NormalizeURL(parsed, f), nil +} + +// NormalizeURL returns the normalized string. +// It takes a parsed URL object as input, as well as the normalization flags. +func NormalizeURL(u *url.URL, f NormalizationFlags) string { + for _, k := range flagsOrder { + if f&k == k { + flags[k](u) + } + } + return urlesc.Escape(u) +} + +func lowercaseScheme(u *url.URL) { + if len(u.Scheme) > 0 { + u.Scheme = strings.ToLower(u.Scheme) + } +} + +func lowercaseHost(u *url.URL) { + if len(u.Host) > 0 { + u.Host = strings.ToLower(u.Host) + } +} + +func removeDefaultPort(u *url.URL) { + if len(u.Host) > 0 { + scheme := strings.ToLower(u.Scheme) + u.Host = rxPort.ReplaceAllStringFunc(u.Host, func(val string) string { + if (scheme == "http" && val == defaultHttpPort) || (scheme == "https" && val == defaultHttpsPort) { + return "" + } + return val + }) + } +} + +func removeTrailingSlash(u *url.URL) { + if l := len(u.Path); l > 0 { + if strings.HasSuffix(u.Path, "/") { + u.Path = u.Path[:l-1] + } + } else if l = len(u.Host); l > 0 { + if strings.HasSuffix(u.Host, "/") { + u.Host = u.Host[:l-1] + } + } +} + +func addTrailingSlash(u *url.URL) { + if l := len(u.Path); l > 0 { + if !strings.HasSuffix(u.Path, "/") { + u.Path += "/" + } + } else if l = len(u.Host); l > 0 { + if !strings.HasSuffix(u.Host, "/") { + u.Host += "/" + } + } +} + +func removeDotSegments(u *url.URL) { + if len(u.Path) > 0 { + var dotFree []string + var lastIsDot bool + + sections := strings.Split(u.Path, "/") + for _, s := range sections { + if s == ".." { + if len(dotFree) > 0 { + dotFree = dotFree[:len(dotFree)-1] + } + } else if s != "." { + dotFree = append(dotFree, s) + } + lastIsDot = (s == "." || s == "..") + } + // Special case if host does not end with / and new path does not begin with / + u.Path = strings.Join(dotFree, "/") + if u.Host != "" && !strings.HasSuffix(u.Host, "/") && !strings.HasPrefix(u.Path, "/") { + u.Path = "/" + u.Path + } + // Special case if the last segment was a dot, make sure the path ends with a slash + if lastIsDot && !strings.HasSuffix(u.Path, "/") { + u.Path += "/" + } + } +} + +func removeDirectoryIndex(u *url.URL) { + if len(u.Path) > 0 { + u.Path = rxDirIndex.ReplaceAllString(u.Path, "$1") + } +} + +func removeFragment(u *url.URL) { + u.Fragment = "" +} + +func forceHTTP(u *url.URL) { + if strings.ToLower(u.Scheme) == "https" { + u.Scheme = "http" + } +} + +func removeDuplicateSlashes(u *url.URL) { + if len(u.Path) > 0 { + u.Path = rxDupSlashes.ReplaceAllString(u.Path, "/") + } +} + +func removeWWW(u *url.URL) { + if len(u.Host) > 0 && strings.HasPrefix(strings.ToLower(u.Host), "www.") { + u.Host = u.Host[4:] + } +} + +func addWWW(u *url.URL) { + if len(u.Host) > 0 && !strings.HasPrefix(strings.ToLower(u.Host), "www.") { + u.Host = "www." + u.Host + } +} + +func sortQuery(u *url.URL) { + q := u.Query() + + if len(q) > 0 { + arKeys := make([]string, len(q)) + i := 0 + for k := range q { + arKeys[i] = k + i++ + } + sort.Strings(arKeys) + buf := new(bytes.Buffer) + for _, k := range arKeys { + sort.Strings(q[k]) + for _, v := range q[k] { + if buf.Len() > 0 { + buf.WriteRune('&') + } + buf.WriteString(fmt.Sprintf("%s=%s", k, urlesc.QueryEscape(v))) + } + } + + // Rebuild the raw query string + u.RawQuery = buf.String() + } +} + +func decodeDWORDHost(u *url.URL) { + if len(u.Host) > 0 { + if matches := rxDWORDHost.FindStringSubmatch(u.Host); len(matches) > 2 { + var parts [4]int64 + + dword, _ := strconv.ParseInt(matches[1], 10, 0) + for i, shift := range []uint{24, 16, 8, 0} { + parts[i] = dword >> shift & 0xFF + } + u.Host = fmt.Sprintf("%d.%d.%d.%d%s", parts[0], parts[1], parts[2], parts[3], matches[2]) + } + } +} + +func decodeOctalHost(u *url.URL) { + if len(u.Host) > 0 { + if matches := rxOctalHost.FindStringSubmatch(u.Host); len(matches) > 5 { + var parts [4]int64 + + for i := 1; i <= 4; i++ { + parts[i-1], _ = strconv.ParseInt(matches[i], 8, 0) + } + u.Host = fmt.Sprintf("%d.%d.%d.%d%s", parts[0], parts[1], parts[2], parts[3], matches[5]) + } + } +} + +func decodeHexHost(u *url.URL) { + if len(u.Host) > 0 { + if matches := rxHexHost.FindStringSubmatch(u.Host); len(matches) > 2 { + // Conversion is safe because of regex validation + parsed, _ := strconv.ParseInt(matches[1], 16, 0) + // Set host as DWORD (base 10) encoded host + u.Host = fmt.Sprintf("%d%s", parsed, matches[2]) + // The rest is the same as decoding a DWORD host + decodeDWORDHost(u) + } + } +} + +func removeUnncessaryHostDots(u *url.URL) { + if len(u.Host) > 0 { + if matches := rxHostDots.FindStringSubmatch(u.Host); len(matches) > 1 { + // Trim the leading and trailing dots + u.Host = strings.Trim(matches[1], ".") + if len(matches) > 2 { + u.Host += matches[2] + } + } + } +} + +func removeEmptyPortSeparator(u *url.URL) { + if len(u.Host) > 0 { + u.Host = rxEmptyPort.ReplaceAllString(u.Host, "") + } +} diff --git a/vendor/github.com/PuerkitoBio/urlesc/.travis.yml b/vendor/github.com/PuerkitoBio/urlesc/.travis.yml new file mode 100644 index 00000000000..ba6b225f91e --- /dev/null +++ b/vendor/github.com/PuerkitoBio/urlesc/.travis.yml @@ -0,0 +1,15 @@ +language: go + +go: + - 1.4.x + - 1.5.x + - 1.6.x + - 1.7.x + - 1.8.x + - tip + +install: + - go build . + +script: + - go test -v diff --git a/vendor/github.com/PuerkitoBio/urlesc/LICENSE b/vendor/github.com/PuerkitoBio/urlesc/LICENSE new file mode 100644 index 00000000000..74487567632 --- /dev/null +++ b/vendor/github.com/PuerkitoBio/urlesc/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2012 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/PuerkitoBio/urlesc/README.md b/vendor/github.com/PuerkitoBio/urlesc/README.md new file mode 100644 index 00000000000..57aff0a5396 --- /dev/null +++ b/vendor/github.com/PuerkitoBio/urlesc/README.md @@ -0,0 +1,16 @@ +urlesc [![Build Status](https://travis-ci.org/PuerkitoBio/urlesc.svg?branch=master)](https://travis-ci.org/PuerkitoBio/urlesc) [![GoDoc](http://godoc.org/github.com/PuerkitoBio/urlesc?status.svg)](http://godoc.org/github.com/PuerkitoBio/urlesc) +====== + +Package urlesc implements query escaping as per RFC 3986. + +It contains some parts of the net/url package, modified so as to allow +some reserved characters incorrectly escaped by net/url (see [issue 5684](https://github.com/golang/go/issues/5684)). + +## Install + + go get github.com/PuerkitoBio/urlesc + +## License + +Go license (BSD-3-Clause) + diff --git a/vendor/github.com/PuerkitoBio/urlesc/urlesc.go b/vendor/github.com/PuerkitoBio/urlesc/urlesc.go new file mode 100644 index 00000000000..1b84624594d --- /dev/null +++ b/vendor/github.com/PuerkitoBio/urlesc/urlesc.go @@ -0,0 +1,180 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package urlesc implements query escaping as per RFC 3986. +// It contains some parts of the net/url package, modified so as to allow +// some reserved characters incorrectly escaped by net/url. +// See https://github.com/golang/go/issues/5684 +package urlesc + +import ( + "bytes" + "net/url" + "strings" +) + +type encoding int + +const ( + encodePath encoding = 1 + iota + encodeUserPassword + encodeQueryComponent + encodeFragment +) + +// Return true if the specified character should be escaped when +// appearing in a URL string, according to RFC 3986. +func shouldEscape(c byte, mode encoding) bool { + // §2.3 Unreserved characters (alphanum) + if 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || '0' <= c && c <= '9' { + return false + } + + switch c { + case '-', '.', '_', '~': // §2.3 Unreserved characters (mark) + return false + + // §2.2 Reserved characters (reserved) + case ':', '/', '?', '#', '[', ']', '@', // gen-delims + '!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '=': // sub-delims + // Different sections of the URL allow a few of + // the reserved characters to appear unescaped. + switch mode { + case encodePath: // §3.3 + // The RFC allows sub-delims and : @. + // '/', '[' and ']' can be used to assign meaning to individual path + // segments. This package only manipulates the path as a whole, + // so we allow those as well. That leaves only ? and # to escape. + return c == '?' || c == '#' + + case encodeUserPassword: // §3.2.1 + // The RFC allows : and sub-delims in + // userinfo. The parsing of userinfo treats ':' as special so we must escape + // all the gen-delims. + return c == ':' || c == '/' || c == '?' || c == '#' || c == '[' || c == ']' || c == '@' + + case encodeQueryComponent: // §3.4 + // The RFC allows / and ?. + return c != '/' && c != '?' + + case encodeFragment: // §4.1 + // The RFC text is silent but the grammar allows + // everything, so escape nothing but # + return c == '#' + } + } + + // Everything else must be escaped. + return true +} + +// QueryEscape escapes the string so it can be safely placed +// inside a URL query. +func QueryEscape(s string) string { + return escape(s, encodeQueryComponent) +} + +func escape(s string, mode encoding) string { + spaceCount, hexCount := 0, 0 + for i := 0; i < len(s); i++ { + c := s[i] + if shouldEscape(c, mode) { + if c == ' ' && mode == encodeQueryComponent { + spaceCount++ + } else { + hexCount++ + } + } + } + + if spaceCount == 0 && hexCount == 0 { + return s + } + + t := make([]byte, len(s)+2*hexCount) + j := 0 + for i := 0; i < len(s); i++ { + switch c := s[i]; { + case c == ' ' && mode == encodeQueryComponent: + t[j] = '+' + j++ + case shouldEscape(c, mode): + t[j] = '%' + t[j+1] = "0123456789ABCDEF"[c>>4] + t[j+2] = "0123456789ABCDEF"[c&15] + j += 3 + default: + t[j] = s[i] + j++ + } + } + return string(t) +} + +var uiReplacer = strings.NewReplacer( + "%21", "!", + "%27", "'", + "%28", "(", + "%29", ")", + "%2A", "*", +) + +// unescapeUserinfo unescapes some characters that need not to be escaped as per RFC3986. +func unescapeUserinfo(s string) string { + return uiReplacer.Replace(s) +} + +// Escape reassembles the URL into a valid URL string. +// The general form of the result is one of: +// +// scheme:opaque +// scheme://userinfo@host/path?query#fragment +// +// If u.Opaque is non-empty, String uses the first form; +// otherwise it uses the second form. +// +// In the second form, the following rules apply: +// - if u.Scheme is empty, scheme: is omitted. +// - if u.User is nil, userinfo@ is omitted. +// - if u.Host is empty, host/ is omitted. +// - if u.Scheme and u.Host are empty and u.User is nil, +// the entire scheme://userinfo@host/ is omitted. +// - if u.Host is non-empty and u.Path begins with a /, +// the form host/path does not add its own /. +// - if u.RawQuery is empty, ?query is omitted. +// - if u.Fragment is empty, #fragment is omitted. +func Escape(u *url.URL) string { + var buf bytes.Buffer + if u.Scheme != "" { + buf.WriteString(u.Scheme) + buf.WriteByte(':') + } + if u.Opaque != "" { + buf.WriteString(u.Opaque) + } else { + if u.Scheme != "" || u.Host != "" || u.User != nil { + buf.WriteString("//") + if ui := u.User; ui != nil { + buf.WriteString(unescapeUserinfo(ui.String())) + buf.WriteByte('@') + } + if h := u.Host; h != "" { + buf.WriteString(h) + } + } + if u.Path != "" && u.Path[0] != '/' && u.Host != "" { + buf.WriteByte('/') + } + buf.WriteString(escape(u.Path, encodePath)) + } + if u.RawQuery != "" { + buf.WriteByte('?') + buf.WriteString(u.RawQuery) + } + if u.Fragment != "" { + buf.WriteByte('#') + buf.WriteString(escape(u.Fragment, encodeFragment)) + } + return buf.String() +} diff --git a/vendor/github.com/asaskevich/govalidator/README.md b/vendor/github.com/asaskevich/govalidator/README.md index 39121ea8e37..2c3fc35eb64 100644 --- a/vendor/github.com/asaskevich/govalidator/README.md +++ b/vendor/github.com/asaskevich/govalidator/README.md @@ -177,6 +177,7 @@ func IsPrintableASCII(str string) bool func IsRFC3339(str string) bool func IsRFC3339WithoutZone(str string) bool func IsRGBcolor(str string) bool +func IsRegex(str string) bool func IsRequestURI(rawurl string) bool func IsRequestURL(rawurl string) bool func IsRipeMD128(str string) bool @@ -203,6 +204,7 @@ func IsUUID(str string) bool func IsUUIDv3(str string) bool func IsUUIDv4(str string) bool func IsUUIDv5(str string) bool +func IsULID(str string) bool func IsUnixTime(str string) bool func IsUpperCase(str string) bool func IsVariableWidth(str string) bool @@ -382,6 +384,7 @@ Here is a list of available validators for struct fields (validator - used funct "rfc3339WithoutZone": IsRFC3339WithoutZone, "ISO3166Alpha2": IsISO3166Alpha2, "ISO3166Alpha3": IsISO3166Alpha3, +"ulid": IsULID, ``` Validators with parameters diff --git a/vendor/github.com/asaskevich/govalidator/patterns.go b/vendor/github.com/asaskevich/govalidator/patterns.go index 106ed94f80a..bafc3765ea1 100644 --- a/vendor/github.com/asaskevich/govalidator/patterns.go +++ b/vendor/github.com/asaskevich/govalidator/patterns.go @@ -42,6 +42,8 @@ const ( SSN string = `^\d{3}[- ]?\d{2}[- ]?\d{4}$` WinPath string = `^[a-zA-Z]:\\(?:[^\\/:*?"<>|\r\n]+\\)*[^\\/:*?"<>|\r\n]*$` UnixPath string = `^(/[^/\x00]*)+/?$` + WinARPath string = `^(?:(?:[a-zA-Z]:|\\\\[a-z0-9_.$●-]+\\[a-z0-9_.$●-]+)\\|\\?[^\\/:*?"<>|\r\n]+\\?)(?:[^\\/:*?"<>|\r\n]+\\)*[^\\/:*?"<>|\r\n]*$` + UnixARPath string = `^((\.{0,2}/)?([^/\x00]*))+/?$` Semver string = "^v?(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)(-(0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(\\.(0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(\\+[0-9a-zA-Z-]+(\\.[0-9a-zA-Z-]+)*)?$" tagName string = "valid" hasLowerCase string = ".*[[:lower:]]" @@ -50,6 +52,7 @@ const ( hasWhitespaceOnly string = "^[[:space:]]+$" IMEI string = "^[0-9a-f]{14}$|^\\d{15}$|^\\d{18}$" IMSI string = "^\\d{14,15}$" + E164 string = `^\+?[1-9]\d{1,14}$` ) // Used by IsFilePath func @@ -97,6 +100,8 @@ var ( rxSSN = regexp.MustCompile(SSN) rxWinPath = regexp.MustCompile(WinPath) rxUnixPath = regexp.MustCompile(UnixPath) + rxARWinPath = regexp.MustCompile(WinARPath) + rxARUnixPath = regexp.MustCompile(UnixARPath) rxSemver = regexp.MustCompile(Semver) rxHasLowerCase = regexp.MustCompile(hasLowerCase) rxHasUpperCase = regexp.MustCompile(hasUpperCase) @@ -104,4 +109,5 @@ var ( rxHasWhitespaceOnly = regexp.MustCompile(hasWhitespaceOnly) rxIMEI = regexp.MustCompile(IMEI) rxIMSI = regexp.MustCompile(IMSI) + rxE164 = regexp.MustCompile(E164) ) diff --git a/vendor/github.com/asaskevich/govalidator/types.go b/vendor/github.com/asaskevich/govalidator/types.go index 54218bf05a2..c573abb51af 100644 --- a/vendor/github.com/asaskevich/govalidator/types.go +++ b/vendor/github.com/asaskevich/govalidator/types.go @@ -165,6 +165,7 @@ var TagMap = map[string]Validator{ "ISO3166Alpha3": IsISO3166Alpha3, "ISO4217": IsISO4217, "IMEI": IsIMEI, + "ulid": IsULID, } // ISO3166Entry stores country codes diff --git a/vendor/github.com/asaskevich/govalidator/validator.go b/vendor/github.com/asaskevich/govalidator/validator.go index 5c918fc4bc7..46ecfc84a4c 100644 --- a/vendor/github.com/asaskevich/govalidator/validator.go +++ b/vendor/github.com/asaskevich/govalidator/validator.go @@ -361,9 +361,96 @@ func IsUUID(str string) bool { return rxUUID.MatchString(str) } +// Byte to index table for O(1) lookups when unmarshaling. +// We use 0xFF as sentinel value for invalid indexes. +var ulidDec = [...]byte{ + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x01, + 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, + 0x0F, 0x10, 0x11, 0xFF, 0x12, 0x13, 0xFF, 0x14, 0x15, 0xFF, + 0x16, 0x17, 0x18, 0x19, 0x1A, 0xFF, 0x1B, 0x1C, 0x1D, 0x1E, + 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0A, 0x0B, 0x0C, + 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0xFF, 0x12, 0x13, 0xFF, 0x14, + 0x15, 0xFF, 0x16, 0x17, 0x18, 0x19, 0x1A, 0xFF, 0x1B, 0x1C, + 0x1D, 0x1E, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +} + +// EncodedSize is the length of a text encoded ULID. +const ulidEncodedSize = 26 + +// IsULID checks if the string is a ULID. +// +// Implementation got from: +// https://github.com/oklog/ulid (Apache-2.0 License) +// +func IsULID(str string) bool { + // Check if a base32 encoded ULID is the right length. + if len(str) != ulidEncodedSize { + return false + } + + // Check if all the characters in a base32 encoded ULID are part of the + // expected base32 character set. + if ulidDec[str[0]] == 0xFF || + ulidDec[str[1]] == 0xFF || + ulidDec[str[2]] == 0xFF || + ulidDec[str[3]] == 0xFF || + ulidDec[str[4]] == 0xFF || + ulidDec[str[5]] == 0xFF || + ulidDec[str[6]] == 0xFF || + ulidDec[str[7]] == 0xFF || + ulidDec[str[8]] == 0xFF || + ulidDec[str[9]] == 0xFF || + ulidDec[str[10]] == 0xFF || + ulidDec[str[11]] == 0xFF || + ulidDec[str[12]] == 0xFF || + ulidDec[str[13]] == 0xFF || + ulidDec[str[14]] == 0xFF || + ulidDec[str[15]] == 0xFF || + ulidDec[str[16]] == 0xFF || + ulidDec[str[17]] == 0xFF || + ulidDec[str[18]] == 0xFF || + ulidDec[str[19]] == 0xFF || + ulidDec[str[20]] == 0xFF || + ulidDec[str[21]] == 0xFF || + ulidDec[str[22]] == 0xFF || + ulidDec[str[23]] == 0xFF || + ulidDec[str[24]] == 0xFF || + ulidDec[str[25]] == 0xFF { + return false + } + + // Check if the first character in a base32 encoded ULID will overflow. This + // happens because the base32 representation encodes 130 bits, while the + // ULID is only 128 bits. + // + // See https://github.com/oklog/ulid/issues/9 for details. + if str[0] > '7' { + return false + } + return true +} + // IsCreditCard checks if the string is a credit card. func IsCreditCard(str string) bool { - sanitized := notNumberRegexp.ReplaceAllString(str, "") + sanitized := whiteSpacesAndMinus.ReplaceAllString(str, "") if !rxCreditCard.MatchString(sanitized) { return false } @@ -509,6 +596,27 @@ func IsFilePath(str string) (bool, int) { return false, Unknown } +//IsWinFilePath checks both relative & absolute paths in Windows +func IsWinFilePath(str string) bool { + if rxARWinPath.MatchString(str) { + //check windows path limit see: + // http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx#maxpath + if len(str[3:]) > 32767 { + return false + } + return true + } + return false +} + +//IsUnixFilePath checks both relative & absolute paths in Unix +func IsUnixFilePath(str string) bool { + if rxARUnixPath.MatchString(str) { + return true + } + return false +} + // IsDataURI checks if a string is base64 encoded data URI such as an image func IsDataURI(str string) bool { dataURI := strings.Split(str, ",") @@ -586,11 +694,13 @@ func IsHash(str string, algorithm string) bool { len = "40" } else if algo == "tiger192" { len = "48" - } else if algo == "sha256" { + } else if algo == "sha3-224" { + len = "56" + } else if algo == "sha256" || algo == "sha3-256" { len = "64" - } else if algo == "sha384" { + } else if algo == "sha384" || algo == "sha3-384" { len = "96" - } else if algo == "sha512" { + } else if algo == "sha512" || algo == "sha3-512" { len = "128" } else { return false @@ -599,6 +709,26 @@ func IsHash(str string, algorithm string) bool { return Matches(str, "^[a-f0-9]{"+len+"}$") } +// IsSHA3224 checks is a string is a SHA3-224 hash. Alias for `IsHash(str, "sha3-224")` +func IsSHA3224(str string) bool { + return IsHash(str, "sha3-224") +} + +// IsSHA3256 checks is a string is a SHA3-256 hash. Alias for `IsHash(str, "sha3-256")` +func IsSHA3256(str string) bool { + return IsHash(str, "sha3-256") +} + +// IsSHA3384 checks is a string is a SHA3-384 hash. Alias for `IsHash(str, "sha3-384")` +func IsSHA3384(str string) bool { + return IsHash(str, "sha3-384") +} + +// IsSHA3512 checks is a string is a SHA3-512 hash. Alias for `IsHash(str, "sha3-512")` +func IsSHA3512(str string) bool { + return IsHash(str, "sha3-512") +} + // IsSHA512 checks is a string is a SHA512 hash. Alias for `IsHash(str, "sha512")` func IsSHA512(str string) bool { return IsHash(str, "sha512") @@ -819,6 +949,14 @@ func IsRsaPublicKey(str string, keylen int) bool { return bitlen == int(keylen) } +// IsRegex checks if a give string is a valid regex with RE2 syntax or not +func IsRegex(str string) bool { + if _, err := regexp.Compile(str); err == nil { + return true + } + return false +} + func toJSONName(tag string) string { if tag == "" { return "" @@ -1625,3 +1763,7 @@ func (sv stringValues) Len() int { return len(sv) } func (sv stringValues) Swap(i, j int) { sv[i], sv[j] = sv[j], sv[i] } func (sv stringValues) Less(i, j int) bool { return sv.get(i) < sv.get(j) } func (sv stringValues) get(i int) string { return sv[i].String() } + +func IsE164(str string) bool { + return rxE164.MatchString(str) +} diff --git a/vendor/github.com/fatih/color/.travis.yml b/vendor/github.com/fatih/color/.travis.yml deleted file mode 100644 index 95f8a1ff5c7..00000000000 --- a/vendor/github.com/fatih/color/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ -language: go -go: - - 1.8.x - - tip - diff --git a/vendor/github.com/fatih/color/Gopkg.lock b/vendor/github.com/fatih/color/Gopkg.lock deleted file mode 100644 index 7d879e9caf0..00000000000 --- a/vendor/github.com/fatih/color/Gopkg.lock +++ /dev/null @@ -1,27 +0,0 @@ -# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. - - -[[projects]] - name = "github.com/mattn/go-colorable" - packages = ["."] - revision = "167de6bfdfba052fa6b2d3664c8f5272e23c9072" - version = "v0.0.9" - -[[projects]] - name = "github.com/mattn/go-isatty" - packages = ["."] - revision = "0360b2af4f38e8d38c7fce2a9f4e702702d73a39" - version = "v0.0.3" - -[[projects]] - branch = "master" - name = "golang.org/x/sys" - packages = ["unix"] - revision = "37707fdb30a5b38865cfb95e5aab41707daec7fd" - -[solve-meta] - analyzer-name = "dep" - analyzer-version = 1 - inputs-digest = "e8a50671c3cb93ea935bf210b1cd20702876b9d9226129be581ef646d1565cdc" - solver-name = "gps-cdcl" - solver-version = 1 diff --git a/vendor/github.com/fatih/color/Gopkg.toml b/vendor/github.com/fatih/color/Gopkg.toml deleted file mode 100644 index ff1617f71da..00000000000 --- a/vendor/github.com/fatih/color/Gopkg.toml +++ /dev/null @@ -1,30 +0,0 @@ - -# Gopkg.toml example -# -# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md -# for detailed Gopkg.toml documentation. -# -# required = ["github.com/user/thing/cmd/thing"] -# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] -# -# [[constraint]] -# name = "github.com/user/project" -# version = "1.0.0" -# -# [[constraint]] -# name = "github.com/user/project2" -# branch = "dev" -# source = "github.com/myfork/project2" -# -# [[override]] -# name = "github.com/x/y" -# version = "2.4.0" - - -[[constraint]] - name = "github.com/mattn/go-colorable" - version = "0.0.9" - -[[constraint]] - name = "github.com/mattn/go-isatty" - version = "0.0.3" diff --git a/vendor/github.com/fatih/color/README.md b/vendor/github.com/fatih/color/README.md index 3fc95446028..5c751f2158c 100644 --- a/vendor/github.com/fatih/color/README.md +++ b/vendor/github.com/fatih/color/README.md @@ -1,14 +1,11 @@ -# Color [![GoDoc](https://godoc.org/github.com/fatih/color?status.svg)](https://godoc.org/github.com/fatih/color) [![Build Status](https://img.shields.io/travis/fatih/color.svg?style=flat-square)](https://travis-ci.org/fatih/color) - - +# color [![](https://github.com/fatih/color/workflows/build/badge.svg)](https://github.com/fatih/color/actions) [![PkgGoDev](https://pkg.go.dev/badge/github.com/fatih/color)](https://pkg.go.dev/github.com/fatih/color) Color lets you use colorized outputs in terms of [ANSI Escape Codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors) in Go (Golang). It has support for Windows too! The API can be used in several ways, pick one that suits you. - -![Color](https://i.imgur.com/c1JI0lA.png) +![Color](https://user-images.githubusercontent.com/438920/96832689-03b3e000-13f4-11eb-9803-46f4c4de3406.jpg) ## Install @@ -17,9 +14,6 @@ suits you. go get github.com/fatih/color ``` -Note that the `vendor` folder is here for stability. Remove the folder if you -already have the dependencies in your GOPATH. - ## Examples ### Standard colors @@ -133,14 +127,16 @@ fmt.Println("All text will now be bold magenta.") There might be a case where you want to explicitly disable/enable color output. the `go-isatty` package will automatically disable color output for non-tty output streams -(for example if the output were piped directly to `less`) +(for example if the output were piped directly to `less`). -`Color` has support to disable/enable colors both globally and for single color -definitions. For example suppose you have a CLI app and a `--no-color` bool flag. You -can easily disable the color output with: +The `color` package also disables color output if the [`NO_COLOR`](https://no-color.org) environment +variable is set (regardless of its value). -```go +`Color` has support to disable/enable colors programatically both globally and +for single color definitions. For example suppose you have a CLI app and a +`--no-color` bool flag. You can easily disable the color output with: +```go var flagNoColor = flag.Bool("no-color", false, "Disable color output") if *flagNoColor { @@ -162,6 +158,10 @@ c.EnableColor() c.Println("This prints again cyan...") ``` +## GitHub Actions + +To output color in GitHub Actions (or other CI systems that support ANSI colors), make sure to set `color.NoColor = false` so that it bypasses the check for non-tty output streams. + ## Todo * Save/Return previous values @@ -176,4 +176,3 @@ c.Println("This prints again cyan...") ## License The MIT License (MIT) - see [`LICENSE.md`](https://github.com/fatih/color/blob/master/LICENSE.md) for more details - diff --git a/vendor/github.com/fatih/color/color.go b/vendor/github.com/fatih/color/color.go index 91c8e9f0620..98a60f3c88d 100644 --- a/vendor/github.com/fatih/color/color.go +++ b/vendor/github.com/fatih/color/color.go @@ -15,9 +15,11 @@ import ( var ( // NoColor defines if the output is colorized or not. It's dynamically set to // false or true based on the stdout's file descriptor referring to a terminal - // or not. This is a global option and affects all colors. For more control - // over each color block use the methods DisableColor() individually. - NoColor = os.Getenv("TERM") == "dumb" || + // or not. It's also set to true if the NO_COLOR environment variable is + // set (regardless of its value). This is a global option and affects all + // colors. For more control over each color block use the methods + // DisableColor() individually. + NoColor = noColorExists() || os.Getenv("TERM") == "dumb" || (!isatty.IsTerminal(os.Stdout.Fd()) && !isatty.IsCygwinTerminal(os.Stdout.Fd())) // Output defines the standard output of the print functions. By default @@ -33,6 +35,12 @@ var ( colorsCacheMu sync.Mutex // protects colorsCache ) +// noColorExists returns true if the environment variable NO_COLOR exists. +func noColorExists() bool { + _, exists := os.LookupEnv("NO_COLOR") + return exists +} + // Color defines a custom color object which is defined by SGR parameters. type Color struct { params []Attribute @@ -108,7 +116,14 @@ const ( // New returns a newly created color object. func New(value ...Attribute) *Color { - c := &Color{params: make([]Attribute, 0)} + c := &Color{ + params: make([]Attribute, 0), + } + + if noColorExists() { + c.noColor = boolPtr(true) + } + c.Add(value...) return c } @@ -387,7 +402,7 @@ func (c *Color) EnableColor() { } func (c *Color) isNoColorSet() bool { - // check first if we have user setted action + // check first if we have user set action if c.noColor != nil { return *c.noColor } diff --git a/vendor/github.com/fatih/color/doc.go b/vendor/github.com/fatih/color/doc.go index cf1e96500f4..04541de786f 100644 --- a/vendor/github.com/fatih/color/doc.go +++ b/vendor/github.com/fatih/color/doc.go @@ -118,6 +118,8 @@ the color output with: color.NoColor = true // disables colorized output } +You can also disable the color by setting the NO_COLOR environment variable to any value. + It also has support for single color definitions (local). You can disable/enable color output on the fly: diff --git a/vendor/github.com/go-logr/logr/logr.go b/vendor/github.com/go-logr/logr/logr.go index 44cd398c9f8..c05482a2031 100644 --- a/vendor/github.com/go-logr/logr/logr.go +++ b/vendor/github.com/go-logr/logr/logr.go @@ -43,7 +43,9 @@ limitations under the License. // // Info() and Error() are very similar, but they are separate methods so that // LogSink implementations can choose to do things like attach additional -// information (such as stack traces) on calls to Error(). +// information (such as stack traces) on calls to Error(). Error() messages are +// always logged, regardless of the current verbosity. If there is no error +// instance available, passing nil is valid. // // Verbosity // @@ -53,6 +55,7 @@ limitations under the License. // Log-lines with V-levels that are not enabled (as per the LogSink) will not // be written. Level V(0) is the default, and logger.V(0).Info() has the same // meaning as logger.Info(). Negative V-levels have the same meaning as V(0). +// Error messages do not have a verbosity level and are always logged. // // Where we might have written: // if flVerbose >= 2 { @@ -253,11 +256,13 @@ func (l Logger) Info(msg string, keysAndValues ...interface{}) { // Error logs an error, with the given message and key/value pairs as context. // It functions similarly to Info, but may have unique behavior, and should be // preferred for logging errors (see the package documentations for more -// information). +// information). The log message will always be emitted, regardless of +// verbosity level. // // The msg argument should be used to add context to any underlying error, // while the err argument should be used to attach the actual error that -// triggered this log line, if present. +// triggered this log line, if present. The err parameter is optional +// and nil may be passed instead of an error instance. func (l Logger) Error(err error, msg string, keysAndValues ...interface{}) { if withHelper, ok := l.sink.(CallStackHelperLogSink); ok { withHelper.GetCallStackHelper()() diff --git a/vendor/github.com/go-openapi/analysis/.codecov.yml b/vendor/github.com/go-openapi/analysis/.codecov.yml new file mode 100644 index 00000000000..841c4281e23 --- /dev/null +++ b/vendor/github.com/go-openapi/analysis/.codecov.yml @@ -0,0 +1,5 @@ +coverage: + status: + patch: + default: + target: 80% diff --git a/vendor/github.com/go-openapi/analysis/.gitattributes b/vendor/github.com/go-openapi/analysis/.gitattributes new file mode 100644 index 00000000000..d020be8ea4e --- /dev/null +++ b/vendor/github.com/go-openapi/analysis/.gitattributes @@ -0,0 +1,2 @@ +*.go text eol=lf + diff --git a/vendor/github.com/go-openapi/analysis/.gitignore b/vendor/github.com/go-openapi/analysis/.gitignore new file mode 100644 index 00000000000..87c3bd3e66e --- /dev/null +++ b/vendor/github.com/go-openapi/analysis/.gitignore @@ -0,0 +1,5 @@ +secrets.yml +coverage.out +coverage.txt +*.cov +.idea diff --git a/vendor/github.com/go-openapi/analysis/.golangci.yml b/vendor/github.com/go-openapi/analysis/.golangci.yml new file mode 100644 index 00000000000..8cad2987919 --- /dev/null +++ b/vendor/github.com/go-openapi/analysis/.golangci.yml @@ -0,0 +1,53 @@ +linters-settings: + govet: + check-shadowing: true + golint: + min-confidence: 0 + gocyclo: + min-complexity: 40 + gocognit: + min-complexity: 40 + maligned: + suggest-new: true + dupl: + threshold: 150 + goconst: + min-len: 2 + min-occurrences: 4 + +linters: + enable-all: true + disable: + - maligned + - lll + - gochecknoglobals + - gochecknoinits + # scopelint is useful, but also reports false positives + # that unfortunately can't be disabled. So we disable the + # linter rather than changing code that works. + # see: https://github.com/kyoh86/scopelint/issues/4 + - scopelint + - godox + - gocognit + #- whitespace + - wsl + - funlen + - testpackage + - wrapcheck + #- nlreturn + - gomnd + - goerr113 + - exhaustivestruct + #- errorlint + #- nestif + - gofumpt + - godot + - gci + - dogsled + - paralleltest + - tparallel + - thelper + - ifshort + - forbidigo + - cyclop + - varnamelen diff --git a/vendor/github.com/go-openapi/analysis/CODE_OF_CONDUCT.md b/vendor/github.com/go-openapi/analysis/CODE_OF_CONDUCT.md new file mode 100644 index 00000000000..9322b065e37 --- /dev/null +++ b/vendor/github.com/go-openapi/analysis/CODE_OF_CONDUCT.md @@ -0,0 +1,74 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or +advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at ivan+abuse@flanders.co.nz. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/vendor/github.com/go-openapi/analysis/LICENSE b/vendor/github.com/go-openapi/analysis/LICENSE new file mode 100644 index 00000000000..d6456956733 --- /dev/null +++ b/vendor/github.com/go-openapi/analysis/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/go-openapi/analysis/README.md b/vendor/github.com/go-openapi/analysis/README.md new file mode 100644 index 00000000000..aad6da10fe7 --- /dev/null +++ b/vendor/github.com/go-openapi/analysis/README.md @@ -0,0 +1,31 @@ +# OpenAPI initiative analysis + +[![Build Status](https://travis-ci.org/go-openapi/analysis.svg?branch=master)](https://travis-ci.org/go-openapi/analysis) +[![Build status](https://ci.appveyor.com/api/projects/status/x377t5o9ennm847o/branch/master?svg=true)](https://ci.appveyor.com/project/casualjim/go-openapi/analysis/branch/master) +[![codecov](https://codecov.io/gh/go-openapi/analysis/branch/master/graph/badge.svg)](https://codecov.io/gh/go-openapi/analysis) +[![Slack Status](https://slackin.goswagger.io/badge.svg)](https://slackin.goswagger.io) +[![license](http://img.shields.io/badge/license-Apache%20v2-orange.svg)](https://raw.githubusercontent.com/go-openapi/analysis/master/LICENSE) +[![Go Reference](https://pkg.go.dev/badge/github.com/go-openapi/analysis.svg)](https://pkg.go.dev/github.com/go-openapi/analysis) +[![Go Report Card](https://goreportcard.com/badge/github.com/go-openapi/analysis)](https://goreportcard.com/report/github.com/go-openapi/analysis) + + +A foundational library to analyze an OAI specification document for easier reasoning about the content. + +## What's inside? + +* A analyzer providing methods to walk the functional content of a specification +* A spec flattener producing a self-contained document bundle, while preserving `$ref`s +* A spec merger ("mixin") to merge several spec documents into a primary spec +* A spec "fixer" ensuring that response descriptions are non empty + +[Documentation](https://godoc.org/github.com/go-openapi/analysis) + +## FAQ + +* Does this library support OpenAPI 3? + +> No. +> This package currently only supports OpenAPI 2.0 (aka Swagger 2.0). +> There is no plan to make it evolve toward supporting OpenAPI 3.x. +> This [discussion thread](https://github.com/go-openapi/spec/issues/21) relates the full story. +> diff --git a/vendor/github.com/go-openapi/analysis/analyzer.go b/vendor/github.com/go-openapi/analysis/analyzer.go new file mode 100644 index 00000000000..c17aee1b617 --- /dev/null +++ b/vendor/github.com/go-openapi/analysis/analyzer.go @@ -0,0 +1,1064 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package analysis + +import ( + "fmt" + slashpath "path" + "strconv" + "strings" + + "github.com/go-openapi/jsonpointer" + "github.com/go-openapi/spec" + "github.com/go-openapi/swag" +) + +type referenceAnalysis struct { + schemas map[string]spec.Ref + responses map[string]spec.Ref + parameters map[string]spec.Ref + items map[string]spec.Ref + headerItems map[string]spec.Ref + parameterItems map[string]spec.Ref + allRefs map[string]spec.Ref + pathItems map[string]spec.Ref +} + +func (r *referenceAnalysis) addRef(key string, ref spec.Ref) { + r.allRefs["#"+key] = ref +} + +func (r *referenceAnalysis) addItemsRef(key string, items *spec.Items, location string) { + r.items["#"+key] = items.Ref + r.addRef(key, items.Ref) + if location == "header" { + // NOTE: in swagger 2.0, headers and parameters (but not body param schemas) are simple schemas + // and $ref are not supported here. However it is possible to analyze this. + r.headerItems["#"+key] = items.Ref + } else { + r.parameterItems["#"+key] = items.Ref + } +} + +func (r *referenceAnalysis) addSchemaRef(key string, ref SchemaRef) { + r.schemas["#"+key] = ref.Schema.Ref + r.addRef(key, ref.Schema.Ref) +} + +func (r *referenceAnalysis) addResponseRef(key string, resp *spec.Response) { + r.responses["#"+key] = resp.Ref + r.addRef(key, resp.Ref) +} + +func (r *referenceAnalysis) addParamRef(key string, param *spec.Parameter) { + r.parameters["#"+key] = param.Ref + r.addRef(key, param.Ref) +} + +func (r *referenceAnalysis) addPathItemRef(key string, pathItem *spec.PathItem) { + r.pathItems["#"+key] = pathItem.Ref + r.addRef(key, pathItem.Ref) +} + +type patternAnalysis struct { + parameters map[string]string + headers map[string]string + items map[string]string + schemas map[string]string + allPatterns map[string]string +} + +func (p *patternAnalysis) addPattern(key, pattern string) { + p.allPatterns["#"+key] = pattern +} + +func (p *patternAnalysis) addParameterPattern(key, pattern string) { + p.parameters["#"+key] = pattern + p.addPattern(key, pattern) +} + +func (p *patternAnalysis) addHeaderPattern(key, pattern string) { + p.headers["#"+key] = pattern + p.addPattern(key, pattern) +} + +func (p *patternAnalysis) addItemsPattern(key, pattern string) { + p.items["#"+key] = pattern + p.addPattern(key, pattern) +} + +func (p *patternAnalysis) addSchemaPattern(key, pattern string) { + p.schemas["#"+key] = pattern + p.addPattern(key, pattern) +} + +type enumAnalysis struct { + parameters map[string][]interface{} + headers map[string][]interface{} + items map[string][]interface{} + schemas map[string][]interface{} + allEnums map[string][]interface{} +} + +func (p *enumAnalysis) addEnum(key string, enum []interface{}) { + p.allEnums["#"+key] = enum +} + +func (p *enumAnalysis) addParameterEnum(key string, enum []interface{}) { + p.parameters["#"+key] = enum + p.addEnum(key, enum) +} + +func (p *enumAnalysis) addHeaderEnum(key string, enum []interface{}) { + p.headers["#"+key] = enum + p.addEnum(key, enum) +} + +func (p *enumAnalysis) addItemsEnum(key string, enum []interface{}) { + p.items["#"+key] = enum + p.addEnum(key, enum) +} + +func (p *enumAnalysis) addSchemaEnum(key string, enum []interface{}) { + p.schemas["#"+key] = enum + p.addEnum(key, enum) +} + +// New takes a swagger spec object and returns an analyzed spec document. +// The analyzed document contains a number of indices that make it easier to +// reason about semantics of a swagger specification for use in code generation +// or validation etc. +func New(doc *spec.Swagger) *Spec { + a := &Spec{ + spec: doc, + references: referenceAnalysis{}, + patterns: patternAnalysis{}, + enums: enumAnalysis{}, + } + a.reset() + a.initialize() + + return a +} + +// Spec is an analyzed specification object. It takes a swagger spec object and turns it into a registry +// with a bunch of utility methods to act on the information in the spec. +type Spec struct { + spec *spec.Swagger + consumes map[string]struct{} + produces map[string]struct{} + authSchemes map[string]struct{} + operations map[string]map[string]*spec.Operation + references referenceAnalysis + patterns patternAnalysis + enums enumAnalysis + allSchemas map[string]SchemaRef + allOfs map[string]SchemaRef +} + +func (s *Spec) reset() { + s.consumes = make(map[string]struct{}, 150) + s.produces = make(map[string]struct{}, 150) + s.authSchemes = make(map[string]struct{}, 150) + s.operations = make(map[string]map[string]*spec.Operation, 150) + s.allSchemas = make(map[string]SchemaRef, 150) + s.allOfs = make(map[string]SchemaRef, 150) + s.references.schemas = make(map[string]spec.Ref, 150) + s.references.pathItems = make(map[string]spec.Ref, 150) + s.references.responses = make(map[string]spec.Ref, 150) + s.references.parameters = make(map[string]spec.Ref, 150) + s.references.items = make(map[string]spec.Ref, 150) + s.references.headerItems = make(map[string]spec.Ref, 150) + s.references.parameterItems = make(map[string]spec.Ref, 150) + s.references.allRefs = make(map[string]spec.Ref, 150) + s.patterns.parameters = make(map[string]string, 150) + s.patterns.headers = make(map[string]string, 150) + s.patterns.items = make(map[string]string, 150) + s.patterns.schemas = make(map[string]string, 150) + s.patterns.allPatterns = make(map[string]string, 150) + s.enums.parameters = make(map[string][]interface{}, 150) + s.enums.headers = make(map[string][]interface{}, 150) + s.enums.items = make(map[string][]interface{}, 150) + s.enums.schemas = make(map[string][]interface{}, 150) + s.enums.allEnums = make(map[string][]interface{}, 150) +} + +func (s *Spec) reload() { + s.reset() + s.initialize() +} + +func (s *Spec) initialize() { + for _, c := range s.spec.Consumes { + s.consumes[c] = struct{}{} + } + for _, c := range s.spec.Produces { + s.produces[c] = struct{}{} + } + for _, ss := range s.spec.Security { + for k := range ss { + s.authSchemes[k] = struct{}{} + } + } + for path, pathItem := range s.AllPaths() { + s.analyzeOperations(path, &pathItem) //#nosec + } + + for name, parameter := range s.spec.Parameters { + refPref := slashpath.Join("/parameters", jsonpointer.Escape(name)) + if parameter.Items != nil { + s.analyzeItems("items", parameter.Items, refPref, "parameter") + } + if parameter.In == "body" && parameter.Schema != nil { + s.analyzeSchema("schema", parameter.Schema, refPref) + } + if parameter.Pattern != "" { + s.patterns.addParameterPattern(refPref, parameter.Pattern) + } + if len(parameter.Enum) > 0 { + s.enums.addParameterEnum(refPref, parameter.Enum) + } + } + + for name, response := range s.spec.Responses { + refPref := slashpath.Join("/responses", jsonpointer.Escape(name)) + for k, v := range response.Headers { + hRefPref := slashpath.Join(refPref, "headers", k) + if v.Items != nil { + s.analyzeItems("items", v.Items, hRefPref, "header") + } + if v.Pattern != "" { + s.patterns.addHeaderPattern(hRefPref, v.Pattern) + } + if len(v.Enum) > 0 { + s.enums.addHeaderEnum(hRefPref, v.Enum) + } + } + if response.Schema != nil { + s.analyzeSchema("schema", response.Schema, refPref) + } + } + + for name := range s.spec.Definitions { + schema := s.spec.Definitions[name] + s.analyzeSchema(name, &schema, "/definitions") + } + // TODO: after analyzing all things and flattening schemas etc + // resolve all the collected references to their final representations + // best put in a separate method because this could get expensive +} + +func (s *Spec) analyzeOperations(path string, pi *spec.PathItem) { + // TODO: resolve refs here? + // Currently, operations declared via pathItem $ref are known only after expansion + op := pi + if pi.Ref.String() != "" { + key := slashpath.Join("/paths", jsonpointer.Escape(path)) + s.references.addPathItemRef(key, pi) + } + s.analyzeOperation("GET", path, op.Get) + s.analyzeOperation("PUT", path, op.Put) + s.analyzeOperation("POST", path, op.Post) + s.analyzeOperation("PATCH", path, op.Patch) + s.analyzeOperation("DELETE", path, op.Delete) + s.analyzeOperation("HEAD", path, op.Head) + s.analyzeOperation("OPTIONS", path, op.Options) + for i, param := range op.Parameters { + refPref := slashpath.Join("/paths", jsonpointer.Escape(path), "parameters", strconv.Itoa(i)) + if param.Ref.String() != "" { + s.references.addParamRef(refPref, ¶m) //#nosec + } + if param.Pattern != "" { + s.patterns.addParameterPattern(refPref, param.Pattern) + } + if len(param.Enum) > 0 { + s.enums.addParameterEnum(refPref, param.Enum) + } + if param.Items != nil { + s.analyzeItems("items", param.Items, refPref, "parameter") + } + if param.Schema != nil { + s.analyzeSchema("schema", param.Schema, refPref) + } + } +} + +func (s *Spec) analyzeItems(name string, items *spec.Items, prefix, location string) { + if items == nil { + return + } + refPref := slashpath.Join(prefix, name) + s.analyzeItems(name, items.Items, refPref, location) + if items.Ref.String() != "" { + s.references.addItemsRef(refPref, items, location) + } + if items.Pattern != "" { + s.patterns.addItemsPattern(refPref, items.Pattern) + } + if len(items.Enum) > 0 { + s.enums.addItemsEnum(refPref, items.Enum) + } +} + +func (s *Spec) analyzeParameter(prefix string, i int, param spec.Parameter) { + refPref := slashpath.Join(prefix, "parameters", strconv.Itoa(i)) + if param.Ref.String() != "" { + s.references.addParamRef(refPref, ¶m) //#nosec + } + + if param.Pattern != "" { + s.patterns.addParameterPattern(refPref, param.Pattern) + } + + if len(param.Enum) > 0 { + s.enums.addParameterEnum(refPref, param.Enum) + } + + s.analyzeItems("items", param.Items, refPref, "parameter") + if param.In == "body" && param.Schema != nil { + s.analyzeSchema("schema", param.Schema, refPref) + } +} + +func (s *Spec) analyzeOperation(method, path string, op *spec.Operation) { + if op == nil { + return + } + + for _, c := range op.Consumes { + s.consumes[c] = struct{}{} + } + + for _, c := range op.Produces { + s.produces[c] = struct{}{} + } + + for _, ss := range op.Security { + for k := range ss { + s.authSchemes[k] = struct{}{} + } + } + + if _, ok := s.operations[method]; !ok { + s.operations[method] = make(map[string]*spec.Operation) + } + + s.operations[method][path] = op + prefix := slashpath.Join("/paths", jsonpointer.Escape(path), strings.ToLower(method)) + for i, param := range op.Parameters { + s.analyzeParameter(prefix, i, param) + } + + if op.Responses == nil { + return + } + + if op.Responses.Default != nil { + s.analyzeDefaultResponse(prefix, op.Responses.Default) + } + + for k, res := range op.Responses.StatusCodeResponses { + s.analyzeResponse(prefix, k, res) + } +} + +func (s *Spec) analyzeDefaultResponse(prefix string, res *spec.Response) { + refPref := slashpath.Join(prefix, "responses", "default") + if res.Ref.String() != "" { + s.references.addResponseRef(refPref, res) + } + + for k, v := range res.Headers { + hRefPref := slashpath.Join(refPref, "headers", k) + s.analyzeItems("items", v.Items, hRefPref, "header") + if v.Pattern != "" { + s.patterns.addHeaderPattern(hRefPref, v.Pattern) + } + } + + if res.Schema != nil { + s.analyzeSchema("schema", res.Schema, refPref) + } +} + +func (s *Spec) analyzeResponse(prefix string, k int, res spec.Response) { + refPref := slashpath.Join(prefix, "responses", strconv.Itoa(k)) + if res.Ref.String() != "" { + s.references.addResponseRef(refPref, &res) //#nosec + } + + for k, v := range res.Headers { + hRefPref := slashpath.Join(refPref, "headers", k) + s.analyzeItems("items", v.Items, hRefPref, "header") + if v.Pattern != "" { + s.patterns.addHeaderPattern(hRefPref, v.Pattern) + } + + if len(v.Enum) > 0 { + s.enums.addHeaderEnum(hRefPref, v.Enum) + } + } + + if res.Schema != nil { + s.analyzeSchema("schema", res.Schema, refPref) + } +} + +func (s *Spec) analyzeSchema(name string, schema *spec.Schema, prefix string) { + refURI := slashpath.Join(prefix, jsonpointer.Escape(name)) + schRef := SchemaRef{ + Name: name, + Schema: schema, + Ref: spec.MustCreateRef("#" + refURI), + TopLevel: prefix == "/definitions", + } + + s.allSchemas["#"+refURI] = schRef + + if schema.Ref.String() != "" { + s.references.addSchemaRef(refURI, schRef) + } + + if schema.Pattern != "" { + s.patterns.addSchemaPattern(refURI, schema.Pattern) + } + + if len(schema.Enum) > 0 { + s.enums.addSchemaEnum(refURI, schema.Enum) + } + + for k, v := range schema.Definitions { + v := v + s.analyzeSchema(k, &v, slashpath.Join(refURI, "definitions")) + } + + for k, v := range schema.Properties { + v := v + s.analyzeSchema(k, &v, slashpath.Join(refURI, "properties")) + } + + for k, v := range schema.PatternProperties { + v := v + // NOTE: swagger 2.0 does not support PatternProperties. + // However it is possible to analyze this in a schema + s.analyzeSchema(k, &v, slashpath.Join(refURI, "patternProperties")) + } + + for i := range schema.AllOf { + v := &schema.AllOf[i] + s.analyzeSchema(strconv.Itoa(i), v, slashpath.Join(refURI, "allOf")) + } + + if len(schema.AllOf) > 0 { + s.allOfs["#"+refURI] = schRef + } + + for i := range schema.AnyOf { + v := &schema.AnyOf[i] + // NOTE: swagger 2.0 does not support anyOf constructs. + // However it is possible to analyze this in a schema + s.analyzeSchema(strconv.Itoa(i), v, slashpath.Join(refURI, "anyOf")) + } + + for i := range schema.OneOf { + v := &schema.OneOf[i] + // NOTE: swagger 2.0 does not support oneOf constructs. + // However it is possible to analyze this in a schema + s.analyzeSchema(strconv.Itoa(i), v, slashpath.Join(refURI, "oneOf")) + } + + if schema.Not != nil { + // NOTE: swagger 2.0 does not support "not" constructs. + // However it is possible to analyze this in a schema + s.analyzeSchema("not", schema.Not, refURI) + } + + if schema.AdditionalProperties != nil && schema.AdditionalProperties.Schema != nil { + s.analyzeSchema("additionalProperties", schema.AdditionalProperties.Schema, refURI) + } + + if schema.AdditionalItems != nil && schema.AdditionalItems.Schema != nil { + // NOTE: swagger 2.0 does not support AdditionalItems. + // However it is possible to analyze this in a schema + s.analyzeSchema("additionalItems", schema.AdditionalItems.Schema, refURI) + } + + if schema.Items != nil { + if schema.Items.Schema != nil { + s.analyzeSchema("items", schema.Items.Schema, refURI) + } + + for i := range schema.Items.Schemas { + sch := &schema.Items.Schemas[i] + s.analyzeSchema(strconv.Itoa(i), sch, slashpath.Join(refURI, "items")) + } + } +} + +// SecurityRequirement is a representation of a security requirement for an operation +type SecurityRequirement struct { + Name string + Scopes []string +} + +// SecurityRequirementsFor gets the security requirements for the operation +func (s *Spec) SecurityRequirementsFor(operation *spec.Operation) [][]SecurityRequirement { + if s.spec.Security == nil && operation.Security == nil { + return nil + } + + schemes := s.spec.Security + if operation.Security != nil { + schemes = operation.Security + } + + result := [][]SecurityRequirement{} + for _, scheme := range schemes { + if len(scheme) == 0 { + // append a zero object for anonymous + result = append(result, []SecurityRequirement{{}}) + + continue + } + + var reqs []SecurityRequirement + for k, v := range scheme { + if v == nil { + v = []string{} + } + reqs = append(reqs, SecurityRequirement{Name: k, Scopes: v}) + } + + result = append(result, reqs) + } + + return result +} + +// SecurityDefinitionsForRequirements gets the matching security definitions for a set of requirements +func (s *Spec) SecurityDefinitionsForRequirements(requirements []SecurityRequirement) map[string]spec.SecurityScheme { + result := make(map[string]spec.SecurityScheme) + + for _, v := range requirements { + if definition, ok := s.spec.SecurityDefinitions[v.Name]; ok { + if definition != nil { + result[v.Name] = *definition + } + } + } + + return result +} + +// SecurityDefinitionsFor gets the matching security definitions for a set of requirements +func (s *Spec) SecurityDefinitionsFor(operation *spec.Operation) map[string]spec.SecurityScheme { + requirements := s.SecurityRequirementsFor(operation) + if len(requirements) == 0 { + return nil + } + + result := make(map[string]spec.SecurityScheme) + for _, reqs := range requirements { + for _, v := range reqs { + if v.Name == "" { + // optional requirement + continue + } + + if _, ok := result[v.Name]; ok { + // duplicate requirement + continue + } + + if definition, ok := s.spec.SecurityDefinitions[v.Name]; ok { + if definition != nil { + result[v.Name] = *definition + } + } + } + } + + return result +} + +// ConsumesFor gets the mediatypes for the operation +func (s *Spec) ConsumesFor(operation *spec.Operation) []string { + if len(operation.Consumes) == 0 { + cons := make(map[string]struct{}, len(s.spec.Consumes)) + for _, k := range s.spec.Consumes { + cons[k] = struct{}{} + } + + return s.structMapKeys(cons) + } + + cons := make(map[string]struct{}, len(operation.Consumes)) + for _, c := range operation.Consumes { + cons[c] = struct{}{} + } + + return s.structMapKeys(cons) +} + +// ProducesFor gets the mediatypes for the operation +func (s *Spec) ProducesFor(operation *spec.Operation) []string { + if len(operation.Produces) == 0 { + prod := make(map[string]struct{}, len(s.spec.Produces)) + for _, k := range s.spec.Produces { + prod[k] = struct{}{} + } + + return s.structMapKeys(prod) + } + + prod := make(map[string]struct{}, len(operation.Produces)) + for _, c := range operation.Produces { + prod[c] = struct{}{} + } + + return s.structMapKeys(prod) +} + +func mapKeyFromParam(param *spec.Parameter) string { + return fmt.Sprintf("%s#%s", param.In, fieldNameFromParam(param)) +} + +func fieldNameFromParam(param *spec.Parameter) string { + // TODO: this should be x-go-name + if nm, ok := param.Extensions.GetString("go-name"); ok { + return nm + } + + return swag.ToGoName(param.Name) +} + +// ErrorOnParamFunc is a callback function to be invoked +// whenever an error is encountered while resolving references +// on parameters. +// +// This function takes as input the spec.Parameter which triggered the +// error and the error itself. +// +// If the callback function returns false, the calling function should bail. +// +// If it returns true, the calling function should continue evaluating parameters. +// A nil ErrorOnParamFunc must be evaluated as equivalent to panic(). +type ErrorOnParamFunc func(spec.Parameter, error) bool + +func (s *Spec) paramsAsMap(parameters []spec.Parameter, res map[string]spec.Parameter, callmeOnError ErrorOnParamFunc) { + for _, param := range parameters { + pr := param + if pr.Ref.String() == "" { + res[mapKeyFromParam(&pr)] = pr + + continue + } + + // resolve $ref + if callmeOnError == nil { + callmeOnError = func(_ spec.Parameter, err error) bool { + panic(err) + } + } + + obj, _, err := pr.Ref.GetPointer().Get(s.spec) + if err != nil { + if callmeOnError(param, fmt.Errorf("invalid reference: %q", pr.Ref.String())) { + continue + } + + break + } + + objAsParam, ok := obj.(spec.Parameter) + if !ok { + if callmeOnError(param, fmt.Errorf("resolved reference is not a parameter: %q", pr.Ref.String())) { + continue + } + + break + } + + pr = objAsParam + res[mapKeyFromParam(&pr)] = pr + } +} + +// ParametersFor the specified operation id. +// +// Assumes parameters properly resolve references if any and that +// such references actually resolve to a parameter object. +// Otherwise, panics. +func (s *Spec) ParametersFor(operationID string) []spec.Parameter { + return s.SafeParametersFor(operationID, nil) +} + +// SafeParametersFor the specified operation id. +// +// Does not assume parameters properly resolve references or that +// such references actually resolve to a parameter object. +// +// Upon error, invoke a ErrorOnParamFunc callback with the erroneous +// parameters. If the callback is set to nil, panics upon errors. +func (s *Spec) SafeParametersFor(operationID string, callmeOnError ErrorOnParamFunc) []spec.Parameter { + gatherParams := func(pi *spec.PathItem, op *spec.Operation) []spec.Parameter { + bag := make(map[string]spec.Parameter) + s.paramsAsMap(pi.Parameters, bag, callmeOnError) + s.paramsAsMap(op.Parameters, bag, callmeOnError) + + var res []spec.Parameter + for _, v := range bag { + res = append(res, v) + } + + return res + } + + for _, pi := range s.spec.Paths.Paths { + if pi.Get != nil && pi.Get.ID == operationID { + return gatherParams(&pi, pi.Get) //#nosec + } + if pi.Head != nil && pi.Head.ID == operationID { + return gatherParams(&pi, pi.Head) //#nosec + } + if pi.Options != nil && pi.Options.ID == operationID { + return gatherParams(&pi, pi.Options) //#nosec + } + if pi.Post != nil && pi.Post.ID == operationID { + return gatherParams(&pi, pi.Post) //#nosec + } + if pi.Patch != nil && pi.Patch.ID == operationID { + return gatherParams(&pi, pi.Patch) //#nosec + } + if pi.Put != nil && pi.Put.ID == operationID { + return gatherParams(&pi, pi.Put) //#nosec + } + if pi.Delete != nil && pi.Delete.ID == operationID { + return gatherParams(&pi, pi.Delete) //#nosec + } + } + + return nil +} + +// ParamsFor the specified method and path. Aggregates them with the defaults etc, so it's all the params that +// apply for the method and path. +// +// Assumes parameters properly resolve references if any and that +// such references actually resolve to a parameter object. +// Otherwise, panics. +func (s *Spec) ParamsFor(method, path string) map[string]spec.Parameter { + return s.SafeParamsFor(method, path, nil) +} + +// SafeParamsFor the specified method and path. Aggregates them with the defaults etc, so it's all the params that +// apply for the method and path. +// +// Does not assume parameters properly resolve references or that +// such references actually resolve to a parameter object. +// +// Upon error, invoke a ErrorOnParamFunc callback with the erroneous +// parameters. If the callback is set to nil, panics upon errors. +func (s *Spec) SafeParamsFor(method, path string, callmeOnError ErrorOnParamFunc) map[string]spec.Parameter { + res := make(map[string]spec.Parameter) + if pi, ok := s.spec.Paths.Paths[path]; ok { + s.paramsAsMap(pi.Parameters, res, callmeOnError) + s.paramsAsMap(s.operations[strings.ToUpper(method)][path].Parameters, res, callmeOnError) + } + + return res +} + +// OperationForName gets the operation for the given id +func (s *Spec) OperationForName(operationID string) (string, string, *spec.Operation, bool) { + for method, pathItem := range s.operations { + for path, op := range pathItem { + if operationID == op.ID { + return method, path, op, true + } + } + } + + return "", "", nil, false +} + +// OperationFor the given method and path +func (s *Spec) OperationFor(method, path string) (*spec.Operation, bool) { + if mp, ok := s.operations[strings.ToUpper(method)]; ok { + op, fn := mp[path] + + return op, fn + } + + return nil, false +} + +// Operations gathers all the operations specified in the spec document +func (s *Spec) Operations() map[string]map[string]*spec.Operation { + return s.operations +} + +func (s *Spec) structMapKeys(mp map[string]struct{}) []string { + if len(mp) == 0 { + return nil + } + + result := make([]string, 0, len(mp)) + for k := range mp { + result = append(result, k) + } + + return result +} + +// AllPaths returns all the paths in the swagger spec +func (s *Spec) AllPaths() map[string]spec.PathItem { + if s.spec == nil || s.spec.Paths == nil { + return nil + } + + return s.spec.Paths.Paths +} + +// OperationIDs gets all the operation ids based on method an dpath +func (s *Spec) OperationIDs() []string { + if len(s.operations) == 0 { + return nil + } + + result := make([]string, 0, len(s.operations)) + for method, v := range s.operations { + for p, o := range v { + if o.ID != "" { + result = append(result, o.ID) + } else { + result = append(result, fmt.Sprintf("%s %s", strings.ToUpper(method), p)) + } + } + } + + return result +} + +// OperationMethodPaths gets all the operation ids based on method an dpath +func (s *Spec) OperationMethodPaths() []string { + if len(s.operations) == 0 { + return nil + } + + result := make([]string, 0, len(s.operations)) + for method, v := range s.operations { + for p := range v { + result = append(result, fmt.Sprintf("%s %s", strings.ToUpper(method), p)) + } + } + + return result +} + +// RequiredConsumes gets all the distinct consumes that are specified in the specification document +func (s *Spec) RequiredConsumes() []string { + return s.structMapKeys(s.consumes) +} + +// RequiredProduces gets all the distinct produces that are specified in the specification document +func (s *Spec) RequiredProduces() []string { + return s.structMapKeys(s.produces) +} + +// RequiredSecuritySchemes gets all the distinct security schemes that are specified in the swagger spec +func (s *Spec) RequiredSecuritySchemes() []string { + return s.structMapKeys(s.authSchemes) +} + +// SchemaRef is a reference to a schema +type SchemaRef struct { + Name string + Ref spec.Ref + Schema *spec.Schema + TopLevel bool +} + +// SchemasWithAllOf returns schema references to all schemas that are defined +// with an allOf key +func (s *Spec) SchemasWithAllOf() (result []SchemaRef) { + for _, v := range s.allOfs { + result = append(result, v) + } + + return +} + +// AllDefinitions returns schema references for all the definitions that were discovered +func (s *Spec) AllDefinitions() (result []SchemaRef) { + for _, v := range s.allSchemas { + result = append(result, v) + } + + return +} + +// AllDefinitionReferences returns json refs for all the discovered schemas +func (s *Spec) AllDefinitionReferences() (result []string) { + for _, v := range s.references.schemas { + result = append(result, v.String()) + } + + return +} + +// AllParameterReferences returns json refs for all the discovered parameters +func (s *Spec) AllParameterReferences() (result []string) { + for _, v := range s.references.parameters { + result = append(result, v.String()) + } + + return +} + +// AllResponseReferences returns json refs for all the discovered responses +func (s *Spec) AllResponseReferences() (result []string) { + for _, v := range s.references.responses { + result = append(result, v.String()) + } + + return +} + +// AllPathItemReferences returns the references for all the items +func (s *Spec) AllPathItemReferences() (result []string) { + for _, v := range s.references.pathItems { + result = append(result, v.String()) + } + + return +} + +// AllItemsReferences returns the references for all the items in simple schemas (parameters or headers). +// +// NOTE: since Swagger 2.0 forbids $ref in simple params, this should always yield an empty slice for a valid +// Swagger 2.0 spec. +func (s *Spec) AllItemsReferences() (result []string) { + for _, v := range s.references.items { + result = append(result, v.String()) + } + + return +} + +// AllReferences returns all the references found in the document, with possible duplicates +func (s *Spec) AllReferences() (result []string) { + for _, v := range s.references.allRefs { + result = append(result, v.String()) + } + + return +} + +// AllRefs returns all the unique references found in the document +func (s *Spec) AllRefs() (result []spec.Ref) { + set := make(map[string]struct{}) + for _, v := range s.references.allRefs { + a := v.String() + if a == "" { + continue + } + + if _, ok := set[a]; !ok { + set[a] = struct{}{} + result = append(result, v) + } + } + + return +} + +func cloneStringMap(source map[string]string) map[string]string { + res := make(map[string]string, len(source)) + for k, v := range source { + res[k] = v + } + + return res +} + +func cloneEnumMap(source map[string][]interface{}) map[string][]interface{} { + res := make(map[string][]interface{}, len(source)) + for k, v := range source { + res[k] = v + } + + return res +} + +// ParameterPatterns returns all the patterns found in parameters +// the map is cloned to avoid accidental changes +func (s *Spec) ParameterPatterns() map[string]string { + return cloneStringMap(s.patterns.parameters) +} + +// HeaderPatterns returns all the patterns found in response headers +// the map is cloned to avoid accidental changes +func (s *Spec) HeaderPatterns() map[string]string { + return cloneStringMap(s.patterns.headers) +} + +// ItemsPatterns returns all the patterns found in simple array items +// the map is cloned to avoid accidental changes +func (s *Spec) ItemsPatterns() map[string]string { + return cloneStringMap(s.patterns.items) +} + +// SchemaPatterns returns all the patterns found in schemas +// the map is cloned to avoid accidental changes +func (s *Spec) SchemaPatterns() map[string]string { + return cloneStringMap(s.patterns.schemas) +} + +// AllPatterns returns all the patterns found in the spec +// the map is cloned to avoid accidental changes +func (s *Spec) AllPatterns() map[string]string { + return cloneStringMap(s.patterns.allPatterns) +} + +// ParameterEnums returns all the enums found in parameters +// the map is cloned to avoid accidental changes +func (s *Spec) ParameterEnums() map[string][]interface{} { + return cloneEnumMap(s.enums.parameters) +} + +// HeaderEnums returns all the enums found in response headers +// the map is cloned to avoid accidental changes +func (s *Spec) HeaderEnums() map[string][]interface{} { + return cloneEnumMap(s.enums.headers) +} + +// ItemsEnums returns all the enums found in simple array items +// the map is cloned to avoid accidental changes +func (s *Spec) ItemsEnums() map[string][]interface{} { + return cloneEnumMap(s.enums.items) +} + +// SchemaEnums returns all the enums found in schemas +// the map is cloned to avoid accidental changes +func (s *Spec) SchemaEnums() map[string][]interface{} { + return cloneEnumMap(s.enums.schemas) +} + +// AllEnums returns all the enums found in the spec +// the map is cloned to avoid accidental changes +func (s *Spec) AllEnums() map[string][]interface{} { + return cloneEnumMap(s.enums.allEnums) +} diff --git a/vendor/github.com/go-openapi/analysis/appveyor.yml b/vendor/github.com/go-openapi/analysis/appveyor.yml new file mode 100644 index 00000000000..c2f6fd733a9 --- /dev/null +++ b/vendor/github.com/go-openapi/analysis/appveyor.yml @@ -0,0 +1,32 @@ +version: "0.1.{build}" + +clone_folder: C:\go-openapi\analysis +shallow_clone: true # for startup speed +pull_requests: + do_not_increment_build_number: true + +#skip_tags: true +#skip_branch_with_pr: true + +# appveyor.yml +build: off + +environment: + GOPATH: c:\gopath + +stack: go 1.16 + +test_script: + - go test -v -timeout 20m ./... + +deploy: off + +notifications: + - provider: Slack + incoming_webhook: https://hooks.slack.com/services/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 + auth_token: + secure: Sf7kZf7ZGbnwWUMpffHwMu5A0cHkLK2MYY32LNTPj4+/3qC3Ghl7+9v4TSLOqOlCwdRNjOGblAq7s+GDJed6/xgRQl1JtCi1klzZNrYX4q01pgTPvvGcwbBkIYgeMaPeIRcK9OZnud7sRXdttozgTOpytps2U6Js32ip7uj5mHSg2ub0FwoSJwlS6dbezZ8+eDhoha0F/guY99BEwx8Bd+zROrT2TFGsSGOFGN6wFc7moCqTHO/YkWib13a2QNXqOxCCVBy/lt76Wp+JkeFppjHlzs/2lP3EAk13RIUAaesdEUHvIHrzCyNJEd3/+KO2DzsWOYfpktd+KBCvgaYOsoo7ubdT3IROeAegZdCgo/6xgCEsmFc9ZcqCfN5yNx2A+BZ2Vwmpws+bQ1E1+B5HDzzaiLcYfG4X2O210QVGVDLWsv1jqD+uPYeHY2WRfh5ZsIUFvaqgUEnwHwrK44/8REAhQavt1QAj5uJpsRd7CkRVPWRNK+yIky+wgbVUFEchRNmS55E7QWf+W4+4QZkQi7vUTMc9nbTUu2Es9NfvfudOpM2wZbn98fjpb/qq/nRv6Bk+ca+7XD5/IgNLMbWp2ouDdzbiHLCOfDUiHiDJhLfFZx9Bwo7ZwfzeOlbrQX66bx7xRKYmOe4DLrXhNcpbsMa8qbfxlZRCmYbubB/Y8h4= + channel: bots + on_build_success: false + on_build_failure: true + on_build_status_changed: true diff --git a/vendor/github.com/go-openapi/analysis/debug.go b/vendor/github.com/go-openapi/analysis/debug.go new file mode 100644 index 00000000000..33c15704ecb --- /dev/null +++ b/vendor/github.com/go-openapi/analysis/debug.go @@ -0,0 +1,23 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package analysis + +import ( + "os" + + "github.com/go-openapi/analysis/internal/debug" +) + +var debugLog = debug.GetLogger("analysis", os.Getenv("SWAGGER_DEBUG") != "") diff --git a/vendor/github.com/go-openapi/analysis/doc.go b/vendor/github.com/go-openapi/analysis/doc.go new file mode 100644 index 00000000000..d5294c0950b --- /dev/null +++ b/vendor/github.com/go-openapi/analysis/doc.go @@ -0,0 +1,43 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/* +Package analysis provides methods to work with a Swagger specification document from +package go-openapi/spec. + +Analyzing a specification + +An analysed specification object (type Spec) provides methods to work with swagger definition. + +Flattening or expanding a specification + +Flattening a specification bundles all remote $ref in the main spec document. +Depending on flattening options, additional preprocessing may take place: + - full flattening: replacing all inline complex constructs by a named entry in #/definitions + - expand: replace all $ref's in the document by their expanded content + +Merging several specifications + +Mixin several specifications merges all Swagger constructs, and warns about found conflicts. + +Fixing a specification + +Unmarshalling a specification with golang json unmarshalling may lead to +some unwanted result on present but empty fields. + +Analyzing a Swagger schema + +Swagger schemas are analyzed to determine their complexity and qualify their content. +*/ +package analysis diff --git a/vendor/github.com/go-openapi/analysis/fixer.go b/vendor/github.com/go-openapi/analysis/fixer.go new file mode 100644 index 00000000000..7c2ca084162 --- /dev/null +++ b/vendor/github.com/go-openapi/analysis/fixer.go @@ -0,0 +1,79 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package analysis + +import "github.com/go-openapi/spec" + +// FixEmptyResponseDescriptions replaces empty ("") response +// descriptions in the input with "(empty)" to ensure that the +// resulting Swagger is stays valid. The problem appears to arise +// from reading in valid specs that have a explicit response +// description of "" (valid, response.description is required), but +// due to zero values being omitted upon re-serializing (omitempty) we +// lose them unless we stick some chars in there. +func FixEmptyResponseDescriptions(s *spec.Swagger) { + for k, v := range s.Responses { + FixEmptyDesc(&v) //#nosec + s.Responses[k] = v + } + + if s.Paths == nil { + return + } + + for _, v := range s.Paths.Paths { + if v.Get != nil { + FixEmptyDescs(v.Get.Responses) + } + if v.Put != nil { + FixEmptyDescs(v.Put.Responses) + } + if v.Post != nil { + FixEmptyDescs(v.Post.Responses) + } + if v.Delete != nil { + FixEmptyDescs(v.Delete.Responses) + } + if v.Options != nil { + FixEmptyDescs(v.Options.Responses) + } + if v.Head != nil { + FixEmptyDescs(v.Head.Responses) + } + if v.Patch != nil { + FixEmptyDescs(v.Patch.Responses) + } + } +} + +// FixEmptyDescs adds "(empty)" as the description for any Response in +// the given Responses object that doesn't already have one. +func FixEmptyDescs(rs *spec.Responses) { + FixEmptyDesc(rs.Default) + for k, v := range rs.StatusCodeResponses { + FixEmptyDesc(&v) //#nosec + rs.StatusCodeResponses[k] = v + } +} + +// FixEmptyDesc adds "(empty)" as the description to the given +// Response object if it doesn't already have one and isn't a +// ref. No-op on nil input. +func FixEmptyDesc(rs *spec.Response) { + if rs == nil || rs.Description != "" || rs.Ref.Ref.GetURL() != nil { + return + } + rs.Description = "(empty)" +} diff --git a/vendor/github.com/go-openapi/analysis/flatten.go b/vendor/github.com/go-openapi/analysis/flatten.go new file mode 100644 index 00000000000..0576220fb3d --- /dev/null +++ b/vendor/github.com/go-openapi/analysis/flatten.go @@ -0,0 +1,802 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package analysis + +import ( + "fmt" + "log" + "path" + "sort" + "strings" + + "github.com/go-openapi/analysis/internal/flatten/normalize" + "github.com/go-openapi/analysis/internal/flatten/operations" + "github.com/go-openapi/analysis/internal/flatten/replace" + "github.com/go-openapi/analysis/internal/flatten/schutils" + "github.com/go-openapi/analysis/internal/flatten/sortref" + "github.com/go-openapi/jsonpointer" + "github.com/go-openapi/spec" +) + +const definitionsPath = "#/definitions" + +// newRef stores information about refs created during the flattening process +type newRef struct { + key string + newName string + path string + isOAIGen bool + resolved bool + schema *spec.Schema + parents []string +} + +// context stores intermediary results from flatten +type context struct { + newRefs map[string]*newRef + warnings []string + resolved map[string]string +} + +func newContext() *context { + return &context{ + newRefs: make(map[string]*newRef, 150), + warnings: make([]string, 0), + resolved: make(map[string]string, 50), + } +} + +// Flatten an analyzed spec and produce a self-contained spec bundle. +// +// There is a minimal and a full flattening mode. +// +// +// Minimally flattening a spec means: +// - Expanding parameters, responses, path items, parameter items and header items (references to schemas are left +// unscathed) +// - Importing external (http, file) references so they become internal to the document +// - Moving every JSON pointer to a $ref to a named definition (i.e. the reworked spec does not contain pointers +// like "$ref": "#/definitions/myObject/allOfs/1") +// +// A minimally flattened spec thus guarantees the following properties: +// - all $refs point to a local definition (i.e. '#/definitions/...') +// - definitions are unique +// +// NOTE: arbitrary JSON pointers (other than $refs to top level definitions) are rewritten as definitions if they +// represent a complex schema or express commonality in the spec. +// Otherwise, they are simply expanded. +// Self-referencing JSON pointers cannot resolve to a type and trigger an error. +// +// +// Minimal flattening is necessary and sufficient for codegen rendering using go-swagger. +// +// Fully flattening a spec means: +// - Moving every complex inline schema to be a definition with an auto-generated name in a depth-first fashion. +// +// By complex, we mean every JSON object with some properties. +// Arrays, when they do not define a tuple, +// or empty objects with or without additionalProperties, are not considered complex and remain inline. +// +// NOTE: rewritten schemas get a vendor extension x-go-gen-location so we know from which part of the spec definitions +// have been created. +// +// Available flattening options: +// - Minimal: stops flattening after minimal $ref processing, leaving schema constructs untouched +// - Expand: expand all $ref's in the document (inoperant if Minimal set to true) +// - Verbose: croaks about name conflicts detected +// - RemoveUnused: removes unused parameters, responses and definitions after expansion/flattening +// +// NOTE: expansion removes all $ref save circular $ref, which remain in place +// +// TODO: additional options +// - ProgagateNameExtensions: ensure that created entries properly follow naming rules when their parent have set a +// x-go-name extension +// - LiftAllOfs: +// - limit the flattening of allOf members when simple objects +// - merge allOf with validation only +// - merge allOf with extensions only +// - ... +// +func Flatten(opts FlattenOpts) error { + debugLog("FlattenOpts: %#v", opts) + + opts.flattenContext = newContext() + + // 1. Recursively expand responses, parameters, path items and items in simple schemas. + // + // This simplifies the spec and leaves only the $ref's in schema objects. + if err := expand(&opts); err != nil { + return err + } + + // 2. Strip the current document from absolute $ref's that actually a in the root, + // so we can recognize them as proper definitions + // + // In particular, this works around issue go-openapi/spec#76: leading absolute file in $ref is stripped + if err := normalizeRef(&opts); err != nil { + return err + } + + // 3. Optionally remove shared parameters and responses already expanded (now unused). + // + // Operation parameters (i.e. under paths) remain. + if opts.RemoveUnused { + removeUnusedShared(&opts) + } + + // 4. Import all remote references. + if err := importReferences(&opts); err != nil { + return err + } + + // 5. full flattening: rewrite inline schemas (schemas that aren't simple types or arrays or maps) + if !opts.Minimal && !opts.Expand { + if err := nameInlinedSchemas(&opts); err != nil { + return err + } + } + + // 6. Rewrite JSON pointers other than $ref to named definitions + // and attempt to resolve conflicting names whenever possible. + if err := stripPointersAndOAIGen(&opts); err != nil { + return err + } + + // 7. Strip the spec from unused definitions + if opts.RemoveUnused { + removeUnused(&opts) + } + + // 8. Issue warning notifications, if any + opts.croak() + + // TODO: simplify known schema patterns to flat objects with properties + // examples: + // - lift simple allOf object, + // - empty allOf with validation only or extensions only + // - rework allOf arrays + // - rework allOf additionalProperties + + return nil +} + +func expand(opts *FlattenOpts) error { + if err := spec.ExpandSpec(opts.Swagger(), opts.ExpandOpts(!opts.Expand)); err != nil { + return err + } + + opts.Spec.reload() // re-analyze + + return nil +} + +// normalizeRef strips the current file from any absolute file $ref. This works around issue go-openapi/spec#76: +// leading absolute file in $ref is stripped +func normalizeRef(opts *FlattenOpts) error { + debugLog("normalizeRef") + + altered := false + for k, w := range opts.Spec.references.allRefs { + if !strings.HasPrefix(w.String(), opts.BasePath+definitionsPath) { // may be a mix of / and \, depending on OS + continue + } + + altered = true + debugLog("stripping absolute path for: %s", w.String()) + + // strip the base path from definition + if err := replace.UpdateRef(opts.Swagger(), k, + spec.MustCreateRef(path.Join(definitionsPath, path.Base(w.String())))); err != nil { + return err + } + } + + if altered { + opts.Spec.reload() // re-analyze + } + + return nil +} + +func removeUnusedShared(opts *FlattenOpts) { + opts.Swagger().Parameters = nil + opts.Swagger().Responses = nil + + opts.Spec.reload() // re-analyze +} + +func importReferences(opts *FlattenOpts) error { + var ( + imported bool + err error + ) + + for !imported && err == nil { + // iteratively import remote references until none left. + // This inlining deals with name conflicts by introducing auto-generated names ("OAIGen") + imported, err = importExternalReferences(opts) + + opts.Spec.reload() // re-analyze + } + + return err +} + +// nameInlinedSchemas replaces every complex inline construct by a named definition. +func nameInlinedSchemas(opts *FlattenOpts) error { + debugLog("nameInlinedSchemas") + + namer := &InlineSchemaNamer{ + Spec: opts.Swagger(), + Operations: operations.AllOpRefsByRef(opts.Spec, nil), + flattenContext: opts.flattenContext, + opts: opts, + } + + depthFirst := sortref.DepthFirst(opts.Spec.allSchemas) + for _, key := range depthFirst { + sch := opts.Spec.allSchemas[key] + if sch.Schema == nil || sch.Schema.Ref.String() != "" || sch.TopLevel { + continue + } + + asch, err := Schema(SchemaOpts{Schema: sch.Schema, Root: opts.Swagger(), BasePath: opts.BasePath}) + if err != nil { + return fmt.Errorf("schema analysis [%s]: %w", key, err) + } + + if asch.isAnalyzedAsComplex() { // move complex schemas to definitions + if err := namer.Name(key, sch.Schema, asch); err != nil { + return err + } + } + } + + opts.Spec.reload() // re-analyze + + return nil +} + +func removeUnused(opts *FlattenOpts) { + expected := make(map[string]struct{}) + for k := range opts.Swagger().Definitions { + expected[path.Join(definitionsPath, jsonpointer.Escape(k))] = struct{}{} + } + + for _, k := range opts.Spec.AllDefinitionReferences() { + delete(expected, k) + } + + for k := range expected { + debugLog("removing unused definition %s", path.Base(k)) + if opts.Verbose { + log.Printf("info: removing unused definition: %s", path.Base(k)) + } + delete(opts.Swagger().Definitions, path.Base(k)) + } + + opts.Spec.reload() // re-analyze +} + +func importKnownRef(entry sortref.RefRevIdx, refStr, newName string, opts *FlattenOpts) error { + // rewrite ref with already resolved external ref (useful for cyclical refs): + // rewrite external refs to local ones + debugLog("resolving known ref [%s] to %s", refStr, newName) + + for _, key := range entry.Keys { + if err := replace.UpdateRef(opts.Swagger(), key, spec.MustCreateRef(path.Join(definitionsPath, newName))); err != nil { + return err + } + } + + return nil +} + +func importNewRef(entry sortref.RefRevIdx, refStr string, opts *FlattenOpts) error { + var ( + isOAIGen bool + newName string + ) + + debugLog("resolving schema from remote $ref [%s]", refStr) + + sch, err := spec.ResolveRefWithBase(opts.Swagger(), &entry.Ref, opts.ExpandOpts(false)) + if err != nil { + return fmt.Errorf("could not resolve schema: %w", err) + } + + // at this stage only $ref analysis matters + partialAnalyzer := &Spec{ + references: referenceAnalysis{}, + patterns: patternAnalysis{}, + enums: enumAnalysis{}, + } + partialAnalyzer.reset() + partialAnalyzer.analyzeSchema("", sch, "/") + + // now rewrite those refs with rebase + for key, ref := range partialAnalyzer.references.allRefs { + if err := replace.UpdateRef(sch, key, spec.MustCreateRef(normalize.RebaseRef(entry.Ref.String(), ref.String()))); err != nil { + return fmt.Errorf("failed to rewrite ref for key %q at %s: %w", key, entry.Ref.String(), err) + } + } + + // generate a unique name - isOAIGen means that a naming conflict was resolved by changing the name + newName, isOAIGen = uniqifyName(opts.Swagger().Definitions, nameFromRef(entry.Ref)) + debugLog("new name for [%s]: %s - with name conflict:%t", strings.Join(entry.Keys, ", "), newName, isOAIGen) + + opts.flattenContext.resolved[refStr] = newName + + // rewrite the external refs to local ones + for _, key := range entry.Keys { + if err := replace.UpdateRef(opts.Swagger(), key, + spec.MustCreateRef(path.Join(definitionsPath, newName))); err != nil { + return err + } + + // keep track of created refs + resolved := false + if _, ok := opts.flattenContext.newRefs[key]; ok { + resolved = opts.flattenContext.newRefs[key].resolved + } + + debugLog("keeping track of ref: %s (%s), resolved: %t", key, newName, resolved) + opts.flattenContext.newRefs[key] = &newRef{ + key: key, + newName: newName, + path: path.Join(definitionsPath, newName), + isOAIGen: isOAIGen, + resolved: resolved, + schema: sch, + } + } + + // add the resolved schema to the definitions + schutils.Save(opts.Swagger(), newName, sch) + + return nil +} + +// importExternalReferences iteratively digs remote references and imports them into the main schema. +// +// At every iteration, new remotes may be found when digging deeper: they are rebased to the current schema before being imported. +// +// This returns true when no more remote references can be found. +func importExternalReferences(opts *FlattenOpts) (bool, error) { + debugLog("importExternalReferences") + + groupedRefs := sortref.ReverseIndex(opts.Spec.references.schemas, opts.BasePath) + sortedRefStr := make([]string, 0, len(groupedRefs)) + if opts.flattenContext == nil { + opts.flattenContext = newContext() + } + + // sort $ref resolution to ensure deterministic name conflict resolution + for refStr := range groupedRefs { + sortedRefStr = append(sortedRefStr, refStr) + } + sort.Strings(sortedRefStr) + + complete := true + + for _, refStr := range sortedRefStr { + entry := groupedRefs[refStr] + if entry.Ref.HasFragmentOnly { + continue + } + + complete = false + + newName := opts.flattenContext.resolved[refStr] + if newName != "" { + if err := importKnownRef(entry, refStr, newName, opts); err != nil { + return false, err + } + + continue + } + + // resolve schemas + if err := importNewRef(entry, refStr, opts); err != nil { + return false, err + } + } + + // maintains ref index entries + for k := range opts.flattenContext.newRefs { + r := opts.flattenContext.newRefs[k] + + // update tracking with resolved schemas + if r.schema.Ref.String() != "" { + ref := spec.MustCreateRef(r.path) + sch, err := spec.ResolveRefWithBase(opts.Swagger(), &ref, opts.ExpandOpts(false)) + if err != nil { + return false, fmt.Errorf("could not resolve schema: %w", err) + } + + r.schema = sch + } + + if r.path == k { + continue + } + + // update tracking with renamed keys: got a cascade of refs + renamed := *r + renamed.key = r.path + opts.flattenContext.newRefs[renamed.path] = &renamed + + // indirect ref + r.newName = path.Base(k) + r.schema = spec.RefSchema(r.path) + r.path = k + r.isOAIGen = strings.Contains(k, "OAIGen") + } + + return complete, nil +} + +// stripPointersAndOAIGen removes anonymous JSON pointers from spec and chain with name conflicts handler. +// This loops until the spec has no such pointer and all name conflicts have been reduced as much as possible. +func stripPointersAndOAIGen(opts *FlattenOpts) error { + // name all JSON pointers to anonymous documents + if err := namePointers(opts); err != nil { + return err + } + + // remove unnecessary OAIGen ref (created when flattening external refs creates name conflicts) + hasIntroducedPointerOrInline, ers := stripOAIGen(opts) + if ers != nil { + return ers + } + + // iterate as pointer or OAIGen resolution may introduce inline schemas or pointers + for hasIntroducedPointerOrInline { + if !opts.Minimal { + opts.Spec.reload() // re-analyze + if err := nameInlinedSchemas(opts); err != nil { + return err + } + } + + if err := namePointers(opts); err != nil { + return err + } + + // restrip and re-analyze + var err error + if hasIntroducedPointerOrInline, err = stripOAIGen(opts); err != nil { + return err + } + } + + return nil +} + +// stripOAIGen strips the spec from unnecessary OAIGen constructs, initially created to dedupe flattened definitions. +// +// A dedupe is deemed unnecessary whenever: +// - the only conflict is with its (single) parent: OAIGen is merged into its parent (reinlining) +// - there is a conflict with multiple parents: merge OAIGen in first parent, the rewrite other parents to point to +// the first parent. +// +// This function returns true whenever it re-inlined a complex schema, so the caller may chose to iterate +// pointer and name resolution again. +func stripOAIGen(opts *FlattenOpts) (bool, error) { + debugLog("stripOAIGen") + replacedWithComplex := false + + // figure out referers of OAIGen definitions (doing it before the ref start mutating) + for _, r := range opts.flattenContext.newRefs { + updateRefParents(opts.Spec.references.allRefs, r) + } + + for k := range opts.flattenContext.newRefs { + r := opts.flattenContext.newRefs[k] + debugLog("newRefs[%s]: isOAIGen: %t, resolved: %t, name: %s, path:%s, #parents: %d, parents: %v, ref: %s", + k, r.isOAIGen, r.resolved, r.newName, r.path, len(r.parents), r.parents, r.schema.Ref.String()) + + if !r.isOAIGen || len(r.parents) == 0 { + continue + } + + hasReplacedWithComplex, err := stripOAIGenForRef(opts, k, r) + if err != nil { + return replacedWithComplex, err + } + + replacedWithComplex = replacedWithComplex || hasReplacedWithComplex + } + + debugLog("replacedWithComplex: %t", replacedWithComplex) + opts.Spec.reload() // re-analyze + + return replacedWithComplex, nil +} + +// updateRefParents updates all parents of an updated $ref +func updateRefParents(allRefs map[string]spec.Ref, r *newRef) { + if !r.isOAIGen || r.resolved { // bail on already resolved entries (avoid looping) + return + } + for k, v := range allRefs { + if r.path != v.String() { + continue + } + + found := false + for _, p := range r.parents { + if p == k { + found = true + + break + } + } + if !found { + r.parents = append(r.parents, k) + } + } +} + +func stripOAIGenForRef(opts *FlattenOpts, k string, r *newRef) (bool, error) { + replacedWithComplex := false + + pr := sortref.TopmostFirst(r.parents) + + // rewrite first parent schema in hierarchical then lexicographical order + debugLog("rewrite first parent %s with schema", pr[0]) + if err := replace.UpdateRefWithSchema(opts.Swagger(), pr[0], r.schema); err != nil { + return false, err + } + + if pa, ok := opts.flattenContext.newRefs[pr[0]]; ok && pa.isOAIGen { + // update parent in ref index entry + debugLog("update parent entry: %s", pr[0]) + pa.schema = r.schema + pa.resolved = false + replacedWithComplex = true + } + + // rewrite other parents to point to first parent + if len(pr) > 1 { + for _, p := range pr[1:] { + replacingRef := spec.MustCreateRef(pr[0]) + + // set complex when replacing ref is an anonymous jsonpointer: further processing may be required + replacedWithComplex = replacedWithComplex || path.Dir(replacingRef.String()) != definitionsPath + debugLog("rewrite parent with ref: %s", replacingRef.String()) + + // NOTE: it is possible at this stage to introduce json pointers (to non-definitions places). + // Those are stripped later on. + if err := replace.UpdateRef(opts.Swagger(), p, replacingRef); err != nil { + return false, err + } + + if pa, ok := opts.flattenContext.newRefs[p]; ok && pa.isOAIGen { + // update parent in ref index + debugLog("update parent entry: %s", p) + pa.schema = r.schema + pa.resolved = false + replacedWithComplex = true + } + } + } + + // remove OAIGen definition + debugLog("removing definition %s", path.Base(r.path)) + delete(opts.Swagger().Definitions, path.Base(r.path)) + + // propagate changes in ref index for keys which have this one as a parent + for kk, value := range opts.flattenContext.newRefs { + if kk == k || !value.isOAIGen || value.resolved { + continue + } + + found := false + newParents := make([]string, 0, len(value.parents)) + for _, parent := range value.parents { + switch { + case parent == r.path: + found = true + parent = pr[0] + case strings.HasPrefix(parent, r.path+"/"): + found = true + parent = path.Join(pr[0], strings.TrimPrefix(parent, r.path)) + } + + newParents = append(newParents, parent) + } + + if found { + value.parents = newParents + } + } + + // mark naming conflict as resolved + debugLog("marking naming conflict resolved for key: %s", r.key) + opts.flattenContext.newRefs[r.key].isOAIGen = false + opts.flattenContext.newRefs[r.key].resolved = true + + // determine if the previous substitution did inline a complex schema + if r.schema != nil && r.schema.Ref.String() == "" { // inline schema + asch, err := Schema(SchemaOpts{Schema: r.schema, Root: opts.Swagger(), BasePath: opts.BasePath}) + if err != nil { + return false, err + } + + debugLog("re-inlined schema: parent: %s, %t", pr[0], asch.isAnalyzedAsComplex()) + replacedWithComplex = replacedWithComplex || !(path.Dir(pr[0]) == definitionsPath) && asch.isAnalyzedAsComplex() + } + + return replacedWithComplex, nil +} + +// namePointers replaces all JSON pointers to anonymous documents by a $ref to a new named definitions. +// +// This is carried on depth-first. Pointers to $refs which are top level definitions are replaced by the $ref itself. +// Pointers to simple types are expanded, unless they express commonality (i.e. several such $ref are used). +func namePointers(opts *FlattenOpts) error { + debugLog("name pointers") + + refsToReplace := make(map[string]SchemaRef, len(opts.Spec.references.schemas)) + for k, ref := range opts.Spec.references.allRefs { + if path.Dir(ref.String()) == definitionsPath { + // this a ref to a top-level definition: ok + continue + } + + result, err := replace.DeepestRef(opts.Swagger(), opts.ExpandOpts(false), ref) + if err != nil { + return fmt.Errorf("at %s, %w", k, err) + } + + replacingRef := result.Ref + sch := result.Schema + if opts.flattenContext != nil { + opts.flattenContext.warnings = append(opts.flattenContext.warnings, result.Warnings...) + } + + debugLog("planning pointer to replace at %s: %s, resolved to: %s", k, ref.String(), replacingRef.String()) + refsToReplace[k] = SchemaRef{ + Name: k, // caller + Ref: replacingRef, // called + Schema: sch, + TopLevel: path.Dir(replacingRef.String()) == definitionsPath, + } + } + + depthFirst := sortref.DepthFirst(refsToReplace) + namer := &InlineSchemaNamer{ + Spec: opts.Swagger(), + Operations: operations.AllOpRefsByRef(opts.Spec, nil), + flattenContext: opts.flattenContext, + opts: opts, + } + + for _, key := range depthFirst { + v := refsToReplace[key] + // update current replacement, which may have been updated by previous changes of deeper elements + result, erd := replace.DeepestRef(opts.Swagger(), opts.ExpandOpts(false), v.Ref) + if erd != nil { + return fmt.Errorf("at %s, %w", key, erd) + } + + if opts.flattenContext != nil { + opts.flattenContext.warnings = append(opts.flattenContext.warnings, result.Warnings...) + } + + v.Ref = result.Ref + v.Schema = result.Schema + v.TopLevel = path.Dir(result.Ref.String()) == definitionsPath + debugLog("replacing pointer at %s: resolved to: %s", key, v.Ref.String()) + + if v.TopLevel { + debugLog("replace pointer %s by canonical definition: %s", key, v.Ref.String()) + + // if the schema is a $ref to a top level definition, just rewrite the pointer to this $ref + if err := replace.UpdateRef(opts.Swagger(), key, v.Ref); err != nil { + return err + } + + continue + } + + if err := flattenAnonPointer(key, v, refsToReplace, namer, opts); err != nil { + return err + } + } + + opts.Spec.reload() // re-analyze + + return nil +} + +func flattenAnonPointer(key string, v SchemaRef, refsToReplace map[string]SchemaRef, namer *InlineSchemaNamer, opts *FlattenOpts) error { + // this is a JSON pointer to an anonymous document (internal or external): + // create a definition for this schema when: + // - it is a complex schema + // - or it is pointed by more than one $ref (i.e. expresses commonality) + // otherwise, expand the pointer (single reference to a simple type) + // + // The named definition for this follows the target's key, not the caller's + debugLog("namePointers at %s for %s", key, v.Ref.String()) + + // qualify the expanded schema + asch, ers := Schema(SchemaOpts{Schema: v.Schema, Root: opts.Swagger(), BasePath: opts.BasePath}) + if ers != nil { + return fmt.Errorf("schema analysis [%s]: %w", key, ers) + } + callers := make([]string, 0, 64) + + debugLog("looking for callers") + + an := New(opts.Swagger()) + for k, w := range an.references.allRefs { + r, err := replace.DeepestRef(opts.Swagger(), opts.ExpandOpts(false), w) + if err != nil { + return fmt.Errorf("at %s, %w", key, err) + } + + if opts.flattenContext != nil { + opts.flattenContext.warnings = append(opts.flattenContext.warnings, r.Warnings...) + } + + if r.Ref.String() == v.Ref.String() { + callers = append(callers, k) + } + } + + debugLog("callers for %s: %d", v.Ref.String(), len(callers)) + if len(callers) == 0 { + // has already been updated and resolved + return nil + } + + parts := sortref.KeyParts(v.Ref.String()) + debugLog("number of callers for %s: %d", v.Ref.String(), len(callers)) + + // identifying edge case when the namer did nothing because we point to a non-schema object + // no definition is created and we expand the $ref for all callers + if (!asch.IsSimpleSchema || len(callers) > 1) && !parts.IsSharedParam() && !parts.IsSharedResponse() { + debugLog("replace JSON pointer at [%s] by definition: %s", key, v.Ref.String()) + if err := namer.Name(v.Ref.String(), v.Schema, asch); err != nil { + return err + } + + // regular case: we named the $ref as a definition, and we move all callers to this new $ref + for _, caller := range callers { + if caller == key { + continue + } + + // move $ref for next to resolve + debugLog("identified caller of %s at [%s]", v.Ref.String(), caller) + c := refsToReplace[caller] + c.Ref = v.Ref + refsToReplace[caller] = c + } + + return nil + } + + debugLog("expand JSON pointer for key=%s", key) + + if err := replace.UpdateRefWithSchema(opts.Swagger(), key, v.Schema); err != nil { + return err + } + // NOTE: there is no other caller to update + + return nil +} diff --git a/vendor/github.com/go-openapi/analysis/flatten_name.go b/vendor/github.com/go-openapi/analysis/flatten_name.go new file mode 100644 index 00000000000..3ad2ccfbfd5 --- /dev/null +++ b/vendor/github.com/go-openapi/analysis/flatten_name.go @@ -0,0 +1,293 @@ +package analysis + +import ( + "fmt" + "path" + "sort" + "strings" + + "github.com/go-openapi/analysis/internal/flatten/operations" + "github.com/go-openapi/analysis/internal/flatten/replace" + "github.com/go-openapi/analysis/internal/flatten/schutils" + "github.com/go-openapi/analysis/internal/flatten/sortref" + "github.com/go-openapi/spec" + "github.com/go-openapi/swag" +) + +// InlineSchemaNamer finds a new name for an inlined type +type InlineSchemaNamer struct { + Spec *spec.Swagger + Operations map[string]operations.OpRef + flattenContext *context + opts *FlattenOpts +} + +// Name yields a new name for the inline schema +func (isn *InlineSchemaNamer) Name(key string, schema *spec.Schema, aschema *AnalyzedSchema) error { + debugLog("naming inlined schema at %s", key) + + parts := sortref.KeyParts(key) + for _, name := range namesFromKey(parts, aschema, isn.Operations) { + if name == "" { + continue + } + + // create unique name + newName, isOAIGen := uniqifyName(isn.Spec.Definitions, swag.ToJSONName(name)) + + // clone schema + sch := schutils.Clone(schema) + + // replace values on schema + if err := replace.RewriteSchemaToRef(isn.Spec, key, + spec.MustCreateRef(path.Join(definitionsPath, newName))); err != nil { + return fmt.Errorf("error while creating definition %q from inline schema: %w", newName, err) + } + + // rewrite any dependent $ref pointing to this place, + // when not already pointing to a top-level definition. + // + // NOTE: this is important if such referers use arbitrary JSON pointers. + an := New(isn.Spec) + for k, v := range an.references.allRefs { + r, erd := replace.DeepestRef(isn.opts.Swagger(), isn.opts.ExpandOpts(false), v) + if erd != nil { + return fmt.Errorf("at %s, %w", k, erd) + } + + if isn.opts.flattenContext != nil { + isn.opts.flattenContext.warnings = append(isn.opts.flattenContext.warnings, r.Warnings...) + } + + if r.Ref.String() != key && (r.Ref.String() != path.Join(definitionsPath, newName) || path.Dir(v.String()) == definitionsPath) { + continue + } + + debugLog("found a $ref to a rewritten schema: %s points to %s", k, v.String()) + + // rewrite $ref to the new target + if err := replace.UpdateRef(isn.Spec, k, + spec.MustCreateRef(path.Join(definitionsPath, newName))); err != nil { + return err + } + } + + // NOTE: this extension is currently not used by go-swagger (provided for information only) + sch.AddExtension("x-go-gen-location", GenLocation(parts)) + + // save cloned schema to definitions + schutils.Save(isn.Spec, newName, sch) + + // keep track of created refs + if isn.flattenContext == nil { + continue + } + + debugLog("track created ref: key=%s, newName=%s, isOAIGen=%t", key, newName, isOAIGen) + resolved := false + + if _, ok := isn.flattenContext.newRefs[key]; ok { + resolved = isn.flattenContext.newRefs[key].resolved + } + + isn.flattenContext.newRefs[key] = &newRef{ + key: key, + newName: newName, + path: path.Join(definitionsPath, newName), + isOAIGen: isOAIGen, + resolved: resolved, + schema: sch, + } + } + + return nil +} + +// uniqifyName yields a unique name for a definition +func uniqifyName(definitions spec.Definitions, name string) (string, bool) { + isOAIGen := false + if name == "" { + name = "oaiGen" + isOAIGen = true + } + + if len(definitions) == 0 { + return name, isOAIGen + } + + unq := true + for k := range definitions { + if strings.EqualFold(k, name) { + unq = false + + break + } + } + + if unq { + return name, isOAIGen + } + + name += "OAIGen" + isOAIGen = true + var idx int + unique := name + _, known := definitions[unique] + + for known { + idx++ + unique = fmt.Sprintf("%s%d", name, idx) + _, known = definitions[unique] + } + + return unique, isOAIGen +} + +func namesFromKey(parts sortref.SplitKey, aschema *AnalyzedSchema, operations map[string]operations.OpRef) []string { + var ( + baseNames [][]string + startIndex int + ) + + if parts.IsOperation() { + baseNames, startIndex = namesForOperation(parts, operations) + } + + // definitions + if parts.IsDefinition() { + baseNames, startIndex = namesForDefinition(parts) + } + + result := make([]string, 0, len(baseNames)) + for _, segments := range baseNames { + nm := parts.BuildName(segments, startIndex, partAdder(aschema)) + if nm == "" { + continue + } + + result = append(result, nm) + } + sort.Strings(result) + + return result +} + +func namesForParam(parts sortref.SplitKey, operations map[string]operations.OpRef) ([][]string, int) { + var ( + baseNames [][]string + startIndex int + ) + + piref := parts.PathItemRef() + if piref.String() != "" && parts.IsOperationParam() { + if op, ok := operations[piref.String()]; ok { + startIndex = 5 + baseNames = append(baseNames, []string{op.ID, "params", "body"}) + } + } else if parts.IsSharedOperationParam() { + pref := parts.PathRef() + for k, v := range operations { + if strings.HasPrefix(k, pref.String()) { + startIndex = 4 + baseNames = append(baseNames, []string{v.ID, "params", "body"}) + } + } + } + + return baseNames, startIndex +} + +func namesForOperation(parts sortref.SplitKey, operations map[string]operations.OpRef) ([][]string, int) { + var ( + baseNames [][]string + startIndex int + ) + + // params + if parts.IsOperationParam() || parts.IsSharedOperationParam() { + baseNames, startIndex = namesForParam(parts, operations) + } + + // responses + if parts.IsOperationResponse() { + piref := parts.PathItemRef() + if piref.String() != "" { + if op, ok := operations[piref.String()]; ok { + startIndex = 6 + baseNames = append(baseNames, []string{op.ID, parts.ResponseName(), "body"}) + } + } + } + + return baseNames, startIndex +} + +func namesForDefinition(parts sortref.SplitKey) ([][]string, int) { + nm := parts.DefinitionName() + if nm != "" { + return [][]string{{parts.DefinitionName()}}, 2 + } + + return [][]string{}, 0 +} + +// partAdder knows how to interpret a schema when it comes to build a name from parts +func partAdder(aschema *AnalyzedSchema) sortref.PartAdder { + return func(part string) []string { + segments := make([]string, 0, 2) + + if part == "items" || part == "additionalItems" { + if aschema.IsTuple || aschema.IsTupleWithExtra { + segments = append(segments, "tuple") + } else { + segments = append(segments, "items") + } + + if part == "additionalItems" { + segments = append(segments, part) + } + + return segments + } + + segments = append(segments, part) + + return segments + } +} + +func nameFromRef(ref spec.Ref) string { + u := ref.GetURL() + if u.Fragment != "" { + return swag.ToJSONName(path.Base(u.Fragment)) + } + + if u.Path != "" { + bn := path.Base(u.Path) + if bn != "" && bn != "/" { + ext := path.Ext(bn) + if ext != "" { + return swag.ToJSONName(bn[:len(bn)-len(ext)]) + } + + return swag.ToJSONName(bn) + } + } + + return swag.ToJSONName(strings.ReplaceAll(u.Host, ".", " ")) +} + +// GenLocation indicates from which section of the specification (models or operations) a definition has been created. +// +// This is reflected in the output spec with a "x-go-gen-location" extension. At the moment, this is is provided +// for information only. +func GenLocation(parts sortref.SplitKey) string { + switch { + case parts.IsOperation(): + return "operations" + case parts.IsDefinition(): + return "models" + default: + return "" + } +} diff --git a/vendor/github.com/go-openapi/analysis/flatten_options.go b/vendor/github.com/go-openapi/analysis/flatten_options.go new file mode 100644 index 00000000000..c5bb97b0a69 --- /dev/null +++ b/vendor/github.com/go-openapi/analysis/flatten_options.go @@ -0,0 +1,78 @@ +package analysis + +import ( + "log" + + "github.com/go-openapi/spec" +) + +// FlattenOpts configuration for flattening a swagger specification. +// +// The BasePath parameter is used to locate remote relative $ref found in the specification. +// This path is a file: it points to the location of the root document and may be either a local +// file path or a URL. +// +// If none specified, relative references (e.g. "$ref": "folder/schema.yaml#/definitions/...") +// found in the spec are searched from the current working directory. +type FlattenOpts struct { + Spec *Spec // The analyzed spec to work with + flattenContext *context // Internal context to track flattening activity + + BasePath string // The location of the root document for this spec to resolve relative $ref + + // Flattening options + Expand bool // When true, skip flattening the spec and expand it instead (if Minimal is false) + Minimal bool // When true, do not decompose complex structures such as allOf + Verbose bool // enable some reporting on possible name conflicts detected + RemoveUnused bool // When true, remove unused parameters, responses and definitions after expansion/flattening + ContinueOnError bool // Continue when spec expansion issues are found + + /* Extra keys */ + _ struct{} // require keys +} + +// ExpandOpts creates a spec.ExpandOptions to configure expanding a specification document. +func (f *FlattenOpts) ExpandOpts(skipSchemas bool) *spec.ExpandOptions { + return &spec.ExpandOptions{ + RelativeBase: f.BasePath, + SkipSchemas: skipSchemas, + ContinueOnError: f.ContinueOnError, + } +} + +// Swagger gets the swagger specification for this flatten operation +func (f *FlattenOpts) Swagger() *spec.Swagger { + return f.Spec.spec +} + +// croak logs notifications and warnings about valid, but possibly unwanted constructs resulting +// from flattening a spec +func (f *FlattenOpts) croak() { + if !f.Verbose { + return + } + + reported := make(map[string]bool, len(f.flattenContext.newRefs)) + for _, v := range f.Spec.references.allRefs { + // warns about duplicate handling + for _, r := range f.flattenContext.newRefs { + if r.isOAIGen && r.path == v.String() { + reported[r.newName] = true + } + } + } + + for k := range reported { + log.Printf("warning: duplicate flattened definition name resolved as %s", k) + } + + // warns about possible type mismatches + uniqueMsg := make(map[string]bool) + for _, msg := range f.flattenContext.warnings { + if _, ok := uniqueMsg[msg]; ok { + continue + } + log.Printf("warning: %s", msg) + uniqueMsg[msg] = true + } +} diff --git a/vendor/github.com/go-openapi/analysis/internal/debug/debug.go b/vendor/github.com/go-openapi/analysis/internal/debug/debug.go new file mode 100644 index 00000000000..ec0fec02298 --- /dev/null +++ b/vendor/github.com/go-openapi/analysis/internal/debug/debug.go @@ -0,0 +1,41 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package debug + +import ( + "fmt" + "log" + "os" + "path/filepath" + "runtime" +) + +var ( + output = os.Stdout +) + +// GetLogger provides a prefix debug logger +func GetLogger(prefix string, debug bool) func(string, ...interface{}) { + if debug { + logger := log.New(output, fmt.Sprintf("%s:", prefix), log.LstdFlags) + + return func(msg string, args ...interface{}) { + _, file1, pos1, _ := runtime.Caller(1) + logger.Printf("%s:%d: %s", filepath.Base(file1), pos1, fmt.Sprintf(msg, args...)) + } + } + + return func(msg string, args ...interface{}) {} +} diff --git a/vendor/github.com/go-openapi/analysis/internal/flatten/normalize/normalize.go b/vendor/github.com/go-openapi/analysis/internal/flatten/normalize/normalize.go new file mode 100644 index 00000000000..8c9df0580da --- /dev/null +++ b/vendor/github.com/go-openapi/analysis/internal/flatten/normalize/normalize.go @@ -0,0 +1,87 @@ +package normalize + +import ( + "net/url" + "path" + "path/filepath" + "strings" + + "github.com/go-openapi/spec" +) + +// RebaseRef rebases a remote ref relative to a base ref. +// +// NOTE: does not support JSONschema ID for $ref (we assume we are working with swagger specs here). +// +// NOTE(windows): +// * refs are assumed to have been normalized with drive letter lower cased (from go-openapi/spec) +// * "/ in paths may appear as escape sequences +func RebaseRef(baseRef string, ref string) string { + baseRef, _ = url.PathUnescape(baseRef) + ref, _ = url.PathUnescape(ref) + + if baseRef == "" || baseRef == "." || strings.HasPrefix(baseRef, "#") { + return ref + } + + parts := strings.Split(ref, "#") + + baseParts := strings.Split(baseRef, "#") + baseURL, _ := url.Parse(baseParts[0]) + if strings.HasPrefix(ref, "#") { + if baseURL.Host == "" { + return strings.Join([]string{baseParts[0], parts[1]}, "#") + } + + return strings.Join([]string{baseParts[0], parts[1]}, "#") + } + + refURL, _ := url.Parse(parts[0]) + if refURL.Host != "" || filepath.IsAbs(parts[0]) { + // not rebasing an absolute path + return ref + } + + // there is a relative path + var basePath string + if baseURL.Host != "" { + // when there is a host, standard URI rules apply (with "/") + baseURL.Path = path.Dir(baseURL.Path) + baseURL.Path = path.Join(baseURL.Path, "/"+parts[0]) + + return baseURL.String() + } + + // this is a local relative path + // basePart[0] and parts[0] are local filesystem directories/files + basePath = filepath.Dir(baseParts[0]) + relPath := filepath.Join(basePath, string(filepath.Separator)+parts[0]) + if len(parts) > 1 { + return strings.Join([]string{relPath, parts[1]}, "#") + } + + return relPath +} + +// Path renders absolute path on remote file refs +// +// NOTE(windows): +// * refs are assumed to have been normalized with drive letter lower cased (from go-openapi/spec) +// * "/ in paths may appear as escape sequences +func Path(ref spec.Ref, basePath string) string { + uri, _ := url.PathUnescape(ref.String()) + if ref.HasFragmentOnly || filepath.IsAbs(uri) { + return uri + } + + refURL, _ := url.Parse(uri) + if refURL.Host != "" { + return uri + } + + parts := strings.Split(uri, "#") + // BasePath, parts[0] are local filesystem directories, guaranteed to be absolute at this stage + parts[0] = filepath.Join(filepath.Dir(basePath), parts[0]) + + return strings.Join(parts, "#") +} diff --git a/vendor/github.com/go-openapi/analysis/internal/flatten/operations/operations.go b/vendor/github.com/go-openapi/analysis/internal/flatten/operations/operations.go new file mode 100644 index 00000000000..7f3a2b8717f --- /dev/null +++ b/vendor/github.com/go-openapi/analysis/internal/flatten/operations/operations.go @@ -0,0 +1,90 @@ +package operations + +import ( + "path" + "sort" + "strings" + + "github.com/go-openapi/jsonpointer" + "github.com/go-openapi/spec" + "github.com/go-openapi/swag" +) + +// AllOpRefsByRef returns an index of sortable operations +func AllOpRefsByRef(specDoc Provider, operationIDs []string) map[string]OpRef { + return OpRefsByRef(GatherOperations(specDoc, operationIDs)) +} + +// OpRefsByRef indexes a map of sortable operations +func OpRefsByRef(oprefs map[string]OpRef) map[string]OpRef { + result := make(map[string]OpRef, len(oprefs)) + for _, v := range oprefs { + result[v.Ref.String()] = v + } + + return result +} + +// OpRef is an indexable, sortable operation +type OpRef struct { + Method string + Path string + Key string + ID string + Op *spec.Operation + Ref spec.Ref +} + +// OpRefs is a sortable collection of operations +type OpRefs []OpRef + +func (o OpRefs) Len() int { return len(o) } +func (o OpRefs) Swap(i, j int) { o[i], o[j] = o[j], o[i] } +func (o OpRefs) Less(i, j int) bool { return o[i].Key < o[j].Key } + +// Provider knows how to collect operations from a spec +type Provider interface { + Operations() map[string]map[string]*spec.Operation +} + +// GatherOperations builds a map of sorted operations from a spec +func GatherOperations(specDoc Provider, operationIDs []string) map[string]OpRef { + var oprefs OpRefs + + for method, pathItem := range specDoc.Operations() { + for pth, operation := range pathItem { + vv := *operation + oprefs = append(oprefs, OpRef{ + Key: swag.ToGoName(strings.ToLower(method) + " " + pth), + Method: method, + Path: pth, + ID: vv.ID, + Op: &vv, + Ref: spec.MustCreateRef("#" + path.Join("/paths", jsonpointer.Escape(pth), method)), + }) + } + } + + sort.Sort(oprefs) + + operations := make(map[string]OpRef) + for _, opr := range oprefs { + nm := opr.ID + if nm == "" { + nm = opr.Key + } + + oo, found := operations[nm] + if found && oo.Method != opr.Method && oo.Path != opr.Path { + nm = opr.Key + } + + if len(operationIDs) == 0 || swag.ContainsStrings(operationIDs, opr.ID) || swag.ContainsStrings(operationIDs, nm) { + opr.ID = nm + opr.Op.ID = nm + operations[nm] = opr + } + } + + return operations +} diff --git a/vendor/github.com/go-openapi/analysis/internal/flatten/replace/replace.go b/vendor/github.com/go-openapi/analysis/internal/flatten/replace/replace.go new file mode 100644 index 00000000000..26c2a05a310 --- /dev/null +++ b/vendor/github.com/go-openapi/analysis/internal/flatten/replace/replace.go @@ -0,0 +1,434 @@ +package replace + +import ( + "fmt" + "net/url" + "os" + "path" + "strconv" + + "github.com/go-openapi/analysis/internal/debug" + "github.com/go-openapi/jsonpointer" + "github.com/go-openapi/spec" +) + +const definitionsPath = "#/definitions" + +var debugLog = debug.GetLogger("analysis/flatten/replace", os.Getenv("SWAGGER_DEBUG") != "") + +// RewriteSchemaToRef replaces a schema with a Ref +func RewriteSchemaToRef(sp *spec.Swagger, key string, ref spec.Ref) error { + debugLog("rewriting schema to ref for %s with %s", key, ref.String()) + _, value, err := getPointerFromKey(sp, key) + if err != nil { + return err + } + + switch refable := value.(type) { + case *spec.Schema: + return rewriteParentRef(sp, key, ref) + + case spec.Schema: + return rewriteParentRef(sp, key, ref) + + case *spec.SchemaOrArray: + if refable.Schema != nil { + refable.Schema = &spec.Schema{SchemaProps: spec.SchemaProps{Ref: ref}} + } + + case *spec.SchemaOrBool: + if refable.Schema != nil { + refable.Schema = &spec.Schema{SchemaProps: spec.SchemaProps{Ref: ref}} + } + default: + return fmt.Errorf("no schema with ref found at %s for %T", key, value) + } + + return nil +} + +func rewriteParentRef(sp *spec.Swagger, key string, ref spec.Ref) error { + parent, entry, pvalue, err := getParentFromKey(sp, key) + if err != nil { + return err + } + + debugLog("rewriting holder for %T", pvalue) + switch container := pvalue.(type) { + case spec.Response: + if err := rewriteParentRef(sp, "#"+parent, ref); err != nil { + return err + } + + case *spec.Response: + container.Schema = &spec.Schema{SchemaProps: spec.SchemaProps{Ref: ref}} + + case *spec.Responses: + statusCode, err := strconv.Atoi(entry) + if err != nil { + return fmt.Errorf("%s not a number: %w", key[1:], err) + } + resp := container.StatusCodeResponses[statusCode] + resp.Schema = &spec.Schema{SchemaProps: spec.SchemaProps{Ref: ref}} + container.StatusCodeResponses[statusCode] = resp + + case map[string]spec.Response: + resp := container[entry] + resp.Schema = &spec.Schema{SchemaProps: spec.SchemaProps{Ref: ref}} + container[entry] = resp + + case spec.Parameter: + if err := rewriteParentRef(sp, "#"+parent, ref); err != nil { + return err + } + + case map[string]spec.Parameter: + param := container[entry] + param.Schema = &spec.Schema{SchemaProps: spec.SchemaProps{Ref: ref}} + container[entry] = param + + case []spec.Parameter: + idx, err := strconv.Atoi(entry) + if err != nil { + return fmt.Errorf("%s not a number: %w", key[1:], err) + } + param := container[idx] + param.Schema = &spec.Schema{SchemaProps: spec.SchemaProps{Ref: ref}} + container[idx] = param + + case spec.Definitions: + container[entry] = spec.Schema{SchemaProps: spec.SchemaProps{Ref: ref}} + + case map[string]spec.Schema: + container[entry] = spec.Schema{SchemaProps: spec.SchemaProps{Ref: ref}} + + case []spec.Schema: + idx, err := strconv.Atoi(entry) + if err != nil { + return fmt.Errorf("%s not a number: %w", key[1:], err) + } + container[idx] = spec.Schema{SchemaProps: spec.SchemaProps{Ref: ref}} + + case *spec.SchemaOrArray: + // NOTE: this is necessarily an array - otherwise, the parent would be *Schema + idx, err := strconv.Atoi(entry) + if err != nil { + return fmt.Errorf("%s not a number: %w", key[1:], err) + } + container.Schemas[idx] = spec.Schema{SchemaProps: spec.SchemaProps{Ref: ref}} + + case spec.SchemaProperties: + container[entry] = spec.Schema{SchemaProps: spec.SchemaProps{Ref: ref}} + + // NOTE: can't have case *spec.SchemaOrBool = parent in this case is *Schema + + default: + return fmt.Errorf("unhandled parent schema rewrite %s (%T)", key, pvalue) + } + + return nil +} + +// getPointerFromKey retrieves the content of the JSON pointer "key" +func getPointerFromKey(sp interface{}, key string) (string, interface{}, error) { + switch sp.(type) { + case *spec.Schema: + case *spec.Swagger: + default: + panic("unexpected type used in getPointerFromKey") + } + if key == "#/" { + return "", sp, nil + } + // unescape chars in key, e.g. "{}" from path params + pth, _ := url.PathUnescape(key[1:]) + ptr, err := jsonpointer.New(pth) + if err != nil { + return "", nil, err + } + + value, _, err := ptr.Get(sp) + if err != nil { + debugLog("error when getting key: %s with path: %s", key, pth) + + return "", nil, err + } + + return pth, value, nil +} + +// getParentFromKey retrieves the container of the JSON pointer "key" +func getParentFromKey(sp interface{}, key string) (string, string, interface{}, error) { + switch sp.(type) { + case *spec.Schema: + case *spec.Swagger: + default: + panic("unexpected type used in getPointerFromKey") + } + // unescape chars in key, e.g. "{}" from path params + pth, _ := url.PathUnescape(key[1:]) + + parent, entry := path.Dir(pth), path.Base(pth) + debugLog("getting schema holder at: %s, with entry: %s", parent, entry) + + pptr, err := jsonpointer.New(parent) + if err != nil { + return "", "", nil, err + } + pvalue, _, err := pptr.Get(sp) + if err != nil { + return "", "", nil, fmt.Errorf("can't get parent for %s: %w", parent, err) + } + + return parent, entry, pvalue, nil +} + +// UpdateRef replaces a ref by another one +func UpdateRef(sp interface{}, key string, ref spec.Ref) error { + switch sp.(type) { + case *spec.Schema: + case *spec.Swagger: + default: + panic("unexpected type used in getPointerFromKey") + } + debugLog("updating ref for %s with %s", key, ref.String()) + pth, value, err := getPointerFromKey(sp, key) + if err != nil { + return err + } + + switch refable := value.(type) { + case *spec.Schema: + refable.Ref = ref + case *spec.SchemaOrArray: + if refable.Schema != nil { + refable.Schema.Ref = ref + } + case *spec.SchemaOrBool: + if refable.Schema != nil { + refable.Schema.Ref = ref + } + case spec.Schema: + debugLog("rewriting holder for %T", refable) + _, entry, pvalue, erp := getParentFromKey(sp, key) + if erp != nil { + return err + } + switch container := pvalue.(type) { + case spec.Definitions: + container[entry] = spec.Schema{SchemaProps: spec.SchemaProps{Ref: ref}} + + case map[string]spec.Schema: + container[entry] = spec.Schema{SchemaProps: spec.SchemaProps{Ref: ref}} + + case []spec.Schema: + idx, err := strconv.Atoi(entry) + if err != nil { + return fmt.Errorf("%s not a number: %w", pth, err) + } + container[idx] = spec.Schema{SchemaProps: spec.SchemaProps{Ref: ref}} + + case *spec.SchemaOrArray: + // NOTE: this is necessarily an array - otherwise, the parent would be *Schema + idx, err := strconv.Atoi(entry) + if err != nil { + return fmt.Errorf("%s not a number: %w", pth, err) + } + container.Schemas[idx] = spec.Schema{SchemaProps: spec.SchemaProps{Ref: ref}} + + case spec.SchemaProperties: + container[entry] = spec.Schema{SchemaProps: spec.SchemaProps{Ref: ref}} + + // NOTE: can't have case *spec.SchemaOrBool = parent in this case is *Schema + + default: + return fmt.Errorf("unhandled container type at %s: %T", key, value) + } + + default: + return fmt.Errorf("no schema with ref found at %s for %T", key, value) + } + + return nil +} + +// UpdateRefWithSchema replaces a ref with a schema (i.e. re-inline schema) +func UpdateRefWithSchema(sp *spec.Swagger, key string, sch *spec.Schema) error { + debugLog("updating ref for %s with schema", key) + pth, value, err := getPointerFromKey(sp, key) + if err != nil { + return err + } + + switch refable := value.(type) { + case *spec.Schema: + *refable = *sch + case spec.Schema: + _, entry, pvalue, erp := getParentFromKey(sp, key) + if erp != nil { + return err + } + switch container := pvalue.(type) { + case spec.Definitions: + container[entry] = *sch + + case map[string]spec.Schema: + container[entry] = *sch + + case []spec.Schema: + idx, err := strconv.Atoi(entry) + if err != nil { + return fmt.Errorf("%s not a number: %w", pth, err) + } + container[idx] = *sch + + case *spec.SchemaOrArray: + // NOTE: this is necessarily an array - otherwise, the parent would be *Schema + idx, err := strconv.Atoi(entry) + if err != nil { + return fmt.Errorf("%s not a number: %w", pth, err) + } + container.Schemas[idx] = *sch + + case spec.SchemaProperties: + container[entry] = *sch + + // NOTE: can't have case *spec.SchemaOrBool = parent in this case is *Schema + + default: + return fmt.Errorf("unhandled type for parent of [%s]: %T", key, value) + } + case *spec.SchemaOrArray: + *refable.Schema = *sch + // NOTE: can't have case *spec.SchemaOrBool = parent in this case is *Schema + case *spec.SchemaOrBool: + *refable.Schema = *sch + default: + return fmt.Errorf("no schema with ref found at %s for %T", key, value) + } + + return nil +} + +// DeepestRefResult holds the results from DeepestRef analysis +type DeepestRefResult struct { + Ref spec.Ref + Schema *spec.Schema + Warnings []string +} + +// DeepestRef finds the first definition ref, from a cascade of nested refs which are not definitions. +// - if no definition is found, returns the deepest ref. +// - pointers to external files are expanded +// +// NOTE: all external $ref's are assumed to be already expanded at this stage. +func DeepestRef(sp *spec.Swagger, opts *spec.ExpandOptions, ref spec.Ref) (*DeepestRefResult, error) { + if !ref.HasFragmentOnly { + // we found an external $ref, which is odd at this stage: + // do nothing on external $refs + return &DeepestRefResult{Ref: ref}, nil + } + + currentRef := ref + visited := make(map[string]bool, 64) + warnings := make([]string, 0, 2) + +DOWNREF: + for currentRef.String() != "" { + if path.Dir(currentRef.String()) == definitionsPath { + // this is a top-level definition: stop here and return this ref + return &DeepestRefResult{Ref: currentRef}, nil + } + + if _, beenThere := visited[currentRef.String()]; beenThere { + return nil, + fmt.Errorf("cannot resolve cyclic chain of pointers under %s", currentRef.String()) + } + + visited[currentRef.String()] = true + value, _, err := currentRef.GetPointer().Get(sp) + if err != nil { + return nil, err + } + + switch refable := value.(type) { + case *spec.Schema: + if refable.Ref.String() == "" { + break DOWNREF + } + currentRef = refable.Ref + + case spec.Schema: + if refable.Ref.String() == "" { + break DOWNREF + } + currentRef = refable.Ref + + case *spec.SchemaOrArray: + if refable.Schema == nil || refable.Schema != nil && refable.Schema.Ref.String() == "" { + break DOWNREF + } + currentRef = refable.Schema.Ref + + case *spec.SchemaOrBool: + if refable.Schema == nil || refable.Schema != nil && refable.Schema.Ref.String() == "" { + break DOWNREF + } + currentRef = refable.Schema.Ref + + case spec.Response: + // a pointer points to a schema initially marshalled in responses section... + // Attempt to convert this to a schema. If this fails, the spec is invalid + asJSON, _ := refable.MarshalJSON() + var asSchema spec.Schema + + err := asSchema.UnmarshalJSON(asJSON) + if err != nil { + return nil, + fmt.Errorf("invalid type for resolved JSON pointer %s. Expected a schema a, got: %T", + currentRef.String(), value) + } + warnings = append(warnings, fmt.Sprintf("found $ref %q (response) interpreted as schema", currentRef.String())) + + if asSchema.Ref.String() == "" { + break DOWNREF + } + currentRef = asSchema.Ref + + case spec.Parameter: + // a pointer points to a schema initially marshalled in parameters section... + // Attempt to convert this to a schema. If this fails, the spec is invalid + asJSON, _ := refable.MarshalJSON() + var asSchema spec.Schema + if err := asSchema.UnmarshalJSON(asJSON); err != nil { + return nil, + fmt.Errorf("invalid type for resolved JSON pointer %s. Expected a schema a, got: %T", + currentRef.String(), value) + } + + warnings = append(warnings, fmt.Sprintf("found $ref %q (parameter) interpreted as schema", currentRef.String())) + + if asSchema.Ref.String() == "" { + break DOWNREF + } + currentRef = asSchema.Ref + + default: + return nil, + fmt.Errorf("unhandled type to resolve JSON pointer %s. Expected a Schema, got: %T", + currentRef.String(), value) + } + } + + // assess what schema we're ending with + sch, erv := spec.ResolveRefWithBase(sp, ¤tRef, opts) + if erv != nil { + return nil, erv + } + + if sch == nil { + return nil, fmt.Errorf("no schema found at %s", currentRef.String()) + } + + return &DeepestRefResult{Ref: currentRef, Schema: sch, Warnings: warnings}, nil +} diff --git a/vendor/github.com/go-openapi/analysis/internal/flatten/schutils/flatten_schema.go b/vendor/github.com/go-openapi/analysis/internal/flatten/schutils/flatten_schema.go new file mode 100644 index 00000000000..4590236e683 --- /dev/null +++ b/vendor/github.com/go-openapi/analysis/internal/flatten/schutils/flatten_schema.go @@ -0,0 +1,29 @@ +// Package schutils provides tools to save or clone a schema +// when flattening a spec. +package schutils + +import ( + "github.com/go-openapi/spec" + "github.com/go-openapi/swag" +) + +// Save registers a schema as an entry in spec #/definitions +func Save(sp *spec.Swagger, name string, schema *spec.Schema) { + if schema == nil { + return + } + + if sp.Definitions == nil { + sp.Definitions = make(map[string]spec.Schema, 150) + } + + sp.Definitions[name] = *schema +} + +// Clone deep-clones a schema +func Clone(schema *spec.Schema) *spec.Schema { + var sch spec.Schema + _ = swag.FromDynamicJSON(schema, &sch) + + return &sch +} diff --git a/vendor/github.com/go-openapi/analysis/internal/flatten/sortref/keys.go b/vendor/github.com/go-openapi/analysis/internal/flatten/sortref/keys.go new file mode 100644 index 00000000000..18e552eadce --- /dev/null +++ b/vendor/github.com/go-openapi/analysis/internal/flatten/sortref/keys.go @@ -0,0 +1,201 @@ +package sortref + +import ( + "net/http" + "path" + "strconv" + "strings" + + "github.com/go-openapi/jsonpointer" + "github.com/go-openapi/spec" +) + +const ( + paths = "paths" + responses = "responses" + parameters = "parameters" + definitions = "definitions" +) + +var ( + ignoredKeys map[string]struct{} + validMethods map[string]struct{} +) + +func init() { + ignoredKeys = map[string]struct{}{ + "schema": {}, + "properties": {}, + "not": {}, + "anyOf": {}, + "oneOf": {}, + } + + validMethods = map[string]struct{}{ + "GET": {}, + "HEAD": {}, + "OPTIONS": {}, + "PATCH": {}, + "POST": {}, + "PUT": {}, + "DELETE": {}, + } +} + +// Key represent a key item constructed from /-separated segments +type Key struct { + Segments int + Key string +} + +// Keys is a sortable collable collection of Keys +type Keys []Key + +func (k Keys) Len() int { return len(k) } +func (k Keys) Swap(i, j int) { k[i], k[j] = k[j], k[i] } +func (k Keys) Less(i, j int) bool { + return k[i].Segments > k[j].Segments || (k[i].Segments == k[j].Segments && k[i].Key < k[j].Key) +} + +// KeyParts construct a SplitKey with all its /-separated segments decomposed. It is sortable. +func KeyParts(key string) SplitKey { + var res []string + for _, part := range strings.Split(key[1:], "/") { + if part != "" { + res = append(res, jsonpointer.Unescape(part)) + } + } + + return res +} + +// SplitKey holds of the parts of a /-separated key, soi that their location may be determined. +type SplitKey []string + +// IsDefinition is true when the split key is in the #/definitions section of a spec +func (s SplitKey) IsDefinition() bool { + return len(s) > 1 && s[0] == definitions +} + +// DefinitionName yields the name of the definition +func (s SplitKey) DefinitionName() string { + if !s.IsDefinition() { + return "" + } + + return s[1] +} + +func (s SplitKey) isKeyName(i int) bool { + if i <= 0 { + return false + } + + count := 0 + for idx := i - 1; idx > 0; idx-- { + if s[idx] != "properties" { + break + } + count++ + } + + return count%2 != 0 +} + +// PartAdder know how to construct the components of a new name +type PartAdder func(string) []string + +// BuildName builds a name from segments +func (s SplitKey) BuildName(segments []string, startIndex int, adder PartAdder) string { + for i, part := range s[startIndex:] { + if _, ignored := ignoredKeys[part]; !ignored || s.isKeyName(startIndex+i) { + segments = append(segments, adder(part)...) + } + } + + return strings.Join(segments, " ") +} + +// IsOperation is true when the split key is in the operations section +func (s SplitKey) IsOperation() bool { + return len(s) > 1 && s[0] == paths +} + +// IsSharedOperationParam is true when the split key is in the parameters section of a path +func (s SplitKey) IsSharedOperationParam() bool { + return len(s) > 2 && s[0] == paths && s[2] == parameters +} + +// IsSharedParam is true when the split key is in the #/parameters section of a spec +func (s SplitKey) IsSharedParam() bool { + return len(s) > 1 && s[0] == parameters +} + +// IsOperationParam is true when the split key is in the parameters section of an operation +func (s SplitKey) IsOperationParam() bool { + return len(s) > 3 && s[0] == paths && s[3] == parameters +} + +// IsOperationResponse is true when the split key is in the responses section of an operation +func (s SplitKey) IsOperationResponse() bool { + return len(s) > 3 && s[0] == paths && s[3] == responses +} + +// IsSharedResponse is true when the split key is in the #/responses section of a spec +func (s SplitKey) IsSharedResponse() bool { + return len(s) > 1 && s[0] == responses +} + +// IsDefaultResponse is true when the split key is the default response for an operation +func (s SplitKey) IsDefaultResponse() bool { + return len(s) > 4 && s[0] == paths && s[3] == responses && s[4] == "default" +} + +// IsStatusCodeResponse is true when the split key is an operation response with a status code +func (s SplitKey) IsStatusCodeResponse() bool { + isInt := func() bool { + _, err := strconv.Atoi(s[4]) + + return err == nil + } + + return len(s) > 4 && s[0] == paths && s[3] == responses && isInt() +} + +// ResponseName yields either the status code or "Default" for a response +func (s SplitKey) ResponseName() string { + if s.IsStatusCodeResponse() { + code, _ := strconv.Atoi(s[4]) + + return http.StatusText(code) + } + + if s.IsDefaultResponse() { + return "Default" + } + + return "" +} + +// PathItemRef constructs a $ref object from a split key of the form /{path}/{method} +func (s SplitKey) PathItemRef() spec.Ref { + if len(s) < 3 { + return spec.Ref{} + } + + pth, method := s[1], s[2] + if _, isValidMethod := validMethods[strings.ToUpper(method)]; !isValidMethod && !strings.HasPrefix(method, "x-") { + return spec.Ref{} + } + + return spec.MustCreateRef("#" + path.Join("/", paths, jsonpointer.Escape(pth), strings.ToUpper(method))) +} + +// PathRef constructs a $ref object from a split key of the form /paths/{reference} +func (s SplitKey) PathRef() spec.Ref { + if !s.IsOperation() { + return spec.Ref{} + } + + return spec.MustCreateRef("#" + path.Join("/", paths, jsonpointer.Escape(s[1]))) +} diff --git a/vendor/github.com/go-openapi/analysis/internal/flatten/sortref/sort_ref.go b/vendor/github.com/go-openapi/analysis/internal/flatten/sortref/sort_ref.go new file mode 100644 index 00000000000..73243df87f0 --- /dev/null +++ b/vendor/github.com/go-openapi/analysis/internal/flatten/sortref/sort_ref.go @@ -0,0 +1,141 @@ +package sortref + +import ( + "reflect" + "sort" + "strings" + + "github.com/go-openapi/analysis/internal/flatten/normalize" + "github.com/go-openapi/spec" +) + +var depthGroupOrder = []string{ + "sharedParam", "sharedResponse", "sharedOpParam", "opParam", "codeResponse", "defaultResponse", "definition", +} + +type mapIterator struct { + len int + mapIter *reflect.MapIter +} + +func (i *mapIterator) Next() bool { + return i.mapIter.Next() +} + +func (i *mapIterator) Len() int { + return i.len +} + +func (i *mapIterator) Key() string { + return i.mapIter.Key().String() +} + +func mustMapIterator(anyMap interface{}) *mapIterator { + val := reflect.ValueOf(anyMap) + + return &mapIterator{mapIter: val.MapRange(), len: val.Len()} +} + +// DepthFirst sorts a map of anything. It groups keys by category +// (shared params, op param, statuscode response, default response, definitions) +// sort groups internally by number of parts in the key and lexical names +// flatten groups into a single list of keys +func DepthFirst(in interface{}) []string { + iterator := mustMapIterator(in) + sorted := make([]string, 0, iterator.Len()) + grouped := make(map[string]Keys, iterator.Len()) + + for iterator.Next() { + k := iterator.Key() + split := KeyParts(k) + var pk string + + if split.IsSharedOperationParam() { + pk = "sharedOpParam" + } + if split.IsOperationParam() { + pk = "opParam" + } + if split.IsStatusCodeResponse() { + pk = "codeResponse" + } + if split.IsDefaultResponse() { + pk = "defaultResponse" + } + if split.IsDefinition() { + pk = "definition" + } + if split.IsSharedParam() { + pk = "sharedParam" + } + if split.IsSharedResponse() { + pk = "sharedResponse" + } + grouped[pk] = append(grouped[pk], Key{Segments: len(split), Key: k}) + } + + for _, pk := range depthGroupOrder { + res := grouped[pk] + sort.Sort(res) + + for _, v := range res { + sorted = append(sorted, v.Key) + } + } + + return sorted +} + +// topMostRefs is able to sort refs by hierarchical then lexicographic order, +// yielding refs ordered breadth-first. +type topmostRefs []string + +func (k topmostRefs) Len() int { return len(k) } +func (k topmostRefs) Swap(i, j int) { k[i], k[j] = k[j], k[i] } +func (k topmostRefs) Less(i, j int) bool { + li, lj := len(strings.Split(k[i], "/")), len(strings.Split(k[j], "/")) + if li == lj { + return k[i] < k[j] + } + + return li < lj +} + +// TopmostFirst sorts references by depth +func TopmostFirst(refs []string) []string { + res := topmostRefs(refs) + sort.Sort(res) + + return res +} + +// RefRevIdx is a reverse index for references +type RefRevIdx struct { + Ref spec.Ref + Keys []string +} + +// ReverseIndex builds a reverse index for references in schemas +func ReverseIndex(schemas map[string]spec.Ref, basePath string) map[string]RefRevIdx { + collected := make(map[string]RefRevIdx) + for key, schRef := range schemas { + // normalize paths before sorting, + // so we get together keys that are from the same external file + normalizedPath := normalize.Path(schRef, basePath) + + entry, ok := collected[normalizedPath] + if ok { + entry.Keys = append(entry.Keys, key) + collected[normalizedPath] = entry + + continue + } + + collected[normalizedPath] = RefRevIdx{ + Ref: schRef, + Keys: []string{key}, + } + } + + return collected +} diff --git a/vendor/github.com/go-openapi/analysis/mixin.go b/vendor/github.com/go-openapi/analysis/mixin.go new file mode 100644 index 00000000000..b253052648c --- /dev/null +++ b/vendor/github.com/go-openapi/analysis/mixin.go @@ -0,0 +1,515 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package analysis + +import ( + "fmt" + "reflect" + + "github.com/go-openapi/spec" +) + +// Mixin modifies the primary swagger spec by adding the paths and +// definitions from the mixin specs. Top level parameters and +// responses from the mixins are also carried over. Operation id +// collisions are avoided by appending "Mixin" but only if +// needed. +// +// The following parts of primary are subject to merge, filling empty details +// - Info +// - BasePath +// - Host +// - ExternalDocs +// +// Consider calling FixEmptyResponseDescriptions() on the modified primary +// if you read them from storage and they are valid to start with. +// +// Entries in "paths", "definitions", "parameters" and "responses" are +// added to the primary in the order of the given mixins. If the entry +// already exists in primary it is skipped with a warning message. +// +// The count of skipped entries (from collisions) is returned so any +// deviation from the number expected can flag a warning in your build +// scripts. Carefully review the collisions before accepting them; +// consider renaming things if possible. +// +// No key normalization takes place (paths, type defs, +// etc). Ensure they are canonical if your downstream tools do +// key normalization of any form. +// +// Merging schemes (http, https), and consumers/producers do not account for +// collisions. +func Mixin(primary *spec.Swagger, mixins ...*spec.Swagger) []string { + skipped := make([]string, 0, len(mixins)) + opIds := getOpIds(primary) + initPrimary(primary) + + for i, m := range mixins { + skipped = append(skipped, mergeSwaggerProps(primary, m)...) + + skipped = append(skipped, mergeConsumes(primary, m)...) + + skipped = append(skipped, mergeProduces(primary, m)...) + + skipped = append(skipped, mergeTags(primary, m)...) + + skipped = append(skipped, mergeSchemes(primary, m)...) + + skipped = append(skipped, mergeSecurityDefinitions(primary, m)...) + + skipped = append(skipped, mergeSecurityRequirements(primary, m)...) + + skipped = append(skipped, mergeDefinitions(primary, m)...) + + // merging paths requires a map of operationIDs to work with + skipped = append(skipped, mergePaths(primary, m, opIds, i)...) + + skipped = append(skipped, mergeParameters(primary, m)...) + + skipped = append(skipped, mergeResponses(primary, m)...) + } + + return skipped +} + +// getOpIds extracts all the paths..operationIds from the given +// spec and returns them as the keys in a map with 'true' values. +func getOpIds(s *spec.Swagger) map[string]bool { + rv := make(map[string]bool) + if s.Paths == nil { + return rv + } + + for _, v := range s.Paths.Paths { + piops := pathItemOps(v) + + for _, op := range piops { + rv[op.ID] = true + } + } + + return rv +} + +func pathItemOps(p spec.PathItem) []*spec.Operation { + var rv []*spec.Operation + rv = appendOp(rv, p.Get) + rv = appendOp(rv, p.Put) + rv = appendOp(rv, p.Post) + rv = appendOp(rv, p.Delete) + rv = appendOp(rv, p.Head) + rv = appendOp(rv, p.Patch) + + return rv +} + +func appendOp(ops []*spec.Operation, op *spec.Operation) []*spec.Operation { + if op == nil { + return ops + } + + return append(ops, op) +} + +func mergeSecurityDefinitions(primary *spec.Swagger, m *spec.Swagger) (skipped []string) { + for k, v := range m.SecurityDefinitions { + if _, exists := primary.SecurityDefinitions[k]; exists { + warn := fmt.Sprintf( + "SecurityDefinitions entry '%v' already exists in primary or higher priority mixin, skipping\n", k) + skipped = append(skipped, warn) + + continue + } + + primary.SecurityDefinitions[k] = v + } + + return +} + +func mergeSecurityRequirements(primary *spec.Swagger, m *spec.Swagger) (skipped []string) { + for _, v := range m.Security { + found := false + for _, vv := range primary.Security { + if reflect.DeepEqual(v, vv) { + found = true + + break + } + } + + if found { + warn := fmt.Sprintf( + "Security requirement: '%v' already exists in primary or higher priority mixin, skipping\n", v) + skipped = append(skipped, warn) + + continue + } + primary.Security = append(primary.Security, v) + } + + return +} + +func mergeDefinitions(primary *spec.Swagger, m *spec.Swagger) (skipped []string) { + for k, v := range m.Definitions { + // assume name collisions represent IDENTICAL type. careful. + if _, exists := primary.Definitions[k]; exists { + warn := fmt.Sprintf( + "definitions entry '%v' already exists in primary or higher priority mixin, skipping\n", k) + skipped = append(skipped, warn) + + continue + } + primary.Definitions[k] = v + } + + return +} + +func mergePaths(primary *spec.Swagger, m *spec.Swagger, opIds map[string]bool, mixIndex int) (skipped []string) { + if m.Paths != nil { + for k, v := range m.Paths.Paths { + if _, exists := primary.Paths.Paths[k]; exists { + warn := fmt.Sprintf( + "paths entry '%v' already exists in primary or higher priority mixin, skipping\n", k) + skipped = append(skipped, warn) + + continue + } + + // Swagger requires that operationIds be + // unique within a spec. If we find a + // collision we append "Mixin0" to the + // operatoinId we are adding, where 0 is mixin + // index. We assume that operationIds with + // all the proivded specs are already unique. + piops := pathItemOps(v) + for _, piop := range piops { + if opIds[piop.ID] { + piop.ID = fmt.Sprintf("%v%v%v", piop.ID, "Mixin", mixIndex) + } + opIds[piop.ID] = true + } + primary.Paths.Paths[k] = v + } + } + + return +} + +func mergeParameters(primary *spec.Swagger, m *spec.Swagger) (skipped []string) { + for k, v := range m.Parameters { + // could try to rename on conflict but would + // have to fix $refs in the mixin. Complain + // for now + if _, exists := primary.Parameters[k]; exists { + warn := fmt.Sprintf( + "top level parameters entry '%v' already exists in primary or higher priority mixin, skipping\n", k) + skipped = append(skipped, warn) + + continue + } + primary.Parameters[k] = v + } + + return +} + +func mergeResponses(primary *spec.Swagger, m *spec.Swagger) (skipped []string) { + for k, v := range m.Responses { + // could try to rename on conflict but would + // have to fix $refs in the mixin. Complain + // for now + if _, exists := primary.Responses[k]; exists { + warn := fmt.Sprintf( + "top level responses entry '%v' already exists in primary or higher priority mixin, skipping\n", k) + skipped = append(skipped, warn) + + continue + } + primary.Responses[k] = v + } + + return skipped +} + +func mergeConsumes(primary *spec.Swagger, m *spec.Swagger) []string { + for _, v := range m.Consumes { + found := false + for _, vv := range primary.Consumes { + if v == vv { + found = true + + break + } + } + + if found { + // no warning here: we just skip it + continue + } + primary.Consumes = append(primary.Consumes, v) + } + + return []string{} +} + +func mergeProduces(primary *spec.Swagger, m *spec.Swagger) []string { + for _, v := range m.Produces { + found := false + for _, vv := range primary.Produces { + if v == vv { + found = true + + break + } + } + + if found { + // no warning here: we just skip it + continue + } + primary.Produces = append(primary.Produces, v) + } + + return []string{} +} + +func mergeTags(primary *spec.Swagger, m *spec.Swagger) (skipped []string) { + for _, v := range m.Tags { + found := false + for _, vv := range primary.Tags { + if v.Name == vv.Name { + found = true + + break + } + } + + if found { + warn := fmt.Sprintf( + "top level tags entry with name '%v' already exists in primary or higher priority mixin, skipping\n", + v.Name, + ) + skipped = append(skipped, warn) + + continue + } + + primary.Tags = append(primary.Tags, v) + } + + return +} + +func mergeSchemes(primary *spec.Swagger, m *spec.Swagger) []string { + for _, v := range m.Schemes { + found := false + for _, vv := range primary.Schemes { + if v == vv { + found = true + + break + } + } + + if found { + // no warning here: we just skip it + continue + } + primary.Schemes = append(primary.Schemes, v) + } + + return []string{} +} + +func mergeSwaggerProps(primary *spec.Swagger, m *spec.Swagger) []string { + var skipped, skippedInfo, skippedDocs []string + + primary.Extensions, skipped = mergeExtensions(primary.Extensions, m.Extensions) + + // merging details in swagger top properties + if primary.Host == "" { + primary.Host = m.Host + } + + if primary.BasePath == "" { + primary.BasePath = m.BasePath + } + + if primary.Info == nil { + primary.Info = m.Info + } else if m.Info != nil { + skippedInfo = mergeInfo(primary.Info, m.Info) + skipped = append(skipped, skippedInfo...) + } + + if primary.ExternalDocs == nil { + primary.ExternalDocs = m.ExternalDocs + } else if m != nil { + skippedDocs = mergeExternalDocs(primary.ExternalDocs, m.ExternalDocs) + skipped = append(skipped, skippedDocs...) + } + + return skipped +} + +// nolint: unparam +func mergeExternalDocs(primary *spec.ExternalDocumentation, m *spec.ExternalDocumentation) []string { + if primary.Description == "" { + primary.Description = m.Description + } + + if primary.URL == "" { + primary.URL = m.URL + } + + return nil +} + +func mergeInfo(primary *spec.Info, m *spec.Info) []string { + var sk, skipped []string + + primary.Extensions, sk = mergeExtensions(primary.Extensions, m.Extensions) + skipped = append(skipped, sk...) + + if primary.Description == "" { + primary.Description = m.Description + } + + if primary.Title == "" { + primary.Description = m.Description + } + + if primary.TermsOfService == "" { + primary.TermsOfService = m.TermsOfService + } + + if primary.Version == "" { + primary.Version = m.Version + } + + if primary.Contact == nil { + primary.Contact = m.Contact + } else if m.Contact != nil { + var csk []string + primary.Contact.Extensions, csk = mergeExtensions(primary.Contact.Extensions, m.Contact.Extensions) + skipped = append(skipped, csk...) + + if primary.Contact.Name == "" { + primary.Contact.Name = m.Contact.Name + } + + if primary.Contact.URL == "" { + primary.Contact.URL = m.Contact.URL + } + + if primary.Contact.Email == "" { + primary.Contact.Email = m.Contact.Email + } + } + + if primary.License == nil { + primary.License = m.License + } else if m.License != nil { + var lsk []string + primary.License.Extensions, lsk = mergeExtensions(primary.License.Extensions, m.License.Extensions) + skipped = append(skipped, lsk...) + + if primary.License.Name == "" { + primary.License.Name = m.License.Name + } + + if primary.License.URL == "" { + primary.License.URL = m.License.URL + } + } + + return skipped +} + +func mergeExtensions(primary spec.Extensions, m spec.Extensions) (result spec.Extensions, skipped []string) { + if primary == nil { + result = m + + return + } + + if m == nil { + result = primary + + return + } + + result = primary + for k, v := range m { + if _, found := primary[k]; found { + skipped = append(skipped, k) + + continue + } + + primary[k] = v + } + + return +} + +func initPrimary(primary *spec.Swagger) { + if primary.SecurityDefinitions == nil { + primary.SecurityDefinitions = make(map[string]*spec.SecurityScheme) + } + + if primary.Security == nil { + primary.Security = make([]map[string][]string, 0, 10) + } + + if primary.Produces == nil { + primary.Produces = make([]string, 0, 10) + } + + if primary.Consumes == nil { + primary.Consumes = make([]string, 0, 10) + } + + if primary.Tags == nil { + primary.Tags = make([]spec.Tag, 0, 10) + } + + if primary.Schemes == nil { + primary.Schemes = make([]string, 0, 10) + } + + if primary.Paths == nil { + primary.Paths = &spec.Paths{Paths: make(map[string]spec.PathItem)} + } + + if primary.Paths.Paths == nil { + primary.Paths.Paths = make(map[string]spec.PathItem) + } + + if primary.Definitions == nil { + primary.Definitions = make(spec.Definitions) + } + + if primary.Parameters == nil { + primary.Parameters = make(map[string]spec.Parameter) + } + + if primary.Responses == nil { + primary.Responses = make(map[string]spec.Response) + } +} diff --git a/vendor/github.com/go-openapi/analysis/schema.go b/vendor/github.com/go-openapi/analysis/schema.go new file mode 100644 index 00000000000..fc055095cbb --- /dev/null +++ b/vendor/github.com/go-openapi/analysis/schema.go @@ -0,0 +1,256 @@ +package analysis + +import ( + "fmt" + + "github.com/go-openapi/spec" + "github.com/go-openapi/strfmt" +) + +// SchemaOpts configures the schema analyzer +type SchemaOpts struct { + Schema *spec.Schema + Root interface{} + BasePath string + _ struct{} +} + +// Schema analysis, will classify the schema according to known +// patterns. +func Schema(opts SchemaOpts) (*AnalyzedSchema, error) { + if opts.Schema == nil { + return nil, fmt.Errorf("no schema to analyze") + } + + a := &AnalyzedSchema{ + schema: opts.Schema, + root: opts.Root, + basePath: opts.BasePath, + } + + a.initializeFlags() + a.inferKnownType() + a.inferEnum() + a.inferBaseType() + + if err := a.inferMap(); err != nil { + return nil, err + } + if err := a.inferArray(); err != nil { + return nil, err + } + + a.inferTuple() + + if err := a.inferFromRef(); err != nil { + return nil, err + } + + a.inferSimpleSchema() + + return a, nil +} + +// AnalyzedSchema indicates what the schema represents +type AnalyzedSchema struct { + schema *spec.Schema + root interface{} + basePath string + + hasProps bool + hasAllOf bool + hasItems bool + hasAdditionalProps bool + hasAdditionalItems bool + hasRef bool + + IsKnownType bool + IsSimpleSchema bool + IsArray bool + IsSimpleArray bool + IsMap bool + IsSimpleMap bool + IsExtendedObject bool + IsTuple bool + IsTupleWithExtra bool + IsBaseType bool + IsEnum bool +} + +// Inherits copies value fields from other onto this schema +func (a *AnalyzedSchema) inherits(other *AnalyzedSchema) { + if other == nil { + return + } + a.hasProps = other.hasProps + a.hasAllOf = other.hasAllOf + a.hasItems = other.hasItems + a.hasAdditionalItems = other.hasAdditionalItems + a.hasAdditionalProps = other.hasAdditionalProps + a.hasRef = other.hasRef + + a.IsKnownType = other.IsKnownType + a.IsSimpleSchema = other.IsSimpleSchema + a.IsArray = other.IsArray + a.IsSimpleArray = other.IsSimpleArray + a.IsMap = other.IsMap + a.IsSimpleMap = other.IsSimpleMap + a.IsExtendedObject = other.IsExtendedObject + a.IsTuple = other.IsTuple + a.IsTupleWithExtra = other.IsTupleWithExtra + a.IsBaseType = other.IsBaseType + a.IsEnum = other.IsEnum +} + +func (a *AnalyzedSchema) inferFromRef() error { + if a.hasRef { + sch := new(spec.Schema) + sch.Ref = a.schema.Ref + err := spec.ExpandSchema(sch, a.root, nil) + if err != nil { + return err + } + rsch, err := Schema(SchemaOpts{ + Schema: sch, + Root: a.root, + BasePath: a.basePath, + }) + if err != nil { + // NOTE(fredbi): currently the only cause for errors is + // unresolved ref. Since spec.ExpandSchema() expands the + // schema recursively, there is no chance to get there, + // until we add more causes for error in this schema analysis. + return err + } + a.inherits(rsch) + } + + return nil +} + +func (a *AnalyzedSchema) inferSimpleSchema() { + a.IsSimpleSchema = a.IsKnownType || a.IsSimpleArray || a.IsSimpleMap +} + +func (a *AnalyzedSchema) inferKnownType() { + tpe := a.schema.Type + format := a.schema.Format + a.IsKnownType = tpe.Contains("boolean") || + tpe.Contains("integer") || + tpe.Contains("number") || + tpe.Contains("string") || + (format != "" && strfmt.Default.ContainsName(format)) || + (a.isObjectType() && !a.hasProps && !a.hasAllOf && !a.hasAdditionalProps && !a.hasAdditionalItems) +} + +func (a *AnalyzedSchema) inferMap() error { + if !a.isObjectType() { + return nil + } + + hasExtra := a.hasProps || a.hasAllOf + a.IsMap = a.hasAdditionalProps && !hasExtra + a.IsExtendedObject = a.hasAdditionalProps && hasExtra + + if !a.IsMap { + return nil + } + + // maps + if a.schema.AdditionalProperties.Schema != nil { + msch, err := Schema(SchemaOpts{ + Schema: a.schema.AdditionalProperties.Schema, + Root: a.root, + BasePath: a.basePath, + }) + if err != nil { + return err + } + a.IsSimpleMap = msch.IsSimpleSchema + } else if a.schema.AdditionalProperties.Allows { + a.IsSimpleMap = true + } + + return nil +} + +func (a *AnalyzedSchema) inferArray() error { + // an array has Items defined as an object schema, otherwise we qualify this JSON array as a tuple + // (yes, even if the Items array contains only one element). + // arrays in JSON schema may be unrestricted (i.e no Items specified). + // Note that arrays in Swagger MUST have Items. Nonetheless, we analyze unrestricted arrays. + // + // NOTE: the spec package misses the distinction between: + // items: [] and items: {}, so we consider both arrays here. + a.IsArray = a.isArrayType() && (a.schema.Items == nil || a.schema.Items.Schemas == nil) + if a.IsArray && a.hasItems { + if a.schema.Items.Schema != nil { + itsch, err := Schema(SchemaOpts{ + Schema: a.schema.Items.Schema, + Root: a.root, + BasePath: a.basePath, + }) + if err != nil { + return err + } + + a.IsSimpleArray = itsch.IsSimpleSchema + } + } + + if a.IsArray && !a.hasItems { + a.IsSimpleArray = true + } + + return nil +} + +func (a *AnalyzedSchema) inferTuple() { + tuple := a.hasItems && a.schema.Items.Schemas != nil + a.IsTuple = tuple && !a.hasAdditionalItems + a.IsTupleWithExtra = tuple && a.hasAdditionalItems +} + +func (a *AnalyzedSchema) inferBaseType() { + if a.isObjectType() { + a.IsBaseType = a.schema.Discriminator != "" + } +} + +func (a *AnalyzedSchema) inferEnum() { + a.IsEnum = len(a.schema.Enum) > 0 +} + +func (a *AnalyzedSchema) initializeFlags() { + a.hasProps = len(a.schema.Properties) > 0 + a.hasAllOf = len(a.schema.AllOf) > 0 + a.hasRef = a.schema.Ref.String() != "" + + a.hasItems = a.schema.Items != nil && + (a.schema.Items.Schema != nil || len(a.schema.Items.Schemas) > 0) + + a.hasAdditionalProps = a.schema.AdditionalProperties != nil && + (a.schema.AdditionalProperties.Schema != nil || a.schema.AdditionalProperties.Allows) + + a.hasAdditionalItems = a.schema.AdditionalItems != nil && + (a.schema.AdditionalItems.Schema != nil || a.schema.AdditionalItems.Allows) +} + +func (a *AnalyzedSchema) isObjectType() bool { + return !a.hasRef && (a.schema.Type == nil || a.schema.Type.Contains("") || a.schema.Type.Contains("object")) +} + +func (a *AnalyzedSchema) isArrayType() bool { + return !a.hasRef && (a.schema.Type != nil && a.schema.Type.Contains("array")) +} + +// isAnalyzedAsComplex determines if an analyzed schema is eligible to flattening (i.e. it is "complex"). +// +// Complex means the schema is any of: +// - a simple type (primitive) +// - an array of something (items are possibly complex ; if this is the case, items will generate a definition) +// - a map of something (additionalProperties are possibly complex ; if this is the case, additionalProperties will +// generate a definition) +func (a *AnalyzedSchema) isAnalyzedAsComplex() bool { + return !a.IsSimpleSchema && !a.IsArray && !a.IsMap +} diff --git a/vendor/github.com/go-openapi/errors/.gitattributes b/vendor/github.com/go-openapi/errors/.gitattributes new file mode 100644 index 00000000000..a0717e4b3b9 --- /dev/null +++ b/vendor/github.com/go-openapi/errors/.gitattributes @@ -0,0 +1 @@ +*.go text eol=lf \ No newline at end of file diff --git a/vendor/github.com/go-openapi/errors/.golangci.yml b/vendor/github.com/go-openapi/errors/.golangci.yml index 6badaf1549f..449a43c2bc8 100644 --- a/vendor/github.com/go-openapi/errors/.golangci.yml +++ b/vendor/github.com/go-openapi/errors/.golangci.yml @@ -18,3 +18,29 @@ linters: - maligned - lll - gochecknoglobals + - godox + - gocognit + - whitespace + - wsl + - funlen + - gochecknoglobals + - gochecknoinits + - scopelint + - wrapcheck + - exhaustivestruct + - exhaustive + - nlreturn + - testpackage + - gci + - gofumpt + - goerr113 + - gomnd + - tparallel + - nestif + - godot + - errorlint + - paralleltest + - tparallel + - cyclop + - errname + - varnamelen diff --git a/vendor/github.com/go-openapi/errors/.travis.yml b/vendor/github.com/go-openapi/errors/.travis.yml deleted file mode 100644 index 57631a0b204..00000000000 --- a/vendor/github.com/go-openapi/errors/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -after_success: -- bash <(curl -s https://codecov.io/bash) -go: -- 1.13.x -- 1.14.x -arch: - - amd64 - - ppc64le -install: -- GO111MODULE=off go get -u gotest.tools/gotestsum -language: go -notifications: - slack: - secure: gZGp9NaHxi7zawlXJXKY92BGeDR1x0tbIcTyU5nMKLq0fhIaiEBJEeALwZ4VgqsSv3DytSSF5mLH8fevAM3ixE6hxjKQ+lQuf7V/w3btCN1CSWgoua5LOh1kTnqZQtJuRvO4pzoJcT3bJWBsVZ07VGNVzzJEy/zAKCHFqBUCXShw7QemlLBcYWFNqveTlvDIfCzvouoLnPoXwxEpkjxe9uz/ZKZgAnup/fXjC8RFctmgCnkCyvJTk0Y/fZCsufixJrJhshBWTnlrFCzRmgNkz2d+i1Ls3+MJ5EJJ2Tx/A5S63dL49J1f9Kr0AKHADmulSy8JNzIckKwbyFMYUecrsW+Lsu9DhnVMy1jj5pKsJDLRi2iIU3fXTMWbcyQbXjbbnBO2mPdP3Tzme75y4D9fc8hUPeyqVv2BU26NEbQ7EF2pKJ93OXvci7HlwRBgdJa8j6mP2LEDClcPQW00g7N/OZe0cTOMa8L5AwiBlbArwqt9wv6YLJoTG0wpDhzWsFvbCg5bJxe28Yn3fIDD0Lk1I7iSnBbp/5gzF19jmxqvcT8tHRkDL4xfjbENFTZjA5uB4Z4pj4WSyWQILLV/Jwhe3fi9uQwdviFHfj5pnVrmNUiGSOQL672K5wl2c3E9mGwejvsu2dfEz28n7Y/FUnOpY3/cBS0n27JJaerS0zMKNLE= -script: -- gotestsum -f short-verbose -- -race -coverprofile=coverage.txt -covermode=atomic ./... diff --git a/vendor/github.com/go-openapi/errors/README.md b/vendor/github.com/go-openapi/errors/README.md index 0ce50b23b2e..4aac049e608 100644 --- a/vendor/github.com/go-openapi/errors/README.md +++ b/vendor/github.com/go-openapi/errors/README.md @@ -1,7 +1,10 @@ -# OpenAPI errors [![Build Status](https://travis-ci.org/go-openapi/errors.svg?branch=master)](https://travis-ci.org/go-openapi/errors) [![codecov](https://codecov.io/gh/go-openapi/errors/branch/master/graph/badge.svg)](https://codecov.io/gh/go-openapi/errors) [![Slack Status](https://slackin.goswagger.io/badge.svg)](https://slackin.goswagger.io) +# OpenAPI errors +[![Build Status](https://travis-ci.org/go-openapi/errors.svg?branch=master)](https://travis-ci.org/go-openapi/errors) +[![codecov](https://codecov.io/gh/go-openapi/errors/branch/master/graph/badge.svg)](https://codecov.io/gh/go-openapi/errors) +[![Slack Status](https://slackin.goswagger.io/badge.svg)](https://slackin.goswagger.io) [![license](http://img.shields.io/badge/license-Apache%20v2-orange.svg)](https://raw.githubusercontent.com/go-openapi/errors/master/LICENSE) -[![GoDoc](https://godoc.org/github.com/go-openapi/errors?status.svg)](http://godoc.org/github.com/go-openapi/errors) +[![Go Reference](https://pkg.go.dev/badge/github.com/go-openapi/errors.svg)](https://pkg.go.dev/github.com/go-openapi/errors) [![GolangCI](https://golangci.com/badges/github.com/go-openapi/errors.svg)](https://golangci.com) [![Go Report Card](https://goreportcard.com/badge/github.com/go-openapi/errors)](https://goreportcard.com/report/github.com/go-openapi/errors) diff --git a/vendor/github.com/go-openapi/errors/api.go b/vendor/github.com/go-openapi/errors/api.go index 7667cee76c9..854d6eec1e1 100644 --- a/vendor/github.com/go-openapi/errors/api.go +++ b/vendor/github.com/go-openapi/errors/api.go @@ -44,6 +44,14 @@ func (a *apiError) Code() int32 { return a.code } +// MarshalJSON implements the JSON encoding interface +func (a apiError) MarshalJSON() ([]byte, error) { + return json.Marshal(map[string]interface{}{ + "code": a.code, + "message": a.message, + }) +} + // New creates a new API error with a code and a message func New(code int32, message string, args ...interface{}) Error { if len(args) > 0 { @@ -81,6 +89,15 @@ func (m *MethodNotAllowedError) Code() int32 { return m.code } +// MarshalJSON implements the JSON encoding interface +func (m MethodNotAllowedError) MarshalJSON() ([]byte, error) { + return json.Marshal(map[string]interface{}{ + "code": m.code, + "message": m.message, + "allowed": m.Allowed, + }) +} + func errorAsJSON(err Error) []byte { b, _ := json.Marshal(struct { Code int32 `json:"code"` diff --git a/vendor/github.com/go-openapi/errors/headers.go b/vendor/github.com/go-openapi/errors/headers.go index 0360c094ea3..dfebe8f95f0 100644 --- a/vendor/github.com/go-openapi/errors/headers.go +++ b/vendor/github.com/go-openapi/errors/headers.go @@ -15,6 +15,7 @@ package errors import ( + "encoding/json" "fmt" "net/http" ) @@ -38,11 +39,28 @@ func (e *Validation) Code() int32 { return e.code } -// ValidateName produces an error message name for an aliased property +// MarshalJSON implements the JSON encoding interface +func (e Validation) MarshalJSON() ([]byte, error) { + return json.Marshal(map[string]interface{}{ + "code": e.code, + "message": e.message, + "in": e.In, + "name": e.Name, + "value": e.Value, + "values": e.Values, + }) +} + +// ValidateName sets the name for a validation or updates it for a nested property func (e *Validation) ValidateName(name string) *Validation { - if e.Name == "" && name != "" { - e.Name = name - e.message = name + e.message + if name != "" { + if e.Name == "" { + e.Name = name + e.message = name + e.message + } else { + e.Name = name + "." + e.Name + e.message = name + "." + e.message + } } return e } diff --git a/vendor/github.com/go-openapi/errors/middleware.go b/vendor/github.com/go-openapi/errors/middleware.go index 6390d4636aa..c26ad484ebc 100644 --- a/vendor/github.com/go-openapi/errors/middleware.go +++ b/vendor/github.com/go-openapi/errors/middleware.go @@ -23,9 +23,9 @@ import ( // APIVerificationFailed is an error that contains all the missing info for a mismatched section // between the api registrations and the api spec type APIVerificationFailed struct { - Section string - MissingSpecification []string - MissingRegistration []string + Section string `json:"section,omitempty"` + MissingSpecification []string `json:"missingSpecification,omitempty"` + MissingRegistration []string `json:"missingRegistration,omitempty"` } // diff --git a/vendor/github.com/go-openapi/errors/parsing.go b/vendor/github.com/go-openapi/errors/parsing.go index 0f96ce2094e..5096e1ea7be 100644 --- a/vendor/github.com/go-openapi/errors/parsing.go +++ b/vendor/github.com/go-openapi/errors/parsing.go @@ -14,7 +14,10 @@ package errors -import "fmt" +import ( + "encoding/json" + "fmt" +) // ParseError represents a parsing error type ParseError struct { @@ -35,6 +38,22 @@ func (e *ParseError) Code() int32 { return e.code } +// MarshalJSON implements the JSON encoding interface +func (e ParseError) MarshalJSON() ([]byte, error) { + var reason string + if e.Reason != nil { + reason = e.Reason.Error() + } + return json.Marshal(map[string]interface{}{ + "code": e.code, + "message": e.message, + "in": e.In, + "name": e.Name, + "value": e.Value, + "reason": reason, + }) +} + const ( parseErrorTemplContent = `parsing %s %s from %q failed, because %s` parseErrorTemplContentNoIn = `parsing %s from %q failed, because %s` diff --git a/vendor/github.com/go-openapi/errors/schema.go b/vendor/github.com/go-openapi/errors/schema.go index f4a7d4ac239..da5f6c78cb5 100644 --- a/vendor/github.com/go-openapi/errors/schema.go +++ b/vendor/github.com/go-openapi/errors/schema.go @@ -15,6 +15,7 @@ package errors import ( + "encoding/json" "fmt" "strings" ) @@ -119,6 +120,15 @@ func (c *CompositeError) Error() string { return c.message } +// MarshalJSON implements the JSON encoding interface +func (c CompositeError) MarshalJSON() ([]byte, error) { + return json.Marshal(map[string]interface{}{ + "code": c.code, + "message": c.message, + "errors": c.Errors, + }) +} + // CompositeValidationError an error to wrap a bunch of other errors func CompositeValidationError(errors ...error) *CompositeError { return &CompositeError{ @@ -128,6 +138,19 @@ func CompositeValidationError(errors ...error) *CompositeError { } } +// ValidateName recursively sets the name for all validations or updates them for nested properties +func (c *CompositeError) ValidateName(name string) *CompositeError { + for i, e := range c.Errors { + if ve, ok := e.(*Validation); ok { + c.Errors[i] = ve.ValidateName(name) + } else if ce, ok := e.(*CompositeError); ok { + c.Errors[i] = ce.ValidateName(name) + } + } + + return c +} + // FailedAllPatternProperties an error for when the property doesn't match a pattern func FailedAllPatternProperties(name, in, key string) *Validation { msg := fmt.Sprintf(failedAllPatternProps, name, key, in) diff --git a/vendor/github.com/go-openapi/jsonpointer/.editorconfig b/vendor/github.com/go-openapi/jsonpointer/.editorconfig new file mode 100644 index 00000000000..3152da69a5d --- /dev/null +++ b/vendor/github.com/go-openapi/jsonpointer/.editorconfig @@ -0,0 +1,26 @@ +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true + +# Set default charset +[*.{js,py,go,scala,rb,java,html,css,less,sass,md}] +charset = utf-8 + +# Tab indentation (no size specified) +[*.go] +indent_style = tab + +[*.md] +trim_trailing_whitespace = false + +# Matches the exact files either package.json or .travis.yml +[{package.json,.travis.yml}] +indent_style = space +indent_size = 2 diff --git a/vendor/github.com/go-openapi/jsonpointer/.gitignore b/vendor/github.com/go-openapi/jsonpointer/.gitignore new file mode 100644 index 00000000000..769c244007b --- /dev/null +++ b/vendor/github.com/go-openapi/jsonpointer/.gitignore @@ -0,0 +1 @@ +secrets.yml diff --git a/vendor/github.com/go-openapi/jsonpointer/.travis.yml b/vendor/github.com/go-openapi/jsonpointer/.travis.yml new file mode 100644 index 00000000000..03a22fe06fd --- /dev/null +++ b/vendor/github.com/go-openapi/jsonpointer/.travis.yml @@ -0,0 +1,15 @@ +after_success: +- bash <(curl -s https://codecov.io/bash) +go: +- 1.14.x +- 1.15.x +install: +- GO111MODULE=off go get -u gotest.tools/gotestsum +env: +- GO111MODULE=on +language: go +notifications: + slack: + secure: a5VgoiwB1G/AZqzmephPZIhEB9avMlsWSlVnM1dSAtYAwdrQHGTQxAmpOxYIoSPDhWNN5bfZmjd29++UlTwLcHSR+e0kJhH6IfDlsHj/HplNCJ9tyI0zYc7XchtdKgeMxMzBKCzgwFXGSbQGydXTliDNBo0HOzmY3cou/daMFTP60K+offcjS+3LRAYb1EroSRXZqrk1nuF/xDL3792DZUdPMiFR/L/Df6y74D6/QP4sTkTDFQitz4Wy/7jbsfj8dG6qK2zivgV6/l+w4OVjFkxVpPXogDWY10vVXNVynqxfJ7to2d1I9lNCHE2ilBCkWMIPdyJF7hjF8pKW+82yP4EzRh0vu8Xn0HT5MZpQxdRY/YMxNrWaG7SxsoEaO4q5uhgdzAqLYY3TRa7MjIK+7Ur+aqOeTXn6OKwVi0CjvZ6mIU3WUKSwiwkFZMbjRAkSb5CYwMEfGFO/z964xz83qGt6WAtBXNotqCQpTIiKtDHQeLOMfksHImCg6JLhQcWBVxamVgu0G3Pdh8Y6DyPnxraXY95+QDavbjqv7TeYT9T/FNnrkXaTTK0s4iWE5H4ACU0Qvz0wUYgfQrZv0/Hp7V17+rabUwnzYySHCy9SWX/7OV9Cfh31iMp9ZIffr76xmmThtOEqs8TrTtU6BWI3rWwvA9cXQipZTVtL0oswrGw= +script: +- gotestsum -f short-verbose -- -race -coverprofile=coverage.txt -covermode=atomic ./... diff --git a/vendor/github.com/go-openapi/jsonpointer/CODE_OF_CONDUCT.md b/vendor/github.com/go-openapi/jsonpointer/CODE_OF_CONDUCT.md new file mode 100644 index 00000000000..9322b065e37 --- /dev/null +++ b/vendor/github.com/go-openapi/jsonpointer/CODE_OF_CONDUCT.md @@ -0,0 +1,74 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or +advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at ivan+abuse@flanders.co.nz. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/vendor/github.com/go-openapi/jsonpointer/LICENSE b/vendor/github.com/go-openapi/jsonpointer/LICENSE new file mode 100644 index 00000000000..d6456956733 --- /dev/null +++ b/vendor/github.com/go-openapi/jsonpointer/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/go-openapi/jsonpointer/README.md b/vendor/github.com/go-openapi/jsonpointer/README.md new file mode 100644 index 00000000000..813788aff1c --- /dev/null +++ b/vendor/github.com/go-openapi/jsonpointer/README.md @@ -0,0 +1,15 @@ +# gojsonpointer [![Build Status](https://travis-ci.org/go-openapi/jsonpointer.svg?branch=master)](https://travis-ci.org/go-openapi/jsonpointer) [![codecov](https://codecov.io/gh/go-openapi/jsonpointer/branch/master/graph/badge.svg)](https://codecov.io/gh/go-openapi/jsonpointer) [![Slack Status](https://slackin.goswagger.io/badge.svg)](https://slackin.goswagger.io) + +[![license](http://img.shields.io/badge/license-Apache%20v2-orange.svg)](https://raw.githubusercontent.com/go-openapi/jsonpointer/master/LICENSE) [![GoDoc](https://godoc.org/github.com/go-openapi/jsonpointer?status.svg)](http://godoc.org/github.com/go-openapi/jsonpointer) +An implementation of JSON Pointer - Go language + +## Status +Completed YES + +Tested YES + +## References +http://tools.ietf.org/html/draft-ietf-appsawg-json-pointer-07 + +### Note +The 4.Evaluation part of the previous reference, starting with 'If the currently referenced value is a JSON array, the reference token MUST contain either...' is not implemented. diff --git a/vendor/github.com/go-openapi/jsonpointer/pointer.go b/vendor/github.com/go-openapi/jsonpointer/pointer.go new file mode 100644 index 00000000000..7df9853def6 --- /dev/null +++ b/vendor/github.com/go-openapi/jsonpointer/pointer.go @@ -0,0 +1,390 @@ +// Copyright 2013 sigu-399 ( https://github.com/sigu-399 ) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// author sigu-399 +// author-github https://github.com/sigu-399 +// author-mail sigu.399@gmail.com +// +// repository-name jsonpointer +// repository-desc An implementation of JSON Pointer - Go language +// +// description Main and unique file. +// +// created 25-02-2013 + +package jsonpointer + +import ( + "errors" + "fmt" + "reflect" + "strconv" + "strings" + + "github.com/go-openapi/swag" +) + +const ( + emptyPointer = `` + pointerSeparator = `/` + + invalidStart = `JSON pointer must be empty or start with a "` + pointerSeparator +) + +var jsonPointableType = reflect.TypeOf(new(JSONPointable)).Elem() +var jsonSetableType = reflect.TypeOf(new(JSONSetable)).Elem() + +// JSONPointable is an interface for structs to implement when they need to customize the +// json pointer process +type JSONPointable interface { + JSONLookup(string) (interface{}, error) +} + +// JSONSetable is an interface for structs to implement when they need to customize the +// json pointer process +type JSONSetable interface { + JSONSet(string, interface{}) error +} + +// New creates a new json pointer for the given string +func New(jsonPointerString string) (Pointer, error) { + + var p Pointer + err := p.parse(jsonPointerString) + return p, err + +} + +// Pointer the json pointer reprsentation +type Pointer struct { + referenceTokens []string +} + +// "Constructor", parses the given string JSON pointer +func (p *Pointer) parse(jsonPointerString string) error { + + var err error + + if jsonPointerString != emptyPointer { + if !strings.HasPrefix(jsonPointerString, pointerSeparator) { + err = errors.New(invalidStart) + } else { + referenceTokens := strings.Split(jsonPointerString, pointerSeparator) + for _, referenceToken := range referenceTokens[1:] { + p.referenceTokens = append(p.referenceTokens, referenceToken) + } + } + } + + return err +} + +// Get uses the pointer to retrieve a value from a JSON document +func (p *Pointer) Get(document interface{}) (interface{}, reflect.Kind, error) { + return p.get(document, swag.DefaultJSONNameProvider) +} + +// Set uses the pointer to set a value from a JSON document +func (p *Pointer) Set(document interface{}, value interface{}) (interface{}, error) { + return document, p.set(document, value, swag.DefaultJSONNameProvider) +} + +// GetForToken gets a value for a json pointer token 1 level deep +func GetForToken(document interface{}, decodedToken string) (interface{}, reflect.Kind, error) { + return getSingleImpl(document, decodedToken, swag.DefaultJSONNameProvider) +} + +// SetForToken gets a value for a json pointer token 1 level deep +func SetForToken(document interface{}, decodedToken string, value interface{}) (interface{}, error) { + return document, setSingleImpl(document, value, decodedToken, swag.DefaultJSONNameProvider) +} + +func getSingleImpl(node interface{}, decodedToken string, nameProvider *swag.NameProvider) (interface{}, reflect.Kind, error) { + rValue := reflect.Indirect(reflect.ValueOf(node)) + kind := rValue.Kind() + + if rValue.Type().Implements(jsonPointableType) { + r, err := node.(JSONPointable).JSONLookup(decodedToken) + if err != nil { + return nil, kind, err + } + return r, kind, nil + } + + switch kind { + case reflect.Struct: + nm, ok := nameProvider.GetGoNameForType(rValue.Type(), decodedToken) + if !ok { + return nil, kind, fmt.Errorf("object has no field %q", decodedToken) + } + fld := rValue.FieldByName(nm) + return fld.Interface(), kind, nil + + case reflect.Map: + kv := reflect.ValueOf(decodedToken) + mv := rValue.MapIndex(kv) + + if mv.IsValid() { + return mv.Interface(), kind, nil + } + return nil, kind, fmt.Errorf("object has no key %q", decodedToken) + + case reflect.Slice: + tokenIndex, err := strconv.Atoi(decodedToken) + if err != nil { + return nil, kind, err + } + sLength := rValue.Len() + if tokenIndex < 0 || tokenIndex >= sLength { + return nil, kind, fmt.Errorf("index out of bounds array[0,%d] index '%d'", sLength-1, tokenIndex) + } + + elem := rValue.Index(tokenIndex) + return elem.Interface(), kind, nil + + default: + return nil, kind, fmt.Errorf("invalid token reference %q", decodedToken) + } + +} + +func setSingleImpl(node, data interface{}, decodedToken string, nameProvider *swag.NameProvider) error { + rValue := reflect.Indirect(reflect.ValueOf(node)) + + if ns, ok := node.(JSONSetable); ok { // pointer impl + return ns.JSONSet(decodedToken, data) + } + + if rValue.Type().Implements(jsonSetableType) { + return node.(JSONSetable).JSONSet(decodedToken, data) + } + + switch rValue.Kind() { + case reflect.Struct: + nm, ok := nameProvider.GetGoNameForType(rValue.Type(), decodedToken) + if !ok { + return fmt.Errorf("object has no field %q", decodedToken) + } + fld := rValue.FieldByName(nm) + if fld.IsValid() { + fld.Set(reflect.ValueOf(data)) + } + return nil + + case reflect.Map: + kv := reflect.ValueOf(decodedToken) + rValue.SetMapIndex(kv, reflect.ValueOf(data)) + return nil + + case reflect.Slice: + tokenIndex, err := strconv.Atoi(decodedToken) + if err != nil { + return err + } + sLength := rValue.Len() + if tokenIndex < 0 || tokenIndex >= sLength { + return fmt.Errorf("index out of bounds array[0,%d] index '%d'", sLength, tokenIndex) + } + + elem := rValue.Index(tokenIndex) + if !elem.CanSet() { + return fmt.Errorf("can't set slice index %s to %v", decodedToken, data) + } + elem.Set(reflect.ValueOf(data)) + return nil + + default: + return fmt.Errorf("invalid token reference %q", decodedToken) + } + +} + +func (p *Pointer) get(node interface{}, nameProvider *swag.NameProvider) (interface{}, reflect.Kind, error) { + + if nameProvider == nil { + nameProvider = swag.DefaultJSONNameProvider + } + + kind := reflect.Invalid + + // Full document when empty + if len(p.referenceTokens) == 0 { + return node, kind, nil + } + + for _, token := range p.referenceTokens { + + decodedToken := Unescape(token) + + r, knd, err := getSingleImpl(node, decodedToken, nameProvider) + if err != nil { + return nil, knd, err + } + node, kind = r, knd + + } + + rValue := reflect.ValueOf(node) + kind = rValue.Kind() + + return node, kind, nil +} + +func (p *Pointer) set(node, data interface{}, nameProvider *swag.NameProvider) error { + knd := reflect.ValueOf(node).Kind() + + if knd != reflect.Ptr && knd != reflect.Struct && knd != reflect.Map && knd != reflect.Slice && knd != reflect.Array { + return fmt.Errorf("only structs, pointers, maps and slices are supported for setting values") + } + + if nameProvider == nil { + nameProvider = swag.DefaultJSONNameProvider + } + + // Full document when empty + if len(p.referenceTokens) == 0 { + return nil + } + + lastI := len(p.referenceTokens) - 1 + for i, token := range p.referenceTokens { + isLastToken := i == lastI + decodedToken := Unescape(token) + + if isLastToken { + + return setSingleImpl(node, data, decodedToken, nameProvider) + } + + rValue := reflect.Indirect(reflect.ValueOf(node)) + kind := rValue.Kind() + + if rValue.Type().Implements(jsonPointableType) { + r, err := node.(JSONPointable).JSONLookup(decodedToken) + if err != nil { + return err + } + fld := reflect.ValueOf(r) + if fld.CanAddr() && fld.Kind() != reflect.Interface && fld.Kind() != reflect.Map && fld.Kind() != reflect.Slice && fld.Kind() != reflect.Ptr { + node = fld.Addr().Interface() + continue + } + node = r + continue + } + + switch kind { + case reflect.Struct: + nm, ok := nameProvider.GetGoNameForType(rValue.Type(), decodedToken) + if !ok { + return fmt.Errorf("object has no field %q", decodedToken) + } + fld := rValue.FieldByName(nm) + if fld.CanAddr() && fld.Kind() != reflect.Interface && fld.Kind() != reflect.Map && fld.Kind() != reflect.Slice && fld.Kind() != reflect.Ptr { + node = fld.Addr().Interface() + continue + } + node = fld.Interface() + + case reflect.Map: + kv := reflect.ValueOf(decodedToken) + mv := rValue.MapIndex(kv) + + if !mv.IsValid() { + return fmt.Errorf("object has no key %q", decodedToken) + } + if mv.CanAddr() && mv.Kind() != reflect.Interface && mv.Kind() != reflect.Map && mv.Kind() != reflect.Slice && mv.Kind() != reflect.Ptr { + node = mv.Addr().Interface() + continue + } + node = mv.Interface() + + case reflect.Slice: + tokenIndex, err := strconv.Atoi(decodedToken) + if err != nil { + return err + } + sLength := rValue.Len() + if tokenIndex < 0 || tokenIndex >= sLength { + return fmt.Errorf("index out of bounds array[0,%d] index '%d'", sLength, tokenIndex) + } + + elem := rValue.Index(tokenIndex) + if elem.CanAddr() && elem.Kind() != reflect.Interface && elem.Kind() != reflect.Map && elem.Kind() != reflect.Slice && elem.Kind() != reflect.Ptr { + node = elem.Addr().Interface() + continue + } + node = elem.Interface() + + default: + return fmt.Errorf("invalid token reference %q", decodedToken) + } + + } + + return nil +} + +// DecodedTokens returns the decoded tokens +func (p *Pointer) DecodedTokens() []string { + result := make([]string, 0, len(p.referenceTokens)) + for _, t := range p.referenceTokens { + result = append(result, Unescape(t)) + } + return result +} + +// IsEmpty returns true if this is an empty json pointer +// this indicates that it points to the root document +func (p *Pointer) IsEmpty() bool { + return len(p.referenceTokens) == 0 +} + +// Pointer to string representation function +func (p *Pointer) String() string { + + if len(p.referenceTokens) == 0 { + return emptyPointer + } + + pointerString := pointerSeparator + strings.Join(p.referenceTokens, pointerSeparator) + + return pointerString +} + +// Specific JSON pointer encoding here +// ~0 => ~ +// ~1 => / +// ... and vice versa + +const ( + encRefTok0 = `~0` + encRefTok1 = `~1` + decRefTok0 = `~` + decRefTok1 = `/` +) + +// Unescape unescapes a json pointer reference token string to the original representation +func Unescape(token string) string { + step1 := strings.Replace(token, encRefTok1, decRefTok1, -1) + step2 := strings.Replace(step1, encRefTok0, decRefTok0, -1) + return step2 +} + +// Escape escapes a pointer reference token string +func Escape(token string) string { + step1 := strings.Replace(token, decRefTok0, encRefTok0, -1) + step2 := strings.Replace(step1, decRefTok1, encRefTok1, -1) + return step2 +} diff --git a/vendor/github.com/go-openapi/jsonreference/.gitignore b/vendor/github.com/go-openapi/jsonreference/.gitignore new file mode 100644 index 00000000000..769c244007b --- /dev/null +++ b/vendor/github.com/go-openapi/jsonreference/.gitignore @@ -0,0 +1 @@ +secrets.yml diff --git a/vendor/github.com/go-openapi/jsonreference/.golangci.yml b/vendor/github.com/go-openapi/jsonreference/.golangci.yml new file mode 100644 index 00000000000..f9381aee541 --- /dev/null +++ b/vendor/github.com/go-openapi/jsonreference/.golangci.yml @@ -0,0 +1,41 @@ +linters-settings: + govet: + check-shadowing: true + golint: + min-confidence: 0 + gocyclo: + min-complexity: 30 + maligned: + suggest-new: true + dupl: + threshold: 100 + goconst: + min-len: 2 + min-occurrences: 4 +linters: + enable-all: true + disable: + - maligned + - lll + - gochecknoglobals + - godox + - gocognit + - whitespace + - wsl + - funlen + - gochecknoglobals + - gochecknoinits + - scopelint + - wrapcheck + - exhaustivestruct + - exhaustive + - nlreturn + - testpackage + - gci + - gofumpt + - goerr113 + - gomnd + - tparallel + - nestif + - godot + - errorlint diff --git a/vendor/github.com/go-openapi/jsonreference/.travis.yml b/vendor/github.com/go-openapi/jsonreference/.travis.yml new file mode 100644 index 00000000000..05482f4b90c --- /dev/null +++ b/vendor/github.com/go-openapi/jsonreference/.travis.yml @@ -0,0 +1,24 @@ +after_success: +- bash <(curl -s https://codecov.io/bash) +go: +- 1.14.x +- 1.x +install: +- go get gotest.tools/gotestsum +jobs: + include: + # include linting job, but only for latest go version and amd64 arch + - go: 1.x + arch: amd64 + install: + go get github.com/golangci/golangci-lint/cmd/golangci-lint + script: + - golangci-lint run --new-from-rev master +env: +- GO111MODULE=on +language: go +notifications: + slack: + secure: OpQG/36F7DSF00HLm9WZMhyqFCYYyYTsVDObW226cWiR8PWYiNfLZiSEvIzT1Gx4dDjhigKTIqcLhG34CkL5iNXDjm9Yyo2RYhQPlK8NErNqUEXuBqn4RqYHW48VGhEhOyDd4Ei0E2FN5ZbgpvHgtpkdZ6XDi64r3Ac89isP9aPHXQTuv2Jog6b4/OKKiUTftLcTIst0p4Cp3gqOJWf1wnoj+IadWiECNVQT6zb47IYjtyw6+uV8iUjTzdKcRB6Zc6b4Dq7JAg1Zd7Jfxkql3hlKp4PNlRf9Cy7y5iA3G7MLyg3FcPX5z2kmcyPt2jOTRMBWUJ5zIQpOxizAcN8WsT3WWBL5KbuYK6k0PzujrIDLqdxGpNmjkkMfDBT9cKmZpm2FdW+oZgPFJP+oKmAo4u4KJz/vjiPTXgQlN5bmrLuRMCp+AwC5wkIohTqWZVPE2TK6ZSnMYcg/W39s+RP/9mJoyryAvPSpBOLTI+biCgaUCTOAZxNTWpMFc3tPYntc41WWkdKcooZ9JA5DwfcaVFyTGQ3YXz+HvX6G1z/gW0Q/A4dBi9mj2iE1xm7tRTT+4VQ2AXFvSEI1HJpfPgYnwAtwOD1v3Qm2EUHk9sCdtEDR4wVGEPIVn44GnwFMnGKx9JWppMPYwFu3SVDdHt+E+LOlhZUply11Aa+IVrT2KUQ= +script: +- gotestsum -f short-verbose -- -race -coverprofile=coverage.txt -covermode=atomic ./... diff --git a/vendor/github.com/go-openapi/jsonreference/CODE_OF_CONDUCT.md b/vendor/github.com/go-openapi/jsonreference/CODE_OF_CONDUCT.md new file mode 100644 index 00000000000..9322b065e37 --- /dev/null +++ b/vendor/github.com/go-openapi/jsonreference/CODE_OF_CONDUCT.md @@ -0,0 +1,74 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or +advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at ivan+abuse@flanders.co.nz. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/vendor/github.com/go-openapi/jsonreference/LICENSE b/vendor/github.com/go-openapi/jsonreference/LICENSE new file mode 100644 index 00000000000..d6456956733 --- /dev/null +++ b/vendor/github.com/go-openapi/jsonreference/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/go-openapi/jsonreference/README.md b/vendor/github.com/go-openapi/jsonreference/README.md new file mode 100644 index 00000000000..b94753aa527 --- /dev/null +++ b/vendor/github.com/go-openapi/jsonreference/README.md @@ -0,0 +1,15 @@ +# gojsonreference [![Build Status](https://travis-ci.org/go-openapi/jsonreference.svg?branch=master)](https://travis-ci.org/go-openapi/jsonreference) [![codecov](https://codecov.io/gh/go-openapi/jsonreference/branch/master/graph/badge.svg)](https://codecov.io/gh/go-openapi/jsonreference) [![Slack Status](https://slackin.goswagger.io/badge.svg)](https://slackin.goswagger.io) + +[![license](http://img.shields.io/badge/license-Apache%20v2-orange.svg)](https://raw.githubusercontent.com/go-openapi/jsonreference/master/LICENSE) [![GoDoc](https://godoc.org/github.com/go-openapi/jsonreference?status.svg)](http://godoc.org/github.com/go-openapi/jsonreference) +An implementation of JSON Reference - Go language + +## Status +Feature complete. Stable API + +## Dependencies +https://github.com/go-openapi/jsonpointer + +## References +http://tools.ietf.org/html/draft-ietf-appsawg-json-pointer-07 + +http://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03 diff --git a/vendor/github.com/go-openapi/jsonreference/reference.go b/vendor/github.com/go-openapi/jsonreference/reference.go new file mode 100644 index 00000000000..3bc0a6e26f8 --- /dev/null +++ b/vendor/github.com/go-openapi/jsonreference/reference.go @@ -0,0 +1,156 @@ +// Copyright 2013 sigu-399 ( https://github.com/sigu-399 ) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// author sigu-399 +// author-github https://github.com/sigu-399 +// author-mail sigu.399@gmail.com +// +// repository-name jsonreference +// repository-desc An implementation of JSON Reference - Go language +// +// description Main and unique file. +// +// created 26-02-2013 + +package jsonreference + +import ( + "errors" + "net/url" + "strings" + + "github.com/PuerkitoBio/purell" + "github.com/go-openapi/jsonpointer" +) + +const ( + fragmentRune = `#` +) + +// New creates a new reference for the given string +func New(jsonReferenceString string) (Ref, error) { + + var r Ref + err := r.parse(jsonReferenceString) + return r, err + +} + +// MustCreateRef parses the ref string and panics when it's invalid. +// Use the New method for a version that returns an error +func MustCreateRef(ref string) Ref { + r, err := New(ref) + if err != nil { + panic(err) + } + return r +} + +// Ref represents a json reference object +type Ref struct { + referenceURL *url.URL + referencePointer jsonpointer.Pointer + + HasFullURL bool + HasURLPathOnly bool + HasFragmentOnly bool + HasFileScheme bool + HasFullFilePath bool +} + +// GetURL gets the URL for this reference +func (r *Ref) GetURL() *url.URL { + return r.referenceURL +} + +// GetPointer gets the json pointer for this reference +func (r *Ref) GetPointer() *jsonpointer.Pointer { + return &r.referencePointer +} + +// String returns the best version of the url for this reference +func (r *Ref) String() string { + + if r.referenceURL != nil { + return r.referenceURL.String() + } + + if r.HasFragmentOnly { + return fragmentRune + r.referencePointer.String() + } + + return r.referencePointer.String() +} + +// IsRoot returns true if this reference is a root document +func (r *Ref) IsRoot() bool { + return r.referenceURL != nil && + !r.IsCanonical() && + !r.HasURLPathOnly && + r.referenceURL.Fragment == "" +} + +// IsCanonical returns true when this pointer starts with http(s):// or file:// +func (r *Ref) IsCanonical() bool { + return (r.HasFileScheme && r.HasFullFilePath) || (!r.HasFileScheme && r.HasFullURL) +} + +// "Constructor", parses the given string JSON reference +func (r *Ref) parse(jsonReferenceString string) error { + + parsed, err := url.Parse(jsonReferenceString) + if err != nil { + return err + } + + r.referenceURL, _ = url.Parse(purell.NormalizeURL(parsed, purell.FlagsSafe|purell.FlagRemoveDuplicateSlashes)) + refURL := r.referenceURL + + if refURL.Scheme != "" && refURL.Host != "" { + r.HasFullURL = true + } else { + if refURL.Path != "" { + r.HasURLPathOnly = true + } else if refURL.RawQuery == "" && refURL.Fragment != "" { + r.HasFragmentOnly = true + } + } + + r.HasFileScheme = refURL.Scheme == "file" + r.HasFullFilePath = strings.HasPrefix(refURL.Path, "/") + + // invalid json-pointer error means url has no json-pointer fragment. simply ignore error + r.referencePointer, _ = jsonpointer.New(refURL.Fragment) + + return nil +} + +// Inherits creates a new reference from a parent and a child +// If the child cannot inherit from the parent, an error is returned +func (r *Ref) Inherits(child Ref) (*Ref, error) { + childURL := child.GetURL() + parentURL := r.GetURL() + if childURL == nil { + return nil, errors.New("child url is nil") + } + if parentURL == nil { + return &child, nil + } + + ref, err := New(parentURL.ResolveReference(childURL).String()) + if err != nil { + return nil, err + } + return &ref, nil +} diff --git a/vendor/github.com/go-openapi/loads/.editorconfig b/vendor/github.com/go-openapi/loads/.editorconfig new file mode 100644 index 00000000000..3152da69a5d --- /dev/null +++ b/vendor/github.com/go-openapi/loads/.editorconfig @@ -0,0 +1,26 @@ +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true + +# Set default charset +[*.{js,py,go,scala,rb,java,html,css,less,sass,md}] +charset = utf-8 + +# Tab indentation (no size specified) +[*.go] +indent_style = tab + +[*.md] +trim_trailing_whitespace = false + +# Matches the exact files either package.json or .travis.yml +[{package.json,.travis.yml}] +indent_style = space +indent_size = 2 diff --git a/vendor/github.com/go-openapi/loads/.gitignore b/vendor/github.com/go-openapi/loads/.gitignore new file mode 100644 index 00000000000..e4f15f17bfc --- /dev/null +++ b/vendor/github.com/go-openapi/loads/.gitignore @@ -0,0 +1,4 @@ +secrets.yml +coverage.out +profile.cov +profile.out diff --git a/vendor/github.com/go-openapi/loads/.golangci.yml b/vendor/github.com/go-openapi/loads/.golangci.yml new file mode 100644 index 00000000000..d48b4a5156e --- /dev/null +++ b/vendor/github.com/go-openapi/loads/.golangci.yml @@ -0,0 +1,44 @@ +linters-settings: + govet: + check-shadowing: true + golint: + min-confidence: 0 + gocyclo: + min-complexity: 30 + maligned: + suggest-new: true + dupl: + threshold: 100 + goconst: + min-len: 2 + min-occurrences: 4 + +linters: + enable-all: true + disable: + - maligned + - lll + - gochecknoglobals + - gochecknoinits + - godox + - gocognit + - whitespace + - wsl + - funlen + - gochecknoglobals + - gochecknoinits + - scopelint + - wrapcheck + - exhaustivestruct + - exhaustive + - nlreturn + - testpackage + - gci + - gofumpt + - goerr113 + - gomnd + - tparallel + - nestif + - godot + - errorlint + - paralleltest diff --git a/vendor/github.com/go-openapi/loads/.travis.yml b/vendor/github.com/go-openapi/loads/.travis.yml new file mode 100644 index 00000000000..cd4a7c331bc --- /dev/null +++ b/vendor/github.com/go-openapi/loads/.travis.yml @@ -0,0 +1,25 @@ +after_success: +- bash <(curl -s https://codecov.io/bash) +go: +- 1.16.x +- 1.x +install: +- go get gotest.tools/gotestsum +language: go +arch: +- amd64 +- ppc64le +jobs: + include: + # include linting job, but only for latest go version and amd64 arch + - go: 1.x + arch: amd64 + install: + go get github.com/golangci/golangci-lint/cmd/golangci-lint + script: + - golangci-lint run --new-from-rev master +notifications: + slack: + secure: OxkPwVp35qBTUilgWC8xykSj+sGMcj0h8IIOKD+Rflx2schZVlFfdYdyVBM+s9OqeOfvtuvnR9v1Ye2rPKAvcjWdC4LpRGUsgmItZaI6Um8Aj6+K9udCw5qrtZVfOVmRu8LieH//XznWWKdOultUuniW0MLqw5+II87Gd00RWbCGi0hk0PykHe7uK+PDA2BEbqyZ2WKKYCvfB3j+0nrFOHScXqnh0V05l2E83J4+Sgy1fsPy+1WdX58ZlNBG333ibaC1FS79XvKSmTgKRkx3+YBo97u6ZtUmJa5WZjf2OdLG3KIckGWAv6R5xgxeU31N0Ng8L332w/Edpp2O/M2bZwdnKJ8hJQikXIAQbICbr+lTDzsoNzMdEIYcHpJ5hjPbiUl3Bmd+Jnsjf5McgAZDiWIfpCKZ29tPCEkVwRsOCqkyPRMNMzHHmoja495P5jR+ODS7+J8RFg5xgcnOgpP9D4Wlhztlf5WyZMpkLxTUD+bZq2SRf50HfHFXTkfq22zPl3d1eq0yrLwh/Z/fWKkfb6SyysROL8y6s8u3dpFX1YHSg0BR6i913h4aoZw9B2BG27cafLLTwKYsp2dFo1PWl4O6u9giFJIeqwloZHLKKrwh0cBFhB7RH0I58asxkZpCH6uWjJierahmHe7iS+E6i+9oCHkOZ59hmCYNimIs3hM= +script: +- gotestsum -f short-verbose -- -race -timeout=20m -coverprofile=coverage.txt -covermode=atomic ./... diff --git a/vendor/github.com/go-openapi/loads/CODE_OF_CONDUCT.md b/vendor/github.com/go-openapi/loads/CODE_OF_CONDUCT.md new file mode 100644 index 00000000000..9322b065e37 --- /dev/null +++ b/vendor/github.com/go-openapi/loads/CODE_OF_CONDUCT.md @@ -0,0 +1,74 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or +advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at ivan+abuse@flanders.co.nz. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/vendor/github.com/go-openapi/loads/LICENSE b/vendor/github.com/go-openapi/loads/LICENSE new file mode 100644 index 00000000000..d6456956733 --- /dev/null +++ b/vendor/github.com/go-openapi/loads/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/go-openapi/loads/README.md b/vendor/github.com/go-openapi/loads/README.md new file mode 100644 index 00000000000..df1f6264623 --- /dev/null +++ b/vendor/github.com/go-openapi/loads/README.md @@ -0,0 +1,6 @@ +# Loads OAI specs [![Build Status](https://travis-ci.org/go-openapi/loads.svg?branch=master)](https://travis-ci.org/go-openapi/loads) [![codecov](https://codecov.io/gh/go-openapi/loads/branch/master/graph/badge.svg)](https://codecov.io/gh/go-openapi/loads) [![Slack Status](https://slackin.goswagger.io/badge.svg)](https://slackin.goswagger.io) [![Actions/Go Test Status](https://github.com/go-openapi/loads/workflows/Go%20Test/badge.svg)](https://github.com/go-openapi/loads/actions?query=workflow%3A"Go+Test") + +[![license](http://img.shields.io/badge/license-Apache%20v2-orange.svg)](https://raw.githubusercontent.com/go-openapi/loads/master/LICENSE) [![GoDoc](https://godoc.org/github.com/go-openapi/loads?status.svg)](http://godoc.org/github.com/go-openapi/loads) +[![Go Report Card](https://goreportcard.com/badge/github.com/go-openapi/loads)](https://goreportcard.com/report/github.com/go-openapi/loads) + +Loading of OAI specification documents from local or remote locations. Supports JSON and YAML documents. diff --git a/vendor/github.com/go-openapi/loads/doc.go b/vendor/github.com/go-openapi/loads/doc.go new file mode 100644 index 00000000000..3046da4cef3 --- /dev/null +++ b/vendor/github.com/go-openapi/loads/doc.go @@ -0,0 +1,21 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/* +Package loads provides document loading methods for swagger (OAI) specifications. + +It is used by other go-openapi packages to load and run analysis on local or remote spec documents. + +*/ +package loads diff --git a/vendor/github.com/go-openapi/loads/loaders.go b/vendor/github.com/go-openapi/loads/loaders.go new file mode 100644 index 00000000000..44bd32b5b88 --- /dev/null +++ b/vendor/github.com/go-openapi/loads/loaders.go @@ -0,0 +1,134 @@ +package loads + +import ( + "encoding/json" + "errors" + "net/url" + + "github.com/go-openapi/spec" + "github.com/go-openapi/swag" +) + +var ( + // Default chain of loaders, defined at the package level. + // + // By default this matches json and yaml documents. + // + // May be altered with AddLoader(). + loaders *loader +) + +func init() { + jsonLoader := &loader{ + DocLoaderWithMatch: DocLoaderWithMatch{ + Match: func(pth string) bool { + return true + }, + Fn: JSONDoc, + }, + } + + loaders = jsonLoader.WithHead(&loader{ + DocLoaderWithMatch: DocLoaderWithMatch{ + Match: swag.YAMLMatcher, + Fn: swag.YAMLDoc, + }, + }) + + // sets the global default loader for go-openapi/spec + spec.PathLoader = loaders.Load +} + +// DocLoader represents a doc loader type +type DocLoader func(string) (json.RawMessage, error) + +// DocMatcher represents a predicate to check if a loader matches +type DocMatcher func(string) bool + +// DocLoaderWithMatch describes a loading function for a given extension match. +type DocLoaderWithMatch struct { + Fn DocLoader + Match DocMatcher +} + +// NewDocLoaderWithMatch builds a DocLoaderWithMatch to be used in load options +func NewDocLoaderWithMatch(fn DocLoader, matcher DocMatcher) DocLoaderWithMatch { + return DocLoaderWithMatch{ + Fn: fn, + Match: matcher, + } +} + +type loader struct { + DocLoaderWithMatch + Next *loader +} + +// WithHead adds a loader at the head of the current stack +func (l *loader) WithHead(head *loader) *loader { + if head == nil { + return l + } + head.Next = l + return head +} + +// WithNext adds a loader at the trail of the current stack +func (l *loader) WithNext(next *loader) *loader { + l.Next = next + return next +} + +// Load the raw document from path +func (l *loader) Load(path string) (json.RawMessage, error) { + _, erp := url.Parse(path) + if erp != nil { + return nil, erp + } + + var lastErr error = errors.New("no loader matched") // default error if no match was found + for ldr := l; ldr != nil; ldr = ldr.Next { + if ldr.Match != nil && !ldr.Match(path) { + continue + } + + // try then move to next one if there is an error + b, err := ldr.Fn(path) + if err == nil { + return b, nil + } + + lastErr = err + } + + return nil, lastErr +} + +// JSONDoc loads a json document from either a file or a remote url +func JSONDoc(path string) (json.RawMessage, error) { + data, err := swag.LoadFromFileOrHTTP(path) + if err != nil { + return nil, err + } + return json.RawMessage(data), nil +} + +// AddLoader for a document, executed before other previously set loaders. +// +// This sets the configuration at the package level. +// +// NOTE: +// * this updates the default loader used by github.com/go-openapi/spec +// * since this sets package level globals, you shouln't call this concurrently +// +func AddLoader(predicate DocMatcher, load DocLoader) { + loaders = loaders.WithHead(&loader{ + DocLoaderWithMatch: DocLoaderWithMatch{ + Match: predicate, + Fn: load, + }, + }) + + // sets the global default loader for go-openapi/spec + spec.PathLoader = loaders.Load +} diff --git a/vendor/github.com/go-openapi/loads/options.go b/vendor/github.com/go-openapi/loads/options.go new file mode 100644 index 00000000000..f8305d5607c --- /dev/null +++ b/vendor/github.com/go-openapi/loads/options.go @@ -0,0 +1,61 @@ +package loads + +type options struct { + loader *loader +} + +func defaultOptions() *options { + return &options{ + loader: loaders, + } +} + +func loaderFromOptions(options []LoaderOption) *loader { + opts := defaultOptions() + for _, apply := range options { + apply(opts) + } + + return opts.loader +} + +// LoaderOption allows to fine-tune the spec loader behavior +type LoaderOption func(*options) + +// WithDocLoader sets a custom loader for loading specs +func WithDocLoader(l DocLoader) LoaderOption { + return func(opt *options) { + if l == nil { + return + } + opt.loader = &loader{ + DocLoaderWithMatch: DocLoaderWithMatch{ + Fn: l, + }, + } + } +} + +// WithDocLoaderMatches sets a chain of custom loaders for loading specs +// for different extension matches. +// +// Loaders are executed in the order of provided DocLoaderWithMatch'es. +func WithDocLoaderMatches(l ...DocLoaderWithMatch) LoaderOption { + return func(opt *options) { + var final, prev *loader + for _, ldr := range l { + if ldr.Fn == nil { + continue + } + + if prev == nil { + final = &loader{DocLoaderWithMatch: ldr} + prev = final + continue + } + + prev = prev.WithNext(&loader{DocLoaderWithMatch: ldr}) + } + opt.loader = final + } +} diff --git a/vendor/github.com/go-openapi/loads/spec.go b/vendor/github.com/go-openapi/loads/spec.go new file mode 100644 index 00000000000..93c8d4b8955 --- /dev/null +++ b/vendor/github.com/go-openapi/loads/spec.go @@ -0,0 +1,266 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package loads + +import ( + "bytes" + "encoding/gob" + "encoding/json" + "fmt" + + "github.com/go-openapi/analysis" + "github.com/go-openapi/spec" + "github.com/go-openapi/swag" +) + +func init() { + gob.Register(map[string]interface{}{}) + gob.Register([]interface{}{}) +} + +// Document represents a swagger spec document +type Document struct { + // specAnalyzer + Analyzer *analysis.Spec + spec *spec.Swagger + specFilePath string + origSpec *spec.Swagger + schema *spec.Schema + raw json.RawMessage + pathLoader *loader +} + +// JSONSpec loads a spec from a json document +func JSONSpec(path string, options ...LoaderOption) (*Document, error) { + data, err := JSONDoc(path) + if err != nil { + return nil, err + } + // convert to json + return Analyzed(data, "", options...) +} + +// Embedded returns a Document based on embedded specs. No analysis is required +func Embedded(orig, flat json.RawMessage, options ...LoaderOption) (*Document, error) { + var origSpec, flatSpec spec.Swagger + if err := json.Unmarshal(orig, &origSpec); err != nil { + return nil, err + } + if err := json.Unmarshal(flat, &flatSpec); err != nil { + return nil, err + } + return &Document{ + raw: orig, + origSpec: &origSpec, + spec: &flatSpec, + pathLoader: loaderFromOptions(options), + }, nil +} + +// Spec loads a new spec document from a local or remote path +func Spec(path string, options ...LoaderOption) (*Document, error) { + + ldr := loaderFromOptions(options) + + b, err := ldr.Load(path) + if err != nil { + return nil, err + } + + document, err := Analyzed(b, "", options...) + if err != nil { + return nil, err + } + + if document != nil { + document.specFilePath = path + document.pathLoader = ldr + } + + return document, err +} + +// Analyzed creates a new analyzed spec document for a root json.RawMessage. +func Analyzed(data json.RawMessage, version string, options ...LoaderOption) (*Document, error) { + if version == "" { + version = "2.0" + } + if version != "2.0" { + return nil, fmt.Errorf("spec version %q is not supported", version) + } + + raw, err := trimData(data) // trim blanks, then convert yaml docs into json + if err != nil { + return nil, err + } + + swspec := new(spec.Swagger) + if err = json.Unmarshal(raw, swspec); err != nil { + return nil, err + } + + origsqspec, err := cloneSpec(swspec) + if err != nil { + return nil, err + } + + d := &Document{ + Analyzer: analysis.New(swspec), + schema: spec.MustLoadSwagger20Schema(), + spec: swspec, + raw: raw, + origSpec: origsqspec, + pathLoader: loaderFromOptions(options), + } + + return d, nil +} + +func trimData(in json.RawMessage) (json.RawMessage, error) { + trimmed := bytes.TrimSpace(in) + if len(trimmed) == 0 { + return in, nil + } + + if trimmed[0] == '{' || trimmed[0] == '[' { + return trimmed, nil + } + + // assume yaml doc: convert it to json + yml, err := swag.BytesToYAMLDoc(trimmed) + if err != nil { + return nil, fmt.Errorf("analyzed: %v", err) + } + + d, err := swag.YAMLToJSON(yml) + if err != nil { + return nil, fmt.Errorf("analyzed: %v", err) + } + + return d, nil +} + +// Expanded expands the ref fields in the spec document and returns a new spec document +func (d *Document) Expanded(options ...*spec.ExpandOptions) (*Document, error) { + + swspec := new(spec.Swagger) + if err := json.Unmarshal(d.raw, swspec); err != nil { + return nil, err + } + + var expandOptions *spec.ExpandOptions + if len(options) > 0 { + expandOptions = options[0] + } else { + expandOptions = &spec.ExpandOptions{ + RelativeBase: d.specFilePath, + } + } + + if expandOptions.PathLoader == nil { + if d.pathLoader != nil { + // use loader from Document options + expandOptions.PathLoader = d.pathLoader.Load + } else { + // use package level loader + expandOptions.PathLoader = loaders.Load + } + } + + if err := spec.ExpandSpec(swspec, expandOptions); err != nil { + return nil, err + } + + dd := &Document{ + Analyzer: analysis.New(swspec), + spec: swspec, + specFilePath: d.specFilePath, + schema: spec.MustLoadSwagger20Schema(), + raw: d.raw, + origSpec: d.origSpec, + } + return dd, nil +} + +// BasePath the base path for this spec +func (d *Document) BasePath() string { + return d.spec.BasePath +} + +// Version returns the version of this spec +func (d *Document) Version() string { + return d.spec.Swagger +} + +// Schema returns the swagger 2.0 schema +func (d *Document) Schema() *spec.Schema { + return d.schema +} + +// Spec returns the swagger spec object model +func (d *Document) Spec() *spec.Swagger { + return d.spec +} + +// Host returns the host for the API +func (d *Document) Host() string { + return d.spec.Host +} + +// Raw returns the raw swagger spec as json bytes +func (d *Document) Raw() json.RawMessage { + return d.raw +} + +// OrigSpec yields the original spec +func (d *Document) OrigSpec() *spec.Swagger { + return d.origSpec +} + +// ResetDefinitions gives a shallow copy with the models reset to the original spec +func (d *Document) ResetDefinitions() *Document { + defs := make(map[string]spec.Schema, len(d.origSpec.Definitions)) + for k, v := range d.origSpec.Definitions { + defs[k] = v + } + + d.spec.Definitions = defs + return d +} + +// Pristine creates a new pristine document instance based on the input data +func (d *Document) Pristine() *Document { + dd, _ := Analyzed(d.Raw(), d.Version()) + dd.pathLoader = d.pathLoader + return dd +} + +// SpecFilePath returns the file path of the spec if one is defined +func (d *Document) SpecFilePath() string { + return d.specFilePath +} + +func cloneSpec(src *spec.Swagger) (*spec.Swagger, error) { + var b bytes.Buffer + if err := gob.NewEncoder(&b).Encode(src); err != nil { + return nil, err + } + + var dst spec.Swagger + if err := gob.NewDecoder(&b).Decode(&dst); err != nil { + return nil, err + } + return &dst, nil +} diff --git a/vendor/github.com/go-openapi/runtime/.editorconfig b/vendor/github.com/go-openapi/runtime/.editorconfig new file mode 100644 index 00000000000..3152da69a5d --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/.editorconfig @@ -0,0 +1,26 @@ +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true + +# Set default charset +[*.{js,py,go,scala,rb,java,html,css,less,sass,md}] +charset = utf-8 + +# Tab indentation (no size specified) +[*.go] +indent_style = tab + +[*.md] +trim_trailing_whitespace = false + +# Matches the exact files either package.json or .travis.yml +[{package.json,.travis.yml}] +indent_style = space +indent_size = 2 diff --git a/vendor/github.com/go-openapi/runtime/.gitattributes b/vendor/github.com/go-openapi/runtime/.gitattributes new file mode 100644 index 00000000000..d207b1802b2 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/.gitattributes @@ -0,0 +1 @@ +*.go text eol=lf diff --git a/vendor/github.com/go-openapi/runtime/.gitignore b/vendor/github.com/go-openapi/runtime/.gitignore new file mode 100644 index 00000000000..fea8b84eca9 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/.gitignore @@ -0,0 +1,5 @@ +secrets.yml +coverage.out +*.cov +*.out +playground diff --git a/vendor/github.com/go-openapi/runtime/.golangci.yml b/vendor/github.com/go-openapi/runtime/.golangci.yml new file mode 100644 index 00000000000..b1aa7928a7c --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/.golangci.yml @@ -0,0 +1,44 @@ +linters-settings: + govet: + # Using err repeatedly considered as shadowing. + check-shadowing: false + golint: + min-confidence: 0 + gocyclo: + min-complexity: 30 + maligned: + suggest-new: true + dupl: + threshold: 100 + goconst: + min-len: 2 + min-occurrences: 4 +linters: + disable: + - maligned + - lll + - gochecknoglobals + - godox + - gocognit + - whitespace + - wsl + - funlen + - gochecknoglobals + - gochecknoinits + - scopelint + - wrapcheck + - exhaustivestruct + - exhaustive + - nlreturn + - testpackage + - gci + - gofumpt + - goerr113 + - gomnd + - tparallel + - nestif + - godot + - errorlint + - noctx + - interfacer + - nilerr diff --git a/vendor/github.com/go-openapi/runtime/CODE_OF_CONDUCT.md b/vendor/github.com/go-openapi/runtime/CODE_OF_CONDUCT.md new file mode 100644 index 00000000000..9322b065e37 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/CODE_OF_CONDUCT.md @@ -0,0 +1,74 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or +advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at ivan+abuse@flanders.co.nz. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/vendor/github.com/go-openapi/runtime/LICENSE b/vendor/github.com/go-openapi/runtime/LICENSE new file mode 100644 index 00000000000..d6456956733 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/go-openapi/runtime/README.md b/vendor/github.com/go-openapi/runtime/README.md new file mode 100644 index 00000000000..5b1ec649454 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/README.md @@ -0,0 +1,7 @@ +# runtime [![Build Status](https://travis-ci.org/go-openapi/runtime.svg?branch=client-context)](https://travis-ci.org/go-openapi/runtime) [![codecov](https://codecov.io/gh/go-openapi/runtime/branch/master/graph/badge.svg)](https://codecov.io/gh/go-openapi/runtime) [![Slack Status](https://slackin.goswagger.io/badge.svg)](https://slackin.goswagger.io) + +[![license](http://img.shields.io/badge/license-Apache%20v2-orange.svg)](https://raw.githubusercontent.com/go-openapi/runtime/master/LICENSE) [![GoDoc](https://godoc.org/github.com/go-openapi/runtime?status.svg)](http://godoc.org/github.com/go-openapi/runtime) + +# golang Open-API toolkit - runtime + +The runtime component for use in codegeneration or as untyped usage. diff --git a/vendor/github.com/go-openapi/runtime/bytestream.go b/vendor/github.com/go-openapi/runtime/bytestream.go new file mode 100644 index 00000000000..6eb6ceb5c5d --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/bytestream.go @@ -0,0 +1,169 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package runtime + +import ( + "bytes" + "encoding" + "errors" + "fmt" + "io" + "reflect" + + "github.com/go-openapi/swag" +) + +func defaultCloser() error { return nil } + +type byteStreamOpt func(opts *byteStreamOpts) + +// ClosesStream when the bytestream consumer or producer is finished +func ClosesStream(opts *byteStreamOpts) { + opts.Close = true +} + +type byteStreamOpts struct { + Close bool +} + +// ByteStreamConsumer creates a consumer for byte streams, +// takes a Writer/BinaryUnmarshaler interface or binary slice by reference, +// and reads from the provided reader +func ByteStreamConsumer(opts ...byteStreamOpt) Consumer { + var vals byteStreamOpts + for _, opt := range opts { + opt(&vals) + } + + return ConsumerFunc(func(reader io.Reader, data interface{}) error { + if reader == nil { + return errors.New("ByteStreamConsumer requires a reader") // early exit + } + + close := defaultCloser + if vals.Close { + if cl, ok := reader.(io.Closer); ok { + close = cl.Close + } + } + //nolint:errcheck // closing a reader wouldn't fail. + defer close() + + if wrtr, ok := data.(io.Writer); ok { + _, err := io.Copy(wrtr, reader) + return err + } + + buf := new(bytes.Buffer) + _, err := buf.ReadFrom(reader) + if err != nil { + return err + } + b := buf.Bytes() + + if bu, ok := data.(encoding.BinaryUnmarshaler); ok { + return bu.UnmarshalBinary(b) + } + + if data != nil { + if str, ok := data.(*string); ok { + *str = string(b) + return nil + } + } + + if t := reflect.TypeOf(data); data != nil && t.Kind() == reflect.Ptr { + v := reflect.Indirect(reflect.ValueOf(data)) + if t = v.Type(); t.Kind() == reflect.Slice && t.Elem().Kind() == reflect.Uint8 { + v.SetBytes(b) + return nil + } + } + + return fmt.Errorf("%v (%T) is not supported by the ByteStreamConsumer, %s", + data, data, "can be resolved by supporting Writer/BinaryUnmarshaler interface") + }) +} + +// ByteStreamProducer creates a producer for byte streams, +// takes a Reader/BinaryMarshaler interface or binary slice, +// and writes to a writer (essentially a pipe) +func ByteStreamProducer(opts ...byteStreamOpt) Producer { + var vals byteStreamOpts + for _, opt := range opts { + opt(&vals) + } + return ProducerFunc(func(writer io.Writer, data interface{}) error { + if writer == nil { + return errors.New("ByteStreamProducer requires a writer") // early exit + } + close := defaultCloser + if vals.Close { + if cl, ok := writer.(io.Closer); ok { + close = cl.Close + } + } + //nolint:errcheck // TODO: closing a writer would fail. + defer close() + + if rc, ok := data.(io.ReadCloser); ok { + defer rc.Close() + } + + if rdr, ok := data.(io.Reader); ok { + _, err := io.Copy(writer, rdr) + return err + } + + if bm, ok := data.(encoding.BinaryMarshaler); ok { + bytes, err := bm.MarshalBinary() + if err != nil { + return err + } + + _, err = writer.Write(bytes) + return err + } + + if data != nil { + if str, ok := data.(string); ok { + _, err := writer.Write([]byte(str)) + return err + } + + if e, ok := data.(error); ok { + _, err := writer.Write([]byte(e.Error())) + return err + } + + v := reflect.Indirect(reflect.ValueOf(data)) + if t := v.Type(); t.Kind() == reflect.Slice && t.Elem().Kind() == reflect.Uint8 { + _, err := writer.Write(v.Bytes()) + return err + } + if t := v.Type(); t.Kind() == reflect.Struct || t.Kind() == reflect.Slice { + b, err := swag.WriteJSON(data) + if err != nil { + return err + } + _, err = writer.Write(b) + return err + } + } + + return fmt.Errorf("%v (%T) is not supported by the ByteStreamProducer, %s", + data, data, "can be resolved by supporting Reader/BinaryMarshaler interface") + }) +} diff --git a/vendor/github.com/go-openapi/runtime/client/auth_info.go b/vendor/github.com/go-openapi/runtime/client/auth_info.go new file mode 100644 index 00000000000..d37e8f6b73f --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/client/auth_info.go @@ -0,0 +1,77 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package client + +import ( + "encoding/base64" + + "github.com/go-openapi/strfmt" + + "github.com/go-openapi/runtime" +) + +// PassThroughAuth never manipulates the request +var PassThroughAuth runtime.ClientAuthInfoWriter + +func init() { + PassThroughAuth = runtime.ClientAuthInfoWriterFunc(func(_ runtime.ClientRequest, _ strfmt.Registry) error { return nil }) +} + +// BasicAuth provides a basic auth info writer +func BasicAuth(username, password string) runtime.ClientAuthInfoWriter { + return runtime.ClientAuthInfoWriterFunc(func(r runtime.ClientRequest, _ strfmt.Registry) error { + encoded := base64.StdEncoding.EncodeToString([]byte(username + ":" + password)) + return r.SetHeaderParam("Authorization", "Basic "+encoded) + }) +} + +// APIKeyAuth provides an API key auth info writer +func APIKeyAuth(name, in, value string) runtime.ClientAuthInfoWriter { + if in == "query" { + return runtime.ClientAuthInfoWriterFunc(func(r runtime.ClientRequest, _ strfmt.Registry) error { + return r.SetQueryParam(name, value) + }) + } + + if in == "header" { + return runtime.ClientAuthInfoWriterFunc(func(r runtime.ClientRequest, _ strfmt.Registry) error { + return r.SetHeaderParam(name, value) + }) + } + return nil +} + +// BearerToken provides a header based oauth2 bearer access token auth info writer +func BearerToken(token string) runtime.ClientAuthInfoWriter { + return runtime.ClientAuthInfoWriterFunc(func(r runtime.ClientRequest, _ strfmt.Registry) error { + return r.SetHeaderParam("Authorization", "Bearer "+token) + }) +} + +// Compose combines multiple ClientAuthInfoWriters into a single one. +// Useful when multiple auth headers are needed. +func Compose(auths ...runtime.ClientAuthInfoWriter) runtime.ClientAuthInfoWriter { + return runtime.ClientAuthInfoWriterFunc(func(r runtime.ClientRequest, _ strfmt.Registry) error { + for _, auth := range auths { + if auth == nil { + continue + } + if err := auth.AuthenticateRequest(r, nil); err != nil { + return err + } + } + return nil + }) +} diff --git a/vendor/github.com/go-openapi/runtime/client/keepalive.go b/vendor/github.com/go-openapi/runtime/client/keepalive.go new file mode 100644 index 00000000000..e9c250d6a8a --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/client/keepalive.go @@ -0,0 +1,56 @@ +package client + +import ( + "io" + "io/ioutil" + "net/http" + "sync/atomic" +) + +// KeepAliveTransport drains the remaining body from a response +// so that go will reuse the TCP connections. +// This is not enabled by default because there are servers where +// the response never gets closed and that would make the code hang forever. +// So instead it's provided as a http client middleware that can be used to override +// any request. +func KeepAliveTransport(rt http.RoundTripper) http.RoundTripper { + return &keepAliveTransport{wrapped: rt} +} + +type keepAliveTransport struct { + wrapped http.RoundTripper +} + +func (k *keepAliveTransport) RoundTrip(r *http.Request) (*http.Response, error) { + resp, err := k.wrapped.RoundTrip(r) + if err != nil { + return resp, err + } + resp.Body = &drainingReadCloser{rdr: resp.Body} + return resp, nil +} + +type drainingReadCloser struct { + rdr io.ReadCloser + seenEOF uint32 +} + +func (d *drainingReadCloser) Read(p []byte) (n int, err error) { + n, err = d.rdr.Read(p) + if err == io.EOF || n == 0 { + atomic.StoreUint32(&d.seenEOF, 1) + } + return +} + +func (d *drainingReadCloser) Close() error { + // drain buffer + if atomic.LoadUint32(&d.seenEOF) != 1 { + // If the reader side (a HTTP server) is misbehaving, it still may send + // some bytes, but the closer ignores them to keep the underling + // connection open. + //nolint:errcheck + io.Copy(ioutil.Discard, d.rdr) + } + return d.rdr.Close() +} diff --git a/vendor/github.com/go-openapi/runtime/client/opentracing.go b/vendor/github.com/go-openapi/runtime/client/opentracing.go new file mode 100644 index 00000000000..627286d12fa --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/client/opentracing.go @@ -0,0 +1,99 @@ +package client + +import ( + "fmt" + "net/http" + + "github.com/go-openapi/strfmt" + "github.com/opentracing/opentracing-go" + "github.com/opentracing/opentracing-go/ext" + "github.com/opentracing/opentracing-go/log" + + "github.com/go-openapi/runtime" +) + +type tracingTransport struct { + transport runtime.ClientTransport + host string + opts []opentracing.StartSpanOption +} + +func newOpenTracingTransport(transport runtime.ClientTransport, host string, opts []opentracing.StartSpanOption, +) runtime.ClientTransport { + return &tracingTransport{ + transport: transport, + host: host, + opts: opts, + } +} + +func (t *tracingTransport) Submit(op *runtime.ClientOperation) (interface{}, error) { + if op.Context == nil { + return t.transport.Submit(op) + } + + params := op.Params + reader := op.Reader + + var span opentracing.Span + defer func() { + if span != nil { + span.Finish() + } + }() + + op.Params = runtime.ClientRequestWriterFunc(func(req runtime.ClientRequest, reg strfmt.Registry) error { + span = createClientSpan(op, req.GetHeaderParams(), t.host, t.opts) + return params.WriteToRequest(req, reg) + }) + + op.Reader = runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + if span != nil { + code := response.Code() + ext.HTTPStatusCode.Set(span, uint16(code)) + if code >= 400 { + ext.Error.Set(span, true) + } + } + return reader.ReadResponse(response, consumer) + }) + + submit, err := t.transport.Submit(op) + if err != nil && span != nil { + ext.Error.Set(span, true) + span.LogFields(log.Error(err)) + } + return submit, err +} + +func createClientSpan(op *runtime.ClientOperation, header http.Header, host string, + opts []opentracing.StartSpanOption) opentracing.Span { + ctx := op.Context + span := opentracing.SpanFromContext(ctx) + + if span != nil { + opts = append(opts, ext.SpanKindRPCClient) + span, _ = opentracing.StartSpanFromContextWithTracer( + ctx, span.Tracer(), operationName(op), opts...) + + ext.Component.Set(span, "go-openapi") + ext.PeerHostname.Set(span, host) + span.SetTag("http.path", op.PathPattern) + ext.HTTPMethod.Set(span, op.Method) + + _ = span.Tracer().Inject( + span.Context(), + opentracing.HTTPHeaders, + opentracing.HTTPHeadersCarrier(header)) + + return span + } + return nil +} + +func operationName(op *runtime.ClientOperation) string { + if op.ID != "" { + return op.ID + } + return fmt.Sprintf("%s_%s", op.Method, op.PathPattern) +} diff --git a/vendor/github.com/go-openapi/runtime/client/request.go b/vendor/github.com/go-openapi/runtime/client/request.go new file mode 100644 index 00000000000..7d622eee93b --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/client/request.go @@ -0,0 +1,474 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package client + +import ( + "bytes" + "fmt" + "io" + "log" + "mime/multipart" + "net/http" + "net/textproto" + "net/url" + "os" + "path" + "path/filepath" + "strings" + "time" + + "github.com/go-openapi/strfmt" + + "github.com/go-openapi/runtime" +) + +// NewRequest creates a new swagger http client request +func newRequest(method, pathPattern string, writer runtime.ClientRequestWriter) (*request, error) { + return &request{ + pathPattern: pathPattern, + method: method, + writer: writer, + header: make(http.Header), + query: make(url.Values), + timeout: DefaultTimeout, + getBody: getRequestBuffer, + }, nil +} + +// Request represents a swagger client request. +// +// This Request struct converts to a HTTP request. +// There might be others that convert to other transports. +// There is no error checking here, it is assumed to be used after a spec has been validated. +// so impossible combinations should not arise (hopefully). +// +// The main purpose of this struct is to hide the machinery of adding params to a transport request. +// The generated code only implements what is necessary to turn a param into a valid value for these methods. +type request struct { + pathPattern string + method string + writer runtime.ClientRequestWriter + + pathParams map[string]string + header http.Header + query url.Values + formFields url.Values + fileFields map[string][]runtime.NamedReadCloser + payload interface{} + timeout time.Duration + buf *bytes.Buffer + + getBody func(r *request) []byte +} + +var ( + // ensure interface compliance + _ runtime.ClientRequest = new(request) +) + +func (r *request) isMultipart(mediaType string) bool { + if len(r.fileFields) > 0 { + return true + } + + return runtime.MultipartFormMime == mediaType +} + +// BuildHTTP creates a new http request based on the data from the params +func (r *request) BuildHTTP(mediaType, basePath string, producers map[string]runtime.Producer, registry strfmt.Registry) (*http.Request, error) { + return r.buildHTTP(mediaType, basePath, producers, registry, nil) +} +func escapeQuotes(s string) string { + return strings.NewReplacer("\\", "\\\\", `"`, "\\\"").Replace(s) +} + +func logClose(err error, pw *io.PipeWriter) { + log.Println(err) + closeErr := pw.CloseWithError(err) + if closeErr != nil { + log.Println(closeErr) + } +} + +func (r *request) buildHTTP(mediaType, basePath string, producers map[string]runtime.Producer, registry strfmt.Registry, auth runtime.ClientAuthInfoWriter) (*http.Request, error) { + // build the data + if err := r.writer.WriteToRequest(r, registry); err != nil { + return nil, err + } + + // Our body must be an io.Reader. + // When we create the http.Request, if we pass it a + // bytes.Buffer then it will wrap it in an io.ReadCloser + // and set the content length automatically. + var body io.Reader + var pr *io.PipeReader + var pw *io.PipeWriter + + r.buf = bytes.NewBuffer(nil) + if r.payload != nil || len(r.formFields) > 0 || len(r.fileFields) > 0 { + body = r.buf + if r.isMultipart(mediaType) { + pr, pw = io.Pipe() + body = pr + } + } + + // check if this is a form type request + if len(r.formFields) > 0 || len(r.fileFields) > 0 { + if !r.isMultipart(mediaType) { + r.header.Set(runtime.HeaderContentType, mediaType) + formString := r.formFields.Encode() + r.buf.WriteString(formString) + goto DoneChoosingBodySource + } + + mp := multipart.NewWriter(pw) + r.header.Set(runtime.HeaderContentType, mangleContentType(mediaType, mp.Boundary())) + + go func() { + defer func() { + mp.Close() + pw.Close() + }() + + for fn, v := range r.formFields { + for _, vi := range v { + if err := mp.WriteField(fn, vi); err != nil { + logClose(err, pw) + return + } + } + } + + defer func() { + for _, ff := range r.fileFields { + for _, ffi := range ff { + ffi.Close() + } + } + }() + for fn, f := range r.fileFields { + for _, fi := range f { + // Need to read the data so that we can detect the content type + buf := make([]byte, 512) + size, err := fi.Read(buf) + if err != nil { + logClose(err, pw) + return + } + fileContentType := http.DetectContentType(buf) + newFi := runtime.NamedReader(fi.Name(), io.MultiReader(bytes.NewReader(buf[:size]), fi)) + + // Create the MIME headers for the new part + h := make(textproto.MIMEHeader) + h.Set("Content-Disposition", + fmt.Sprintf(`form-data; name="%s"; filename="%s"`, + escapeQuotes(fn), escapeQuotes(filepath.Base(fi.Name())))) + h.Set("Content-Type", fileContentType) + + wrtr, err := mp.CreatePart(h) + if err != nil { + logClose(err, pw) + return + } + if _, err := io.Copy(wrtr, newFi); err != nil { + logClose(err, pw) + } + } + } + }() + + goto DoneChoosingBodySource + } + + // if there is payload, use the producer to write the payload, and then + // set the header to the content-type appropriate for the payload produced + if r.payload != nil { + // TODO: infer most appropriate content type based on the producer used, + // and the `consumers` section of the spec/operation + r.header.Set(runtime.HeaderContentType, mediaType) + if rdr, ok := r.payload.(io.ReadCloser); ok { + body = rdr + goto DoneChoosingBodySource + } + + if rdr, ok := r.payload.(io.Reader); ok { + body = rdr + goto DoneChoosingBodySource + } + + producer := producers[mediaType] + if err := producer.Produce(r.buf, r.payload); err != nil { + return nil, err + } + } + +DoneChoosingBodySource: + + if runtime.CanHaveBody(r.method) && body == nil && r.header.Get(runtime.HeaderContentType) == "" { + r.header.Set(runtime.HeaderContentType, mediaType) + } + + if auth != nil { + // If we're not using r.buf as our http.Request's body, + // either the payload is an io.Reader or io.ReadCloser, + // or we're doing a multipart form/file. + // + // In those cases, if the AuthenticateRequest call asks for the body, + // we must read it into a buffer and provide that, then use that buffer + // as the body of our http.Request. + // + // This is done in-line with the GetBody() request rather than ahead + // of time, because there's no way to know if the AuthenticateRequest + // will even ask for the body of the request. + // + // If for some reason the copy fails, there's no way to return that + // error to the GetBody() call, so return it afterwards. + // + // An error from the copy action is prioritized over any error + // from the AuthenticateRequest call, because the mis-read + // body may have interfered with the auth. + // + var copyErr error + if buf, ok := body.(*bytes.Buffer); body != nil && (!ok || buf != r.buf) { + var copied bool + r.getBody = func(r *request) []byte { + if copied { + return getRequestBuffer(r) + } + + defer func() { + copied = true + }() + + if _, copyErr = io.Copy(r.buf, body); copyErr != nil { + return nil + } + + if closer, ok := body.(io.ReadCloser); ok { + if copyErr = closer.Close(); copyErr != nil { + return nil + } + } + + body = r.buf + return getRequestBuffer(r) + } + } + + authErr := auth.AuthenticateRequest(r, registry) + + if copyErr != nil { + return nil, fmt.Errorf("error retrieving the response body: %v", copyErr) + } + + if authErr != nil { + return nil, authErr + } + } + + // In case the basePath or the request pathPattern include static query parameters, + // parse those out before constructing the final path. The parameters themselves + // will be merged with the ones set by the client, with the priority given first to + // the ones set by the client, then the path pattern, and lastly the base path. + basePathURL, err := url.Parse(basePath) + if err != nil { + return nil, err + } + staticQueryParams := basePathURL.Query() + + pathPatternURL, err := url.Parse(r.pathPattern) + if err != nil { + return nil, err + } + for name, values := range pathPatternURL.Query() { + if _, present := staticQueryParams[name]; present { + staticQueryParams.Del(name) + } + for _, value := range values { + staticQueryParams.Add(name, value) + } + } + + // create http request + var reinstateSlash bool + if pathPatternURL.Path != "" && pathPatternURL.Path != "/" && pathPatternURL.Path[len(pathPatternURL.Path)-1] == '/' { + reinstateSlash = true + } + + urlPath := path.Join(basePathURL.Path, pathPatternURL.Path) + for k, v := range r.pathParams { + urlPath = strings.Replace(urlPath, "{"+k+"}", url.PathEscape(v), -1) + } + if reinstateSlash { + urlPath = urlPath + "/" + } + + req, err := http.NewRequest(r.method, urlPath, body) + if err != nil { + return nil, err + } + + originalParams := r.GetQueryParams() + + // Merge the query parameters extracted from the basePath with the ones set by + // the client in this struct. In case of conflict, the client wins. + for k, v := range staticQueryParams { + _, present := originalParams[k] + if !present { + if err = r.SetQueryParam(k, v...); err != nil { + return nil, err + } + } + } + + req.URL.RawQuery = r.query.Encode() + req.Header = r.header + + return req, nil +} + +func mangleContentType(mediaType, boundary string) string { + if strings.ToLower(mediaType) == runtime.URLencodedFormMime { + return fmt.Sprintf("%s; boundary=%s", mediaType, boundary) + } + return "multipart/form-data; boundary=" + boundary +} + +func (r *request) GetMethod() string { + return r.method +} + +func (r *request) GetPath() string { + path := r.pathPattern + for k, v := range r.pathParams { + path = strings.Replace(path, "{"+k+"}", v, -1) + } + return path +} + +func (r *request) GetBody() []byte { + return r.getBody(r) +} + +func getRequestBuffer(r *request) []byte { + if r.buf == nil { + return nil + } + return r.buf.Bytes() +} + +// SetHeaderParam adds a header param to the request +// when there is only 1 value provided for the varargs, it will set it. +// when there are several values provided for the varargs it will add it (no overriding) +func (r *request) SetHeaderParam(name string, values ...string) error { + if r.header == nil { + r.header = make(http.Header) + } + r.header[http.CanonicalHeaderKey(name)] = values + return nil +} + +// GetHeaderParams returns the all headers currently set for the request +func (r *request) GetHeaderParams() http.Header { + return r.header +} + +// SetQueryParam adds a query param to the request +// when there is only 1 value provided for the varargs, it will set it. +// when there are several values provided for the varargs it will add it (no overriding) +func (r *request) SetQueryParam(name string, values ...string) error { + if r.query == nil { + r.query = make(url.Values) + } + r.query[name] = values + return nil +} + +// GetQueryParams returns a copy of all query params currently set for the request +func (r *request) GetQueryParams() url.Values { + var result = make(url.Values) + for key, value := range r.query { + result[key] = append([]string{}, value...) + } + return result +} + +// SetFormParam adds a forn param to the request +// when there is only 1 value provided for the varargs, it will set it. +// when there are several values provided for the varargs it will add it (no overriding) +func (r *request) SetFormParam(name string, values ...string) error { + if r.formFields == nil { + r.formFields = make(url.Values) + } + r.formFields[name] = values + return nil +} + +// SetPathParam adds a path param to the request +func (r *request) SetPathParam(name string, value string) error { + if r.pathParams == nil { + r.pathParams = make(map[string]string) + } + + r.pathParams[name] = value + return nil +} + +// SetFileParam adds a file param to the request +func (r *request) SetFileParam(name string, files ...runtime.NamedReadCloser) error { + for _, file := range files { + if actualFile, ok := file.(*os.File); ok { + fi, err := os.Stat(actualFile.Name()) + if err != nil { + return err + } + if fi.IsDir() { + return fmt.Errorf("%q is a directory, only files are supported", file.Name()) + } + } + } + + if r.fileFields == nil { + r.fileFields = make(map[string][]runtime.NamedReadCloser) + } + if r.formFields == nil { + r.formFields = make(url.Values) + } + + r.fileFields[name] = files + return nil +} + +func (r *request) GetFileParam() map[string][]runtime.NamedReadCloser { + return r.fileFields +} + +// SetBodyParam sets a body parameter on the request. +// This does not yet serialze the object, this happens as late as possible. +func (r *request) SetBodyParam(payload interface{}) error { + r.payload = payload + return nil +} + +func (r *request) GetBodyParam() interface{} { + return r.payload +} + +// SetTimeout sets the timeout for a request +func (r *request) SetTimeout(timeout time.Duration) error { + r.timeout = timeout + return nil +} diff --git a/vendor/github.com/go-openapi/runtime/client/response.go b/vendor/github.com/go-openapi/runtime/client/response.go new file mode 100644 index 00000000000..b297a12ff03 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/client/response.go @@ -0,0 +1,48 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package client + +import ( + "io" + "net/http" + + "github.com/go-openapi/runtime" +) + +var _ runtime.ClientResponse = response{} + +type response struct { + resp *http.Response +} + +func (r response) Code() int { + return r.resp.StatusCode +} + +func (r response) Message() string { + return r.resp.Status +} + +func (r response) GetHeader(name string) string { + return r.resp.Header.Get(name) +} + +func (r response) GetHeaders(name string) []string { + return r.resp.Header.Values(name) +} + +func (r response) Body() io.ReadCloser { + return r.resp.Body +} diff --git a/vendor/github.com/go-openapi/runtime/client/runtime.go b/vendor/github.com/go-openapi/runtime/client/runtime.go new file mode 100644 index 00000000000..f6ea0fad3c5 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/client/runtime.go @@ -0,0 +1,497 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package client + +import ( + "context" + "crypto" + "crypto/ecdsa" + "crypto/rsa" + "crypto/tls" + "crypto/x509" + "encoding/pem" + "fmt" + "io/ioutil" + "mime" + "net/http" + "net/http/httputil" + "strings" + "sync" + "time" + + "github.com/go-openapi/strfmt" + "github.com/opentracing/opentracing-go" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/logger" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/yamlpc" +) + +// TLSClientOptions to configure client authentication with mutual TLS +type TLSClientOptions struct { + // Certificate is the path to a PEM-encoded certificate to be used for + // client authentication. If set then Key must also be set. + Certificate string + + // LoadedCertificate is the certificate to be used for client authentication. + // This field is ignored if Certificate is set. If this field is set, LoadedKey + // is also required. + LoadedCertificate *x509.Certificate + + // Key is the path to an unencrypted PEM-encoded private key for client + // authentication. This field is required if Certificate is set. + Key string + + // LoadedKey is the key for client authentication. This field is required if + // LoadedCertificate is set. + LoadedKey crypto.PrivateKey + + // CA is a path to a PEM-encoded certificate that specifies the root certificate + // to use when validating the TLS certificate presented by the server. If this field + // (and LoadedCA) is not set, the system certificate pool is used. This field is ignored if LoadedCA + // is set. + CA string + + // LoadedCA specifies the root certificate to use when validating the server's TLS certificate. + // If this field (and CA) is not set, the system certificate pool is used. + LoadedCA *x509.Certificate + + // LoadedCAPool specifies a pool of RootCAs to use when validating the server's TLS certificate. + // If set, it will be combined with the the other loaded certificates (see LoadedCA and CA). + // If neither LoadedCA or CA is set, the provided pool with override the system + // certificate pool. + // The caller must not use the supplied pool after calling TLSClientAuth. + LoadedCAPool *x509.CertPool + + // ServerName specifies the hostname to use when verifying the server certificate. + // If this field is set then InsecureSkipVerify will be ignored and treated as + // false. + ServerName string + + // InsecureSkipVerify controls whether the certificate chain and hostname presented + // by the server are validated. If true, any certificate is accepted. + InsecureSkipVerify bool + + // VerifyPeerCertificate, if not nil, is called after normal + // certificate verification. It receives the raw ASN.1 certificates + // provided by the peer and also any verified chains that normal processing found. + // If it returns a non-nil error, the handshake is aborted and that error results. + // + // If normal verification fails then the handshake will abort before + // considering this callback. If normal verification is disabled by + // setting InsecureSkipVerify then this callback will be considered but + // the verifiedChains argument will always be nil. + VerifyPeerCertificate func(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error + + // SessionTicketsDisabled may be set to true to disable session ticket and + // PSK (resumption) support. Note that on clients, session ticket support is + // also disabled if ClientSessionCache is nil. + SessionTicketsDisabled bool + + // ClientSessionCache is a cache of ClientSessionState entries for TLS + // session resumption. It is only used by clients. + ClientSessionCache tls.ClientSessionCache + + // Prevents callers using unkeyed fields. + _ struct{} +} + +// TLSClientAuth creates a tls.Config for mutual auth +func TLSClientAuth(opts TLSClientOptions) (*tls.Config, error) { + // create client tls config + cfg := &tls.Config{} + + // load client cert if specified + if opts.Certificate != "" { + cert, err := tls.LoadX509KeyPair(opts.Certificate, opts.Key) + if err != nil { + return nil, fmt.Errorf("tls client cert: %v", err) + } + cfg.Certificates = []tls.Certificate{cert} + } else if opts.LoadedCertificate != nil { + block := pem.Block{Type: "CERTIFICATE", Bytes: opts.LoadedCertificate.Raw} + certPem := pem.EncodeToMemory(&block) + + var keyBytes []byte + switch k := opts.LoadedKey.(type) { + case *rsa.PrivateKey: + keyBytes = x509.MarshalPKCS1PrivateKey(k) + case *ecdsa.PrivateKey: + var err error + keyBytes, err = x509.MarshalECPrivateKey(k) + if err != nil { + return nil, fmt.Errorf("tls client priv key: %v", err) + } + default: + return nil, fmt.Errorf("tls client priv key: unsupported key type") + } + + block = pem.Block{Type: "PRIVATE KEY", Bytes: keyBytes} + keyPem := pem.EncodeToMemory(&block) + + cert, err := tls.X509KeyPair(certPem, keyPem) + if err != nil { + return nil, fmt.Errorf("tls client cert: %v", err) + } + cfg.Certificates = []tls.Certificate{cert} + } + + cfg.InsecureSkipVerify = opts.InsecureSkipVerify + + cfg.VerifyPeerCertificate = opts.VerifyPeerCertificate + cfg.SessionTicketsDisabled = opts.SessionTicketsDisabled + cfg.ClientSessionCache = opts.ClientSessionCache + + // When no CA certificate is provided, default to the system cert pool + // that way when a request is made to a server known by the system trust store, + // the name is still verified + if opts.LoadedCA != nil { + caCertPool := basePool(opts.LoadedCAPool) + caCertPool.AddCert(opts.LoadedCA) + cfg.RootCAs = caCertPool + } else if opts.CA != "" { + // load ca cert + caCert, err := ioutil.ReadFile(opts.CA) + if err != nil { + return nil, fmt.Errorf("tls client ca: %v", err) + } + caCertPool := basePool(opts.LoadedCAPool) + caCertPool.AppendCertsFromPEM(caCert) + cfg.RootCAs = caCertPool + } else if opts.LoadedCAPool != nil { + cfg.RootCAs = opts.LoadedCAPool + } + + // apply servername overrride + if opts.ServerName != "" { + cfg.InsecureSkipVerify = false + cfg.ServerName = opts.ServerName + } + + cfg.BuildNameToCertificate() + + return cfg, nil +} + +func basePool(pool *x509.CertPool) *x509.CertPool { + if pool == nil { + return x509.NewCertPool() + } + return pool +} + +// TLSTransport creates a http client transport suitable for mutual tls auth +func TLSTransport(opts TLSClientOptions) (http.RoundTripper, error) { + cfg, err := TLSClientAuth(opts) + if err != nil { + return nil, err + } + + return &http.Transport{TLSClientConfig: cfg}, nil +} + +// TLSClient creates a http.Client for mutual auth +func TLSClient(opts TLSClientOptions) (*http.Client, error) { + transport, err := TLSTransport(opts) + if err != nil { + return nil, err + } + return &http.Client{Transport: transport}, nil +} + +// DefaultTimeout the default request timeout +var DefaultTimeout = 30 * time.Second + +// Runtime represents an API client that uses the transport +// to make http requests based on a swagger specification. +type Runtime struct { + DefaultMediaType string + DefaultAuthentication runtime.ClientAuthInfoWriter + Consumers map[string]runtime.Consumer + Producers map[string]runtime.Producer + + Transport http.RoundTripper + Jar http.CookieJar + //Spec *spec.Document + Host string + BasePath string + Formats strfmt.Registry + Context context.Context + + Debug bool + logger logger.Logger + + clientOnce *sync.Once + client *http.Client + schemes []string +} + +// New creates a new default runtime for a swagger api runtime.Client +func New(host, basePath string, schemes []string) *Runtime { + var rt Runtime + rt.DefaultMediaType = runtime.JSONMime + + // TODO: actually infer this stuff from the spec + rt.Consumers = map[string]runtime.Consumer{ + runtime.YAMLMime: yamlpc.YAMLConsumer(), + runtime.JSONMime: runtime.JSONConsumer(), + runtime.XMLMime: runtime.XMLConsumer(), + runtime.TextMime: runtime.TextConsumer(), + runtime.HTMLMime: runtime.TextConsumer(), + runtime.CSVMime: runtime.CSVConsumer(), + runtime.DefaultMime: runtime.ByteStreamConsumer(), + } + rt.Producers = map[string]runtime.Producer{ + runtime.YAMLMime: yamlpc.YAMLProducer(), + runtime.JSONMime: runtime.JSONProducer(), + runtime.XMLMime: runtime.XMLProducer(), + runtime.TextMime: runtime.TextProducer(), + runtime.HTMLMime: runtime.TextProducer(), + runtime.CSVMime: runtime.CSVProducer(), + runtime.DefaultMime: runtime.ByteStreamProducer(), + } + rt.Transport = http.DefaultTransport + rt.Jar = nil + rt.Host = host + rt.BasePath = basePath + rt.Context = context.Background() + rt.clientOnce = new(sync.Once) + if !strings.HasPrefix(rt.BasePath, "/") { + rt.BasePath = "/" + rt.BasePath + } + + rt.Debug = logger.DebugEnabled() + rt.logger = logger.StandardLogger{} + + if len(schemes) > 0 { + rt.schemes = schemes + } + return &rt +} + +// NewWithClient allows you to create a new transport with a configured http.Client +func NewWithClient(host, basePath string, schemes []string, client *http.Client) *Runtime { + rt := New(host, basePath, schemes) + if client != nil { + rt.clientOnce.Do(func() { + rt.client = client + }) + } + return rt +} + +// WithOpenTracing adds opentracing support to the provided runtime. +// A new client span is created for each request. +// If the context of the client operation does not contain an active span, no span is created. +// The provided opts are applied to each spans - for example to add global tags. +func (r *Runtime) WithOpenTracing(opts ...opentracing.StartSpanOption) runtime.ClientTransport { + return newOpenTracingTransport(r, r.Host, opts) +} + +func (r *Runtime) pickScheme(schemes []string) string { + if v := r.selectScheme(r.schemes); v != "" { + return v + } + if v := r.selectScheme(schemes); v != "" { + return v + } + return "http" +} + +func (r *Runtime) selectScheme(schemes []string) string { + schLen := len(schemes) + if schLen == 0 { + return "" + } + + scheme := schemes[0] + // prefer https, but skip when not possible + if scheme != "https" && schLen > 1 { + for _, sch := range schemes { + if sch == "https" { + scheme = sch + break + } + } + } + return scheme +} +func transportOrDefault(left, right http.RoundTripper) http.RoundTripper { + if left == nil { + return right + } + return left +} + +// EnableConnectionReuse drains the remaining body from a response +// so that go will reuse the TCP connections. +// +// This is not enabled by default because there are servers where +// the response never gets closed and that would make the code hang forever. +// So instead it's provided as a http client middleware that can be used to override +// any request. +func (r *Runtime) EnableConnectionReuse() { + if r.client == nil { + r.Transport = KeepAliveTransport( + transportOrDefault(r.Transport, http.DefaultTransport), + ) + return + } + + r.client.Transport = KeepAliveTransport( + transportOrDefault(r.client.Transport, + transportOrDefault(r.Transport, http.DefaultTransport), + ), + ) +} + +// Submit a request and when there is a body on success it will turn that into the result +// all other things are turned into an api error for swagger which retains the status code +func (r *Runtime) Submit(operation *runtime.ClientOperation) (interface{}, error) { + params, readResponse, auth := operation.Params, operation.Reader, operation.AuthInfo + + request, err := newRequest(operation.Method, operation.PathPattern, params) + if err != nil { + return nil, err + } + + var accept []string + accept = append(accept, operation.ProducesMediaTypes...) + if err = request.SetHeaderParam(runtime.HeaderAccept, accept...); err != nil { + return nil, err + } + + if auth == nil && r.DefaultAuthentication != nil { + auth = r.DefaultAuthentication + } + //if auth != nil { + // if err := auth.AuthenticateRequest(request, r.Formats); err != nil { + // return nil, err + // } + //} + + // TODO: pick appropriate media type + cmt := r.DefaultMediaType + for _, mediaType := range operation.ConsumesMediaTypes { + // Pick first non-empty media type + if mediaType != "" { + cmt = mediaType + break + } + } + + if _, ok := r.Producers[cmt]; !ok && cmt != runtime.MultipartFormMime && cmt != runtime.URLencodedFormMime { + return nil, fmt.Errorf("none of producers: %v registered. try %s", r.Producers, cmt) + } + + req, err := request.buildHTTP(cmt, r.BasePath, r.Producers, r.Formats, auth) + if err != nil { + return nil, err + } + req.URL.Scheme = r.pickScheme(operation.Schemes) + req.URL.Host = r.Host + req.Host = r.Host + + r.clientOnce.Do(func() { + r.client = &http.Client{ + Transport: r.Transport, + Jar: r.Jar, + } + }) + + if r.Debug { + b, err2 := httputil.DumpRequestOut(req, true) + if err2 != nil { + return nil, err2 + } + r.logger.Debugf("%s\n", string(b)) + } + + var hasTimeout bool + pctx := operation.Context + if pctx == nil { + pctx = r.Context + } else { + hasTimeout = true + } + if pctx == nil { + pctx = context.Background() + } + var ctx context.Context + var cancel context.CancelFunc + if hasTimeout { + ctx, cancel = context.WithCancel(pctx) + } else { + ctx, cancel = context.WithTimeout(pctx, request.timeout) + } + defer cancel() + + client := operation.Client + if client == nil { + client = r.client + } + req = req.WithContext(ctx) + res, err := client.Do(req) // make requests, by default follows 10 redirects before failing + if err != nil { + return nil, err + } + defer res.Body.Close() + + ct := res.Header.Get(runtime.HeaderContentType) + if ct == "" { // this should really really never occur + ct = r.DefaultMediaType + } + + if r.Debug { + printBody := true + if ct == runtime.DefaultMime { + printBody = false // Spare the terminal from a binary blob. + } + b, err2 := httputil.DumpResponse(res, printBody) + if err2 != nil { + return nil, err2 + } + r.logger.Debugf("%s\n", string(b)) + } + + mt, _, err := mime.ParseMediaType(ct) + if err != nil { + return nil, fmt.Errorf("parse content type: %s", err) + } + + cons, ok := r.Consumers[mt] + if !ok { + if cons, ok = r.Consumers["*/*"]; !ok { + // scream about not knowing what to do + return nil, fmt.Errorf("no consumer: %q", ct) + } + } + return readResponse.ReadResponse(response{res}, cons) +} + +// SetDebug changes the debug flag. +// It ensures that client and middlewares have the set debug level. +func (r *Runtime) SetDebug(debug bool) { + r.Debug = debug + middleware.Debug = debug +} + +// SetLogger changes the logger stream. +// It ensures that client and middlewares use the same logger. +func (r *Runtime) SetLogger(logger logger.Logger) { + r.logger = logger + middleware.Logger = logger +} diff --git a/vendor/github.com/go-openapi/runtime/client_auth_info.go b/vendor/github.com/go-openapi/runtime/client_auth_info.go new file mode 100644 index 00000000000..c6c97d9a7c3 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/client_auth_info.go @@ -0,0 +1,30 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package runtime + +import "github.com/go-openapi/strfmt" + +// A ClientAuthInfoWriterFunc converts a function to a request writer interface +type ClientAuthInfoWriterFunc func(ClientRequest, strfmt.Registry) error + +// AuthenticateRequest adds authentication data to the request +func (fn ClientAuthInfoWriterFunc) AuthenticateRequest(req ClientRequest, reg strfmt.Registry) error { + return fn(req, reg) +} + +// A ClientAuthInfoWriter implementor knows how to write authentication info to a request +type ClientAuthInfoWriter interface { + AuthenticateRequest(ClientRequest, strfmt.Registry) error +} diff --git a/vendor/github.com/go-openapi/runtime/client_operation.go b/vendor/github.com/go-openapi/runtime/client_operation.go new file mode 100644 index 00000000000..fa21eacf330 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/client_operation.go @@ -0,0 +1,41 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package runtime + +import ( + "context" + "net/http" +) + +// ClientOperation represents the context for a swagger operation to be submitted to the transport +type ClientOperation struct { + ID string + Method string + PathPattern string + ProducesMediaTypes []string + ConsumesMediaTypes []string + Schemes []string + AuthInfo ClientAuthInfoWriter + Params ClientRequestWriter + Reader ClientResponseReader + Context context.Context + Client *http.Client +} + +// A ClientTransport implementor knows how to submit Request objects to some destination +type ClientTransport interface { + //Submit(string, RequestWriter, ResponseReader, AuthInfoWriter) (interface{}, error) + Submit(*ClientOperation) (interface{}, error) +} diff --git a/vendor/github.com/go-openapi/runtime/client_request.go b/vendor/github.com/go-openapi/runtime/client_request.go new file mode 100644 index 00000000000..3efda348216 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/client_request.go @@ -0,0 +1,153 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package runtime + +import ( + "io" + "io/ioutil" + "net/http" + "net/url" + "time" + + "github.com/go-openapi/strfmt" +) + +// ClientRequestWriterFunc converts a function to a request writer interface +type ClientRequestWriterFunc func(ClientRequest, strfmt.Registry) error + +// WriteToRequest adds data to the request +func (fn ClientRequestWriterFunc) WriteToRequest(req ClientRequest, reg strfmt.Registry) error { + return fn(req, reg) +} + +// ClientRequestWriter is an interface for things that know how to write to a request +type ClientRequestWriter interface { + WriteToRequest(ClientRequest, strfmt.Registry) error +} + +// ClientRequest is an interface for things that know how to +// add information to a swagger client request +type ClientRequest interface { + SetHeaderParam(string, ...string) error + + GetHeaderParams() http.Header + + SetQueryParam(string, ...string) error + + SetFormParam(string, ...string) error + + SetPathParam(string, string) error + + GetQueryParams() url.Values + + SetFileParam(string, ...NamedReadCloser) error + + SetBodyParam(interface{}) error + + SetTimeout(time.Duration) error + + GetMethod() string + + GetPath() string + + GetBody() []byte + + GetBodyParam() interface{} + + GetFileParam() map[string][]NamedReadCloser +} + +// NamedReadCloser represents a named ReadCloser interface +type NamedReadCloser interface { + io.ReadCloser + Name() string +} + +// NamedReader creates a NamedReadCloser for use as file upload +func NamedReader(name string, rdr io.Reader) NamedReadCloser { + rc, ok := rdr.(io.ReadCloser) + if !ok { + rc = ioutil.NopCloser(rdr) + } + return &namedReadCloser{ + name: name, + cr: rc, + } +} + +type namedReadCloser struct { + name string + cr io.ReadCloser +} + +func (n *namedReadCloser) Close() error { + return n.cr.Close() +} +func (n *namedReadCloser) Read(p []byte) (int, error) { + return n.cr.Read(p) +} +func (n *namedReadCloser) Name() string { + return n.name +} + +type TestClientRequest struct { + Headers http.Header + Body interface{} +} + +func (t *TestClientRequest) SetHeaderParam(name string, values ...string) error { + if t.Headers == nil { + t.Headers = make(http.Header) + } + t.Headers.Set(name, values[0]) + return nil +} + +func (t *TestClientRequest) SetQueryParam(_ string, _ ...string) error { return nil } + +func (t *TestClientRequest) SetFormParam(_ string, _ ...string) error { return nil } + +func (t *TestClientRequest) SetPathParam(_ string, _ string) error { return nil } + +func (t *TestClientRequest) SetFileParam(_ string, _ ...NamedReadCloser) error { return nil } + +func (t *TestClientRequest) SetBodyParam(body interface{}) error { + t.Body = body + return nil +} + +func (t *TestClientRequest) SetTimeout(time.Duration) error { + return nil +} + +func (t *TestClientRequest) GetQueryParams() url.Values { return nil } + +func (t *TestClientRequest) GetMethod() string { return "" } + +func (t *TestClientRequest) GetPath() string { return "" } + +func (t *TestClientRequest) GetBody() []byte { return nil } + +func (t *TestClientRequest) GetBodyParam() interface{} { + return t.Body +} + +func (t *TestClientRequest) GetFileParam() map[string][]NamedReadCloser { + return nil +} + +func (t *TestClientRequest) GetHeaderParams() http.Header { + return t.Headers +} diff --git a/vendor/github.com/go-openapi/runtime/client_response.go b/vendor/github.com/go-openapi/runtime/client_response.go new file mode 100644 index 00000000000..0b7e3824657 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/client_response.go @@ -0,0 +1,106 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package runtime + +import ( + "fmt" + "io" + + "encoding/json" +) + +// A ClientResponse represents a client response +// This bridges between responses obtained from different transports +type ClientResponse interface { + Code() int + Message() string + GetHeader(string) string + GetHeaders(string) []string + Body() io.ReadCloser +} + +// A ClientResponseReaderFunc turns a function into a ClientResponseReader interface implementation +type ClientResponseReaderFunc func(ClientResponse, Consumer) (interface{}, error) + +// ReadResponse reads the response +func (read ClientResponseReaderFunc) ReadResponse(resp ClientResponse, consumer Consumer) (interface{}, error) { + return read(resp, consumer) +} + +// A ClientResponseReader is an interface for things want to read a response. +// An application of this is to create structs from response values +type ClientResponseReader interface { + ReadResponse(ClientResponse, Consumer) (interface{}, error) +} + +// NewAPIError creates a new API error +func NewAPIError(opName string, payload interface{}, code int) *APIError { + return &APIError{ + OperationName: opName, + Response: payload, + Code: code, + } +} + +// APIError wraps an error model and captures the status code +type APIError struct { + OperationName string + Response interface{} + Code int +} + +func (a *APIError) Error() string { + resp, _ := json.Marshal(a.Response) + return fmt.Sprintf("%s (status %d): %s", a.OperationName, a.Code, resp) +} + +func (a *APIError) String() string { + return a.Error() +} + +// IsSuccess returns true when this elapse o k response returns a 2xx status code +func (o *APIError) IsSuccess() bool { + return o.Code/100 == 2 +} + +// IsRedirect returns true when this elapse o k response returns a 3xx status code +func (o *APIError) IsRedirect() bool { + return o.Code/100 == 3 +} + +// IsClientError returns true when this elapse o k response returns a 4xx status code +func (o *APIError) IsClientError() bool { + return o.Code/100 == 4 +} + +// IsServerError returns true when this elapse o k response returns a 5xx status code +func (o *APIError) IsServerError() bool { + return o.Code/100 == 5 +} + +// IsCode returns true when this elapse o k response returns a 4xx status code +func (o *APIError) IsCode(code int) bool { + return o.Code == code +} + +// A ClientResponseStatus is a common interface implemented by all responses on the generated code +// You can use this to treat any client response based on status code +type ClientResponseStatus interface { + IsSuccess() bool + IsRedirect() bool + IsClientError() bool + IsServerError() bool + IsCode(int) bool +} diff --git a/vendor/github.com/go-openapi/runtime/constants.go b/vendor/github.com/go-openapi/runtime/constants.go new file mode 100644 index 00000000000..a4de897adcd --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/constants.go @@ -0,0 +1,47 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package runtime + +const ( + // HeaderContentType represents a http content-type header, it's value is supposed to be a mime type + HeaderContentType = "Content-Type" + + // HeaderTransferEncoding represents a http transfer-encoding header. + HeaderTransferEncoding = "Transfer-Encoding" + + // HeaderAccept the Accept header + HeaderAccept = "Accept" + + charsetKey = "charset" + + // DefaultMime the default fallback mime type + DefaultMime = "application/octet-stream" + // JSONMime the json mime type + JSONMime = "application/json" + // YAMLMime the yaml mime type + YAMLMime = "application/x-yaml" + // XMLMime the xml mime type + XMLMime = "application/xml" + // TextMime the text mime type + TextMime = "text/plain" + // HTMLMime the html mime type + HTMLMime = "text/html" + // CSVMime the csv mime type + CSVMime = "text/csv" + // MultipartFormMime the multipart form mime type + MultipartFormMime = "multipart/form-data" + // URLencodedFormMime the url encoded form mime type + URLencodedFormMime = "application/x-www-form-urlencoded" +) diff --git a/vendor/github.com/go-openapi/runtime/csv.go b/vendor/github.com/go-openapi/runtime/csv.go new file mode 100644 index 00000000000..d807bd915b4 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/csv.go @@ -0,0 +1,77 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package runtime + +import ( + "bytes" + "encoding/csv" + "errors" + "io" +) + +// CSVConsumer creates a new CSV consumer +func CSVConsumer() Consumer { + return ConsumerFunc(func(reader io.Reader, data interface{}) error { + if reader == nil { + return errors.New("CSVConsumer requires a reader") + } + + csvReader := csv.NewReader(reader) + writer, ok := data.(io.Writer) + if !ok { + return errors.New("data type must be io.Writer") + } + csvWriter := csv.NewWriter(writer) + records, err := csvReader.ReadAll() + if err != nil { + return err + } + for _, r := range records { + if err := csvWriter.Write(r); err != nil { + return err + } + } + csvWriter.Flush() + return nil + }) +} + +// CSVProducer creates a new CSV producer +func CSVProducer() Producer { + return ProducerFunc(func(writer io.Writer, data interface{}) error { + if writer == nil { + return errors.New("CSVProducer requires a writer") + } + + dataBytes, ok := data.([]byte) + if !ok { + return errors.New("data type must be byte array") + } + + csvReader := csv.NewReader(bytes.NewBuffer(dataBytes)) + records, err := csvReader.ReadAll() + if err != nil { + return err + } + csvWriter := csv.NewWriter(writer) + for _, r := range records { + if err := csvWriter.Write(r); err != nil { + return err + } + } + csvWriter.Flush() + return nil + }) +} diff --git a/vendor/github.com/go-openapi/runtime/discard.go b/vendor/github.com/go-openapi/runtime/discard.go new file mode 100644 index 00000000000..0d390cfd64c --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/discard.go @@ -0,0 +1,9 @@ +package runtime + +import "io" + +// DiscardConsumer does absolutely nothing, it's a black hole. +var DiscardConsumer = ConsumerFunc(func(_ io.Reader, _ interface{}) error { return nil }) + +// DiscardProducer does absolutely nothing, it's a black hole. +var DiscardProducer = ProducerFunc(func(_ io.Writer, _ interface{}) error { return nil }) diff --git a/vendor/github.com/go-openapi/runtime/file.go b/vendor/github.com/go-openapi/runtime/file.go new file mode 100644 index 00000000000..85971c18c4b --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/file.go @@ -0,0 +1,33 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package runtime + +import "mime/multipart" + +// File represents an uploaded file. +type File struct { + Data multipart.File + Header *multipart.FileHeader +} + +// Read bytes from the file +func (f *File) Read(p []byte) (n int, err error) { + return f.Data.Read(p) +} + +// Close the file +func (f *File) Close() error { + return f.Data.Close() +} diff --git a/vendor/github.com/go-openapi/runtime/headers.go b/vendor/github.com/go-openapi/runtime/headers.go new file mode 100644 index 00000000000..4d111db4fec --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/headers.go @@ -0,0 +1,45 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package runtime + +import ( + "mime" + "net/http" + + "github.com/go-openapi/errors" +) + +// ContentType parses a content type header +func ContentType(headers http.Header) (string, string, error) { + ct := headers.Get(HeaderContentType) + orig := ct + if ct == "" { + ct = DefaultMime + } + if ct == "" { + return "", "", nil + } + + mt, opts, err := mime.ParseMediaType(ct) + if err != nil { + return "", "", errors.NewParseError(HeaderContentType, "header", orig, err) + } + + if cs, ok := opts[charsetKey]; ok { + return mt, cs, nil + } + + return mt, "", nil +} diff --git a/vendor/github.com/go-openapi/runtime/interfaces.go b/vendor/github.com/go-openapi/runtime/interfaces.go new file mode 100644 index 00000000000..e3341286834 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/interfaces.go @@ -0,0 +1,112 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package runtime + +import ( + "context" + "io" + "net/http" + + "github.com/go-openapi/strfmt" +) + +// OperationHandlerFunc an adapter for a function to the OperationHandler interface +type OperationHandlerFunc func(interface{}) (interface{}, error) + +// Handle implements the operation handler interface +func (s OperationHandlerFunc) Handle(data interface{}) (interface{}, error) { + return s(data) +} + +// OperationHandler a handler for a swagger operation +type OperationHandler interface { + Handle(interface{}) (interface{}, error) +} + +// ConsumerFunc represents a function that can be used as a consumer +type ConsumerFunc func(io.Reader, interface{}) error + +// Consume consumes the reader into the data parameter +func (fn ConsumerFunc) Consume(reader io.Reader, data interface{}) error { + return fn(reader, data) +} + +// Consumer implementations know how to bind the values on the provided interface to +// data provided by the request body +type Consumer interface { + // Consume performs the binding of request values + Consume(io.Reader, interface{}) error +} + +// ProducerFunc represents a function that can be used as a producer +type ProducerFunc func(io.Writer, interface{}) error + +// Produce produces the response for the provided data +func (f ProducerFunc) Produce(writer io.Writer, data interface{}) error { + return f(writer, data) +} + +// Producer implementations know how to turn the provided interface into a valid +// HTTP response +type Producer interface { + // Produce writes to the http response + Produce(io.Writer, interface{}) error +} + +// AuthenticatorFunc turns a function into an authenticator +type AuthenticatorFunc func(interface{}) (bool, interface{}, error) + +// Authenticate authenticates the request with the provided data +func (f AuthenticatorFunc) Authenticate(params interface{}) (bool, interface{}, error) { + return f(params) +} + +// Authenticator represents an authentication strategy +// implementations of Authenticator know how to authenticate the +// request data and translate that into a valid principal object or an error +type Authenticator interface { + Authenticate(interface{}) (bool, interface{}, error) +} + +// AuthorizerFunc turns a function into an authorizer +type AuthorizerFunc func(*http.Request, interface{}) error + +// Authorize authorizes the processing of the request for the principal +func (f AuthorizerFunc) Authorize(r *http.Request, principal interface{}) error { + return f(r, principal) +} + +// Authorizer represents an authorization strategy +// implementations of Authorizer know how to authorize the principal object +// using the request data and returns error if unauthorized +type Authorizer interface { + Authorize(*http.Request, interface{}) error +} + +// Validatable types implementing this interface allow customizing their validation +// this will be used instead of the reflective validation based on the spec document. +// the implementations are assumed to have been generated by the swagger tool so they should +// contain all the validations obtained from the spec +type Validatable interface { + Validate(strfmt.Registry) error +} + +// ContextValidatable types implementing this interface allow customizing their validation +// this will be used instead of the reflective validation based on the spec document. +// the implementations are assumed to have been generated by the swagger tool so they should +// contain all the context validations obtained from the spec +type ContextValidatable interface { + ContextValidate(context.Context, strfmt.Registry) error +} diff --git a/vendor/github.com/go-openapi/runtime/json.go b/vendor/github.com/go-openapi/runtime/json.go new file mode 100644 index 00000000000..5a690559cc5 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/json.go @@ -0,0 +1,38 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package runtime + +import ( + "encoding/json" + "io" +) + +// JSONConsumer creates a new JSON consumer +func JSONConsumer() Consumer { + return ConsumerFunc(func(reader io.Reader, data interface{}) error { + dec := json.NewDecoder(reader) + dec.UseNumber() // preserve number formats + return dec.Decode(data) + }) +} + +// JSONProducer creates a new JSON producer +func JSONProducer() Producer { + return ProducerFunc(func(writer io.Writer, data interface{}) error { + enc := json.NewEncoder(writer) + enc.SetEscapeHTML(false) + return enc.Encode(data) + }) +} diff --git a/vendor/github.com/go-openapi/runtime/logger/logger.go b/vendor/github.com/go-openapi/runtime/logger/logger.go new file mode 100644 index 00000000000..6f4debcc145 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/logger/logger.go @@ -0,0 +1,20 @@ +package logger + +import "os" + +type Logger interface { + Printf(format string, args ...interface{}) + Debugf(format string, args ...interface{}) +} + +func DebugEnabled() bool { + d := os.Getenv("SWAGGER_DEBUG") + if d != "" && d != "false" && d != "0" { + return true + } + d = os.Getenv("DEBUG") + if d != "" && d != "false" && d != "0" { + return true + } + return false +} diff --git a/vendor/github.com/go-openapi/runtime/logger/standard.go b/vendor/github.com/go-openapi/runtime/logger/standard.go new file mode 100644 index 00000000000..f7e67ebb9e7 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/logger/standard.go @@ -0,0 +1,22 @@ +package logger + +import ( + "fmt" + "os" +) + +type StandardLogger struct{} + +func (StandardLogger) Printf(format string, args ...interface{}) { + if len(format) == 0 || format[len(format)-1] != '\n' { + format += "\n" + } + fmt.Fprintf(os.Stderr, format, args...) +} + +func (StandardLogger) Debugf(format string, args ...interface{}) { + if len(format) == 0 || format[len(format)-1] != '\n' { + format += "\n" + } + fmt.Fprintf(os.Stderr, format, args...) +} diff --git a/vendor/github.com/go-openapi/runtime/middleware/context.go b/vendor/github.com/go-openapi/runtime/middleware/context.go new file mode 100644 index 00000000000..250e35fb0e1 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/middleware/context.go @@ -0,0 +1,622 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package middleware + +import ( + stdContext "context" + "fmt" + "net/http" + "strings" + "sync" + + "github.com/go-openapi/analysis" + "github.com/go-openapi/errors" + "github.com/go-openapi/loads" + "github.com/go-openapi/spec" + "github.com/go-openapi/strfmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/logger" + "github.com/go-openapi/runtime/middleware/untyped" + "github.com/go-openapi/runtime/security" +) + +// Debug when true turns on verbose logging +var Debug = logger.DebugEnabled() +var Logger logger.Logger = logger.StandardLogger{} + +func debugLog(format string, args ...interface{}) { + if Debug { + Logger.Printf(format, args...) + } +} + +// A Builder can create middlewares +type Builder func(http.Handler) http.Handler + +// PassthroughBuilder returns the handler, aka the builder identity function +func PassthroughBuilder(handler http.Handler) http.Handler { return handler } + +// RequestBinder is an interface for types to implement +// when they want to be able to bind from a request +type RequestBinder interface { + BindRequest(*http.Request, *MatchedRoute) error +} + +// Responder is an interface for types to implement +// when they want to be considered for writing HTTP responses +type Responder interface { + WriteResponse(http.ResponseWriter, runtime.Producer) +} + +// ResponderFunc wraps a func as a Responder interface +type ResponderFunc func(http.ResponseWriter, runtime.Producer) + +// WriteResponse writes to the response +func (fn ResponderFunc) WriteResponse(rw http.ResponseWriter, pr runtime.Producer) { + fn(rw, pr) +} + +// Context is a type safe wrapper around an untyped request context +// used throughout to store request context with the standard context attached +// to the http.Request +type Context struct { + spec *loads.Document + analyzer *analysis.Spec + api RoutableAPI + router Router +} + +type routableUntypedAPI struct { + api *untyped.API + hlock *sync.Mutex + handlers map[string]map[string]http.Handler + defaultConsumes string + defaultProduces string +} + +func newRoutableUntypedAPI(spec *loads.Document, api *untyped.API, context *Context) *routableUntypedAPI { + var handlers map[string]map[string]http.Handler + if spec == nil || api == nil { + return nil + } + analyzer := analysis.New(spec.Spec()) + for method, hls := range analyzer.Operations() { + um := strings.ToUpper(method) + for path, op := range hls { + schemes := analyzer.SecurityRequirementsFor(op) + + if oh, ok := api.OperationHandlerFor(method, path); ok { + if handlers == nil { + handlers = make(map[string]map[string]http.Handler) + } + if b, ok := handlers[um]; !ok || b == nil { + handlers[um] = make(map[string]http.Handler) + } + + var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + // lookup route info in the context + route, rCtx, _ := context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + + // bind and validate the request using reflection + var bound interface{} + var validation error + bound, r, validation = context.BindAndValidate(r, route) + if validation != nil { + context.Respond(w, r, route.Produces, route, validation) + return + } + + // actually handle the request + result, err := oh.Handle(bound) + if err != nil { + // respond with failure + context.Respond(w, r, route.Produces, route, err) + return + } + + // respond with success + context.Respond(w, r, route.Produces, route, result) + }) + + if len(schemes) > 0 { + handler = newSecureAPI(context, handler) + } + handlers[um][path] = handler + } + } + } + + return &routableUntypedAPI{ + api: api, + hlock: new(sync.Mutex), + handlers: handlers, + defaultProduces: api.DefaultProduces, + defaultConsumes: api.DefaultConsumes, + } +} + +func (r *routableUntypedAPI) HandlerFor(method, path string) (http.Handler, bool) { + r.hlock.Lock() + paths, ok := r.handlers[strings.ToUpper(method)] + if !ok { + r.hlock.Unlock() + return nil, false + } + handler, ok := paths[path] + r.hlock.Unlock() + return handler, ok +} +func (r *routableUntypedAPI) ServeErrorFor(operationID string) func(http.ResponseWriter, *http.Request, error) { + return r.api.ServeError +} +func (r *routableUntypedAPI) ConsumersFor(mediaTypes []string) map[string]runtime.Consumer { + return r.api.ConsumersFor(mediaTypes) +} +func (r *routableUntypedAPI) ProducersFor(mediaTypes []string) map[string]runtime.Producer { + return r.api.ProducersFor(mediaTypes) +} +func (r *routableUntypedAPI) AuthenticatorsFor(schemes map[string]spec.SecurityScheme) map[string]runtime.Authenticator { + return r.api.AuthenticatorsFor(schemes) +} +func (r *routableUntypedAPI) Authorizer() runtime.Authorizer { + return r.api.Authorizer() +} +func (r *routableUntypedAPI) Formats() strfmt.Registry { + return r.api.Formats() +} + +func (r *routableUntypedAPI) DefaultProduces() string { + return r.defaultProduces +} + +func (r *routableUntypedAPI) DefaultConsumes() string { + return r.defaultConsumes +} + +// NewRoutableContext creates a new context for a routable API +func NewRoutableContext(spec *loads.Document, routableAPI RoutableAPI, routes Router) *Context { + var an *analysis.Spec + if spec != nil { + an = analysis.New(spec.Spec()) + } + ctx := &Context{spec: spec, api: routableAPI, analyzer: an, router: routes} + return ctx +} + +// NewContext creates a new context wrapper +func NewContext(spec *loads.Document, api *untyped.API, routes Router) *Context { + var an *analysis.Spec + if spec != nil { + an = analysis.New(spec.Spec()) + } + ctx := &Context{spec: spec, analyzer: an} + ctx.api = newRoutableUntypedAPI(spec, api, ctx) + ctx.router = routes + return ctx +} + +// Serve serves the specified spec with the specified api registrations as a http.Handler +func Serve(spec *loads.Document, api *untyped.API) http.Handler { + return ServeWithBuilder(spec, api, PassthroughBuilder) +} + +// ServeWithBuilder serves the specified spec with the specified api registrations as a http.Handler that is decorated +// by the Builder +func ServeWithBuilder(spec *loads.Document, api *untyped.API, builder Builder) http.Handler { + context := NewContext(spec, api, nil) + return context.APIHandler(builder) +} + +type contextKey int8 + +const ( + _ contextKey = iota + ctxContentType + ctxResponseFormat + ctxMatchedRoute + ctxBoundParams + ctxSecurityPrincipal + ctxSecurityScopes +) + +// MatchedRouteFrom request context value. +func MatchedRouteFrom(req *http.Request) *MatchedRoute { + mr := req.Context().Value(ctxMatchedRoute) + if mr == nil { + return nil + } + if res, ok := mr.(*MatchedRoute); ok { + return res + } + return nil +} + +// SecurityPrincipalFrom request context value. +func SecurityPrincipalFrom(req *http.Request) interface{} { + return req.Context().Value(ctxSecurityPrincipal) +} + +// SecurityScopesFrom request context value. +func SecurityScopesFrom(req *http.Request) []string { + rs := req.Context().Value(ctxSecurityScopes) + if res, ok := rs.([]string); ok { + return res + } + return nil +} + +type contentTypeValue struct { + MediaType string + Charset string +} + +// BasePath returns the base path for this API +func (c *Context) BasePath() string { + return c.spec.BasePath() +} + +// RequiredProduces returns the accepted content types for responses +func (c *Context) RequiredProduces() []string { + return c.analyzer.RequiredProduces() +} + +// BindValidRequest binds a params object to a request but only when the request is valid +// if the request is not valid an error will be returned +func (c *Context) BindValidRequest(request *http.Request, route *MatchedRoute, binder RequestBinder) error { + var res []error + var requestContentType string + + // check and validate content type, select consumer + if runtime.HasBody(request) { + ct, _, err := runtime.ContentType(request.Header) + if err != nil { + res = append(res, err) + } else { + if err := validateContentType(route.Consumes, ct); err != nil { + res = append(res, err) + } + if len(res) == 0 { + cons, ok := route.Consumers[ct] + if !ok { + res = append(res, errors.New(500, "no consumer registered for %s", ct)) + } else { + route.Consumer = cons + requestContentType = ct + } + } + } + } + + // check and validate the response format + if len(res) == 0 { + // if the route does not provide Produces and a default contentType could not be identified + // based on a body, typical for GET and DELETE requests, then default contentType to. + if len(route.Produces) == 0 && requestContentType == "" { + requestContentType = "*/*" + } + + if str := NegotiateContentType(request, route.Produces, requestContentType); str == "" { + res = append(res, errors.InvalidResponseFormat(request.Header.Get(runtime.HeaderAccept), route.Produces)) + } + } + + // now bind the request with the provided binder + // it's assumed the binder will also validate the request and return an error if the + // request is invalid + if binder != nil && len(res) == 0 { + if err := binder.BindRequest(request, route); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContentType gets the parsed value of a content type +// Returns the media type, its charset and a shallow copy of the request +// when its context doesn't contain the content type value, otherwise it returns +// the same request +// Returns the error that runtime.ContentType may retunrs. +func (c *Context) ContentType(request *http.Request) (string, string, *http.Request, error) { + var rCtx = request.Context() + + if v, ok := rCtx.Value(ctxContentType).(*contentTypeValue); ok { + return v.MediaType, v.Charset, request, nil + } + + mt, cs, err := runtime.ContentType(request.Header) + if err != nil { + return "", "", nil, err + } + rCtx = stdContext.WithValue(rCtx, ctxContentType, &contentTypeValue{mt, cs}) + return mt, cs, request.WithContext(rCtx), nil +} + +// LookupRoute looks a route up and returns true when it is found +func (c *Context) LookupRoute(request *http.Request) (*MatchedRoute, bool) { + if route, ok := c.router.Lookup(request.Method, request.URL.EscapedPath()); ok { + return route, ok + } + return nil, false +} + +// RouteInfo tries to match a route for this request +// Returns the matched route, a shallow copy of the request if its context +// contains the matched router, otherwise the same request, and a bool to +// indicate if it the request matches one of the routes, if it doesn't +// then it returns false and nil for the other two return values +func (c *Context) RouteInfo(request *http.Request) (*MatchedRoute, *http.Request, bool) { + var rCtx = request.Context() + + if v, ok := rCtx.Value(ctxMatchedRoute).(*MatchedRoute); ok { + return v, request, ok + } + + if route, ok := c.LookupRoute(request); ok { + rCtx = stdContext.WithValue(rCtx, ctxMatchedRoute, route) + return route, request.WithContext(rCtx), ok + } + + return nil, nil, false +} + +// ResponseFormat negotiates the response content type +// Returns the response format and a shallow copy of the request if its context +// doesn't contain the response format, otherwise the same request +func (c *Context) ResponseFormat(r *http.Request, offers []string) (string, *http.Request) { + var rCtx = r.Context() + + if v, ok := rCtx.Value(ctxResponseFormat).(string); ok { + debugLog("[%s %s] found response format %q in context", r.Method, r.URL.Path, v) + return v, r + } + + format := NegotiateContentType(r, offers, "") + if format != "" { + debugLog("[%s %s] set response format %q in context", r.Method, r.URL.Path, format) + r = r.WithContext(stdContext.WithValue(rCtx, ctxResponseFormat, format)) + } + debugLog("[%s %s] negotiated response format %q", r.Method, r.URL.Path, format) + return format, r +} + +// AllowedMethods gets the allowed methods for the path of this request +func (c *Context) AllowedMethods(request *http.Request) []string { + return c.router.OtherMethods(request.Method, request.URL.EscapedPath()) +} + +// ResetAuth removes the current principal from the request context +func (c *Context) ResetAuth(request *http.Request) *http.Request { + rctx := request.Context() + rctx = stdContext.WithValue(rctx, ctxSecurityPrincipal, nil) + rctx = stdContext.WithValue(rctx, ctxSecurityScopes, nil) + return request.WithContext(rctx) +} + +// Authorize authorizes the request +// Returns the principal object and a shallow copy of the request when its +// context doesn't contain the principal, otherwise the same request or an error +// (the last) if one of the authenticators returns one or an Unauthenticated error +func (c *Context) Authorize(request *http.Request, route *MatchedRoute) (interface{}, *http.Request, error) { + if route == nil || !route.HasAuth() { + return nil, nil, nil + } + + var rCtx = request.Context() + if v := rCtx.Value(ctxSecurityPrincipal); v != nil { + return v, request, nil + } + + applies, usr, err := route.Authenticators.Authenticate(request, route) + if !applies || err != nil || !route.Authenticators.AllowsAnonymous() && usr == nil { + if err != nil { + return nil, nil, err + } + return nil, nil, errors.Unauthenticated("invalid credentials") + } + if route.Authorizer != nil { + if err := route.Authorizer.Authorize(request, usr); err != nil { + if _, ok := err.(errors.Error); ok { + return nil, nil, err + } + + return nil, nil, errors.New(http.StatusForbidden, err.Error()) + } + } + + rCtx = request.Context() + + rCtx = stdContext.WithValue(rCtx, ctxSecurityPrincipal, usr) + rCtx = stdContext.WithValue(rCtx, ctxSecurityScopes, route.Authenticator.AllScopes()) + return usr, request.WithContext(rCtx), nil +} + +// BindAndValidate binds and validates the request +// Returns the validation map and a shallow copy of the request when its context +// doesn't contain the validation, otherwise it returns the same request or an +// CompositeValidationError error +func (c *Context) BindAndValidate(request *http.Request, matched *MatchedRoute) (interface{}, *http.Request, error) { + var rCtx = request.Context() + + if v, ok := rCtx.Value(ctxBoundParams).(*validation); ok { + debugLog("got cached validation (valid: %t)", len(v.result) == 0) + if len(v.result) > 0 { + return v.bound, request, errors.CompositeValidationError(v.result...) + } + return v.bound, request, nil + } + result := validateRequest(c, request, matched) + rCtx = stdContext.WithValue(rCtx, ctxBoundParams, result) + request = request.WithContext(rCtx) + if len(result.result) > 0 { + return result.bound, request, errors.CompositeValidationError(result.result...) + } + debugLog("no validation errors found") + return result.bound, request, nil +} + +// NotFound the default not found responder for when no route has been matched yet +func (c *Context) NotFound(rw http.ResponseWriter, r *http.Request) { + c.Respond(rw, r, []string{c.api.DefaultProduces()}, nil, errors.NotFound("not found")) +} + +// Respond renders the response after doing some content negotiation +func (c *Context) Respond(rw http.ResponseWriter, r *http.Request, produces []string, route *MatchedRoute, data interface{}) { + debugLog("responding to %s %s with produces: %v", r.Method, r.URL.Path, produces) + offers := []string{} + for _, mt := range produces { + if mt != c.api.DefaultProduces() { + offers = append(offers, mt) + } + } + // the default producer is last so more specific producers take precedence + offers = append(offers, c.api.DefaultProduces()) + debugLog("offers: %v", offers) + + var format string + format, r = c.ResponseFormat(r, offers) + rw.Header().Set(runtime.HeaderContentType, format) + + if resp, ok := data.(Responder); ok { + producers := route.Producers + prod, ok := producers[format] + if !ok { + prods := c.api.ProducersFor(normalizeOffers([]string{c.api.DefaultProduces()})) + pr, ok := prods[c.api.DefaultProduces()] + if !ok { + panic(errors.New(http.StatusInternalServerError, "can't find a producer for "+format)) + } + prod = pr + } + resp.WriteResponse(rw, prod) + return + } + + if err, ok := data.(error); ok { + if format == "" { + rw.Header().Set(runtime.HeaderContentType, runtime.JSONMime) + } + + if realm := security.FailedBasicAuth(r); realm != "" { + rw.Header().Set("WWW-Authenticate", fmt.Sprintf("Basic realm=%q", realm)) + } + + if route == nil || route.Operation == nil { + c.api.ServeErrorFor("")(rw, r, err) + return + } + c.api.ServeErrorFor(route.Operation.ID)(rw, r, err) + return + } + + if route == nil || route.Operation == nil { + rw.WriteHeader(200) + if r.Method == "HEAD" { + return + } + producers := c.api.ProducersFor(normalizeOffers(offers)) + prod, ok := producers[format] + if !ok { + panic(errors.New(http.StatusInternalServerError, "can't find a producer for "+format)) + } + if err := prod.Produce(rw, data); err != nil { + panic(err) // let the recovery middleware deal with this + } + return + } + + if _, code, ok := route.Operation.SuccessResponse(); ok { + rw.WriteHeader(code) + if code == 204 || r.Method == "HEAD" { + return + } + + producers := route.Producers + prod, ok := producers[format] + if !ok { + if !ok { + prods := c.api.ProducersFor(normalizeOffers([]string{c.api.DefaultProduces()})) + pr, ok := prods[c.api.DefaultProduces()] + if !ok { + panic(errors.New(http.StatusInternalServerError, "can't find a producer for "+format)) + } + prod = pr + } + } + if err := prod.Produce(rw, data); err != nil { + panic(err) // let the recovery middleware deal with this + } + return + } + + c.api.ServeErrorFor(route.Operation.ID)(rw, r, errors.New(http.StatusInternalServerError, "can't produce response")) +} + +func (c *Context) APIHandlerSwaggerUI(builder Builder) http.Handler { + b := builder + if b == nil { + b = PassthroughBuilder + } + + var title string + sp := c.spec.Spec() + if sp != nil && sp.Info != nil && sp.Info.Title != "" { + title = sp.Info.Title + } + + swaggerUIOpts := SwaggerUIOpts{ + BasePath: c.BasePath(), + Title: title, + } + + return Spec("", c.spec.Raw(), SwaggerUI(swaggerUIOpts, c.RoutesHandler(b))) +} + +// APIHandler returns a handler to serve the API, this includes a swagger spec, router and the contract defined in the swagger spec +func (c *Context) APIHandler(builder Builder) http.Handler { + b := builder + if b == nil { + b = PassthroughBuilder + } + + var title string + sp := c.spec.Spec() + if sp != nil && sp.Info != nil && sp.Info.Title != "" { + title = sp.Info.Title + } + + redocOpts := RedocOpts{ + BasePath: c.BasePath(), + Title: title, + } + + return Spec("", c.spec.Raw(), Redoc(redocOpts, c.RoutesHandler(b))) +} + +// RoutesHandler returns a handler to serve the API, just the routes and the contract defined in the swagger spec +func (c *Context) RoutesHandler(builder Builder) http.Handler { + b := builder + if b == nil { + b = PassthroughBuilder + } + return NewRouter(c, b(NewOperationExecutor(c))) +} diff --git a/vendor/github.com/go-openapi/runtime/middleware/denco/LICENSE b/vendor/github.com/go-openapi/runtime/middleware/denco/LICENSE new file mode 100644 index 00000000000..e65039ad84c --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/middleware/denco/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2014 Naoya Inada + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/github.com/go-openapi/runtime/middleware/denco/README.md b/vendor/github.com/go-openapi/runtime/middleware/denco/README.md new file mode 100644 index 00000000000..30109e17d5e --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/middleware/denco/README.md @@ -0,0 +1,180 @@ +# Denco [![Build Status](https://travis-ci.org/naoina/denco.png?branch=master)](https://travis-ci.org/naoina/denco) + +The fast and flexible HTTP request router for [Go](http://golang.org). + +Denco is based on Double-Array implementation of [Kocha-urlrouter](https://github.com/naoina/kocha-urlrouter). +However, Denco is optimized and some features added. + +## Features + +* Fast (See [go-http-routing-benchmark](https://github.com/naoina/go-http-routing-benchmark)) +* [URL patterns](#url-patterns) (`/foo/:bar` and `/foo/*wildcard`) +* Small (but enough) URL router API +* HTTP request multiplexer like `http.ServeMux` + +## Installation + + go get -u github.com/go-openapi/runtime/middleware/denco + +## Using as HTTP request multiplexer + +```go +package main + +import ( + "fmt" + "log" + "net/http" + + "github.com/go-openapi/runtime/middleware/denco" +) + +func Index(w http.ResponseWriter, r *http.Request, params denco.Params) { + fmt.Fprintf(w, "Welcome to Denco!\n") +} + +func User(w http.ResponseWriter, r *http.Request, params denco.Params) { + fmt.Fprintf(w, "Hello %s!\n", params.Get("name")) +} + +func main() { + mux := denco.NewMux() + handler, err := mux.Build([]denco.Handler{ + mux.GET("/", Index), + mux.GET("/user/:name", User), + mux.POST("/user/:name", User), + }) + if err != nil { + panic(err) + } + log.Fatal(http.ListenAndServe(":8080", handler)) +} +``` + +## Using as URL router + +```go +package main + +import ( + "fmt" + + "github.com/go-openapi/runtime/middleware/denco" +) + +type route struct { + name string +} + +func main() { + router := denco.New() + router.Build([]denco.Record{ + {"/", &route{"root"}}, + {"/user/:id", &route{"user"}}, + {"/user/:name/:id", &route{"username"}}, + {"/static/*filepath", &route{"static"}}, + }) + + data, params, found := router.Lookup("/") + // print `&main.route{name:"root"}, denco.Params(nil), true`. + fmt.Printf("%#v, %#v, %#v\n", data, params, found) + + data, params, found = router.Lookup("/user/hoge") + // print `&main.route{name:"user"}, denco.Params{denco.Param{Name:"id", Value:"hoge"}}, true`. + fmt.Printf("%#v, %#v, %#v\n", data, params, found) + + data, params, found = router.Lookup("/user/hoge/7") + // print `&main.route{name:"username"}, denco.Params{denco.Param{Name:"name", Value:"hoge"}, denco.Param{Name:"id", Value:"7"}}, true`. + fmt.Printf("%#v, %#v, %#v\n", data, params, found) + + data, params, found = router.Lookup("/static/path/to/file") + // print `&main.route{name:"static"}, denco.Params{denco.Param{Name:"filepath", Value:"path/to/file"}}, true`. + fmt.Printf("%#v, %#v, %#v\n", data, params, found) +} +``` + +See [Godoc](http://godoc.org/github.com/go-openapi/runtime/middleware/denco) for more details. + +## Getting the value of path parameter + +You can get the value of path parameter by 2 ways. + +1. Using [`denco.Params.Get`](http://godoc.org/github.com/go-openapi/runtime/middleware/denco#Params.Get) method +2. Find by loop + +```go +package main + +import ( + "fmt" + + "github.com/go-openapi/runtime/middleware/denco" +) + +func main() { + router := denco.New() + if err := router.Build([]denco.Record{ + {"/user/:name/:id", "route1"}, + }); err != nil { + panic(err) + } + + // 1. Using denco.Params.Get method. + _, params, _ := router.Lookup("/user/alice/1") + name := params.Get("name") + if name != "" { + fmt.Printf("Hello %s.\n", name) // prints "Hello alice.". + } + + // 2. Find by loop. + for _, param := range params { + if param.Name == "name" { + fmt.Printf("Hello %s.\n", name) // prints "Hello alice.". + } + } +} +``` + +## URL patterns + +Denco's route matching strategy is "most nearly matching". + +When routes `/:name` and `/alice` have been built, URI `/alice` matches the route `/alice`, not `/:name`. +Because URI `/alice` is more match with the route `/alice` than `/:name`. + +For more example, when routes below have been built: + +``` +/user/alice +/user/:name +/user/:name/:id +/user/alice/:id +/user/:id/bob +``` + +Routes matching are: + +``` +/user/alice => "/user/alice" (no match with "/user/:name") +/user/bob => "/user/:name" +/user/naoina/1 => "/user/:name/1" +/user/alice/1 => "/user/alice/:id" (no match with "/user/:name/:id") +/user/1/bob => "/user/:id/bob" (no match with "/user/:name/:id") +/user/alice/bob => "/user/alice/:id" (no match with "/user/:name/:id" and "/user/:id/bob") +``` + +## Limitation + +Denco has some limitations below. + +* Number of param records (such as `/:name`) must be less than 2^22 +* Number of elements of internal slice must be less than 2^22 + +## Benchmarks + + cd $GOPATH/github.com/go-openapi/runtime/middleware/denco + go test -bench . -benchmem + +## License + +Denco is licensed under the MIT License. diff --git a/vendor/github.com/go-openapi/runtime/middleware/denco/router.go b/vendor/github.com/go-openapi/runtime/middleware/denco/router.go new file mode 100644 index 00000000000..5d2691ec369 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/middleware/denco/router.go @@ -0,0 +1,460 @@ +// Package denco provides fast URL router. +package denco + +import ( + "fmt" + "sort" + "strings" +) + +const ( + // ParamCharacter is a special character for path parameter. + ParamCharacter = ':' + + // WildcardCharacter is a special character for wildcard path parameter. + WildcardCharacter = '*' + + // TerminationCharacter is a special character for end of path. + TerminationCharacter = '#' + + // SeparatorCharacter separates path segments. + SeparatorCharacter = '/' + + // PathParamCharacter indicates a RESTCONF path param + PathParamCharacter = '=' + + // MaxSize is max size of records and internal slice. + MaxSize = (1 << 22) - 1 +) + +// Router represents a URL router. +type Router struct { + // SizeHint expects the maximum number of path parameters in records to Build. + // SizeHint will be used to determine the capacity of the memory to allocate. + // By default, SizeHint will be determined from given records to Build. + SizeHint int + + static map[string]interface{} + param *doubleArray +} + +// New returns a new Router. +func New() *Router { + return &Router{ + SizeHint: -1, + static: make(map[string]interface{}), + param: newDoubleArray(), + } +} + +// Lookup returns data and path parameters that associated with path. +// params is a slice of the Param that arranged in the order in which parameters appeared. +// e.g. when built routing path is "/path/to/:id/:name" and given path is "/path/to/1/alice". params order is [{"id": "1"}, {"name": "alice"}], not [{"name": "alice"}, {"id": "1"}]. +func (rt *Router) Lookup(path string) (data interface{}, params Params, found bool) { + if data, found := rt.static[path]; found { + return data, nil, true + } + if len(rt.param.node) == 1 { + return nil, nil, false + } + nd, params, found := rt.param.lookup(path, make([]Param, 0, rt.SizeHint), 1) + if !found { + return nil, nil, false + } + for i := 0; i < len(params); i++ { + params[i].Name = nd.paramNames[i] + } + return nd.data, params, true +} + +// Build builds URL router from records. +func (rt *Router) Build(records []Record) error { + statics, params := makeRecords(records) + if len(params) > MaxSize { + return fmt.Errorf("denco: too many records") + } + if rt.SizeHint < 0 { + rt.SizeHint = 0 + for _, p := range params { + size := 0 + for _, k := range p.Key { + if k == ParamCharacter || k == WildcardCharacter { + size++ + } + } + if size > rt.SizeHint { + rt.SizeHint = size + } + } + } + for _, r := range statics { + rt.static[r.Key] = r.Value + } + if err := rt.param.build(params, 1, 0, make(map[int]struct{})); err != nil { + return err + } + return nil +} + +// Param represents name and value of path parameter. +type Param struct { + Name string + Value string +} + +// Params represents the name and value of path parameters. +type Params []Param + +// Get gets the first value associated with the given name. +// If there are no values associated with the key, Get returns "". +func (ps Params) Get(name string) string { + for _, p := range ps { + if p.Name == name { + return p.Value + } + } + return "" +} + +type doubleArray struct { + bc []baseCheck + node []*node +} + +func newDoubleArray() *doubleArray { + return &doubleArray{ + bc: []baseCheck{0}, + node: []*node{nil}, // A start index is adjusting to 1 because 0 will be used as a mark of non-existent node. + } +} + +// baseCheck contains BASE, CHECK and Extra flags. +// From the top, 22bits of BASE, 2bits of Extra flags and 8bits of CHECK. +// +// BASE (22bit) | Extra flags (2bit) | CHECK (8bit) +// |----------------------|--|--------| +// 32 10 8 0 +type baseCheck uint32 + +func (bc baseCheck) Base() int { + return int(bc >> 10) +} + +func (bc *baseCheck) SetBase(base int) { + *bc |= baseCheck(base) << 10 +} + +func (bc baseCheck) Check() byte { + return byte(bc) +} + +func (bc *baseCheck) SetCheck(check byte) { + *bc |= baseCheck(check) +} + +func (bc baseCheck) IsEmpty() bool { + return bc&0xfffffcff == 0 +} + +func (bc baseCheck) IsSingleParam() bool { + return bc¶mTypeSingle == paramTypeSingle +} + +func (bc baseCheck) IsWildcardParam() bool { + return bc¶mTypeWildcard == paramTypeWildcard +} + +func (bc baseCheck) IsAnyParam() bool { + return bc¶mTypeAny != 0 +} + +func (bc *baseCheck) SetSingleParam() { + *bc |= (1 << 8) +} + +func (bc *baseCheck) SetWildcardParam() { + *bc |= (1 << 9) +} + +const ( + paramTypeSingle = 0x0100 + paramTypeWildcard = 0x0200 + paramTypeAny = 0x0300 +) + +func (da *doubleArray) lookup(path string, params []Param, idx int) (*node, []Param, bool) { + indices := make([]uint64, 0, 1) + for i := 0; i < len(path); i++ { + if da.bc[idx].IsAnyParam() { + indices = append(indices, (uint64(i)<<32)|(uint64(idx)&0xffffffff)) + } + c := path[i] + if idx = nextIndex(da.bc[idx].Base(), c); idx >= len(da.bc) || da.bc[idx].Check() != c { + goto BACKTRACKING + } + } + if next := nextIndex(da.bc[idx].Base(), TerminationCharacter); next < len(da.bc) && da.bc[next].Check() == TerminationCharacter { + return da.node[da.bc[next].Base()], params, true + } +BACKTRACKING: + for j := len(indices) - 1; j >= 0; j-- { + i, idx := int(indices[j]>>32), int(indices[j]&0xffffffff) + if da.bc[idx].IsSingleParam() { + idx := nextIndex(da.bc[idx].Base(), ParamCharacter) + if idx >= len(da.bc) { + break + } + next := NextSeparator(path, i) + params := append(params, Param{Value: path[i:next]}) + if nd, params, found := da.lookup(path[next:], params, idx); found { + return nd, params, true + } + } + if da.bc[idx].IsWildcardParam() { + idx := nextIndex(da.bc[idx].Base(), WildcardCharacter) + params := append(params, Param{Value: path[i:]}) + return da.node[da.bc[idx].Base()], params, true + } + } + return nil, nil, false +} + +// build builds double-array from records. +func (da *doubleArray) build(srcs []*record, idx, depth int, usedBase map[int]struct{}) error { + sort.Stable(recordSlice(srcs)) + base, siblings, leaf, err := da.arrange(srcs, idx, depth, usedBase) + if err != nil { + return err + } + if leaf != nil { + nd, err := makeNode(leaf) + if err != nil { + return err + } + da.bc[idx].SetBase(len(da.node)) + da.node = append(da.node, nd) + } + for _, sib := range siblings { + da.setCheck(nextIndex(base, sib.c), sib.c) + } + for _, sib := range siblings { + records := srcs[sib.start:sib.end] + switch sib.c { + case ParamCharacter: + for _, r := range records { + next := NextSeparator(r.Key, depth+1) + name := r.Key[depth+1 : next] + r.paramNames = append(r.paramNames, name) + r.Key = r.Key[next:] + } + da.bc[idx].SetSingleParam() + if err := da.build(records, nextIndex(base, sib.c), 0, usedBase); err != nil { + return err + } + case WildcardCharacter: + r := records[0] + name := r.Key[depth+1 : len(r.Key)-1] + r.paramNames = append(r.paramNames, name) + r.Key = "" + da.bc[idx].SetWildcardParam() + if err := da.build(records, nextIndex(base, sib.c), 0, usedBase); err != nil { + return err + } + default: + if err := da.build(records, nextIndex(base, sib.c), depth+1, usedBase); err != nil { + return err + } + } + } + return nil +} + +// setBase sets BASE. +func (da *doubleArray) setBase(i, base int) { + da.bc[i].SetBase(base) +} + +// setCheck sets CHECK. +func (da *doubleArray) setCheck(i int, check byte) { + da.bc[i].SetCheck(check) +} + +// findEmptyIndex returns an index of unused BASE/CHECK node. +func (da *doubleArray) findEmptyIndex(start int) int { + i := start + for ; i < len(da.bc); i++ { + if da.bc[i].IsEmpty() { + break + } + } + return i +} + +// findBase returns good BASE. +func (da *doubleArray) findBase(siblings []sibling, start int, usedBase map[int]struct{}) (base int) { + for idx, firstChar := start+1, siblings[0].c; ; idx = da.findEmptyIndex(idx + 1) { + base = nextIndex(idx, firstChar) + if _, used := usedBase[base]; used { + continue + } + i := 0 + for ; i < len(siblings); i++ { + next := nextIndex(base, siblings[i].c) + if len(da.bc) <= next { + da.bc = append(da.bc, make([]baseCheck, next-len(da.bc)+1)...) + } + if !da.bc[next].IsEmpty() { + break + } + } + if i == len(siblings) { + break + } + } + usedBase[base] = struct{}{} + return base +} + +func (da *doubleArray) arrange(records []*record, idx, depth int, usedBase map[int]struct{}) (base int, siblings []sibling, leaf *record, err error) { + siblings, leaf, err = makeSiblings(records, depth) + if err != nil { + return -1, nil, nil, err + } + if len(siblings) < 1 { + return -1, nil, leaf, nil + } + base = da.findBase(siblings, idx, usedBase) + if base > MaxSize { + return -1, nil, nil, fmt.Errorf("denco: too many elements of internal slice") + } + da.setBase(idx, base) + return base, siblings, leaf, err +} + +// node represents a node of Double-Array. +type node struct { + data interface{} + + // Names of path parameters. + paramNames []string +} + +// makeNode returns a new node from record. +func makeNode(r *record) (*node, error) { + dups := make(map[string]bool) + for _, name := range r.paramNames { + if dups[name] { + return nil, fmt.Errorf("denco: path parameter `%v' is duplicated in the key `%v'", name, r.Key) + } + dups[name] = true + } + return &node{data: r.Value, paramNames: r.paramNames}, nil +} + +// sibling represents an intermediate data of build for Double-Array. +type sibling struct { + // An index of start of duplicated characters. + start int + + // An index of end of duplicated characters. + end int + + // A character of sibling. + c byte +} + +// nextIndex returns a next index of array of BASE/CHECK. +func nextIndex(base int, c byte) int { + return base ^ int(c) +} + +// makeSiblings returns slice of sibling. +func makeSiblings(records []*record, depth int) (sib []sibling, leaf *record, err error) { + var ( + pc byte + n int + ) + for i, r := range records { + if len(r.Key) <= depth { + leaf = r + continue + } + c := r.Key[depth] + switch { + case pc < c: + sib = append(sib, sibling{start: i, c: c}) + case pc == c: + continue + default: + return nil, nil, fmt.Errorf("denco: BUG: routing table hasn't been sorted") + } + if n > 0 { + sib[n-1].end = i + } + pc = c + n++ + } + if n == 0 { + return nil, leaf, nil + } + sib[n-1].end = len(records) + return sib, leaf, nil +} + +// Record represents a record data for router construction. +type Record struct { + // Key for router construction. + Key string + + // Result value for Key. + Value interface{} +} + +// NewRecord returns a new Record. +func NewRecord(key string, value interface{}) Record { + return Record{ + Key: key, + Value: value, + } +} + +// record represents a record that use to build the Double-Array. +type record struct { + Record + paramNames []string +} + +// makeRecords returns the records that use to build Double-Arrays. +func makeRecords(srcs []Record) (statics, params []*record) { + termChar := string(TerminationCharacter) + paramPrefix := string(SeparatorCharacter) + string(ParamCharacter) + wildcardPrefix := string(SeparatorCharacter) + string(WildcardCharacter) + restconfPrefix := string(PathParamCharacter) + string(ParamCharacter) + for _, r := range srcs { + if strings.Contains(r.Key, paramPrefix) || strings.Contains(r.Key, wildcardPrefix) ||strings.Contains(r.Key, restconfPrefix){ + r.Key += termChar + params = append(params, &record{Record: r}) + } else { + statics = append(statics, &record{Record: r}) + } + } + return statics, params +} + +// recordSlice represents a slice of Record for sort and implements the sort.Interface. +type recordSlice []*record + +// Len implements the sort.Interface.Len. +func (rs recordSlice) Len() int { + return len(rs) +} + +// Less implements the sort.Interface.Less. +func (rs recordSlice) Less(i, j int) bool { + return rs[i].Key < rs[j].Key +} + +// Swap implements the sort.Interface.Swap. +func (rs recordSlice) Swap(i, j int) { + rs[i], rs[j] = rs[j], rs[i] +} diff --git a/vendor/github.com/go-openapi/runtime/middleware/denco/server.go b/vendor/github.com/go-openapi/runtime/middleware/denco/server.go new file mode 100644 index 00000000000..0886713c181 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/middleware/denco/server.go @@ -0,0 +1,106 @@ +package denco + +import ( + "net/http" +) + +// Mux represents a multiplexer for HTTP request. +type Mux struct{} + +// NewMux returns a new Mux. +func NewMux() *Mux { + return &Mux{} +} + +// GET is shorthand of Mux.Handler("GET", path, handler). +func (m *Mux) GET(path string, handler HandlerFunc) Handler { + return m.Handler("GET", path, handler) +} + +// POST is shorthand of Mux.Handler("POST", path, handler). +func (m *Mux) POST(path string, handler HandlerFunc) Handler { + return m.Handler("POST", path, handler) +} + +// PUT is shorthand of Mux.Handler("PUT", path, handler). +func (m *Mux) PUT(path string, handler HandlerFunc) Handler { + return m.Handler("PUT", path, handler) +} + +// HEAD is shorthand of Mux.Handler("HEAD", path, handler). +func (m *Mux) HEAD(path string, handler HandlerFunc) Handler { + return m.Handler("HEAD", path, handler) +} + +// Handler returns a handler for HTTP method. +func (m *Mux) Handler(method, path string, handler HandlerFunc) Handler { + return Handler{ + Method: method, + Path: path, + Func: handler, + } +} + +// Build builds a http.Handler. +func (m *Mux) Build(handlers []Handler) (http.Handler, error) { + recordMap := make(map[string][]Record) + for _, h := range handlers { + recordMap[h.Method] = append(recordMap[h.Method], NewRecord(h.Path, h.Func)) + } + mux := newServeMux() + for m, records := range recordMap { + router := New() + if err := router.Build(records); err != nil { + return nil, err + } + mux.routers[m] = router + } + return mux, nil +} + +// Handler represents a handler of HTTP request. +type Handler struct { + // Method is an HTTP method. + Method string + + // Path is a routing path for handler. + Path string + + // Func is a function of handler of HTTP request. + Func HandlerFunc +} + +// The HandlerFunc type is aliased to type of handler function. +type HandlerFunc func(w http.ResponseWriter, r *http.Request, params Params) + +type serveMux struct { + routers map[string]*Router +} + +func newServeMux() *serveMux { + return &serveMux{ + routers: make(map[string]*Router), + } +} + +// ServeHTTP implements http.Handler interface. +func (mux *serveMux) ServeHTTP(w http.ResponseWriter, r *http.Request) { + handler, params := mux.handler(r.Method, r.URL.Path) + handler(w, r, params) +} + +func (mux *serveMux) handler(method, path string) (HandlerFunc, []Param) { + if router, found := mux.routers[method]; found { + if handler, params, found := router.Lookup(path); found { + return handler.(HandlerFunc), params + } + } + return NotFound, nil +} + +// NotFound replies to the request with an HTTP 404 not found error. +// NotFound is called when unknown HTTP method or a handler not found. +// If you want to use the your own NotFound handler, please overwrite this variable. +var NotFound = func(w http.ResponseWriter, r *http.Request, _ Params) { + http.NotFound(w, r) +} diff --git a/vendor/github.com/go-openapi/runtime/middleware/denco/util.go b/vendor/github.com/go-openapi/runtime/middleware/denco/util.go new file mode 100644 index 00000000000..edc1f6ab80a --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/middleware/denco/util.go @@ -0,0 +1,12 @@ +package denco + +// NextSeparator returns an index of next separator in path. +func NextSeparator(path string, start int) int { + for start < len(path) { + if c := path[start]; c == '/' || c == TerminationCharacter { + break + } + start++ + } + return start +} diff --git a/vendor/github.com/go-openapi/runtime/middleware/doc.go b/vendor/github.com/go-openapi/runtime/middleware/doc.go new file mode 100644 index 00000000000..eaf90606ac3 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/middleware/doc.go @@ -0,0 +1,62 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*Package middleware provides the library with helper functions for serving swagger APIs. + +Pseudo middleware handler + + import ( + "net/http" + + "github.com/go-openapi/errors" + ) + + func newCompleteMiddleware(ctx *Context) http.Handler { + return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { + // use context to lookup routes + if matched, ok := ctx.RouteInfo(r); ok { + + if matched.NeedsAuth() { + if _, err := ctx.Authorize(r, matched); err != nil { + ctx.Respond(rw, r, matched.Produces, matched, err) + return + } + } + + bound, validation := ctx.BindAndValidate(r, matched) + if validation != nil { + ctx.Respond(rw, r, matched.Produces, matched, validation) + return + } + + result, err := matched.Handler.Handle(bound) + if err != nil { + ctx.Respond(rw, r, matched.Produces, matched, err) + return + } + + ctx.Respond(rw, r, matched.Produces, matched, result) + return + } + + // Not found, check if it exists in the other methods first + if others := ctx.AllowedMethods(r); len(others) > 0 { + ctx.Respond(rw, r, ctx.spec.RequiredProduces(), nil, errors.MethodNotAllowed(r.Method, others)) + return + } + ctx.Respond(rw, r, ctx.spec.RequiredProduces(), nil, errors.NotFound("path %s was not found", r.URL.Path)) + }) + } +*/ +package middleware diff --git a/vendor/github.com/go-openapi/runtime/middleware/go18.go b/vendor/github.com/go-openapi/runtime/middleware/go18.go new file mode 100644 index 00000000000..75c762c0948 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/middleware/go18.go @@ -0,0 +1,9 @@ +// +build go1.8 + +package middleware + +import "net/url" + +func pathUnescape(path string) (string, error) { + return url.PathUnescape(path) +} diff --git a/vendor/github.com/go-openapi/runtime/middleware/header/header.go b/vendor/github.com/go-openapi/runtime/middleware/header/header.go new file mode 100644 index 00000000000..e069743e30a --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/middleware/header/header.go @@ -0,0 +1,329 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd. + +// this file was taken from the github.com/golang/gddo repository + +// Package header provides functions for parsing HTTP headers. +package header + +import ( + "net/http" + "strings" + "time" +) + +// Octet types from RFC 2616. +var octetTypes [256]octetType + +type octetType byte + +const ( + isToken octetType = 1 << iota + isSpace +) + +func init() { + // OCTET = + // CHAR = + // CTL = + // CR = + // LF = + // SP = + // HT = + // <"> = + // CRLF = CR LF + // LWS = [CRLF] 1*( SP | HT ) + // TEXT = + // separators = "(" | ")" | "<" | ">" | "@" | "," | ";" | ":" | "\" | <"> + // | "/" | "[" | "]" | "?" | "=" | "{" | "}" | SP | HT + // token = 1* + // qdtext = > + + for c := 0; c < 256; c++ { + var t octetType + isCtl := c <= 31 || c == 127 + isChar := 0 <= c && c <= 127 + isSeparator := strings.ContainsRune(" \t\"(),/:;<=>?@[]\\{}", rune(c)) + if strings.ContainsRune(" \t\r\n", rune(c)) { + t |= isSpace + } + if isChar && !isCtl && !isSeparator { + t |= isToken + } + octetTypes[c] = t + } +} + +// Copy returns a shallow copy of the header. +func Copy(header http.Header) http.Header { + h := make(http.Header) + for k, vs := range header { + h[k] = vs + } + return h +} + +var timeLayouts = []string{"Mon, 02 Jan 2006 15:04:05 GMT", time.RFC850, time.ANSIC} + +// ParseTime parses the header as time. The zero value is returned if the +// header is not present or there is an error parsing the +// header. +func ParseTime(header http.Header, key string) time.Time { + if s := header.Get(key); s != "" { + for _, layout := range timeLayouts { + if t, err := time.Parse(layout, s); err == nil { + return t.UTC() + } + } + } + return time.Time{} +} + +// ParseList parses a comma separated list of values. Commas are ignored in +// quoted strings. Quoted values are not unescaped or unquoted. Whitespace is +// trimmed. +func ParseList(header http.Header, key string) []string { + var result []string + for _, s := range header[http.CanonicalHeaderKey(key)] { + begin := 0 + end := 0 + escape := false + quote := false + for i := 0; i < len(s); i++ { + b := s[i] + switch { + case escape: + escape = false + end = i + 1 + case quote: + switch b { + case '\\': + escape = true + case '"': + quote = false + } + end = i + 1 + case b == '"': + quote = true + end = i + 1 + case octetTypes[b]&isSpace != 0: + if begin == end { + begin = i + 1 + end = begin + } + case b == ',': + if begin < end { + result = append(result, s[begin:end]) + } + begin = i + 1 + end = begin + default: + end = i + 1 + } + } + if begin < end { + result = append(result, s[begin:end]) + } + } + return result +} + +// ParseValueAndParams parses a comma separated list of values with optional +// semicolon separated name-value pairs. Content-Type and Content-Disposition +// headers are in this format. +func ParseValueAndParams(header http.Header, key string) (string, map[string]string) { + return parseValueAndParams(header.Get(key)) +} + +func parseValueAndParams(s string) (value string, params map[string]string) { + params = make(map[string]string) + value, s = expectTokenSlash(s) + if value == "" { + return + } + value = strings.ToLower(value) + s = skipSpace(s) + for strings.HasPrefix(s, ";") { + var pkey string + pkey, s = expectToken(skipSpace(s[1:])) + if pkey == "" { + return + } + if !strings.HasPrefix(s, "=") { + return + } + var pvalue string + pvalue, s = expectTokenOrQuoted(s[1:]) + if pvalue == "" { + return + } + pkey = strings.ToLower(pkey) + params[pkey] = pvalue + s = skipSpace(s) + } + return +} + +// AcceptSpec ... +type AcceptSpec struct { + Value string + Q float64 +} + +// ParseAccept2 ... +func ParseAccept2(header http.Header, key string) (specs []AcceptSpec) { + for _, en := range ParseList(header, key) { + v, p := parseValueAndParams(en) + var spec AcceptSpec + spec.Value = v + spec.Q = 1.0 + if p != nil { + if q, ok := p["q"]; ok { + spec.Q, _ = expectQuality(q) + } + } + if spec.Q < 0.0 { + continue + } + specs = append(specs, spec) + } + + return +} + +// ParseAccept parses Accept* headers. +func ParseAccept(header http.Header, key string) (specs []AcceptSpec) { +loop: + for _, s := range header[key] { + for { + var spec AcceptSpec + spec.Value, s = expectTokenSlash(s) + if spec.Value == "" { + continue loop + } + spec.Q = 1.0 + s = skipSpace(s) + if strings.HasPrefix(s, ";") { + s = skipSpace(s[1:]) + for !strings.HasPrefix(s, "q=") && s != "" && !strings.HasPrefix(s, ",") { + s = skipSpace(s[1:]) + } + if strings.HasPrefix(s, "q=") { + spec.Q, s = expectQuality(s[2:]) + if spec.Q < 0.0 { + continue loop + } + } + } + specs = append(specs, spec) + s = skipSpace(s) + if !strings.HasPrefix(s, ",") { + continue loop + } + s = skipSpace(s[1:]) + } + } + return +} + +func skipSpace(s string) (rest string) { + i := 0 + for ; i < len(s); i++ { + if octetTypes[s[i]]&isSpace == 0 { + break + } + } + return s[i:] +} + +func expectToken(s string) (token, rest string) { + i := 0 + for ; i < len(s); i++ { + if octetTypes[s[i]]&isToken == 0 { + break + } + } + return s[:i], s[i:] +} + +func expectTokenSlash(s string) (token, rest string) { + i := 0 + for ; i < len(s); i++ { + b := s[i] + if (octetTypes[b]&isToken == 0) && b != '/' { + break + } + } + return s[:i], s[i:] +} + +func expectQuality(s string) (q float64, rest string) { + switch { + case len(s) == 0: + return -1, "" + case s[0] == '0': + // q is already 0 + s = s[1:] + case s[0] == '1': + s = s[1:] + q = 1 + case s[0] == '.': + // q is already 0 + default: + return -1, "" + } + if !strings.HasPrefix(s, ".") { + return q, s + } + s = s[1:] + i := 0 + n := 0 + d := 1 + for ; i < len(s); i++ { + b := s[i] + if b < '0' || b > '9' { + break + } + n = n*10 + int(b) - '0' + d *= 10 + } + return q + float64(n)/float64(d), s[i:] +} + +func expectTokenOrQuoted(s string) (value string, rest string) { + if !strings.HasPrefix(s, "\"") { + return expectToken(s) + } + s = s[1:] + for i := 0; i < len(s); i++ { + switch s[i] { + case '"': + return s[:i], s[i+1:] + case '\\': + p := make([]byte, len(s)-1) + j := copy(p, s[:i]) + escape := true + for i = i + 1; i < len(s); i++ { + b := s[i] + switch { + case escape: + escape = false + p[j] = b + j++ + case b == '\\': + escape = true + case b == '"': + return string(p[:j]), s[i+1:] + default: + p[j] = b + j++ + } + } + return "", "" + } + } + return "", "" +} diff --git a/vendor/github.com/go-openapi/runtime/middleware/negotiate.go b/vendor/github.com/go-openapi/runtime/middleware/negotiate.go new file mode 100644 index 00000000000..a9b6f27d3d3 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/middleware/negotiate.go @@ -0,0 +1,98 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd. + +// this file was taken from the github.com/golang/gddo repository + +package middleware + +import ( + "net/http" + "strings" + + "github.com/go-openapi/runtime/middleware/header" +) + +// NegotiateContentEncoding returns the best offered content encoding for the +// request's Accept-Encoding header. If two offers match with equal weight and +// then the offer earlier in the list is preferred. If no offers are +// acceptable, then "" is returned. +func NegotiateContentEncoding(r *http.Request, offers []string) string { + bestOffer := "identity" + bestQ := -1.0 + specs := header.ParseAccept(r.Header, "Accept-Encoding") + for _, offer := range offers { + for _, spec := range specs { + if spec.Q > bestQ && + (spec.Value == "*" || spec.Value == offer) { + bestQ = spec.Q + bestOffer = offer + } + } + } + if bestQ == 0 { + bestOffer = "" + } + return bestOffer +} + +// NegotiateContentType returns the best offered content type for the request's +// Accept header. If two offers match with equal weight, then the more specific +// offer is preferred. For example, text/* trumps */*. If two offers match +// with equal weight and specificity, then the offer earlier in the list is +// preferred. If no offers match, then defaultOffer is returned. +func NegotiateContentType(r *http.Request, offers []string, defaultOffer string) string { + bestOffer := defaultOffer + bestQ := -1.0 + bestWild := 3 + specs := header.ParseAccept(r.Header, "Accept") + for _, rawOffer := range offers { + offer := normalizeOffer(rawOffer) + // No Accept header: just return the first offer. + if len(specs) == 0 { + return rawOffer + } + for _, spec := range specs { + switch { + case spec.Q == 0.0: + // ignore + case spec.Q < bestQ: + // better match found + case spec.Value == "*/*": + if spec.Q > bestQ || bestWild > 2 { + bestQ = spec.Q + bestWild = 2 + bestOffer = rawOffer + } + case strings.HasSuffix(spec.Value, "/*"): + if strings.HasPrefix(offer, spec.Value[:len(spec.Value)-1]) && + (spec.Q > bestQ || bestWild > 1) { + bestQ = spec.Q + bestWild = 1 + bestOffer = rawOffer + } + default: + if spec.Value == offer && + (spec.Q > bestQ || bestWild > 0) { + bestQ = spec.Q + bestWild = 0 + bestOffer = rawOffer + } + } + } + } + return bestOffer +} + +func normalizeOffers(orig []string) (norm []string) { + for _, o := range orig { + norm = append(norm, normalizeOffer(o)) + } + return +} + +func normalizeOffer(orig string) string { + return strings.SplitN(orig, ";", 2)[0] +} diff --git a/vendor/github.com/go-openapi/runtime/middleware/not_implemented.go b/vendor/github.com/go-openapi/runtime/middleware/not_implemented.go new file mode 100644 index 00000000000..bc6942a0f1b --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/middleware/not_implemented.go @@ -0,0 +1,67 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package middleware + +import ( + "net/http" + + "github.com/go-openapi/runtime" +) + +type errorResp struct { + code int + response interface{} + headers http.Header +} + +func (e *errorResp) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + for k, v := range e.headers { + for _, val := range v { + rw.Header().Add(k, val) + } + } + if e.code > 0 { + rw.WriteHeader(e.code) + } else { + rw.WriteHeader(http.StatusInternalServerError) + } + if err := producer.Produce(rw, e.response); err != nil { + Logger.Printf("failed to write error response: %v", err) + } +} + +// NotImplemented the error response when the response is not implemented +func NotImplemented(message string) Responder { + return Error(http.StatusNotImplemented, message) +} + +// Error creates a generic responder for returning errors, the data will be serialized +// with the matching producer for the request +func Error(code int, data interface{}, headers ...http.Header) Responder { + var hdr http.Header + for _, h := range headers { + for k, v := range h { + if hdr == nil { + hdr = make(http.Header) + } + hdr[k] = v + } + } + return &errorResp{ + code: code, + response: data, + headers: hdr, + } +} diff --git a/vendor/github.com/go-openapi/runtime/middleware/operation.go b/vendor/github.com/go-openapi/runtime/middleware/operation.go new file mode 100644 index 00000000000..1175a63cf29 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/middleware/operation.go @@ -0,0 +1,30 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package middleware + +import "net/http" + +// NewOperationExecutor creates a context aware middleware that handles the operations after routing +func NewOperationExecutor(ctx *Context) http.Handler { + return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { + // use context to lookup routes + route, rCtx, _ := ctx.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + + route.Handler.ServeHTTP(rw, r) + }) +} diff --git a/vendor/github.com/go-openapi/runtime/middleware/parameter.go b/vendor/github.com/go-openapi/runtime/middleware/parameter.go new file mode 100644 index 00000000000..8fa0cf4e464 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/middleware/parameter.go @@ -0,0 +1,481 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package middleware + +import ( + "encoding" + "encoding/base64" + "fmt" + "io" + "net/http" + "reflect" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/spec" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/go-openapi/runtime" +) + +const defaultMaxMemory = 32 << 20 + +var textUnmarshalType = reflect.TypeOf(new(encoding.TextUnmarshaler)).Elem() + +func newUntypedParamBinder(param spec.Parameter, spec *spec.Swagger, formats strfmt.Registry) *untypedParamBinder { + binder := new(untypedParamBinder) + binder.Name = param.Name + binder.parameter = ¶m + binder.formats = formats + if param.In != "body" { + binder.validator = validate.NewParamValidator(¶m, formats) + } else { + binder.validator = validate.NewSchemaValidator(param.Schema, spec, param.Name, formats) + } + + return binder +} + +type untypedParamBinder struct { + parameter *spec.Parameter + formats strfmt.Registry + Name string + validator validate.EntityValidator +} + +func (p *untypedParamBinder) Type() reflect.Type { + return p.typeForSchema(p.parameter.Type, p.parameter.Format, p.parameter.Items) +} + +func (p *untypedParamBinder) typeForSchema(tpe, format string, items *spec.Items) reflect.Type { + switch tpe { + case "boolean": + return reflect.TypeOf(true) + + case "string": + if tt, ok := p.formats.GetType(format); ok { + return tt + } + return reflect.TypeOf("") + + case "integer": + switch format { + case "int8": + return reflect.TypeOf(int8(0)) + case "int16": + return reflect.TypeOf(int16(0)) + case "int32": + return reflect.TypeOf(int32(0)) + case "int64": + return reflect.TypeOf(int64(0)) + default: + return reflect.TypeOf(int64(0)) + } + + case "number": + switch format { + case "float": + return reflect.TypeOf(float32(0)) + case "double": + return reflect.TypeOf(float64(0)) + } + + case "array": + if items == nil { + return nil + } + itemsType := p.typeForSchema(items.Type, items.Format, items.Items) + if itemsType == nil { + return nil + } + return reflect.MakeSlice(reflect.SliceOf(itemsType), 0, 0).Type() + + case "file": + return reflect.TypeOf(&runtime.File{}).Elem() + + case "object": + return reflect.TypeOf(map[string]interface{}{}) + } + return nil +} + +func (p *untypedParamBinder) allowsMulti() bool { + return p.parameter.In == "query" || p.parameter.In == "formData" +} + +func (p *untypedParamBinder) readValue(values runtime.Gettable, target reflect.Value) ([]string, bool, bool, error) { + name, in, cf, tpe := p.parameter.Name, p.parameter.In, p.parameter.CollectionFormat, p.parameter.Type + if tpe == "array" { + if cf == "multi" { + if !p.allowsMulti() { + return nil, false, false, errors.InvalidCollectionFormat(name, in, cf) + } + vv, hasKey, _ := values.GetOK(name) + return vv, false, hasKey, nil + } + + v, hk, hv := values.GetOK(name) + if !hv { + return nil, false, hk, nil + } + d, c, e := p.readFormattedSliceFieldValue(v[len(v)-1], target) + return d, c, hk, e + } + + vv, hk, _ := values.GetOK(name) + return vv, false, hk, nil +} + +func (p *untypedParamBinder) Bind(request *http.Request, routeParams RouteParams, consumer runtime.Consumer, target reflect.Value) error { + // fmt.Println("binding", p.name, "as", p.Type()) + switch p.parameter.In { + case "query": + data, custom, hasKey, err := p.readValue(runtime.Values(request.URL.Query()), target) + if err != nil { + return err + } + if custom { + return nil + } + + return p.bindValue(data, hasKey, target) + + case "header": + data, custom, hasKey, err := p.readValue(runtime.Values(request.Header), target) + if err != nil { + return err + } + if custom { + return nil + } + return p.bindValue(data, hasKey, target) + + case "path": + data, custom, hasKey, err := p.readValue(routeParams, target) + if err != nil { + return err + } + if custom { + return nil + } + return p.bindValue(data, hasKey, target) + + case "formData": + var err error + var mt string + + mt, _, e := runtime.ContentType(request.Header) + if e != nil { + // because of the interface conversion go thinks the error is not nil + // so we first check for nil and then set the err var if it's not nil + err = e + } + + if err != nil { + return errors.InvalidContentType("", []string{"multipart/form-data", "application/x-www-form-urlencoded"}) + } + + if mt != "multipart/form-data" && mt != "application/x-www-form-urlencoded" { + return errors.InvalidContentType(mt, []string{"multipart/form-data", "application/x-www-form-urlencoded"}) + } + + if mt == "multipart/form-data" { + if err = request.ParseMultipartForm(defaultMaxMemory); err != nil { + return errors.NewParseError(p.Name, p.parameter.In, "", err) + } + } + + if err = request.ParseForm(); err != nil { + return errors.NewParseError(p.Name, p.parameter.In, "", err) + } + + if p.parameter.Type == "file" { + file, header, ffErr := request.FormFile(p.parameter.Name) + if ffErr != nil { + return errors.NewParseError(p.Name, p.parameter.In, "", ffErr) + } + target.Set(reflect.ValueOf(runtime.File{Data: file, Header: header})) + return nil + } + + if request.MultipartForm != nil { + data, custom, hasKey, rvErr := p.readValue(runtime.Values(request.MultipartForm.Value), target) + if rvErr != nil { + return rvErr + } + if custom { + return nil + } + return p.bindValue(data, hasKey, target) + } + data, custom, hasKey, err := p.readValue(runtime.Values(request.PostForm), target) + if err != nil { + return err + } + if custom { + return nil + } + return p.bindValue(data, hasKey, target) + + case "body": + newValue := reflect.New(target.Type()) + if !runtime.HasBody(request) { + if p.parameter.Default != nil { + target.Set(reflect.ValueOf(p.parameter.Default)) + } + + return nil + } + if err := consumer.Consume(request.Body, newValue.Interface()); err != nil { + if err == io.EOF && p.parameter.Default != nil { + target.Set(reflect.ValueOf(p.parameter.Default)) + return nil + } + tpe := p.parameter.Type + if p.parameter.Format != "" { + tpe = p.parameter.Format + } + return errors.InvalidType(p.Name, p.parameter.In, tpe, nil) + } + target.Set(reflect.Indirect(newValue)) + return nil + default: + return errors.New(500, fmt.Sprintf("invalid parameter location %q", p.parameter.In)) + } +} + +func (p *untypedParamBinder) bindValue(data []string, hasKey bool, target reflect.Value) error { + if p.parameter.Type == "array" { + return p.setSliceFieldValue(target, p.parameter.Default, data, hasKey) + } + var d string + if len(data) > 0 { + d = data[len(data)-1] + } + return p.setFieldValue(target, p.parameter.Default, d, hasKey) +} + +func (p *untypedParamBinder) setFieldValue(target reflect.Value, defaultValue interface{}, data string, hasKey bool) error { + tpe := p.parameter.Type + if p.parameter.Format != "" { + tpe = p.parameter.Format + } + + if (!hasKey || (!p.parameter.AllowEmptyValue && data == "")) && p.parameter.Required && p.parameter.Default == nil { + return errors.Required(p.Name, p.parameter.In, data) + } + + ok, err := p.tryUnmarshaler(target, defaultValue, data) + if err != nil { + return errors.InvalidType(p.Name, p.parameter.In, tpe, data) + } + if ok { + return nil + } + + defVal := reflect.Zero(target.Type()) + if defaultValue != nil { + defVal = reflect.ValueOf(defaultValue) + } + + if tpe == "byte" { + if data == "" { + if target.CanSet() { + target.SetBytes(defVal.Bytes()) + } + return nil + } + + b, err := base64.StdEncoding.DecodeString(data) + if err != nil { + b, err = base64.URLEncoding.DecodeString(data) + if err != nil { + return errors.InvalidType(p.Name, p.parameter.In, tpe, data) + } + } + if target.CanSet() { + target.SetBytes(b) + } + return nil + } + + switch target.Kind() { + case reflect.Bool: + if data == "" { + if target.CanSet() { + target.SetBool(defVal.Bool()) + } + return nil + } + b, err := swag.ConvertBool(data) + if err != nil { + return err + } + if target.CanSet() { + target.SetBool(b) + } + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + if data == "" { + if target.CanSet() { + rd := defVal.Convert(reflect.TypeOf(int64(0))) + target.SetInt(rd.Int()) + } + return nil + } + i, err := strconv.ParseInt(data, 10, 64) + if err != nil { + return errors.InvalidType(p.Name, p.parameter.In, tpe, data) + } + if target.OverflowInt(i) { + return errors.InvalidType(p.Name, p.parameter.In, tpe, data) + } + if target.CanSet() { + target.SetInt(i) + } + + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + if data == "" { + if target.CanSet() { + rd := defVal.Convert(reflect.TypeOf(uint64(0))) + target.SetUint(rd.Uint()) + } + return nil + } + u, err := strconv.ParseUint(data, 10, 64) + if err != nil { + return errors.InvalidType(p.Name, p.parameter.In, tpe, data) + } + if target.OverflowUint(u) { + return errors.InvalidType(p.Name, p.parameter.In, tpe, data) + } + if target.CanSet() { + target.SetUint(u) + } + + case reflect.Float32, reflect.Float64: + if data == "" { + if target.CanSet() { + rd := defVal.Convert(reflect.TypeOf(float64(0))) + target.SetFloat(rd.Float()) + } + return nil + } + f, err := strconv.ParseFloat(data, 64) + if err != nil { + return errors.InvalidType(p.Name, p.parameter.In, tpe, data) + } + if target.OverflowFloat(f) { + return errors.InvalidType(p.Name, p.parameter.In, tpe, data) + } + if target.CanSet() { + target.SetFloat(f) + } + + case reflect.String: + value := data + if value == "" { + value = defVal.String() + } + // validate string + if target.CanSet() { + target.SetString(value) + } + + case reflect.Ptr: + if data == "" && defVal.Kind() == reflect.Ptr { + if target.CanSet() { + target.Set(defVal) + } + return nil + } + newVal := reflect.New(target.Type().Elem()) + if err := p.setFieldValue(reflect.Indirect(newVal), defVal, data, hasKey); err != nil { + return err + } + if target.CanSet() { + target.Set(newVal) + } + + default: + return errors.InvalidType(p.Name, p.parameter.In, tpe, data) + } + return nil +} + +func (p *untypedParamBinder) tryUnmarshaler(target reflect.Value, defaultValue interface{}, data string) (bool, error) { + if !target.CanSet() { + return false, nil + } + // When a type implements encoding.TextUnmarshaler we'll use that instead of reflecting some more + if reflect.PtrTo(target.Type()).Implements(textUnmarshalType) { + if defaultValue != nil && len(data) == 0 { + target.Set(reflect.ValueOf(defaultValue)) + return true, nil + } + value := reflect.New(target.Type()) + if err := value.Interface().(encoding.TextUnmarshaler).UnmarshalText([]byte(data)); err != nil { + return true, err + } + target.Set(reflect.Indirect(value)) + return true, nil + } + return false, nil +} + +func (p *untypedParamBinder) readFormattedSliceFieldValue(data string, target reflect.Value) ([]string, bool, error) { + ok, err := p.tryUnmarshaler(target, p.parameter.Default, data) + if err != nil { + return nil, true, err + } + if ok { + return nil, true, nil + } + + return swag.SplitByFormat(data, p.parameter.CollectionFormat), false, nil +} + +func (p *untypedParamBinder) setSliceFieldValue(target reflect.Value, defaultValue interface{}, data []string, hasKey bool) error { + sz := len(data) + if (!hasKey || (!p.parameter.AllowEmptyValue && (sz == 0 || (sz == 1 && data[0] == "")))) && p.parameter.Required && defaultValue == nil { + return errors.Required(p.Name, p.parameter.In, data) + } + + defVal := reflect.Zero(target.Type()) + if defaultValue != nil { + defVal = reflect.ValueOf(defaultValue) + } + + if !target.CanSet() { + return nil + } + if sz == 0 { + target.Set(defVal) + return nil + } + + value := reflect.MakeSlice(reflect.SliceOf(target.Type().Elem()), sz, sz) + + for i := 0; i < sz; i++ { + if err := p.setFieldValue(value.Index(i), nil, data[i], hasKey); err != nil { + return err + } + } + + target.Set(value) + + return nil +} diff --git a/vendor/github.com/go-openapi/runtime/middleware/pre_go18.go b/vendor/github.com/go-openapi/runtime/middleware/pre_go18.go new file mode 100644 index 00000000000..03385251e19 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/middleware/pre_go18.go @@ -0,0 +1,9 @@ +// +build !go1.8 + +package middleware + +import "net/url" + +func pathUnescape(path string) (string, error) { + return url.QueryUnescape(path) +} diff --git a/vendor/github.com/go-openapi/runtime/middleware/rapidoc.go b/vendor/github.com/go-openapi/runtime/middleware/rapidoc.go new file mode 100644 index 00000000000..4be330d6dc3 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/middleware/rapidoc.go @@ -0,0 +1,90 @@ +package middleware + +import ( + "bytes" + "fmt" + "html/template" + "net/http" + "path" +) + +// RapiDocOpts configures the RapiDoc middlewares +type RapiDocOpts struct { + // BasePath for the UI path, defaults to: / + BasePath string + // Path combines with BasePath for the full UI path, defaults to: docs + Path string + // SpecURL the url to find the spec for + SpecURL string + // RapiDocURL for the js that generates the rapidoc site, defaults to: https://cdn.jsdelivr.net/npm/rapidoc/bundles/rapidoc.standalone.js + RapiDocURL string + // Title for the documentation site, default to: API documentation + Title string +} + +// EnsureDefaults in case some options are missing +func (r *RapiDocOpts) EnsureDefaults() { + if r.BasePath == "" { + r.BasePath = "/" + } + if r.Path == "" { + r.Path = "docs" + } + if r.SpecURL == "" { + r.SpecURL = "/swagger.json" + } + if r.RapiDocURL == "" { + r.RapiDocURL = rapidocLatest + } + if r.Title == "" { + r.Title = "API documentation" + } +} + +// RapiDoc creates a middleware to serve a documentation site for a swagger spec. +// This allows for altering the spec before starting the http listener. +// +func RapiDoc(opts RapiDocOpts, next http.Handler) http.Handler { + opts.EnsureDefaults() + + pth := path.Join(opts.BasePath, opts.Path) + tmpl := template.Must(template.New("rapidoc").Parse(rapidocTemplate)) + + buf := bytes.NewBuffer(nil) + _ = tmpl.Execute(buf, opts) + b := buf.Bytes() + + return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { + if r.URL.Path == pth { + rw.Header().Set("Content-Type", "text/html; charset=utf-8") + rw.WriteHeader(http.StatusOK) + + _, _ = rw.Write(b) + return + } + + if next == nil { + rw.Header().Set("Content-Type", "text/plain") + rw.WriteHeader(http.StatusNotFound) + _, _ = rw.Write([]byte(fmt.Sprintf("%q not found", pth))) + return + } + next.ServeHTTP(rw, r) + }) +} + +const ( + rapidocLatest = "https://unpkg.com/rapidoc/dist/rapidoc-min.js" + rapidocTemplate = ` + + + {{ .Title }} + + + + + + + +` +) diff --git a/vendor/github.com/go-openapi/runtime/middleware/redoc.go b/vendor/github.com/go-openapi/runtime/middleware/redoc.go new file mode 100644 index 00000000000..019c854295b --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/middleware/redoc.go @@ -0,0 +1,103 @@ +package middleware + +import ( + "bytes" + "fmt" + "html/template" + "net/http" + "path" +) + +// RedocOpts configures the Redoc middlewares +type RedocOpts struct { + // BasePath for the UI path, defaults to: / + BasePath string + // Path combines with BasePath for the full UI path, defaults to: docs + Path string + // SpecURL the url to find the spec for + SpecURL string + // RedocURL for the js that generates the redoc site, defaults to: https://cdn.jsdelivr.net/npm/redoc/bundles/redoc.standalone.js + RedocURL string + // Title for the documentation site, default to: API documentation + Title string +} + +// EnsureDefaults in case some options are missing +func (r *RedocOpts) EnsureDefaults() { + if r.BasePath == "" { + r.BasePath = "/" + } + if r.Path == "" { + r.Path = "docs" + } + if r.SpecURL == "" { + r.SpecURL = "/swagger.json" + } + if r.RedocURL == "" { + r.RedocURL = redocLatest + } + if r.Title == "" { + r.Title = "API documentation" + } +} + +// Redoc creates a middleware to serve a documentation site for a swagger spec. +// This allows for altering the spec before starting the http listener. +// +func Redoc(opts RedocOpts, next http.Handler) http.Handler { + opts.EnsureDefaults() + + pth := path.Join(opts.BasePath, opts.Path) + tmpl := template.Must(template.New("redoc").Parse(redocTemplate)) + + buf := bytes.NewBuffer(nil) + _ = tmpl.Execute(buf, opts) + b := buf.Bytes() + + return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { + if r.URL.Path == pth { + rw.Header().Set("Content-Type", "text/html; charset=utf-8") + rw.WriteHeader(http.StatusOK) + + _, _ = rw.Write(b) + return + } + + if next == nil { + rw.Header().Set("Content-Type", "text/plain") + rw.WriteHeader(http.StatusNotFound) + _, _ = rw.Write([]byte(fmt.Sprintf("%q not found", pth))) + return + } + next.ServeHTTP(rw, r) + }) +} + +const ( + redocLatest = "https://cdn.jsdelivr.net/npm/redoc/bundles/redoc.standalone.js" + redocTemplate = ` + + + {{ .Title }} + + + + + + + + + + + + + +` +) diff --git a/vendor/github.com/go-openapi/runtime/middleware/request.go b/vendor/github.com/go-openapi/runtime/middleware/request.go new file mode 100644 index 00000000000..760c37861d0 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/middleware/request.go @@ -0,0 +1,104 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package middleware + +import ( + "net/http" + "reflect" + + "github.com/go-openapi/errors" + "github.com/go-openapi/spec" + "github.com/go-openapi/strfmt" + + "github.com/go-openapi/runtime" +) + +// UntypedRequestBinder binds and validates the data from a http request +type UntypedRequestBinder struct { + Spec *spec.Swagger + Parameters map[string]spec.Parameter + Formats strfmt.Registry + paramBinders map[string]*untypedParamBinder +} + +// NewUntypedRequestBinder creates a new binder for reading a request. +func NewUntypedRequestBinder(parameters map[string]spec.Parameter, spec *spec.Swagger, formats strfmt.Registry) *UntypedRequestBinder { + binders := make(map[string]*untypedParamBinder) + for fieldName, param := range parameters { + binders[fieldName] = newUntypedParamBinder(param, spec, formats) + } + return &UntypedRequestBinder{ + Parameters: parameters, + paramBinders: binders, + Spec: spec, + Formats: formats, + } +} + +// Bind perform the databinding and validation +func (o *UntypedRequestBinder) Bind(request *http.Request, routeParams RouteParams, consumer runtime.Consumer, data interface{}) error { + val := reflect.Indirect(reflect.ValueOf(data)) + isMap := val.Kind() == reflect.Map + var result []error + debugLog("binding %d parameters for %s %s", len(o.Parameters), request.Method, request.URL.EscapedPath()) + for fieldName, param := range o.Parameters { + binder := o.paramBinders[fieldName] + debugLog("binding parameter %s for %s %s", fieldName, request.Method, request.URL.EscapedPath()) + var target reflect.Value + if !isMap { + binder.Name = fieldName + target = val.FieldByName(fieldName) + } + + if isMap { + tpe := binder.Type() + if tpe == nil { + if param.Schema.Type.Contains("array") { + tpe = reflect.TypeOf([]interface{}{}) + } else { + tpe = reflect.TypeOf(map[string]interface{}{}) + } + } + target = reflect.Indirect(reflect.New(tpe)) + } + + if !target.IsValid() { + result = append(result, errors.New(500, "parameter name %q is an unknown field", binder.Name)) + continue + } + + if err := binder.Bind(request, routeParams, consumer, target); err != nil { + result = append(result, err) + continue + } + + if binder.validator != nil { + rr := binder.validator.Validate(target.Interface()) + if rr != nil && rr.HasErrors() { + result = append(result, rr.AsError()) + } + } + + if isMap { + val.SetMapIndex(reflect.ValueOf(param.Name), target) + } + } + + if len(result) > 0 { + return errors.CompositeValidationError(result...) + } + + return nil +} diff --git a/vendor/github.com/go-openapi/runtime/middleware/router.go b/vendor/github.com/go-openapi/runtime/middleware/router.go new file mode 100644 index 00000000000..5052031c8d7 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/middleware/router.go @@ -0,0 +1,488 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package middleware + +import ( + "fmt" + "net/http" + fpath "path" + "regexp" + "strings" + + "github.com/go-openapi/runtime/security" + "github.com/go-openapi/swag" + + "github.com/go-openapi/analysis" + "github.com/go-openapi/errors" + "github.com/go-openapi/loads" + "github.com/go-openapi/spec" + "github.com/go-openapi/strfmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware/denco" +) + +// RouteParam is a object to capture route params in a framework agnostic way. +// implementations of the muxer should use these route params to communicate with the +// swagger framework +type RouteParam struct { + Name string + Value string +} + +// RouteParams the collection of route params +type RouteParams []RouteParam + +// Get gets the value for the route param for the specified key +func (r RouteParams) Get(name string) string { + vv, _, _ := r.GetOK(name) + if len(vv) > 0 { + return vv[len(vv)-1] + } + return "" +} + +// GetOK gets the value but also returns booleans to indicate if a key or value +// is present. This aids in validation and satisfies an interface in use there +// +// The returned values are: data, has key, has value +func (r RouteParams) GetOK(name string) ([]string, bool, bool) { + for _, p := range r { + if p.Name == name { + return []string{p.Value}, true, p.Value != "" + } + } + return nil, false, false +} + +// NewRouter creates a new context aware router middleware +func NewRouter(ctx *Context, next http.Handler) http.Handler { + if ctx.router == nil { + ctx.router = DefaultRouter(ctx.spec, ctx.api) + } + + return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { + if _, rCtx, ok := ctx.RouteInfo(r); ok { + next.ServeHTTP(rw, rCtx) + return + } + + // Not found, check if it exists in the other methods first + if others := ctx.AllowedMethods(r); len(others) > 0 { + ctx.Respond(rw, r, ctx.analyzer.RequiredProduces(), nil, errors.MethodNotAllowed(r.Method, others)) + return + } + + ctx.Respond(rw, r, ctx.analyzer.RequiredProduces(), nil, errors.NotFound("path %s was not found", r.URL.EscapedPath())) + }) +} + +// RoutableAPI represents an interface for things that can serve +// as a provider of implementations for the swagger router +type RoutableAPI interface { + HandlerFor(string, string) (http.Handler, bool) + ServeErrorFor(string) func(http.ResponseWriter, *http.Request, error) + ConsumersFor([]string) map[string]runtime.Consumer + ProducersFor([]string) map[string]runtime.Producer + AuthenticatorsFor(map[string]spec.SecurityScheme) map[string]runtime.Authenticator + Authorizer() runtime.Authorizer + Formats() strfmt.Registry + DefaultProduces() string + DefaultConsumes() string +} + +// Router represents a swagger aware router +type Router interface { + Lookup(method, path string) (*MatchedRoute, bool) + OtherMethods(method, path string) []string +} + +type defaultRouteBuilder struct { + spec *loads.Document + analyzer *analysis.Spec + api RoutableAPI + records map[string][]denco.Record +} + +type defaultRouter struct { + spec *loads.Document + routers map[string]*denco.Router +} + +func newDefaultRouteBuilder(spec *loads.Document, api RoutableAPI) *defaultRouteBuilder { + return &defaultRouteBuilder{ + spec: spec, + analyzer: analysis.New(spec.Spec()), + api: api, + records: make(map[string][]denco.Record), + } +} + +// DefaultRouter creates a default implemenation of the router +func DefaultRouter(spec *loads.Document, api RoutableAPI) Router { + builder := newDefaultRouteBuilder(spec, api) + if spec != nil { + for method, paths := range builder.analyzer.Operations() { + for path, operation := range paths { + fp := fpath.Join(spec.BasePath(), path) + debugLog("adding route %s %s %q", method, fp, operation.ID) + builder.AddRoute(method, fp, operation) + } + } + } + return builder.Build() +} + +// RouteAuthenticator is an authenticator that can compose several authenticators together. +// It also knows when it contains an authenticator that allows for anonymous pass through. +// Contains a group of 1 or more authenticators that have a logical AND relationship +type RouteAuthenticator struct { + Authenticator map[string]runtime.Authenticator + Schemes []string + Scopes map[string][]string + allScopes []string + commonScopes []string + allowAnonymous bool +} + +func (ra *RouteAuthenticator) AllowsAnonymous() bool { + return ra.allowAnonymous +} + +// AllScopes returns a list of unique scopes that is the combination +// of all the scopes in the requirements +func (ra *RouteAuthenticator) AllScopes() []string { + return ra.allScopes +} + +// CommonScopes returns a list of unique scopes that are common in all the +// scopes in the requirements +func (ra *RouteAuthenticator) CommonScopes() []string { + return ra.commonScopes +} + +// Authenticate Authenticator interface implementation +func (ra *RouteAuthenticator) Authenticate(req *http.Request, route *MatchedRoute) (bool, interface{}, error) { + if ra.allowAnonymous { + route.Authenticator = ra + return true, nil, nil + } + // iterate in proper order + var lastResult interface{} + for _, scheme := range ra.Schemes { + if authenticator, ok := ra.Authenticator[scheme]; ok { + applies, princ, err := authenticator.Authenticate(&security.ScopedAuthRequest{ + Request: req, + RequiredScopes: ra.Scopes[scheme], + }) + if !applies { + return false, nil, nil + } + if err != nil { + route.Authenticator = ra + return true, nil, err + } + lastResult = princ + } + } + route.Authenticator = ra + return true, lastResult, nil +} + +func stringSliceUnion(slices ...[]string) []string { + unique := make(map[string]struct{}) + var result []string + for _, slice := range slices { + for _, entry := range slice { + if _, ok := unique[entry]; ok { + continue + } + unique[entry] = struct{}{} + result = append(result, entry) + } + } + return result +} + +func stringSliceIntersection(slices ...[]string) []string { + unique := make(map[string]int) + var intersection []string + + total := len(slices) + var emptyCnt int + for _, slice := range slices { + if len(slice) == 0 { + emptyCnt++ + continue + } + + for _, entry := range slice { + unique[entry]++ + if unique[entry] == total-emptyCnt { // this entry appeared in all the non-empty slices + intersection = append(intersection, entry) + } + } + } + + return intersection +} + +// RouteAuthenticators represents a group of authenticators that represent a logical OR +type RouteAuthenticators []RouteAuthenticator + +// AllowsAnonymous returns true when there is an authenticator that means optional auth +func (ras RouteAuthenticators) AllowsAnonymous() bool { + for _, ra := range ras { + if ra.AllowsAnonymous() { + return true + } + } + return false +} + +// Authenticate method implemention so this collection can be used as authenticator +func (ras RouteAuthenticators) Authenticate(req *http.Request, route *MatchedRoute) (bool, interface{}, error) { + var lastError error + var allowsAnon bool + var anonAuth RouteAuthenticator + + for _, ra := range ras { + if ra.AllowsAnonymous() { + anonAuth = ra + allowsAnon = true + continue + } + applies, usr, err := ra.Authenticate(req, route) + if !applies || err != nil || usr == nil { + if err != nil { + lastError = err + } + continue + } + return applies, usr, nil + } + + if allowsAnon && lastError == nil { + route.Authenticator = &anonAuth + return true, nil, lastError + } + return lastError != nil, nil, lastError +} + +type routeEntry struct { + PathPattern string + BasePath string + Operation *spec.Operation + Consumes []string + Consumers map[string]runtime.Consumer + Produces []string + Producers map[string]runtime.Producer + Parameters map[string]spec.Parameter + Handler http.Handler + Formats strfmt.Registry + Binder *UntypedRequestBinder + Authenticators RouteAuthenticators + Authorizer runtime.Authorizer +} + +// MatchedRoute represents the route that was matched in this request +type MatchedRoute struct { + routeEntry + Params RouteParams + Consumer runtime.Consumer + Producer runtime.Producer + Authenticator *RouteAuthenticator +} + +// HasAuth returns true when the route has a security requirement defined +func (m *MatchedRoute) HasAuth() bool { + return len(m.Authenticators) > 0 +} + +// NeedsAuth returns true when the request still +// needs to perform authentication +func (m *MatchedRoute) NeedsAuth() bool { + return m.HasAuth() && m.Authenticator == nil +} + +func (d *defaultRouter) Lookup(method, path string) (*MatchedRoute, bool) { + mth := strings.ToUpper(method) + debugLog("looking up route for %s %s", method, path) + if Debug { + if len(d.routers) == 0 { + debugLog("there are no known routers") + } + for meth := range d.routers { + debugLog("got a router for %s", meth) + } + } + if router, ok := d.routers[mth]; ok { + if m, rp, ok := router.Lookup(fpath.Clean(path)); ok && m != nil { + if entry, ok := m.(*routeEntry); ok { + debugLog("found a route for %s %s with %d parameters", method, path, len(entry.Parameters)) + var params RouteParams + for _, p := range rp { + v, err := pathUnescape(p.Value) + if err != nil { + debugLog("failed to escape %q: %v", p.Value, err) + v = p.Value + } + // a workaround to handle fragment/composing parameters until they are supported in denco router + // check if this parameter is a fragment within a path segment + if xpos := strings.Index(entry.PathPattern, fmt.Sprintf("{%s}", p.Name)) + len(p.Name) + 2; xpos < len(entry.PathPattern) && entry.PathPattern[xpos] != '/' { + // extract fragment parameters + ep := strings.Split(entry.PathPattern[xpos:], "/")[0] + pnames, pvalues := decodeCompositParams(p.Name, v, ep, nil, nil) + for i, pname := range pnames { + params = append(params, RouteParam{Name: pname, Value: pvalues[i]}) + } + } else { + // use the parameter directly + params = append(params, RouteParam{Name: p.Name, Value: v}) + } + } + return &MatchedRoute{routeEntry: *entry, Params: params}, true + } + } else { + debugLog("couldn't find a route by path for %s %s", method, path) + } + } else { + debugLog("couldn't find a route by method for %s %s", method, path) + } + return nil, false +} + +func (d *defaultRouter) OtherMethods(method, path string) []string { + mn := strings.ToUpper(method) + var methods []string + for k, v := range d.routers { + if k != mn { + if _, _, ok := v.Lookup(fpath.Clean(path)); ok { + methods = append(methods, k) + continue + } + } + } + return methods +} + +// convert swagger parameters per path segment into a denco parameter as multiple parameters per segment are not supported in denco +var pathConverter = regexp.MustCompile(`{(.+?)}([^/]*)`) + +func decodeCompositParams(name string, value string, pattern string, names []string, values []string) ([]string, []string) { + pleft := strings.Index(pattern, "{") + names = append(names, name) + if pleft < 0 { + if strings.HasSuffix(value, pattern) { + values = append(values, value[:len(value)-len(pattern)]) + } else { + values = append(values, "") + } + } else { + toskip := pattern[:pleft] + pright := strings.Index(pattern, "}") + vright := strings.Index(value, toskip) + if vright >= 0 { + values = append(values, value[:vright]) + } else { + values = append(values, "") + value = "" + } + return decodeCompositParams(pattern[pleft+1:pright], value[vright+len(toskip):], pattern[pright+1:], names, values) + } + return names, values +} + +func (d *defaultRouteBuilder) AddRoute(method, path string, operation *spec.Operation) { + mn := strings.ToUpper(method) + + bp := fpath.Clean(d.spec.BasePath()) + if len(bp) > 0 && bp[len(bp)-1] == '/' { + bp = bp[:len(bp)-1] + } + + debugLog("operation: %#v", *operation) + if handler, ok := d.api.HandlerFor(method, strings.TrimPrefix(path, bp)); ok { + consumes := d.analyzer.ConsumesFor(operation) + produces := d.analyzer.ProducesFor(operation) + parameters := d.analyzer.ParamsFor(method, strings.TrimPrefix(path, bp)) + + // add API defaults if not part of the spec + if defConsumes := d.api.DefaultConsumes(); defConsumes != "" && !swag.ContainsStringsCI(consumes, defConsumes) { + consumes = append(consumes, defConsumes) + } + + if defProduces := d.api.DefaultProduces(); defProduces != "" && !swag.ContainsStringsCI(produces, defProduces) { + produces = append(produces, defProduces) + } + + record := denco.NewRecord(pathConverter.ReplaceAllString(path, ":$1"), &routeEntry{ + BasePath: bp, + PathPattern: path, + Operation: operation, + Handler: handler, + Consumes: consumes, + Produces: produces, + Consumers: d.api.ConsumersFor(normalizeOffers(consumes)), + Producers: d.api.ProducersFor(normalizeOffers(produces)), + Parameters: parameters, + Formats: d.api.Formats(), + Binder: NewUntypedRequestBinder(parameters, d.spec.Spec(), d.api.Formats()), + Authenticators: d.buildAuthenticators(operation), + Authorizer: d.api.Authorizer(), + }) + d.records[mn] = append(d.records[mn], record) + } +} + +func (d *defaultRouteBuilder) buildAuthenticators(operation *spec.Operation) RouteAuthenticators { + requirements := d.analyzer.SecurityRequirementsFor(operation) + var auths []RouteAuthenticator + for _, reqs := range requirements { + var schemes []string + scopes := make(map[string][]string, len(reqs)) + var scopeSlices [][]string + for _, req := range reqs { + schemes = append(schemes, req.Name) + scopes[req.Name] = req.Scopes + scopeSlices = append(scopeSlices, req.Scopes) + } + + definitions := d.analyzer.SecurityDefinitionsForRequirements(reqs) + authenticators := d.api.AuthenticatorsFor(definitions) + auths = append(auths, RouteAuthenticator{ + Authenticator: authenticators, + Schemes: schemes, + Scopes: scopes, + allScopes: stringSliceUnion(scopeSlices...), + commonScopes: stringSliceIntersection(scopeSlices...), + allowAnonymous: len(reqs) == 1 && reqs[0].Name == "", + }) + } + return auths +} + +func (d *defaultRouteBuilder) Build() *defaultRouter { + routers := make(map[string]*denco.Router) + for method, records := range d.records { + router := denco.New() + _ = router.Build(records) + routers[method] = router + } + return &defaultRouter{ + spec: d.spec, + routers: routers, + } +} diff --git a/vendor/github.com/go-openapi/runtime/middleware/security.go b/vendor/github.com/go-openapi/runtime/middleware/security.go new file mode 100644 index 00000000000..2b061caefcb --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/middleware/security.go @@ -0,0 +1,39 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package middleware + +import "net/http" + +func newSecureAPI(ctx *Context, next http.Handler) http.Handler { + return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := ctx.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + if route != nil && !route.NeedsAuth() { + next.ServeHTTP(rw, r) + return + } + + _, rCtx, err := ctx.Authorize(r, route) + if err != nil { + ctx.Respond(rw, r, route.Produces, route, err) + return + } + r = rCtx + + next.ServeHTTP(rw, r) + }) +} diff --git a/vendor/github.com/go-openapi/runtime/middleware/spec.go b/vendor/github.com/go-openapi/runtime/middleware/spec.go new file mode 100644 index 00000000000..f0291429806 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/middleware/spec.go @@ -0,0 +1,48 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package middleware + +import ( + "net/http" + "path" +) + +// Spec creates a middleware to serve a swagger spec. +// This allows for altering the spec before starting the http listener. +// This can be useful if you want to serve the swagger spec from another path than /swagger.json +// +func Spec(basePath string, b []byte, next http.Handler) http.Handler { + if basePath == "" { + basePath = "/" + } + pth := path.Join(basePath, "swagger.json") + + return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { + if r.URL.Path == pth { + rw.Header().Set("Content-Type", "application/json") + rw.WriteHeader(http.StatusOK) + //#nosec + _, _ = rw.Write(b) + return + } + + if next == nil { + rw.Header().Set("Content-Type", "application/json") + rw.WriteHeader(http.StatusNotFound) + return + } + next.ServeHTTP(rw, r) + }) +} diff --git a/vendor/github.com/go-openapi/runtime/middleware/swaggerui.go b/vendor/github.com/go-openapi/runtime/middleware/swaggerui.go new file mode 100644 index 00000000000..2c92f5c91f3 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/middleware/swaggerui.go @@ -0,0 +1,162 @@ +package middleware + +import ( + "bytes" + "fmt" + "html/template" + "net/http" + "path" +) + +// SwaggerUIOpts configures the Swaggerui middlewares +type SwaggerUIOpts struct { + // BasePath for the UI path, defaults to: / + BasePath string + // Path combines with BasePath for the full UI path, defaults to: docs + Path string + // SpecURL the url to find the spec for + SpecURL string + + // The three components needed to embed swagger-ui + SwaggerURL string + SwaggerPresetURL string + SwaggerStylesURL string + + Favicon32 string + Favicon16 string + + // Title for the documentation site, default to: API documentation + Title string +} + +// EnsureDefaults in case some options are missing +func (r *SwaggerUIOpts) EnsureDefaults() { + if r.BasePath == "" { + r.BasePath = "/" + } + if r.Path == "" { + r.Path = "docs" + } + if r.SpecURL == "" { + r.SpecURL = "/swagger.json" + } + if r.SwaggerURL == "" { + r.SwaggerURL = swaggerLatest + } + if r.SwaggerPresetURL == "" { + r.SwaggerPresetURL = swaggerPresetLatest + } + if r.SwaggerStylesURL == "" { + r.SwaggerStylesURL = swaggerStylesLatest + } + if r.Favicon16 == "" { + r.Favicon16 = swaggerFavicon16Latest + } + if r.Favicon32 == "" { + r.Favicon32 = swaggerFavicon32Latest + } + if r.Title == "" { + r.Title = "API documentation" + } +} + +// SwaggerUI creates a middleware to serve a documentation site for a swagger spec. +// This allows for altering the spec before starting the http listener. +func SwaggerUI(opts SwaggerUIOpts, next http.Handler) http.Handler { + opts.EnsureDefaults() + + pth := path.Join(opts.BasePath, opts.Path) + tmpl := template.Must(template.New("swaggerui").Parse(swaggeruiTemplate)) + + buf := bytes.NewBuffer(nil) + _ = tmpl.Execute(buf, &opts) + b := buf.Bytes() + + return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { + if r.URL.Path == pth { + rw.Header().Set("Content-Type", "text/html; charset=utf-8") + rw.WriteHeader(http.StatusOK) + + _, _ = rw.Write(b) + return + } + + if next == nil { + rw.Header().Set("Content-Type", "text/plain") + rw.WriteHeader(http.StatusNotFound) + _, _ = rw.Write([]byte(fmt.Sprintf("%q not found", pth))) + return + } + next.ServeHTTP(rw, r) + }) +} + +const ( + swaggerLatest = "https://unpkg.com/swagger-ui-dist/swagger-ui-bundle.js" + swaggerPresetLatest = "https://unpkg.com/swagger-ui-dist/swagger-ui-standalone-preset.js" + swaggerStylesLatest = "https://unpkg.com/swagger-ui-dist/swagger-ui.css" + swaggerFavicon32Latest = "https://unpkg.com/swagger-ui-dist/favicon-32x32.png" + swaggerFavicon16Latest = "https://unpkg.com/swagger-ui-dist/favicon-16x16.png" + swaggeruiTemplate = ` + + + + + {{ .Title }} + + + + + + + + +
+ + + + + + +` +) diff --git a/vendor/github.com/go-openapi/runtime/middleware/untyped/api.go b/vendor/github.com/go-openapi/runtime/middleware/untyped/api.go new file mode 100644 index 00000000000..39a85f7d9e8 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/middleware/untyped/api.go @@ -0,0 +1,286 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package untyped + +import ( + "fmt" + "net/http" + "sort" + "strings" + + "github.com/go-openapi/analysis" + "github.com/go-openapi/errors" + "github.com/go-openapi/loads" + "github.com/go-openapi/spec" + "github.com/go-openapi/strfmt" + + "github.com/go-openapi/runtime" +) + +// NewAPI creates the default untyped API +func NewAPI(spec *loads.Document) *API { + var an *analysis.Spec + if spec != nil && spec.Spec() != nil { + an = analysis.New(spec.Spec()) + } + api := &API{ + spec: spec, + analyzer: an, + consumers: make(map[string]runtime.Consumer, 10), + producers: make(map[string]runtime.Producer, 10), + authenticators: make(map[string]runtime.Authenticator), + operations: make(map[string]map[string]runtime.OperationHandler), + ServeError: errors.ServeError, + Models: make(map[string]func() interface{}), + formats: strfmt.NewFormats(), + } + return api.WithJSONDefaults() +} + +// API represents an untyped mux for a swagger spec +type API struct { + spec *loads.Document + analyzer *analysis.Spec + DefaultProduces string + DefaultConsumes string + consumers map[string]runtime.Consumer + producers map[string]runtime.Producer + authenticators map[string]runtime.Authenticator + authorizer runtime.Authorizer + operations map[string]map[string]runtime.OperationHandler + ServeError func(http.ResponseWriter, *http.Request, error) + Models map[string]func() interface{} + formats strfmt.Registry +} + +// WithJSONDefaults loads the json defaults for this api +func (d *API) WithJSONDefaults() *API { + d.DefaultConsumes = runtime.JSONMime + d.DefaultProduces = runtime.JSONMime + d.consumers[runtime.JSONMime] = runtime.JSONConsumer() + d.producers[runtime.JSONMime] = runtime.JSONProducer() + return d +} + +// WithoutJSONDefaults clears the json defaults for this api +func (d *API) WithoutJSONDefaults() *API { + d.DefaultConsumes = "" + d.DefaultProduces = "" + delete(d.consumers, runtime.JSONMime) + delete(d.producers, runtime.JSONMime) + return d +} + +// Formats returns the registered string formats +func (d *API) Formats() strfmt.Registry { + if d.formats == nil { + d.formats = strfmt.NewFormats() + } + return d.formats +} + +// RegisterFormat registers a custom format validator +func (d *API) RegisterFormat(name string, format strfmt.Format, validator strfmt.Validator) { + if d.formats == nil { + d.formats = strfmt.NewFormats() + } + d.formats.Add(name, format, validator) +} + +// RegisterAuth registers an auth handler in this api +func (d *API) RegisterAuth(scheme string, handler runtime.Authenticator) { + if d.authenticators == nil { + d.authenticators = make(map[string]runtime.Authenticator) + } + d.authenticators[scheme] = handler +} + +// RegisterAuthorizer registers an authorizer handler in this api +func (d *API) RegisterAuthorizer(handler runtime.Authorizer) { + d.authorizer = handler +} + +// RegisterConsumer registers a consumer for a media type. +func (d *API) RegisterConsumer(mediaType string, handler runtime.Consumer) { + if d.consumers == nil { + d.consumers = make(map[string]runtime.Consumer, 10) + } + d.consumers[strings.ToLower(mediaType)] = handler +} + +// RegisterProducer registers a producer for a media type +func (d *API) RegisterProducer(mediaType string, handler runtime.Producer) { + if d.producers == nil { + d.producers = make(map[string]runtime.Producer, 10) + } + d.producers[strings.ToLower(mediaType)] = handler +} + +// RegisterOperation registers an operation handler for an operation name +func (d *API) RegisterOperation(method, path string, handler runtime.OperationHandler) { + if d.operations == nil { + d.operations = make(map[string]map[string]runtime.OperationHandler, 30) + } + um := strings.ToUpper(method) + if b, ok := d.operations[um]; !ok || b == nil { + d.operations[um] = make(map[string]runtime.OperationHandler) + } + d.operations[um][path] = handler +} + +// OperationHandlerFor returns the operation handler for the specified id if it can be found +func (d *API) OperationHandlerFor(method, path string) (runtime.OperationHandler, bool) { + if d.operations == nil { + return nil, false + } + if pi, ok := d.operations[strings.ToUpper(method)]; ok { + h, ok := pi[path] + return h, ok + } + return nil, false +} + +// ConsumersFor gets the consumers for the specified media types +func (d *API) ConsumersFor(mediaTypes []string) map[string]runtime.Consumer { + result := make(map[string]runtime.Consumer) + for _, mt := range mediaTypes { + if consumer, ok := d.consumers[mt]; ok { + result[mt] = consumer + } + } + return result +} + +// ProducersFor gets the producers for the specified media types +func (d *API) ProducersFor(mediaTypes []string) map[string]runtime.Producer { + result := make(map[string]runtime.Producer) + for _, mt := range mediaTypes { + if producer, ok := d.producers[mt]; ok { + result[mt] = producer + } + } + return result +} + +// AuthenticatorsFor gets the authenticators for the specified security schemes +func (d *API) AuthenticatorsFor(schemes map[string]spec.SecurityScheme) map[string]runtime.Authenticator { + result := make(map[string]runtime.Authenticator) + for k := range schemes { + if a, ok := d.authenticators[k]; ok { + result[k] = a + } + } + return result +} + +// Authorizer returns the registered authorizer +func (d *API) Authorizer() runtime.Authorizer { + return d.authorizer +} + +// Validate validates this API for any missing items +func (d *API) Validate() error { + return d.validate() +} + +// validateWith validates the registrations in this API against the provided spec analyzer +func (d *API) validate() error { + var consumes []string + for k := range d.consumers { + consumes = append(consumes, k) + } + + var produces []string + for k := range d.producers { + produces = append(produces, k) + } + + var authenticators []string + for k := range d.authenticators { + authenticators = append(authenticators, k) + } + + var operations []string + for m, v := range d.operations { + for p := range v { + operations = append(operations, fmt.Sprintf("%s %s", strings.ToUpper(m), p)) + } + } + + var definedAuths []string + for k := range d.spec.Spec().SecurityDefinitions { + definedAuths = append(definedAuths, k) + } + + if err := d.verify("consumes", consumes, d.analyzer.RequiredConsumes()); err != nil { + return err + } + if err := d.verify("produces", produces, d.analyzer.RequiredProduces()); err != nil { + return err + } + if err := d.verify("operation", operations, d.analyzer.OperationMethodPaths()); err != nil { + return err + } + + requiredAuths := d.analyzer.RequiredSecuritySchemes() + if err := d.verify("auth scheme", authenticators, requiredAuths); err != nil { + return err + } + if err := d.verify("security definitions", definedAuths, requiredAuths); err != nil { + return err + } + return nil +} + +func (d *API) verify(name string, registrations []string, expectations []string) error { + sort.Strings(registrations) + sort.Strings(expectations) + + expected := map[string]struct{}{} + seen := map[string]struct{}{} + + for _, v := range expectations { + expected[v] = struct{}{} + } + + var unspecified []string + for _, v := range registrations { + seen[v] = struct{}{} + if _, ok := expected[v]; !ok { + unspecified = append(unspecified, v) + } + } + + for k := range seen { + delete(expected, k) + } + + var unregistered []string + for k := range expected { + unregistered = append(unregistered, k) + } + sort.Strings(unspecified) + sort.Strings(unregistered) + + if len(unregistered) > 0 || len(unspecified) > 0 { + return &errors.APIVerificationFailed{ + Section: name, + MissingSpecification: unspecified, + MissingRegistration: unregistered, + } + } + + return nil +} diff --git a/vendor/github.com/go-openapi/runtime/middleware/validation.go b/vendor/github.com/go-openapi/runtime/middleware/validation.go new file mode 100644 index 00000000000..1f0135b5788 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/middleware/validation.go @@ -0,0 +1,126 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package middleware + +import ( + "mime" + "net/http" + "strings" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" + + "github.com/go-openapi/runtime" +) + +type validation struct { + context *Context + result []error + request *http.Request + route *MatchedRoute + bound map[string]interface{} +} + +// ContentType validates the content type of a request +func validateContentType(allowed []string, actual string) error { + debugLog("validating content type for %q against [%s]", actual, strings.Join(allowed, ", ")) + if len(allowed) == 0 { + return nil + } + mt, _, err := mime.ParseMediaType(actual) + if err != nil { + return errors.InvalidContentType(actual, allowed) + } + if swag.ContainsStringsCI(allowed, mt) { + return nil + } + if swag.ContainsStringsCI(allowed, "*/*") { + return nil + } + parts := strings.Split(actual, "/") + if len(parts) == 2 && swag.ContainsStringsCI(allowed, parts[0]+"/*") { + return nil + } + return errors.InvalidContentType(actual, allowed) +} + +func validateRequest(ctx *Context, request *http.Request, route *MatchedRoute) *validation { + debugLog("validating request %s %s", request.Method, request.URL.EscapedPath()) + validate := &validation{ + context: ctx, + request: request, + route: route, + bound: make(map[string]interface{}), + } + + validate.contentType() + if len(validate.result) == 0 { + validate.responseFormat() + } + if len(validate.result) == 0 { + validate.parameters() + } + + return validate +} + +func (v *validation) parameters() { + debugLog("validating request parameters for %s %s", v.request.Method, v.request.URL.EscapedPath()) + if result := v.route.Binder.Bind(v.request, v.route.Params, v.route.Consumer, v.bound); result != nil { + if result.Error() == "validation failure list" { + for _, e := range result.(*errors.Validation).Value.([]interface{}) { + v.result = append(v.result, e.(error)) + } + return + } + v.result = append(v.result, result) + } +} + +func (v *validation) contentType() { + if len(v.result) == 0 && runtime.HasBody(v.request) { + debugLog("validating body content type for %s %s", v.request.Method, v.request.URL.EscapedPath()) + ct, _, req, err := v.context.ContentType(v.request) + if err != nil { + v.result = append(v.result, err) + } else { + v.request = req + } + + if len(v.result) == 0 { + if err := validateContentType(v.route.Consumes, ct); err != nil { + v.result = append(v.result, err) + } + } + if ct != "" && v.route.Consumer == nil { + cons, ok := v.route.Consumers[ct] + if !ok { + v.result = append(v.result, errors.New(500, "no consumer registered for %s", ct)) + } else { + v.route.Consumer = cons + } + } + } +} + +func (v *validation) responseFormat() { + // if the route provides values for Produces and no format could be identify then return an error. + // if the route does not specify values for Produces then treat request as valid since the API designer + // choose not to specify the format for responses. + if str, rCtx := v.context.ResponseFormat(v.request, v.route.Produces); str == "" && len(v.route.Produces) > 0 { + v.request = rCtx + v.result = append(v.result, errors.InvalidResponseFormat(v.request.Header.Get(runtime.HeaderAccept), v.route.Produces)) + } +} diff --git a/vendor/github.com/go-openapi/runtime/request.go b/vendor/github.com/go-openapi/runtime/request.go new file mode 100644 index 00000000000..078fda17396 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/request.go @@ -0,0 +1,139 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package runtime + +import ( + "bufio" + "io" + "net/http" + "strings" + + "github.com/go-openapi/swag" +) + +// CanHaveBody returns true if this method can have a body +func CanHaveBody(method string) bool { + mn := strings.ToUpper(method) + return mn == "POST" || mn == "PUT" || mn == "PATCH" || mn == "DELETE" +} + +// IsSafe returns true if this is a request with a safe method +func IsSafe(r *http.Request) bool { + mn := strings.ToUpper(r.Method) + return mn == "GET" || mn == "HEAD" +} + +// AllowsBody returns true if the request allows for a body +func AllowsBody(r *http.Request) bool { + mn := strings.ToUpper(r.Method) + return mn != "HEAD" +} + +// HasBody returns true if this method needs a content-type +func HasBody(r *http.Request) bool { + // happy case: we have a content length set + if r.ContentLength > 0 { + return true + } + + if r.Header.Get("content-length") != "" { + // in this case, no Transfer-Encoding should be present + // we have a header set but it was explicitly set to 0, so we assume no body + return false + } + + rdr := newPeekingReader(r.Body) + r.Body = rdr + return rdr.HasContent() +} + +func newPeekingReader(r io.ReadCloser) *peekingReader { + if r == nil { + return nil + } + return &peekingReader{ + underlying: bufio.NewReader(r), + orig: r, + } +} + +type peekingReader struct { + underlying interface { + Buffered() int + Peek(int) ([]byte, error) + Read([]byte) (int, error) + } + orig io.ReadCloser +} + +func (p *peekingReader) HasContent() bool { + if p == nil { + return false + } + if p.underlying.Buffered() > 0 { + return true + } + b, err := p.underlying.Peek(1) + if err != nil { + return false + } + return len(b) > 0 +} + +func (p *peekingReader) Read(d []byte) (int, error) { + if p == nil { + return 0, io.EOF + } + return p.underlying.Read(d) +} + +func (p *peekingReader) Close() error { + p.underlying = nil + if p.orig != nil { + return p.orig.Close() + } + return nil +} + +// JSONRequest creates a new http request with json headers set +func JSONRequest(method, urlStr string, body io.Reader) (*http.Request, error) { + req, err := http.NewRequest(method, urlStr, body) + if err != nil { + return nil, err + } + req.Header.Add(HeaderContentType, JSONMime) + req.Header.Add(HeaderAccept, JSONMime) + return req, nil +} + +// Gettable for things with a method GetOK(string) (data string, hasKey bool, hasValue bool) +type Gettable interface { + GetOK(string) ([]string, bool, bool) +} + +// ReadSingleValue reads a single value from the source +func ReadSingleValue(values Gettable, name string) string { + vv, _, hv := values.GetOK(name) + if hv { + return vv[len(vv)-1] + } + return "" +} + +// ReadCollectionValue reads a collection value from a string data source +func ReadCollectionValue(values Gettable, name, collectionFormat string) []string { + v := ReadSingleValue(values, name) + return swag.SplitByFormat(v, collectionFormat) +} diff --git a/vendor/github.com/go-openapi/runtime/security/authenticator.go b/vendor/github.com/go-openapi/runtime/security/authenticator.go new file mode 100644 index 00000000000..476d26c3e77 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/security/authenticator.go @@ -0,0 +1,276 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package security + +import ( + "context" + "net/http" + "strings" + + "github.com/go-openapi/errors" + + "github.com/go-openapi/runtime" +) + +const ( + query = "query" + header = "header" +) + +// HttpAuthenticator is a function that authenticates a HTTP request +func HttpAuthenticator(handler func(*http.Request) (bool, interface{}, error)) runtime.Authenticator { + return runtime.AuthenticatorFunc(func(params interface{}) (bool, interface{}, error) { + if request, ok := params.(*http.Request); ok { + return handler(request) + } + if scoped, ok := params.(*ScopedAuthRequest); ok { + return handler(scoped.Request) + } + return false, nil, nil + }) +} + +// ScopedAuthenticator is a function that authenticates a HTTP request against a list of valid scopes +func ScopedAuthenticator(handler func(*ScopedAuthRequest) (bool, interface{}, error)) runtime.Authenticator { + return runtime.AuthenticatorFunc(func(params interface{}) (bool, interface{}, error) { + if request, ok := params.(*ScopedAuthRequest); ok { + return handler(request) + } + return false, nil, nil + }) +} + +// UserPassAuthentication authentication function +type UserPassAuthentication func(string, string) (interface{}, error) + +// UserPassAuthenticationCtx authentication function with context.Context +type UserPassAuthenticationCtx func(context.Context, string, string) (context.Context, interface{}, error) + +// TokenAuthentication authentication function +type TokenAuthentication func(string) (interface{}, error) + +// TokenAuthenticationCtx authentication function with context.Context +type TokenAuthenticationCtx func(context.Context, string) (context.Context, interface{}, error) + +// ScopedTokenAuthentication authentication function +type ScopedTokenAuthentication func(string, []string) (interface{}, error) + +// ScopedTokenAuthenticationCtx authentication function with context.Context +type ScopedTokenAuthenticationCtx func(context.Context, string, []string) (context.Context, interface{}, error) + +var DefaultRealmName = "API" + +type secCtxKey uint8 + +const ( + failedBasicAuth secCtxKey = iota + oauth2SchemeName +) + +func FailedBasicAuth(r *http.Request) string { + return FailedBasicAuthCtx(r.Context()) +} + +func FailedBasicAuthCtx(ctx context.Context) string { + v, ok := ctx.Value(failedBasicAuth).(string) + if !ok { + return "" + } + return v +} + +func OAuth2SchemeName(r *http.Request) string { + return OAuth2SchemeNameCtx(r.Context()) +} + +func OAuth2SchemeNameCtx(ctx context.Context) string { + v, ok := ctx.Value(oauth2SchemeName).(string) + if !ok { + return "" + } + return v +} + +// BasicAuth creates a basic auth authenticator with the provided authentication function +func BasicAuth(authenticate UserPassAuthentication) runtime.Authenticator { + return BasicAuthRealm(DefaultRealmName, authenticate) +} + +// BasicAuthRealm creates a basic auth authenticator with the provided authentication function and realm name +func BasicAuthRealm(realm string, authenticate UserPassAuthentication) runtime.Authenticator { + if realm == "" { + realm = DefaultRealmName + } + + return HttpAuthenticator(func(r *http.Request) (bool, interface{}, error) { + if usr, pass, ok := r.BasicAuth(); ok { + p, err := authenticate(usr, pass) + if err != nil { + *r = *r.WithContext(context.WithValue(r.Context(), failedBasicAuth, realm)) + } + return true, p, err + } + *r = *r.WithContext(context.WithValue(r.Context(), failedBasicAuth, realm)) + return false, nil, nil + }) +} + +// BasicAuthCtx creates a basic auth authenticator with the provided authentication function with support for context.Context +func BasicAuthCtx(authenticate UserPassAuthenticationCtx) runtime.Authenticator { + return BasicAuthRealmCtx(DefaultRealmName, authenticate) +} + +// BasicAuthRealmCtx creates a basic auth authenticator with the provided authentication function and realm name with support for context.Context +func BasicAuthRealmCtx(realm string, authenticate UserPassAuthenticationCtx) runtime.Authenticator { + if realm == "" { + realm = DefaultRealmName + } + + return HttpAuthenticator(func(r *http.Request) (bool, interface{}, error) { + if usr, pass, ok := r.BasicAuth(); ok { + ctx, p, err := authenticate(r.Context(), usr, pass) + if err != nil { + ctx = context.WithValue(ctx, failedBasicAuth, realm) + } + *r = *r.WithContext(ctx) + return true, p, err + } + *r = *r.WithContext(context.WithValue(r.Context(), failedBasicAuth, realm)) + return false, nil, nil + }) +} + +// APIKeyAuth creates an authenticator that uses a token for authorization. +// This token can be obtained from either a header or a query string +func APIKeyAuth(name, in string, authenticate TokenAuthentication) runtime.Authenticator { + inl := strings.ToLower(in) + if inl != query && inl != header { + // panic because this is most likely a typo + panic(errors.New(500, "api key auth: in value needs to be either \"query\" or \"header\".")) + } + + var getToken func(*http.Request) string + switch inl { + case header: + getToken = func(r *http.Request) string { return r.Header.Get(name) } + case query: + getToken = func(r *http.Request) string { return r.URL.Query().Get(name) } + } + + return HttpAuthenticator(func(r *http.Request) (bool, interface{}, error) { + token := getToken(r) + if token == "" { + return false, nil, nil + } + + p, err := authenticate(token) + return true, p, err + }) +} + +// APIKeyAuthCtx creates an authenticator that uses a token for authorization with support for context.Context. +// This token can be obtained from either a header or a query string +func APIKeyAuthCtx(name, in string, authenticate TokenAuthenticationCtx) runtime.Authenticator { + inl := strings.ToLower(in) + if inl != query && inl != header { + // panic because this is most likely a typo + panic(errors.New(500, "api key auth: in value needs to be either \"query\" or \"header\".")) + } + + var getToken func(*http.Request) string + switch inl { + case header: + getToken = func(r *http.Request) string { return r.Header.Get(name) } + case query: + getToken = func(r *http.Request) string { return r.URL.Query().Get(name) } + } + + return HttpAuthenticator(func(r *http.Request) (bool, interface{}, error) { + token := getToken(r) + if token == "" { + return false, nil, nil + } + + ctx, p, err := authenticate(r.Context(), token) + *r = *r.WithContext(ctx) + return true, p, err + }) +} + +// ScopedAuthRequest contains both a http request and the required scopes for a particular operation +type ScopedAuthRequest struct { + Request *http.Request + RequiredScopes []string +} + +// BearerAuth for use with oauth2 flows +func BearerAuth(name string, authenticate ScopedTokenAuthentication) runtime.Authenticator { + const prefix = "Bearer " + return ScopedAuthenticator(func(r *ScopedAuthRequest) (bool, interface{}, error) { + var token string + hdr := r.Request.Header.Get("Authorization") + if strings.HasPrefix(hdr, prefix) { + token = strings.TrimPrefix(hdr, prefix) + } + if token == "" { + qs := r.Request.URL.Query() + token = qs.Get("access_token") + } + //#nosec + ct, _, _ := runtime.ContentType(r.Request.Header) + if token == "" && (ct == "application/x-www-form-urlencoded" || ct == "multipart/form-data") { + token = r.Request.FormValue("access_token") + } + + if token == "" { + return false, nil, nil + } + + rctx := context.WithValue(r.Request.Context(), oauth2SchemeName, name) + *r.Request = *r.Request.WithContext(rctx) + p, err := authenticate(token, r.RequiredScopes) + return true, p, err + }) +} + +// BearerAuthCtx for use with oauth2 flows with support for context.Context. +func BearerAuthCtx(name string, authenticate ScopedTokenAuthenticationCtx) runtime.Authenticator { + const prefix = "Bearer " + return ScopedAuthenticator(func(r *ScopedAuthRequest) (bool, interface{}, error) { + var token string + hdr := r.Request.Header.Get("Authorization") + if strings.HasPrefix(hdr, prefix) { + token = strings.TrimPrefix(hdr, prefix) + } + if token == "" { + qs := r.Request.URL.Query() + token = qs.Get("access_token") + } + //#nosec + ct, _, _ := runtime.ContentType(r.Request.Header) + if token == "" && (ct == "application/x-www-form-urlencoded" || ct == "multipart/form-data") { + token = r.Request.FormValue("access_token") + } + + if token == "" { + return false, nil, nil + } + + rctx := context.WithValue(r.Request.Context(), oauth2SchemeName, name) + ctx, p, err := authenticate(rctx, token, r.RequiredScopes) + *r.Request = *r.Request.WithContext(ctx) + return true, p, err + }) +} diff --git a/vendor/github.com/go-openapi/runtime/security/authorizer.go b/vendor/github.com/go-openapi/runtime/security/authorizer.go new file mode 100644 index 00000000000..00c1a4d6a4c --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/security/authorizer.go @@ -0,0 +1,27 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package security + +import ( + "net/http" + + "github.com/go-openapi/runtime" +) + +// Authorized provides a default implementation of the Authorizer interface where all +// requests are authorized (successful) +func Authorized() runtime.Authorizer { + return runtime.AuthorizerFunc(func(_ *http.Request, _ interface{}) error { return nil }) +} diff --git a/vendor/github.com/go-openapi/runtime/statuses.go b/vendor/github.com/go-openapi/runtime/statuses.go new file mode 100644 index 00000000000..3b011a0bff1 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/statuses.go @@ -0,0 +1,90 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package runtime + +// Statuses lists the most common HTTP status codes to default message +// taken from https://httpstatuses.com/ +var Statuses = map[int]string{ + 100: "Continue", + 101: "Switching Protocols", + 102: "Processing", + 103: "Checkpoint", + 122: "URI too long", + 200: "OK", + 201: "Created", + 202: "Accepted", + 203: "Request Processed", + 204: "No Content", + 205: "Reset Content", + 206: "Partial Content", + 207: "Multi-Status", + 208: "Already Reported", + 226: "IM Used", + 300: "Multiple Choices", + 301: "Moved Permanently", + 302: "Found", + 303: "See Other", + 304: "Not Modified", + 305: "Use Proxy", + 306: "Switch Proxy", + 307: "Temporary Redirect", + 308: "Permanent Redirect", + 400: "Bad Request", + 401: "Unauthorized", + 402: "Payment Required", + 403: "Forbidden", + 404: "Not Found", + 405: "Method Not Allowed", + 406: "Not Acceptable", + 407: "Proxy Authentication Required", + 408: "Request Timeout", + 409: "Conflict", + 410: "Gone", + 411: "Length Required", + 412: "Precondition Failed", + 413: "Request Entity Too Large", + 414: "Request-URI Too Long", + 415: "Unsupported Media Type", + 416: "Request Range Not Satisfiable", + 417: "Expectation Failed", + 418: "I'm a teapot", + 420: "Enhance Your Calm", + 422: "Unprocessable Entity", + 423: "Locked", + 424: "Failed Dependency", + 426: "Upgrade Required", + 428: "Precondition Required", + 429: "Too Many Requests", + 431: "Request Header Fields Too Large", + 444: "No Response", + 449: "Retry With", + 450: "Blocked by Windows Parental Controls", + 451: "Wrong Exchange Server", + 499: "Client Closed Request", + 500: "Internal Server Error", + 501: "Not Implemented", + 502: "Bad Gateway", + 503: "Service Unavailable", + 504: "Gateway Timeout", + 505: "HTTP Version Not Supported", + 506: "Variant Also Negotiates", + 507: "Insufficient Storage", + 508: "Loop Detected", + 509: "Bandwidth Limit Exceeded", + 510: "Not Extended", + 511: "Network Authentication Required", + 598: "Network read timeout error", + 599: "Network connect timeout error", +} diff --git a/vendor/github.com/go-openapi/runtime/text.go b/vendor/github.com/go-openapi/runtime/text.go new file mode 100644 index 00000000000..f33320b7dd5 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/text.go @@ -0,0 +1,116 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package runtime + +import ( + "bytes" + "encoding" + "errors" + "fmt" + "io" + "reflect" + + "github.com/go-openapi/swag" +) + +// TextConsumer creates a new text consumer +func TextConsumer() Consumer { + return ConsumerFunc(func(reader io.Reader, data interface{}) error { + if reader == nil { + return errors.New("TextConsumer requires a reader") // early exit + } + + buf := new(bytes.Buffer) + _, err := buf.ReadFrom(reader) + if err != nil { + return err + } + b := buf.Bytes() + + // If the buffer is empty, no need to unmarshal it, which causes a panic. + if len(b) == 0 { + return nil + } + + if tu, ok := data.(encoding.TextUnmarshaler); ok { + err := tu.UnmarshalText(b) + if err != nil { + return fmt.Errorf("text consumer: %v", err) + } + + return nil + } + + t := reflect.TypeOf(data) + if data != nil && t.Kind() == reflect.Ptr { + v := reflect.Indirect(reflect.ValueOf(data)) + if t.Elem().Kind() == reflect.String { + v.SetString(string(b)) + return nil + } + } + + return fmt.Errorf("%v (%T) is not supported by the TextConsumer, %s", + data, data, "can be resolved by supporting TextUnmarshaler interface") + }) +} + +// TextProducer creates a new text producer +func TextProducer() Producer { + return ProducerFunc(func(writer io.Writer, data interface{}) error { + if writer == nil { + return errors.New("TextProducer requires a writer") // early exit + } + + if data == nil { + return errors.New("no data given to produce text from") + } + + if tm, ok := data.(encoding.TextMarshaler); ok { + txt, err := tm.MarshalText() + if err != nil { + return fmt.Errorf("text producer: %v", err) + } + _, err = writer.Write(txt) + return err + } + + if str, ok := data.(error); ok { + _, err := writer.Write([]byte(str.Error())) + return err + } + + if str, ok := data.(fmt.Stringer); ok { + _, err := writer.Write([]byte(str.String())) + return err + } + + v := reflect.Indirect(reflect.ValueOf(data)) + if t := v.Type(); t.Kind() == reflect.Struct || t.Kind() == reflect.Slice { + b, err := swag.WriteJSON(data) + if err != nil { + return err + } + _, err = writer.Write(b) + return err + } + if v.Kind() != reflect.String { + return fmt.Errorf("%T is not a supported type by the TextProducer", data) + } + + _, err := writer.Write([]byte(v.String())) + return err + }) +} diff --git a/vendor/github.com/go-openapi/runtime/values.go b/vendor/github.com/go-openapi/runtime/values.go new file mode 100644 index 00000000000..11f5732af4e --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/values.go @@ -0,0 +1,19 @@ +package runtime + +// Values typically represent parameters on a http request. +type Values map[string][]string + +// GetOK returns the values collection for the given key. +// When the key is present in the map it will return true for hasKey. +// When the value is not empty it will return true for hasValue. +func (v Values) GetOK(key string) (value []string, hasKey bool, hasValue bool) { + value, hasKey = v[key] + if !hasKey { + return + } + if len(value) == 0 { + return + } + hasValue = true + return +} diff --git a/vendor/github.com/go-openapi/runtime/xml.go b/vendor/github.com/go-openapi/runtime/xml.go new file mode 100644 index 00000000000..821c7393dfb --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/xml.go @@ -0,0 +1,36 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package runtime + +import ( + "encoding/xml" + "io" +) + +// XMLConsumer creates a new XML consumer +func XMLConsumer() Consumer { + return ConsumerFunc(func(reader io.Reader, data interface{}) error { + dec := xml.NewDecoder(reader) + return dec.Decode(data) + }) +} + +// XMLProducer creates a new XML producer +func XMLProducer() Producer { + return ProducerFunc(func(writer io.Writer, data interface{}) error { + enc := xml.NewEncoder(writer) + return enc.Encode(data) + }) +} diff --git a/vendor/github.com/go-openapi/runtime/yamlpc/yaml.go b/vendor/github.com/go-openapi/runtime/yamlpc/yaml.go new file mode 100644 index 00000000000..b30d3771263 --- /dev/null +++ b/vendor/github.com/go-openapi/runtime/yamlpc/yaml.go @@ -0,0 +1,40 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package yamlpc + +import ( + "io" + + "github.com/go-openapi/runtime" + + "gopkg.in/yaml.v2" +) + +// YAMLConsumer creates a consumer for yaml data +func YAMLConsumer() runtime.Consumer { + return runtime.ConsumerFunc(func(r io.Reader, v interface{}) error { + dec := yaml.NewDecoder(r) + return dec.Decode(v) + }) +} + +// YAMLProducer creates a producer for yaml data +func YAMLProducer() runtime.Producer { + return runtime.ProducerFunc(func(w io.Writer, v interface{}) error { + enc := yaml.NewEncoder(w) + defer enc.Close() + return enc.Encode(v) + }) +} diff --git a/vendor/github.com/go-openapi/spec/.editorconfig b/vendor/github.com/go-openapi/spec/.editorconfig new file mode 100644 index 00000000000..3152da69a5d --- /dev/null +++ b/vendor/github.com/go-openapi/spec/.editorconfig @@ -0,0 +1,26 @@ +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true + +# Set default charset +[*.{js,py,go,scala,rb,java,html,css,less,sass,md}] +charset = utf-8 + +# Tab indentation (no size specified) +[*.go] +indent_style = tab + +[*.md] +trim_trailing_whitespace = false + +# Matches the exact files either package.json or .travis.yml +[{package.json,.travis.yml}] +indent_style = space +indent_size = 2 diff --git a/vendor/github.com/go-openapi/spec/.gitignore b/vendor/github.com/go-openapi/spec/.gitignore new file mode 100644 index 00000000000..dd91ed6a04e --- /dev/null +++ b/vendor/github.com/go-openapi/spec/.gitignore @@ -0,0 +1,2 @@ +secrets.yml +coverage.out diff --git a/vendor/github.com/go-openapi/spec/.golangci.yml b/vendor/github.com/go-openapi/spec/.golangci.yml new file mode 100644 index 00000000000..835d55e7425 --- /dev/null +++ b/vendor/github.com/go-openapi/spec/.golangci.yml @@ -0,0 +1,42 @@ +linters-settings: + govet: + check-shadowing: true + golint: + min-confidence: 0 + gocyclo: + min-complexity: 45 + maligned: + suggest-new: true + dupl: + threshold: 200 + goconst: + min-len: 2 + min-occurrences: 2 + +linters: + enable-all: true + disable: + - maligned + - unparam + - lll + - gochecknoinits + - gochecknoglobals + - funlen + - godox + - gocognit + - whitespace + - wsl + - wrapcheck + - testpackage + - nlreturn + - gomnd + - exhaustivestruct + - goerr113 + - errorlint + - nestif + - godot + - gofumpt + - paralleltest + - tparallel + - thelper + - ifshort diff --git a/vendor/github.com/go-openapi/spec/.travis.yml b/vendor/github.com/go-openapi/spec/.travis.yml new file mode 100644 index 00000000000..2281a07b057 --- /dev/null +++ b/vendor/github.com/go-openapi/spec/.travis.yml @@ -0,0 +1,31 @@ +after_success: +- bash <(curl -s https://codecov.io/bash) +go: +- 1.16.x +- 1.x +arch: + - amd64 +jobs: + include: + # only run fast tests on ppc64le + - go: 1.x + arch: ppc64le + script: + - gotestsum -f short-verbose -- ./... + + # include linting job, but only for latest go version and amd64 arch + - go: 1.x + arch: amd64 + install: + go get github.com/golangci/golangci-lint/cmd/golangci-lint + script: + - golangci-lint run --new-from-rev master + +install: +- GO111MODULE=off go get -u gotest.tools/gotestsum +language: go +notifications: + slack: + secure: QUWvCkBBK09GF7YtEvHHVt70JOkdlNBG0nIKu/5qc4/nW5HP8I2w0SEf/XR2je0eED1Qe3L/AfMCWwrEj+IUZc3l4v+ju8X8R3Lomhme0Eb0jd1MTMCuPcBT47YCj0M7RON7vXtbFfm1hFJ/jLe5+9FXz0hpXsR24PJc5ZIi/ogNwkaPqG4BmndzecpSh0vc2FJPZUD9LT0I09REY/vXR0oQAalLkW0asGD5taHZTUZq/kBpsNxaAFrLM23i4mUcf33M5fjLpvx5LRICrX/57XpBrDh2TooBU6Qj3CgoY0uPRYUmSNxbVx1czNzl2JtEpb5yjoxfVPQeg0BvQM00G8LJINISR+ohrjhkZmAqchDupAX+yFrxTtORa78CtnIL6z/aTNlgwwVD8kvL/1pFA/JWYmKDmz93mV/+6wubGzNSQCstzjkFA4/iZEKewKUoRIAi/fxyscP6L/rCpmY/4llZZvrnyTqVbt6URWpopUpH4rwYqreXAtJxJsfBJIeSmUIiDIOMGkCTvyTEW3fWGmGoqWtSHLoaWDyAIGb7azb+KvfpWtEcoPFWfSWU+LGee0A/YsUhBl7ADB9A0CJEuR8q4BPpKpfLwPKSiKSAXL7zDkyjExyhtgqbSl2jS+rKIHOZNL8JkCcTP2MKMVd563C5rC5FMKqu3S9m2b6380E= +script: +- gotestsum -f short-verbose -- -race -coverprofile=coverage.txt -covermode=atomic ./... diff --git a/vendor/github.com/go-openapi/spec/CODE_OF_CONDUCT.md b/vendor/github.com/go-openapi/spec/CODE_OF_CONDUCT.md new file mode 100644 index 00000000000..9322b065e37 --- /dev/null +++ b/vendor/github.com/go-openapi/spec/CODE_OF_CONDUCT.md @@ -0,0 +1,74 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or +advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at ivan+abuse@flanders.co.nz. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/vendor/github.com/go-openapi/spec/LICENSE b/vendor/github.com/go-openapi/spec/LICENSE new file mode 100644 index 00000000000..d6456956733 --- /dev/null +++ b/vendor/github.com/go-openapi/spec/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/go-openapi/spec/README.md b/vendor/github.com/go-openapi/spec/README.md new file mode 100644 index 00000000000..18782c6dafe --- /dev/null +++ b/vendor/github.com/go-openapi/spec/README.md @@ -0,0 +1,34 @@ +# OAI object model + +[![Build Status](https://travis-ci.org/go-openapi/spec.svg?branch=master)](https://travis-ci.org/go-openapi/spec) + +[![codecov](https://codecov.io/gh/go-openapi/spec/branch/master/graph/badge.svg)](https://codecov.io/gh/go-openapi/spec) +[![Slack Status](https://slackin.goswagger.io/badge.svg)](https://slackin.goswagger.io) +[![license](http://img.shields.io/badge/license-Apache%20v2-orange.svg)](https://raw.githubusercontent.com/go-openapi/spec/master/LICENSE) +[![Go Reference](https://pkg.go.dev/badge/github.com/go-openapi/spec.svg)](https://pkg.go.dev/github.com/go-openapi/spec) +[![Go Report Card](https://goreportcard.com/badge/github.com/go-openapi/spec)](https://goreportcard.com/report/github.com/go-openapi/spec) + +The object model for OpenAPI specification documents. + +### FAQ + +* What does this do? + +> 1. This package knows how to marshal and unmarshal Swagger API specifications into a golang object model +> 2. It knows how to resolve $ref and expand them to make a single root document + +* How does it play with the rest of the go-openapi packages ? + +> 1. This package is at the core of the go-openapi suite of packages and [code generator](https://github.com/go-swagger/go-swagger) +> 2. There is a [spec loading package](https://github.com/go-openapi/loads) to fetch specs as JSON or YAML from local or remote locations +> 3. There is a [spec validation package](https://github.com/go-openapi/validate) built on top of it +> 4. There is a [spec analysis package](https://github.com/go-openapi/analysis) built on top of it, to analyze, flatten, fix and merge spec documents + +* Does this library support OpenAPI 3? + +> No. +> This package currently only supports OpenAPI 2.0 (aka Swagger 2.0). +> There is no plan to make it evolve toward supporting OpenAPI 3.x. +> This [discussion thread](https://github.com/go-openapi/spec/issues/21) relates the full story. +> +> An early attempt to support Swagger 3 may be found at: https://github.com/go-openapi/spec3 diff --git a/vendor/github.com/go-openapi/spec/appveyor.yml b/vendor/github.com/go-openapi/spec/appveyor.yml new file mode 100644 index 00000000000..0903593916e --- /dev/null +++ b/vendor/github.com/go-openapi/spec/appveyor.yml @@ -0,0 +1,32 @@ +version: "0.1.{build}" + +clone_folder: C:\go-openapi\spec +shallow_clone: true # for startup speed +pull_requests: + do_not_increment_build_number: true + +#skip_tags: true +#skip_branch_with_pr: true + +# appveyor.yml +build: off + +environment: + GOPATH: c:\gopath + +stack: go 1.15 + +test_script: + - go test -v -timeout 20m ./... + +deploy: off + +notifications: + - provider: Slack + incoming_webhook: https://hooks.slack.com/services/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 + auth_token: + secure: Sf7kZf7ZGbnwWUMpffHwMu5A0cHkLK2MYY32LNTPj4+/3qC3Ghl7+9v4TSLOqOlCwdRNjOGblAq7s+GDJed6/xgRQl1JtCi1klzZNrYX4q01pgTPvvGcwbBkIYgeMaPeIRcK9OZnud7sRXdttozgTOpytps2U6Js32ip7uj5mHSg2ub0FwoSJwlS6dbezZ8+eDhoha0F/guY99BEwx8Bd+zROrT2TFGsSGOFGN6wFc7moCqTHO/YkWib13a2QNXqOxCCVBy/lt76Wp+JkeFppjHlzs/2lP3EAk13RIUAaesdEUHvIHrzCyNJEd3/+KO2DzsWOYfpktd+KBCvgaYOsoo7ubdT3IROeAegZdCgo/6xgCEsmFc9ZcqCfN5yNx2A+BZ2Vwmpws+bQ1E1+B5HDzzaiLcYfG4X2O210QVGVDLWsv1jqD+uPYeHY2WRfh5ZsIUFvaqgUEnwHwrK44/8REAhQavt1QAj5uJpsRd7CkRVPWRNK+yIky+wgbVUFEchRNmS55E7QWf+W4+4QZkQi7vUTMc9nbTUu2Es9NfvfudOpM2wZbn98fjpb/qq/nRv6Bk+ca+7XD5/IgNLMbWp2ouDdzbiHLCOfDUiHiDJhLfFZx9Bwo7ZwfzeOlbrQX66bx7xRKYmOe4DLrXhNcpbsMa8qbfxlZRCmYbubB/Y8h4= + channel: bots + on_build_success: false + on_build_failure: true + on_build_status_changed: true diff --git a/vendor/github.com/go-openapi/spec/bindata.go b/vendor/github.com/go-openapi/spec/bindata.go new file mode 100644 index 00000000000..afc83850c2e --- /dev/null +++ b/vendor/github.com/go-openapi/spec/bindata.go @@ -0,0 +1,297 @@ +// Code generated by go-bindata. DO NOT EDIT. +// sources: +// schemas/jsonschema-draft-04.json (4.357kB) +// schemas/v2/schema.json (40.248kB) + +package spec + +import ( + "bytes" + "compress/gzip" + "crypto/sha256" + "fmt" + "io" + "io/ioutil" + "os" + "path/filepath" + "strings" + "time" +) + +func bindataRead(data []byte, name string) ([]byte, error) { + gz, err := gzip.NewReader(bytes.NewBuffer(data)) + if err != nil { + return nil, fmt.Errorf("read %q: %v", name, err) + } + + var buf bytes.Buffer + _, err = io.Copy(&buf, gz) + clErr := gz.Close() + + if err != nil { + return nil, fmt.Errorf("read %q: %v", name, err) + } + if clErr != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +type asset struct { + bytes []byte + info os.FileInfo + digest [sha256.Size]byte +} + +type bindataFileInfo struct { + name string + size int64 + mode os.FileMode + modTime time.Time +} + +func (fi bindataFileInfo) Name() string { + return fi.name +} +func (fi bindataFileInfo) Size() int64 { + return fi.size +} +func (fi bindataFileInfo) Mode() os.FileMode { + return fi.mode +} +func (fi bindataFileInfo) ModTime() time.Time { + return fi.modTime +} +func (fi bindataFileInfo) IsDir() bool { + return false +} +func (fi bindataFileInfo) Sys() interface{} { + return nil +} + +var _jsonschemaDraft04Json = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xc4\x57\x3d\x6f\xdb\x3c\x10\xde\xf3\x2b\x08\x26\x63\xf2\x2a\x2f\xd0\xc9\x5b\xd1\x2e\x01\x5a\x34\x43\x37\x23\x03\x6d\x9d\x6c\x06\x14\xa9\x50\x54\x60\xc3\xd0\x7f\x2f\x28\x4a\x14\x29\x91\x92\x2d\xa7\x8d\x97\x28\xbc\xaf\xe7\x8e\xf7\xc5\xd3\x0d\x42\x08\x61\x9a\xe2\x15\xc2\x7b\xa5\x8a\x55\x92\xbc\x96\x82\x3f\x94\xdb\x3d\xe4\xe4\x3f\x21\x77\x49\x2a\x49\xa6\x1e\x1e\xbf\x24\xe6\xec\x16\xdf\x1b\xa1\x3b\xf3\xff\x02\xc9\x14\xca\xad\xa4\x85\xa2\x82\x6b\xe9\x6f\x42\x02\x32\x2c\x28\x07\x45\x5a\x15\x3d\x77\x46\x39\xd5\xcc\x25\x5e\x21\x83\xb8\x21\x18\xb6\xaf\x52\x92\xa3\x47\x68\x88\xea\x58\x80\x56\x4e\x1a\xf2\xbd\x4f\xcc\x29\x7f\x52\x90\x6b\x7d\xff\x0f\x48\xb4\x3d\x3f\x21\x7c\x27\x21\xd3\x2a\x6e\x31\xaa\x2d\x53\xdd\xf3\xe3\x42\x94\x54\xd1\x77\x78\xe2\x0a\x76\x20\xe3\x20\x68\xcb\x30\x86\x41\xf3\x2a\xc7\x2b\xf4\x78\x8e\xfe\xef\x90\x91\x8a\xa9\xc7\xb1\x1d\xc2\xd8\x2f\x0d\x75\xed\xc1\x4e\x9c\xc8\x25\x43\xac\xa8\xbe\xd7\xcc\xa9\xd1\xa9\x21\xa0\x1a\xbd\x04\x61\x94\x34\x2f\x18\xfc\x3e\x16\x50\x8e\x4d\x03\x6f\x1c\x58\xdb\x48\x23\xbc\x11\x82\x01\xe1\xfa\xd3\x3a\x8e\x30\xaf\x18\x33\x7f\xf3\x8d\x39\x11\x9b\x57\xd8\x2a\xfd\x55\x2a\x49\xf9\x0e\xc7\xec\x37\xd4\x25\xf7\xec\x5c\x66\xc7\xd7\x99\xaa\xcf\x4f\x89\x8a\xd3\xb7\x0a\x3a\xaa\x92\x15\xf4\x30\x6f\x1c\xb0\xd6\x46\xe7\x98\x39\x2d\xa4\x28\x40\x2a\x3a\x88\x9e\x29\xba\x88\x37\x2d\xca\x60\x38\xfa\xba\x5b\x20\xac\xa8\x62\xb0\x4c\xd4\xaf\xda\x45\x0a\xba\x5c\x3b\xb9\xc7\x79\xc5\x14\x2d\x18\x34\x19\x1c\x51\xdb\x25\x4d\xb4\x7e\x06\x14\x38\x6c\x59\x55\xd2\x77\xf8\x69\x59\xfc\x7b\x73\xed\x93\x43\xcb\x32\x6d\x3c\x28\xdc\x1b\x9a\xd3\x62\xab\xc2\x27\xf7\x41\xc9\x08\x2b\x23\x08\xad\x13\x57\x21\x9c\xd3\x72\x0d\x42\x72\xf8\x01\x7c\xa7\xf6\x83\xce\x39\xd7\x82\x3c\x1f\x2f\xd6\x60\x1b\xa2\xdf\x35\x89\x52\x20\xe7\x73\x74\xe0\x66\x26\x64\x4e\xb4\x97\x58\xc2\x0e\x0e\xe1\x60\x92\x34\x6d\xa0\x10\xd6\xb5\x83\x61\x27\xe6\x47\xd3\x89\xbd\x63\xfd\x3b\x8d\x03\x3d\x6c\x42\x2d\x5b\x70\xee\xe8\xdf\x4b\xf4\x66\x4e\xe1\x01\x45\x17\x80\x74\xad\x4f\xc3\xf3\xae\xc6\x1d\xc6\xd7\xc2\xce\xc9\xe1\x29\x30\x86\x2f\x4a\xa6\x4b\x15\x84\x73\xc9\x6f\xfd\x7f\xa5\x6e\x9e\xbd\xf1\xb0\xd4\xdd\x45\x5a\xc2\x3e\x4b\x78\xab\xa8\x84\x74\x4a\x91\x3b\x92\x23\x05\xf2\x1c\x1e\x7b\xf3\x09\xf8\xcf\xab\x24\xb6\x60\xa2\xe8\x4c\x9f\x75\x77\xaa\x8c\xe6\x01\x45\x36\x86\xcf\xc3\x63\x3a\xea\xd4\x8d\x7e\x06\xac\x14\x0a\xe0\x29\xf0\xed\x07\x22\x1a\x65\xda\x44\xae\xa2\x73\x1a\xe6\x90\x69\xa2\x8c\x46\xb2\x2f\xde\x49\x38\x08\xed\xfe\xfd\x41\xaf\x9f\xa9\x55\xd7\xdd\x22\x8d\xfa\x45\x63\xc5\x0f\x80\xf3\xb4\x08\xd6\x79\x30\x9e\x93\xee\x59\xa6\xd0\x4b\xee\x22\xe3\x33\xc1\x3a\x27\x68\x36\x78\x7e\x87\x0a\x06\xd5\x2e\x20\xd3\xaf\x15\xfb\xd8\x3b\x73\x14\xbb\x92\xed\x05\x5d\x2e\x29\x38\x2c\x94\xe4\x42\x45\x5e\xd3\xb5\x7d\xdf\x47\xca\x38\xb4\x5c\xaf\xfb\x7d\xdd\x6d\xf4\xa1\x2d\x77\xdd\x2f\xce\x6d\xc4\x7b\x8b\x4e\x67\xa9\x6f\xfe\x04\x00\x00\xff\xff\xb1\xd1\x27\x78\x05\x11\x00\x00") + +func jsonschemaDraft04JsonBytes() ([]byte, error) { + return bindataRead( + _jsonschemaDraft04Json, + "jsonschema-draft-04.json", + ) +} + +func jsonschemaDraft04Json() (*asset, error) { + bytes, err := jsonschemaDraft04JsonBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "jsonschema-draft-04.json", size: 4357, mode: os.FileMode(0640), modTime: time.Unix(1568963823, 0)} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xe1, 0x48, 0x9d, 0xb, 0x47, 0x55, 0xf0, 0x27, 0x93, 0x30, 0x25, 0x91, 0xd3, 0xfc, 0xb8, 0xf0, 0x7b, 0x68, 0x93, 0xa8, 0x2a, 0x94, 0xf2, 0x48, 0x95, 0xf8, 0xe4, 0xed, 0xf1, 0x1b, 0x82, 0xe2}} + return a, nil +} + +var _v2SchemaJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x5d\x4f\x93\xdb\x36\xb2\xbf\xfb\x53\xa0\x14\x57\xd9\xae\xd8\x92\xe3\xf7\x2e\xcf\x97\xd4\xbc\xd8\x49\x66\x37\x5e\x4f\x79\x26\xbb\x87\x78\x5c\x05\x91\x2d\x09\x09\x09\x30\x00\x38\x33\x5a\xef\x7c\xf7\x2d\xf0\x9f\x08\x02\x20\x41\x8a\xd2\xc8\x0e\x0f\xa9\x78\x28\xa0\xd1\xdd\x68\x34\x7e\xdd\xf8\xf7\xf9\x11\x42\x33\x49\x64\x04\xb3\xd7\x68\x76\x86\xfe\x76\xf9\xfe\x1f\xe8\x32\xd8\x40\x8c\xd1\x8a\x71\x74\x79\x8b\xd7\x6b\xe0\xe8\xd5\xfc\x25\x3a\xbb\x38\x9f\xcf\x9e\xab\x0a\x24\x54\xa5\x37\x52\x26\xaf\x17\x0b\x91\x17\x99\x13\xb6\xb8\x79\xb5\x10\x59\xdd\xf9\xef\x82\xd1\x6f\xf2\xc2\x8f\xf3\x4f\xb5\x1a\xea\xc7\x17\x45\x41\xc6\xd7\x8b\x90\xe3\x95\x7c\xf1\xf2\x7f\x8b\xca\x45\x3d\xb9\x4d\x32\xa6\xd8\xf2\x77\x08\x64\xfe\x8d\xc3\x9f\x29\xe1\xa0\x9a\xff\xed\x11\x42\x08\xcd\x8a\xd6\xb3\x9f\x15\x67\x74\xc5\xca\x7f\x27\x58\x6e\xc4\xec\x11\x42\xd7\x59\x5d\x1c\x86\x44\x12\x46\x71\x74\xc1\x59\x02\x5c\x12\x10\xb3\xd7\x68\x85\x23\x01\x59\x81\x04\x4b\x09\x9c\x6a\xbf\x7e\xce\x49\x7d\xba\x7b\x51\xfd\xa1\x44\xe2\xb0\x52\xac\x7d\xb3\x08\x61\x45\x68\x46\x56\x2c\x6e\x80\x86\x8c\xbf\xbd\x93\x40\x05\x61\x74\x96\x95\xbe\x7f\x84\xd0\x7d\x4e\xde\x42\xb7\xe4\xbe\x46\xbb\x14\x5b\x48\x4e\xe8\xba\x90\x05\xa1\x19\xd0\x34\xae\xc4\xce\xbe\xbc\x9a\xbf\x9c\x15\x7f\x5d\x57\xc5\x42\x10\x01\x27\x89\xe2\x48\x51\xb9\xda\x40\xd5\x87\x37\xc0\x15\x5f\x88\xad\x90\xdc\x10\x81\x42\x16\xa4\x31\x50\x39\x2f\x38\xad\xab\xb0\x53\xd8\xac\x94\x56\x6f\xc3\x84\xf4\x11\xa4\x50\xb3\xfa\xe9\xd3\x6f\x9f\x3e\xdf\x2f\xd0\xeb\x8f\x1f\x3f\x7e\xbc\xfe\xf6\xe9\xf7\xaf\x5f\x7f\xfc\x18\x7e\xfb\xec\xfb\xc7\xb3\x36\x79\x54\x43\xe8\x29\xc5\x31\x20\xc6\x11\x49\x9e\xe5\x12\x41\x66\xa0\xe8\xed\x1d\x8e\x93\x08\x5e\xa3\x27\x3b\xc3\x7c\xa2\x73\xba\xc4\x02\x2e\xb0\xdc\xf4\xe5\x76\xd1\xca\x96\xa2\x8a\x94\xcd\x21\xc9\x6c\xec\x2c\x70\x42\x9e\x34\x74\x9d\x19\x7c\xcd\x20\x9c\xea\x2e\x0a\xfe\x42\x84\xd4\x29\x04\x8c\x8a\xb4\x41\xa2\xc1\xdc\x19\x8a\x88\x90\x4a\x49\xef\xce\xdf\xbd\x45\x4a\x52\x81\x70\x10\x40\x22\x21\x44\xcb\x6d\xc5\xec\x4e\x3c\x1c\x45\xef\x57\x9a\xb5\x7d\xae\xfe\xe5\xe4\x31\x86\x90\xe0\xab\x6d\x02\x3b\x2e\xcb\x11\x90\xd9\xa8\xc6\x77\xc2\x59\x98\x06\xfd\xf9\x2e\x78\x45\x01\xa6\xa8\xa0\x71\x5c\xbe\x33\xa7\xd2\xd9\x5f\x95\xef\xd9\xd5\xac\xfd\xdc\x5d\xbf\x5e\xb8\xd1\x3e\xc7\x31\x48\xe0\x5e\x4c\x14\x65\xdf\xb8\xa8\x71\x10\x09\xa3\xc2\xc7\x02\xcb\xa2\x4e\x5a\x02\x82\x94\x13\xb9\xf5\x30\xe6\xb2\xa4\xb5\xfe\x9b\x3e\x7a\xb2\x55\xd2\xa8\x4a\xbc\x16\xb6\x71\x8e\x39\xc7\xdb\x9d\xe1\x10\x09\x71\xbd\x9c\xb3\x41\x89\xd7\xa5\x89\xdc\x57\xb5\x53\x4a\xfe\x4c\xe1\xbc\xa0\x21\x79\x0a\x1a\x0f\x70\xa7\x5c\x08\x8e\xde\xb0\xc0\x43\x24\xad\x74\x63\x0e\xb1\xd9\x90\xe1\xb0\x2d\x13\xa7\x6d\x78\xfd\x04\x14\x38\x8e\x90\xaa\xce\x63\xac\x3e\x23\xbc\x64\xa9\xb4\xf8\x03\x63\xde\xcd\xbe\x16\x13\x4a\x55\xac\x82\x12\xc6\xac\xd4\x35\xf7\x22\xd4\x3a\xff\x22\x73\x0e\x6e\x51\xa0\x75\x1e\xae\x8f\xe8\x5d\xc7\x59\xe6\xe4\x9a\x18\x8d\xd6\x1c\x53\x84\x4d\xb7\x67\x28\x37\x09\x84\x69\x88\x12\x0e\x01\x11\x80\x32\xa2\xf5\xb9\xaa\xc6\xd9\x73\x53\xab\xfb\xb4\x2e\x20\xc6\x54\x92\xa0\x9a\xf3\x69\x1a\x2f\x81\x77\x37\xae\x53\x1a\xce\x40\xc4\xa8\x82\x1c\xb5\xef\xda\x24\x7d\xb9\x61\x69\x14\xa2\x25\xa0\x90\xac\x56\xc0\x81\x4a\xb4\xe2\x2c\xce\x4a\x64\x7a\x9a\x23\xf4\x13\x91\x3f\xa7\x4b\xf4\x63\x84\x6f\x18\x87\x10\xbd\xc3\xfc\x8f\x90\xdd\x52\x44\x04\xc2\x51\xc4\x6e\x21\x74\x48\x21\x81\xc7\xe2\xfd\xea\x12\xf8\x0d\x09\xf6\xe9\x47\x35\xaf\x67\xc4\x14\xf7\x22\x27\x97\xe1\xe2\x76\x2d\x06\x8c\x4a\x1c\x48\x3f\x73\x2d\x0b\x5b\x29\x45\x24\x00\x2a\x0c\x11\xec\x94\xca\xc2\xa6\xc1\x37\x21\x43\x83\x3b\x5f\x97\xf1\x43\x5e\x53\x73\x19\xa5\x36\xd8\x2d\x05\x2e\x34\x0b\xeb\x39\xfc\x1d\x63\x51\x01\xbd\x3d\xbb\x90\x84\x40\x25\x59\x6d\x09\x5d\xa3\x1c\x37\xe6\x5c\x16\x9a\x40\x09\x70\xc1\xe8\x82\xf1\x35\xa6\xe4\xdf\x99\x5c\x8e\x9e\x4d\x79\xb4\x27\x2f\xbf\x7e\xf8\x05\x25\x8c\x50\xa9\x98\x29\x90\x62\x60\xea\x75\xae\x13\xca\xbf\x2b\x1a\x29\x27\x76\xd6\x20\xc6\x64\x5f\xe6\x32\x1a\x08\x87\x21\x07\x21\xbc\xb4\xe4\xe0\x32\x67\xa6\xcd\xf3\x1e\xcd\xd9\x6b\xb6\x6f\x8e\x27\xa7\xed\xdb\xe7\xbc\xcc\x1a\x07\xce\x6f\x87\x33\xf0\xba\x51\x17\x22\x66\x78\x79\x8e\xce\xe5\x13\x81\x80\x06\x2c\xe5\x78\x0d\xa1\xb2\xb8\x54\xa8\x79\x09\xbd\xbf\x3c\x47\x01\x8b\x13\x2c\xc9\x32\xaa\xaa\x1d\xd5\xee\xab\x36\xbd\x6c\xfd\x54\x6c\xc8\x08\x01\x3c\xbd\xe7\x07\x88\xb0\x24\x37\x79\x90\x28\x4a\x1d\x10\x1a\x92\x1b\x12\xa6\x38\x42\x40\xc3\x4c\x43\x62\x8e\xae\x36\xb0\x45\x71\x2a\xa4\x9a\x23\x79\x59\xb1\xa8\xf2\xa4\x0c\x60\x9f\xcc\x8d\x40\xf5\x80\xca\xa8\x99\xc3\xa7\x85\x1f\x31\x25\xa9\x82\xc5\x6d\xbd\xd8\x36\x76\x7c\x02\x28\x97\xf6\x1d\x74\x3b\x11\x7e\x91\xae\x32\xf8\x6c\xf4\xe6\x7b\x9a\xa5\x1f\x62\xc6\x21\xcf\x9a\xe5\xed\x8b\x02\xf3\x2c\x33\x33\xdf\x00\xca\xc9\x09\xb4\x04\xf5\xa5\x08\xd7\xc3\x02\x18\x66\xf1\xab\x1e\x83\x37\x4c\xcd\x12\xc1\x1d\x50\xf6\xaa\xbd\xfe\xe2\x73\x48\x38\x08\xa0\x32\x9b\x18\x44\x86\x0b\x6a\xc1\xaa\x26\x96\x2d\x96\x3c\xa0\x54\x65\x73\xe3\x08\xb5\x8b\x99\xbd\x82\xbc\x9e\xc2\xe8\x53\x46\x83\x3f\x33\x54\x2b\x5b\xad\x92\x79\xd9\x8f\x5d\x93\x98\xf2\xe6\xc6\x1c\xe6\x9a\x9e\xfc\x43\x82\x31\x66\x8e\x53\x77\xfe\x90\xe7\xf3\xf6\xe9\x62\x23\x3f\x10\x93\x18\xae\x72\x1a\x9d\xf9\x48\xcb\xcc\x5a\x65\xc7\x4a\x04\xf0\xf3\xd5\xd5\x05\x8a\x41\x08\xbc\x86\x86\x43\x51\x6c\xe0\x46\x57\xf6\x44\x40\x0d\xfb\xff\xa2\xc3\x7c\x3d\x39\x84\xdc\x09\x22\x64\x4f\x12\xd9\xba\xaa\xf6\xe3\xbd\x56\xdd\x91\x25\x6a\x14\x9c\x89\x34\x8e\x31\xdf\xee\x15\x7e\x2f\x39\x81\x15\x2a\x28\x95\x66\x51\xf5\xfd\x83\xc5\xfe\x15\x07\xcf\xf7\x08\xee\x1d\x8e\xb6\xc5\x52\xcc\x8c\x5a\x93\x66\xc5\xd8\x79\x38\x46\xd6\xa7\x88\x37\xc9\x2e\xe3\xd2\xa5\x7b\x4b\x3a\xdc\xa1\xdc\x9e\x29\xf1\x8c\x8a\x99\x16\x47\x8d\xd4\x78\x8b\xf6\x1c\xe9\x71\x54\x1b\x69\xa8\x4a\x93\x37\xe5\xb2\x2c\x4f\x0c\x92\xab\xa0\x73\x32\x72\x59\xd3\xf0\x2d\x8d\xed\xca\x37\x16\x19\x9e\xdb\x1c\xab\x17\x49\xc3\x0f\x37\xdc\x88\xb1\xb4\xd4\x42\xcb\x58\x5e\x6a\x52\x0b\x15\x10\x0a\xb0\x04\xe7\xf8\x58\x32\x16\x01\xa6\xcd\x01\xb2\xc2\x69\x24\x35\x38\x6f\x30\x6a\xae\x1b\xb4\x71\xaa\xad\x1d\xa0\xd6\x20\x2d\x8b\x3c\xc6\x82\x62\x27\x34\x6d\x15\x84\x7b\x43\xb1\x35\x78\xa6\x24\x77\x28\xc1\x6e\xfc\xe9\x48\x74\xf4\x15\xe3\xe1\x84\x42\x88\x40\x7a\x26\x49\x3b\x48\xb1\xa4\x19\x8e\x0c\xa7\xb5\x01\x6c\x0c\x97\x61\x8a\xc2\x32\xd8\x8c\x44\x69\x24\xbf\x65\x1d\x74\xd6\xe5\x44\xef\xec\x48\x5e\xb7\x8a\xa3\x29\x8e\x41\x64\xce\x1f\x88\xdc\x00\x47\x4b\x40\x98\x6e\xd1\x0d\x8e\x48\x98\x63\x5c\x21\xb1\x4c\x05\x0a\x58\x98\xc5\x6d\x4f\x0a\x77\x53\x4f\x8b\xc4\x44\x1f\xb2\xdf\x8d\x3b\xea\x9f\xfe\xf6\xf2\xc5\xff\x5d\x7f\xfe\x9f\xfb\x67\x8f\xff\xf3\xe9\x69\xd1\xfe\xb3\xc7\xfd\x3c\xf8\x3f\x71\x94\x82\x23\xd1\x72\x00\xb7\x42\x99\x6c\xc0\x60\x7b\x0f\x79\xea\xa8\x53\x4b\x56\x31\xfa\x0b\x52\x9f\x96\xdb\xcd\x2f\xd7\x67\xcd\x04\x19\x85\xfe\xdb\x02\x9a\x59\x03\xad\x63\x3c\xea\xff\x2e\x18\xfd\x00\xd9\xe2\x56\x60\x59\x93\xb9\xb6\xb2\x3e\x3c\x2c\xab\x0f\xa7\xb2\x89\x43\xc7\xf6\xd5\xce\x2e\xad\xa6\xa9\xed\xa6\xc6\x5a\xb4\xa6\x67\xdf\x8c\x26\x7b\x50\x5a\x91\x08\x2e\x6d\xd4\x3a\xc1\x9d\xf2\xdb\xde\x1e\xb2\x2c\x6c\xa5\x64\xc9\x16\xb4\x90\xaa\x4a\xb7\x0c\xde\x13\xc3\x2a\x9a\x11\x9b\x7a\x1b\x3d\x95\x97\x37\x31\x6b\x69\x7e\x34\xc0\x67\x1f\x66\x19\x49\xef\xf1\x25\xf5\xac\x0e\xea\x0a\x28\x8d\x4d\x7e\xd9\x57\x4b\x49\xe5\xc6\xb3\x25\xfd\xe6\x57\x42\x25\xac\xcd\xcf\x36\x74\x8e\xca\x24\x47\xe7\x80\xa8\x92\x72\xbd\x3d\x84\x2d\x65\xe2\x82\x1a\x9c\xc4\x44\x92\x1b\x10\x79\x8a\xc4\x4a\x2f\x60\x51\x04\x81\xaa\xf0\xa3\x95\x27\xd7\x12\x7b\xa3\x96\x03\x45\x96\xc1\x8a\x07\xc9\xb2\xb0\x95\x52\x8c\xef\x48\x9c\xc6\x7e\x94\xca\xc2\x0e\x07\x12\x44\xa9\x20\x37\xf0\xae\x0f\x49\xa3\x96\x9d\x4b\x42\x7b\x70\x59\x14\xee\xe0\xb2\x0f\x49\xa3\x96\x4b\x97\xbf\x00\x5d\x4b\x4f\xfc\xbb\x2b\xee\x92\xb9\x17\xb5\xaa\xb8\x0b\x97\x17\x9b\x43\xfd\xd6\xc2\xb2\xc2\x2e\x29\xcf\xfd\x87\x4a\x55\xda\x25\x63\x1f\x5a\x65\x69\x2b\x2d\x3d\x67\xe9\x41\xae\x5e\xc1\x6e\x2b\xd4\xdb\x3e\xa8\xd3\x26\xd2\x48\x92\x24\xca\x61\x86\x8f\x8c\xbb\xf2\x8e\x91\xdf\x1f\x06\x19\x33\xf3\x03\x4d\xba\xcd\xe2\x2d\xfb\x69\xe9\x16\x15\x13\xd5\x56\x85\x4e\x3c\x5b\x8a\xbf\x25\x72\x83\xee\x5e\x20\x22\xf2\xc8\xaa\x7b\xdb\x8e\xe4\x29\x58\xca\x38\xb7\x3f\x2e\x59\xb8\xbd\xa8\x16\x16\xf7\xdb\x79\x51\x9f\x5a\xb4\x8d\x87\x3a\x6e\xbc\x3e\xc5\xb4\xcd\x58\xf9\xf5\x3c\xb9\x6f\x49\xaf\x57\xc1\xfa\x1c\x5d\x6d\x88\x8a\x8b\xd3\x28\xcc\xb7\xef\x10\x8a\x4a\x74\xa9\x4a\xa7\x62\xbf\x0d\x76\x23\x6f\x59\xd9\x31\xee\x40\x11\xfb\x28\xec\x8d\x22\x1c\x13\x5a\x64\x94\x23\x16\x60\xbb\xd2\x7c\xa0\x98\xb2\xe5\x6e\xbc\x54\x33\xe0\x3e\xb9\x52\x17\xdb\xb7\x1b\xc8\x12\x20\x8c\x23\xca\x64\x7e\x78\xa3\x62\x5b\x75\x56\xd9\x9e\x2a\x91\x27\xb0\x70\x34\x1f\x90\x89\xb5\x86\x73\x7e\x71\xda\x1e\xfb\x3a\x72\xdc\x5e\x79\x88\xcb\x74\x79\xd9\x64\xe4\xd4\xc2\x9e\xce\xb1\xfe\x85\x5a\xc0\xe9\x0c\x34\x3d\xd0\x43\xce\xa1\x36\x39\xd5\xa1\x4e\xf5\xf8\xb1\xa9\x23\x08\x75\x84\xac\x53\x6c\x3a\xc5\xa6\x53\x6c\x3a\xc5\xa6\x7f\xc5\xd8\xf4\x51\xfd\xff\x25\x4e\xfa\x33\x05\xbe\x9d\x60\xd2\x04\x93\x6a\x5f\x33\x9b\x98\x50\xd2\xe1\x50\x52\xc6\xcc\xdb\x38\x91\xdb\xe6\xaa\xa2\x8f\xa1\x6a\xa6\xd4\xc6\x56\xd6\x8c\x40\x02\x68\x48\xe8\x1a\xe1\x9a\xd9\x2e\xb7\x05\xc3\x34\xda\x2a\xbb\xcd\x12\x36\x98\x22\x50\x4c\xa1\x1b\xc5\xd5\x84\xf0\xbe\x24\x84\xf7\x2f\x22\x37\xef\x94\xd7\x9f\xa0\xde\x04\xf5\x26\xa8\x37\x41\x3d\x64\x40\x3d\xe5\xf2\xde\x60\x89\x27\xb4\x37\xa1\xbd\xda\xd7\xd2\x2c\x26\xc0\x37\x01\x3e\x1b\xef\x5f\x06\xe0\x6b\x7c\x5c\x91\x08\x26\x10\x38\x81\xc0\x09\x04\x76\x4a\x3d\x81\xc0\xbf\x12\x08\x4c\xb0\xdc\x7c\x99\x00\xd0\x75\x70\xb4\xf8\x5a\x7c\xea\xde\x3e\x39\x08\x30\x5a\x27\x35\xed\xb4\x65\xad\x69\x74\x10\x88\x79\xe2\x30\x52\x19\xd6\x04\x21\xa7\x95\xd5\x0e\x03\xf8\xda\x20\xd7\x84\xb4\x26\xa4\x35\x21\xad\x09\x69\x21\x03\x69\x51\x46\xff\xff\x18\x9b\x54\xed\x87\x47\x06\x9d\x4e\x73\x6e\x9a\xb3\xa9\xce\x83\x5e\x4b\xc6\x71\x20\x45\xd7\x72\xf5\x40\x72\x0e\x34\x6c\xf4\x6c\xf3\xba\x5e\x4b\x97\x0e\x52\xb8\xbe\x8b\x79\xa0\x10\x86\xa1\x75\xb0\x6f\xec\xc8\xf4\x3d\x4d\x7b\x86\xc2\x02\x31\x12\x51\xbf\x07\x94\xad\x10\xd6\x2e\x79\xcf\xe9\x1c\xf5\x1e\x31\x23\x5c\x18\xfb\x9c\xfb\x70\xe0\x62\xbd\xf7\xb5\x94\xcf\xf3\xf6\xfa\xc5\x4e\x9c\x85\x76\x1d\xae\x37\xbc\xde\xa3\x41\xcb\x29\xd0\x5e\x70\x67\x50\x93\x6d\x98\xa8\xd3\x67\x0f\x68\xb1\xeb\x38\x47\x07\x10\x1b\xd2\xe2\x18\x68\x6d\x40\xbb\xa3\x40\xba\x21\xf2\x8e\x81\xfb\xf6\x92\x77\x2f\x70\xe8\xdb\xb2\x36\xbf\x30\x91\xc5\x21\xe7\x45\xcc\x34\x0c\x48\x8e\xd0\xf2\x9b\x7c\x3c\xbd\x1c\x04\x3e\x07\xe8\x7c\x2f\x84\x7a\x48\x4d\x1f\xba\xe1\x76\x45\x7b\x60\xe0\x01\xca\xee\x04\xca\x31\xbe\x73\x5f\xa3\x70\x0c\xad\x1f\xa5\xf5\x76\xd5\xbb\xd2\x7e\xfb\x30\x90\xcf\xfa\x67\x7a\xe6\xc3\x37\x42\x19\xe2\xc9\x9c\x61\x4c\xe7\xd1\x77\x55\x86\x6e\x8f\x7b\x85\x42\x33\xa3\xaa\x57\xae\xfd\xd5\xcc\x9c\x56\x68\xe2\xde\x0e\xa8\x2c\xa9\xb0\x7d\xf0\x54\x2d\x80\xf2\x48\x39\x3d\x98\x1a\x6d\x0b\x9d\xba\x53\xfb\xce\xf8\xd1\x7e\xbb\x60\x4f\x06\xf5\xce\xda\xab\xeb\xca\xcb\xd5\xac\x20\xda\x72\x3b\xa2\x4b\x38\xd7\xb5\x89\xbe\x42\xd9\xb9\x73\xc4\x0c\x6d\xb7\xd9\xf8\x8d\xbd\x3e\x9c\xf5\x53\x68\x48\x14\x36\x8f\x09\xc5\x92\xf1\x21\xd1\x09\x07\x1c\xbe\xa7\x91\xf3\x6a\xc8\xc1\x57\xb0\xdd\xc5\xc6\x1d\xad\x76\x1d\xa8\x82\x0e\x4c\x38\xfe\xa5\x8c\xc5\x0a\x40\x5d\xa1\xbb\x98\xd1\xfb\x74\x61\xed\x1a\x98\xaf\x3c\x8c\x1e\xe3\xc2\x92\x29\x74\x3e\x99\xd0\xf9\x41\x50\xd0\x38\x4b\x57\x7e\x5b\x7a\x0e\xe6\xce\x4e\xd7\x19\x35\x57\xbb\x3c\x3c\xd2\x5e\x4f\x4b\x4c\xf7\x0f\x4d\x2b\x91\x5d\x94\xa6\x95\xc8\x69\x25\x72\x5a\x89\x7c\xb8\x95\xc8\x07\x80\x8c\xda\x9c\x64\x7b\xb7\x71\xdf\x57\x12\x4b\x9a\x1f\x72\x0c\x13\x03\xad\x3c\xd5\x4e\xde\x8e\x57\x13\x6d\x34\x86\xcf\x97\xe6\xa4\x68\xc4\xb0\xf6\xc9\xc2\xeb\x8d\x0b\xd7\xcd\xfe\xba\xa6\xf5\x30\xeb\x30\x33\xbe\xc7\x56\x27\xab\x08\xd9\x6d\xbb\x09\xee\x7c\x2d\xcf\xee\x87\x38\xac\xc8\xdd\x90\x9a\x58\x4a\x4e\x96\xa9\x79\x79\xf3\xde\x20\xf0\x96\xe3\x24\x19\xeb\xba\xf2\x53\x19\xab\x12\xaf\x47\xb3\xa0\x3e\xef\x9b\x8d\x6d\x6d\x7b\xde\x3b\x3b\x1a\xc0\x3f\x95\x7e\xed\x78\xfb\x76\xb8\xaf\xb3\xdd\xc5\xeb\x95\xed\x5a\x62\x41\x82\xb3\x54\x6e\x80\x4a\x92\x6f\x36\xbd\x34\xae\xde\x6f\xa4\xc0\xbc\x08\xe3\x84\xfc\x1d\xb6\xe3\xd0\x62\x38\x95\x9b\x57\xe7\x71\x12\x91\x80\xc8\x31\x69\x5e\x60\x21\x6e\x19\x0f\xc7\xa4\x79\x96\x28\x3e\x47\x54\x65\x41\x36\x08\x40\x88\x1f\x58\x08\x56\xaa\xd5\xbf\xaf\xad\x96\xd7\xd6\xcf\x87\xf5\x34\x0f\x71\x93\x6e\x26\xed\x98\x5b\x9f\x4f\xcf\x95\x34\xc6\xd7\x11\xfa\xb0\x81\x22\x1a\xdb\xdf\x8e\xdc\xc3\xb9\xf8\xdd\x5d\x3c\x74\xe6\xea\xb7\x8b\xbf\xf5\x6e\xb3\x46\x2e\x64\xf4\xab\x3c\x4e\xcf\x36\x1d\xfe\xfa\xb8\x36\xba\x8a\xd8\xad\xf6\xc6\x41\x2a\x37\x8c\x17\x0f\xda\xfe\xda\xe7\x65\xbc\x71\x2c\x36\x57\x8a\x47\x12\x4c\xf1\xbd\x77\x6b\xa4\x50\x7e\x77\x7b\x22\x60\x89\xef\xcd\xf5\xb9\x0c\x97\x79\x0d\x2b\x35\x43\xcb\x3d\x24\xf1\x78\xfc\xf8\xcb\x1f\x15\x06\xe2\x78\xd8\x51\x21\xd9\x1f\xf0\xf5\x8f\x86\xa4\x50\xfa\xb1\x47\x43\xa5\xdd\x69\x14\xe8\xa3\xc0\x86\x91\xa7\x81\x50\xb4\x7c\xc0\x81\x80\x77\x7a\x9f\xc6\xc2\xa9\x8c\x05\x33\xb0\x3b\x31\xa4\xf4\xd7\x1b\x26\x55\x97\x7c\x65\xf8\x69\x1a\x84\x8e\x41\x78\xd9\xec\xc5\x11\x16\x1e\x74\x91\xf5\x56\xf5\x57\x49\x47\x5c\x92\xa9\x1e\x99\x36\xf4\xdb\xb1\x0e\xd3\x78\x02\xb0\x9b\x25\xcb\xe9\xe9\x1d\x0d\x44\x01\x42\x08\x91\x64\xd9\xdd\x37\x08\x17\xef\xf9\xe5\x0f\xbd\x46\x91\xf5\xf9\x89\x92\x37\xdd\x89\x59\x44\x1f\x9c\xee\x34\x1e\xbe\x47\x83\x32\x72\x8e\x37\xdf\xac\x69\x38\xef\x75\xb0\xda\xdb\xac\x83\x94\x2f\x39\xa6\x62\x05\x1c\x25\x9c\x49\x16\xb0\xa8\x3c\xc7\x7e\x76\x71\x3e\x6f\xb5\x24\xe7\xe8\xb7\xb9\xc7\x6c\x43\x92\xee\x21\xd4\x17\xa1\x7f\xba\x35\xfe\xae\x39\xbc\xde\xba\x69\xd9\x8e\xe1\x62\xde\x64\x7d\x16\x88\x1b\xed\x29\x11\xfd\x4f\xa9\xff\x99\x90\xc4\xf6\xf4\xf9\x6e\xe9\x28\x23\xd7\xca\xe5\xee\xee\x9f\x63\xb1\x5b\xfb\x10\xd7\x2f\x1d\xf2\xe3\xbf\xb9\xb5\x6f\xa4\x6d\x7d\x25\x79\xfb\x24\x31\xea\x56\xbe\x5d\x53\xcd\x2d\x36\xa3\x6d\xdf\xab\x1c\xb8\x6d\x6f\xc0\x98\xa7\xdd\xaa\x86\x8c\x1d\x39\xa3\x9d\x70\x2b\x9b\x68\xd9\xfd\x33\xfe\xa9\xb6\x4a\x2e\x63\x0f\xcf\x68\x27\xd9\x4c\xb9\x46\x6d\xcb\xbe\xa1\xa8\xd6\x5f\xc6\xd6\x9f\xf1\x4f\xf4\xd4\xb4\x78\xd0\xd6\xf4\x13\x3c\x3b\xac\xd0\xdc\x90\x34\xda\xc9\xb4\x9a\x1a\x8d\xbd\x93\x87\xd4\xe2\x21\x1b\xb3\x2b\xd1\xbe\xe7\x69\xd4\x53\x67\xd5\x40\xa0\xe3\x19\x3f\x6d\x1a\xbc\x0e\x86\x3c\x10\xb4\x3d\x2a\xcd\x78\x32\xe6\xab\xbd\x36\xc9\xf4\x3a\x58\xae\xc3\xf4\x47\xea\xbf\xfb\x47\xff\x0d\x00\x00\xff\xff\xd2\x32\x5a\x28\x38\x9d\x00\x00") + +func v2SchemaJsonBytes() ([]byte, error) { + return bindataRead( + _v2SchemaJson, + "v2/schema.json", + ) +} + +func v2SchemaJson() (*asset, error) { + bytes, err := v2SchemaJsonBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "v2/schema.json", size: 40248, mode: os.FileMode(0640), modTime: time.Unix(1568964748, 0)} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xab, 0x88, 0x5e, 0xf, 0xbf, 0x17, 0x74, 0x0, 0xb2, 0x5a, 0x7f, 0xbc, 0x58, 0xcd, 0xc, 0x25, 0x73, 0xd5, 0x29, 0x1c, 0x7a, 0xd0, 0xce, 0x79, 0xd4, 0x89, 0x31, 0x27, 0x90, 0xf2, 0xff, 0xe6}} + return a, nil +} + +// Asset loads and returns the asset for the given name. +// It returns an error if the asset could not be found or +// could not be loaded. +func Asset(name string) ([]byte, error) { + canonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[canonicalName]; ok { + a, err := f() + if err != nil { + return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err) + } + return a.bytes, nil + } + return nil, fmt.Errorf("Asset %s not found", name) +} + +// AssetString returns the asset contents as a string (instead of a []byte). +func AssetString(name string) (string, error) { + data, err := Asset(name) + return string(data), err +} + +// MustAsset is like Asset but panics when Asset would return an error. +// It simplifies safe initialization of global variables. +func MustAsset(name string) []byte { + a, err := Asset(name) + if err != nil { + panic("asset: Asset(" + name + "): " + err.Error()) + } + + return a +} + +// MustAssetString is like AssetString but panics when Asset would return an +// error. It simplifies safe initialization of global variables. +func MustAssetString(name string) string { + return string(MustAsset(name)) +} + +// AssetInfo loads and returns the asset info for the given name. +// It returns an error if the asset could not be found or +// could not be loaded. +func AssetInfo(name string) (os.FileInfo, error) { + canonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[canonicalName]; ok { + a, err := f() + if err != nil { + return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err) + } + return a.info, nil + } + return nil, fmt.Errorf("AssetInfo %s not found", name) +} + +// AssetDigest returns the digest of the file with the given name. It returns an +// error if the asset could not be found or the digest could not be loaded. +func AssetDigest(name string) ([sha256.Size]byte, error) { + canonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[canonicalName]; ok { + a, err := f() + if err != nil { + return [sha256.Size]byte{}, fmt.Errorf("AssetDigest %s can't read by error: %v", name, err) + } + return a.digest, nil + } + return [sha256.Size]byte{}, fmt.Errorf("AssetDigest %s not found", name) +} + +// Digests returns a map of all known files and their checksums. +func Digests() (map[string][sha256.Size]byte, error) { + mp := make(map[string][sha256.Size]byte, len(_bindata)) + for name := range _bindata { + a, err := _bindata[name]() + if err != nil { + return nil, err + } + mp[name] = a.digest + } + return mp, nil +} + +// AssetNames returns the names of the assets. +func AssetNames() []string { + names := make([]string, 0, len(_bindata)) + for name := range _bindata { + names = append(names, name) + } + return names +} + +// _bindata is a table, holding each asset generator, mapped to its name. +var _bindata = map[string]func() (*asset, error){ + "jsonschema-draft-04.json": jsonschemaDraft04Json, + + "v2/schema.json": v2SchemaJson, +} + +// AssetDir returns the file names below a certain +// directory embedded in the file by go-bindata. +// For example if you run go-bindata on data/... and data contains the +// following hierarchy: +// data/ +// foo.txt +// img/ +// a.png +// b.png +// then AssetDir("data") would return []string{"foo.txt", "img"}, +// AssetDir("data/img") would return []string{"a.png", "b.png"}, +// AssetDir("foo.txt") and AssetDir("notexist") would return an error, and +// AssetDir("") will return []string{"data"}. +func AssetDir(name string) ([]string, error) { + node := _bintree + if len(name) != 0 { + canonicalName := strings.Replace(name, "\\", "/", -1) + pathList := strings.Split(canonicalName, "/") + for _, p := range pathList { + node = node.Children[p] + if node == nil { + return nil, fmt.Errorf("Asset %s not found", name) + } + } + } + if node.Func != nil { + return nil, fmt.Errorf("Asset %s not found", name) + } + rv := make([]string, 0, len(node.Children)) + for childName := range node.Children { + rv = append(rv, childName) + } + return rv, nil +} + +type bintree struct { + Func func() (*asset, error) + Children map[string]*bintree +} + +var _bintree = &bintree{nil, map[string]*bintree{ + "jsonschema-draft-04.json": {jsonschemaDraft04Json, map[string]*bintree{}}, + "v2": {nil, map[string]*bintree{ + "schema.json": {v2SchemaJson, map[string]*bintree{}}, + }}, +}} + +// RestoreAsset restores an asset under the given directory. +func RestoreAsset(dir, name string) error { + data, err := Asset(name) + if err != nil { + return err + } + info, err := AssetInfo(name) + if err != nil { + return err + } + err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755)) + if err != nil { + return err + } + err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode()) + if err != nil { + return err + } + return os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime()) +} + +// RestoreAssets restores an asset under the given directory recursively. +func RestoreAssets(dir, name string) error { + children, err := AssetDir(name) + // File + if err != nil { + return RestoreAsset(dir, name) + } + // Dir + for _, child := range children { + err = RestoreAssets(dir, filepath.Join(name, child)) + if err != nil { + return err + } + } + return nil +} + +func _filePath(dir, name string) string { + canonicalName := strings.Replace(name, "\\", "/", -1) + return filepath.Join(append([]string{dir}, strings.Split(canonicalName, "/")...)...) +} diff --git a/vendor/github.com/go-openapi/spec/cache.go b/vendor/github.com/go-openapi/spec/cache.go new file mode 100644 index 00000000000..122993b44b4 --- /dev/null +++ b/vendor/github.com/go-openapi/spec/cache.go @@ -0,0 +1,98 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package spec + +import ( + "sync" +) + +// ResolutionCache a cache for resolving urls +type ResolutionCache interface { + Get(string) (interface{}, bool) + Set(string, interface{}) +} + +type simpleCache struct { + lock sync.RWMutex + store map[string]interface{} +} + +func (s *simpleCache) ShallowClone() ResolutionCache { + store := make(map[string]interface{}, len(s.store)) + s.lock.RLock() + for k, v := range s.store { + store[k] = v + } + s.lock.RUnlock() + + return &simpleCache{ + store: store, + } +} + +// Get retrieves a cached URI +func (s *simpleCache) Get(uri string) (interface{}, bool) { + s.lock.RLock() + v, ok := s.store[uri] + + s.lock.RUnlock() + return v, ok +} + +// Set caches a URI +func (s *simpleCache) Set(uri string, data interface{}) { + s.lock.Lock() + s.store[uri] = data + s.lock.Unlock() +} + +var ( + // resCache is a package level cache for $ref resolution and expansion. + // It is initialized lazily by methods that have the need for it: no + // memory is allocated unless some expander methods are called. + // + // It is initialized with JSON schema and swagger schema, + // which do not mutate during normal operations. + // + // All subsequent utilizations of this cache are produced from a shallow + // clone of this initial version. + resCache *simpleCache + onceCache sync.Once + + _ ResolutionCache = &simpleCache{} +) + +// initResolutionCache initializes the URI resolution cache. To be wrapped in a sync.Once.Do call. +func initResolutionCache() { + resCache = defaultResolutionCache() +} + +func defaultResolutionCache() *simpleCache { + return &simpleCache{store: map[string]interface{}{ + "http://swagger.io/v2/schema.json": MustLoadSwagger20Schema(), + "http://json-schema.org/draft-04/schema": MustLoadJSONSchemaDraft04(), + }} +} + +func cacheOrDefault(cache ResolutionCache) ResolutionCache { + onceCache.Do(initResolutionCache) + + if cache != nil { + return cache + } + + // get a shallow clone of the base cache with swagger and json schema + return resCache.ShallowClone() +} diff --git a/vendor/github.com/go-openapi/spec/contact_info.go b/vendor/github.com/go-openapi/spec/contact_info.go new file mode 100644 index 00000000000..2f7bb219b56 --- /dev/null +++ b/vendor/github.com/go-openapi/spec/contact_info.go @@ -0,0 +1,57 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package spec + +import ( + "encoding/json" + + "github.com/go-openapi/swag" +) + +// ContactInfo contact information for the exposed API. +// +// For more information: http://goo.gl/8us55a#contactObject +type ContactInfo struct { + ContactInfoProps + VendorExtensible +} + +// ContactInfoProps hold the properties of a ContactInfo object +type ContactInfoProps struct { + Name string `json:"name,omitempty"` + URL string `json:"url,omitempty"` + Email string `json:"email,omitempty"` +} + +// UnmarshalJSON hydrates ContactInfo from json +func (c *ContactInfo) UnmarshalJSON(data []byte) error { + if err := json.Unmarshal(data, &c.ContactInfoProps); err != nil { + return err + } + return json.Unmarshal(data, &c.VendorExtensible) +} + +// MarshalJSON produces ContactInfo as json +func (c ContactInfo) MarshalJSON() ([]byte, error) { + b1, err := json.Marshal(c.ContactInfoProps) + if err != nil { + return nil, err + } + b2, err := json.Marshal(c.VendorExtensible) + if err != nil { + return nil, err + } + return swag.ConcatJSON(b1, b2), nil +} diff --git a/vendor/github.com/go-openapi/spec/debug.go b/vendor/github.com/go-openapi/spec/debug.go new file mode 100644 index 00000000000..fc889f6d0b0 --- /dev/null +++ b/vendor/github.com/go-openapi/spec/debug.go @@ -0,0 +1,49 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package spec + +import ( + "fmt" + "log" + "os" + "path" + "runtime" +) + +// Debug is true when the SWAGGER_DEBUG env var is not empty. +// +// It enables a more verbose logging of this package. +var Debug = os.Getenv("SWAGGER_DEBUG") != "" + +var ( + // specLogger is a debug logger for this package + specLogger *log.Logger +) + +func init() { + debugOptions() +} + +func debugOptions() { + specLogger = log.New(os.Stdout, "spec:", log.LstdFlags) +} + +func debugLog(msg string, args ...interface{}) { + // A private, trivial trace logger, based on go-openapi/spec/expander.go:debugLog() + if Debug { + _, file1, pos1, _ := runtime.Caller(1) + specLogger.Printf("%s:%d: %s", path.Base(file1), pos1, fmt.Sprintf(msg, args...)) + } +} diff --git a/vendor/github.com/go-openapi/spec/errors.go b/vendor/github.com/go-openapi/spec/errors.go new file mode 100644 index 00000000000..6992c7ba730 --- /dev/null +++ b/vendor/github.com/go-openapi/spec/errors.go @@ -0,0 +1,19 @@ +package spec + +import "errors" + +// Error codes +var ( + // ErrUnknownTypeForReference indicates that a resolved reference was found in an unsupported container type + ErrUnknownTypeForReference = errors.New("unknown type for the resolved reference") + + // ErrResolveRefNeedsAPointer indicates that a $ref target must be a valid JSON pointer + ErrResolveRefNeedsAPointer = errors.New("resolve ref: target needs to be a pointer") + + // ErrDerefUnsupportedType indicates that a resolved reference was found in an unsupported container type. + // At the moment, $ref are supported only inside: schemas, parameters, responses, path items + ErrDerefUnsupportedType = errors.New("deref: unsupported type") + + // ErrExpandUnsupportedType indicates that $ref expansion is attempted on some invalid type + ErrExpandUnsupportedType = errors.New("expand: unsupported type. Input should be of type *Parameter or *Response") +) diff --git a/vendor/github.com/go-openapi/spec/expander.go b/vendor/github.com/go-openapi/spec/expander.go new file mode 100644 index 00000000000..d4ea889d44d --- /dev/null +++ b/vendor/github.com/go-openapi/spec/expander.go @@ -0,0 +1,594 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package spec + +import ( + "encoding/json" + "fmt" +) + +// ExpandOptions provides options for the spec expander. +// +// RelativeBase is the path to the root document. This can be a remote URL or a path to a local file. +// +// If left empty, the root document is assumed to be located in the current working directory: +// all relative $ref's will be resolved from there. +// +// PathLoader injects a document loading method. By default, this resolves to the function provided by the SpecLoader package variable. +// +type ExpandOptions struct { + RelativeBase string // the path to the root document to expand. This is a file, not a directory + SkipSchemas bool // do not expand schemas, just paths, parameters and responses + ContinueOnError bool // continue expanding even after and error is found + PathLoader func(string) (json.RawMessage, error) `json:"-"` // the document loading method that takes a path as input and yields a json document + AbsoluteCircularRef bool // circular $ref remaining after expansion remain absolute URLs +} + +func optionsOrDefault(opts *ExpandOptions) *ExpandOptions { + if opts != nil { + clone := *opts // shallow clone to avoid internal changes to be propagated to the caller + if clone.RelativeBase != "" { + clone.RelativeBase = normalizeBase(clone.RelativeBase) + } + // if the relative base is empty, let the schema loader choose a pseudo root document + return &clone + } + return &ExpandOptions{} +} + +// ExpandSpec expands the references in a swagger spec +func ExpandSpec(spec *Swagger, options *ExpandOptions) error { + options = optionsOrDefault(options) + resolver := defaultSchemaLoader(spec, options, nil, nil) + + specBasePath := options.RelativeBase + + if !options.SkipSchemas { + for key, definition := range spec.Definitions { + parentRefs := make([]string, 0, 10) + parentRefs = append(parentRefs, fmt.Sprintf("#/definitions/%s", key)) + + def, err := expandSchema(definition, parentRefs, resolver, specBasePath) + if resolver.shouldStopOnError(err) { + return err + } + if def != nil { + spec.Definitions[key] = *def + } + } + } + + for key := range spec.Parameters { + parameter := spec.Parameters[key] + if err := expandParameterOrResponse(¶meter, resolver, specBasePath); resolver.shouldStopOnError(err) { + return err + } + spec.Parameters[key] = parameter + } + + for key := range spec.Responses { + response := spec.Responses[key] + if err := expandParameterOrResponse(&response, resolver, specBasePath); resolver.shouldStopOnError(err) { + return err + } + spec.Responses[key] = response + } + + if spec.Paths != nil { + for key := range spec.Paths.Paths { + pth := spec.Paths.Paths[key] + if err := expandPathItem(&pth, resolver, specBasePath); resolver.shouldStopOnError(err) { + return err + } + spec.Paths.Paths[key] = pth + } + } + + return nil +} + +const rootBase = ".root" + +// baseForRoot loads in the cache the root document and produces a fake ".root" base path entry +// for further $ref resolution +// +// Setting the cache is optional and this parameter may safely be left to nil. +func baseForRoot(root interface{}, cache ResolutionCache) string { + if root == nil { + return "" + } + + // cache the root document to resolve $ref's + normalizedBase := normalizeBase(rootBase) + cache.Set(normalizedBase, root) + + return normalizedBase +} + +// ExpandSchema expands the refs in the schema object with reference to the root object. +// +// go-openapi/validate uses this function. +// +// Notice that it is impossible to reference a json schema in a different document other than root +// (use ExpandSchemaWithBasePath to resolve external references). +// +// Setting the cache is optional and this parameter may safely be left to nil. +func ExpandSchema(schema *Schema, root interface{}, cache ResolutionCache) error { + cache = cacheOrDefault(cache) + if root == nil { + root = schema + } + + opts := &ExpandOptions{ + // when a root is specified, cache the root as an in-memory document for $ref retrieval + RelativeBase: baseForRoot(root, cache), + SkipSchemas: false, + ContinueOnError: false, + } + + return ExpandSchemaWithBasePath(schema, cache, opts) +} + +// ExpandSchemaWithBasePath expands the refs in the schema object, base path configured through expand options. +// +// Setting the cache is optional and this parameter may safely be left to nil. +func ExpandSchemaWithBasePath(schema *Schema, cache ResolutionCache, opts *ExpandOptions) error { + if schema == nil { + return nil + } + + cache = cacheOrDefault(cache) + + opts = optionsOrDefault(opts) + + resolver := defaultSchemaLoader(nil, opts, cache, nil) + + parentRefs := make([]string, 0, 10) + s, err := expandSchema(*schema, parentRefs, resolver, opts.RelativeBase) + if err != nil { + return err + } + if s != nil { + // guard for when continuing on error + *schema = *s + } + + return nil +} + +func expandItems(target Schema, parentRefs []string, resolver *schemaLoader, basePath string) (*Schema, error) { + if target.Items == nil { + return &target, nil + } + + // array + if target.Items.Schema != nil { + t, err := expandSchema(*target.Items.Schema, parentRefs, resolver, basePath) + if err != nil { + return nil, err + } + *target.Items.Schema = *t + } + + // tuple + for i := range target.Items.Schemas { + t, err := expandSchema(target.Items.Schemas[i], parentRefs, resolver, basePath) + if err != nil { + return nil, err + } + target.Items.Schemas[i] = *t + } + + return &target, nil +} + +func expandSchema(target Schema, parentRefs []string, resolver *schemaLoader, basePath string) (*Schema, error) { + if target.Ref.String() == "" && target.Ref.IsRoot() { + newRef := normalizeRef(&target.Ref, basePath) + target.Ref = *newRef + return &target, nil + } + + // change the base path of resolution when an ID is encountered + // otherwise the basePath should inherit the parent's + if target.ID != "" { + basePath, _ = resolver.setSchemaID(target, target.ID, basePath) + } + + if target.Ref.String() != "" { + return expandSchemaRef(target, parentRefs, resolver, basePath) + } + + for k := range target.Definitions { + tt, err := expandSchema(target.Definitions[k], parentRefs, resolver, basePath) + if resolver.shouldStopOnError(err) { + return &target, err + } + if tt != nil { + target.Definitions[k] = *tt + } + } + + t, err := expandItems(target, parentRefs, resolver, basePath) + if resolver.shouldStopOnError(err) { + return &target, err + } + if t != nil { + target = *t + } + + for i := range target.AllOf { + t, err := expandSchema(target.AllOf[i], parentRefs, resolver, basePath) + if resolver.shouldStopOnError(err) { + return &target, err + } + if t != nil { + target.AllOf[i] = *t + } + } + + for i := range target.AnyOf { + t, err := expandSchema(target.AnyOf[i], parentRefs, resolver, basePath) + if resolver.shouldStopOnError(err) { + return &target, err + } + if t != nil { + target.AnyOf[i] = *t + } + } + + for i := range target.OneOf { + t, err := expandSchema(target.OneOf[i], parentRefs, resolver, basePath) + if resolver.shouldStopOnError(err) { + return &target, err + } + if t != nil { + target.OneOf[i] = *t + } + } + + if target.Not != nil { + t, err := expandSchema(*target.Not, parentRefs, resolver, basePath) + if resolver.shouldStopOnError(err) { + return &target, err + } + if t != nil { + *target.Not = *t + } + } + + for k := range target.Properties { + t, err := expandSchema(target.Properties[k], parentRefs, resolver, basePath) + if resolver.shouldStopOnError(err) { + return &target, err + } + if t != nil { + target.Properties[k] = *t + } + } + + if target.AdditionalProperties != nil && target.AdditionalProperties.Schema != nil { + t, err := expandSchema(*target.AdditionalProperties.Schema, parentRefs, resolver, basePath) + if resolver.shouldStopOnError(err) { + return &target, err + } + if t != nil { + *target.AdditionalProperties.Schema = *t + } + } + + for k := range target.PatternProperties { + t, err := expandSchema(target.PatternProperties[k], parentRefs, resolver, basePath) + if resolver.shouldStopOnError(err) { + return &target, err + } + if t != nil { + target.PatternProperties[k] = *t + } + } + + for k := range target.Dependencies { + if target.Dependencies[k].Schema != nil { + t, err := expandSchema(*target.Dependencies[k].Schema, parentRefs, resolver, basePath) + if resolver.shouldStopOnError(err) { + return &target, err + } + if t != nil { + *target.Dependencies[k].Schema = *t + } + } + } + + if target.AdditionalItems != nil && target.AdditionalItems.Schema != nil { + t, err := expandSchema(*target.AdditionalItems.Schema, parentRefs, resolver, basePath) + if resolver.shouldStopOnError(err) { + return &target, err + } + if t != nil { + *target.AdditionalItems.Schema = *t + } + } + return &target, nil +} + +func expandSchemaRef(target Schema, parentRefs []string, resolver *schemaLoader, basePath string) (*Schema, error) { + // if a Ref is found, all sibling fields are skipped + // Ref also changes the resolution scope of children expandSchema + + // here the resolution scope is changed because a $ref was encountered + normalizedRef := normalizeRef(&target.Ref, basePath) + normalizedBasePath := normalizedRef.RemoteURI() + + if resolver.isCircular(normalizedRef, basePath, parentRefs...) { + // this means there is a cycle in the recursion tree: return the Ref + // - circular refs cannot be expanded. We leave them as ref. + // - denormalization means that a new local file ref is set relative to the original basePath + debugLog("short circuit circular ref: basePath: %s, normalizedPath: %s, normalized ref: %s", + basePath, normalizedBasePath, normalizedRef.String()) + if !resolver.options.AbsoluteCircularRef { + target.Ref = denormalizeRef(normalizedRef, resolver.context.basePath, resolver.context.rootID) + } else { + target.Ref = *normalizedRef + } + return &target, nil + } + + var t *Schema + err := resolver.Resolve(&target.Ref, &t, basePath) + if resolver.shouldStopOnError(err) { + return nil, err + } + + if t == nil { + // guard for when continuing on error + return &target, nil + } + + parentRefs = append(parentRefs, normalizedRef.String()) + transitiveResolver := resolver.transitiveResolver(basePath, target.Ref) + + basePath = resolver.updateBasePath(transitiveResolver, normalizedBasePath) + + return expandSchema(*t, parentRefs, transitiveResolver, basePath) +} + +func expandPathItem(pathItem *PathItem, resolver *schemaLoader, basePath string) error { + if pathItem == nil { + return nil + } + + parentRefs := make([]string, 0, 10) + if err := resolver.deref(pathItem, parentRefs, basePath); resolver.shouldStopOnError(err) { + return err + } + + if pathItem.Ref.String() != "" { + transitiveResolver := resolver.transitiveResolver(basePath, pathItem.Ref) + basePath = transitiveResolver.updateBasePath(resolver, basePath) + resolver = transitiveResolver + } + + pathItem.Ref = Ref{} + for i := range pathItem.Parameters { + if err := expandParameterOrResponse(&(pathItem.Parameters[i]), resolver, basePath); resolver.shouldStopOnError(err) { + return err + } + } + + ops := []*Operation{ + pathItem.Get, + pathItem.Head, + pathItem.Options, + pathItem.Put, + pathItem.Post, + pathItem.Patch, + pathItem.Delete, + } + for _, op := range ops { + if err := expandOperation(op, resolver, basePath); resolver.shouldStopOnError(err) { + return err + } + } + + return nil +} + +func expandOperation(op *Operation, resolver *schemaLoader, basePath string) error { + if op == nil { + return nil + } + + for i := range op.Parameters { + param := op.Parameters[i] + if err := expandParameterOrResponse(¶m, resolver, basePath); resolver.shouldStopOnError(err) { + return err + } + op.Parameters[i] = param + } + + if op.Responses == nil { + return nil + } + + responses := op.Responses + if err := expandParameterOrResponse(responses.Default, resolver, basePath); resolver.shouldStopOnError(err) { + return err + } + + for code := range responses.StatusCodeResponses { + response := responses.StatusCodeResponses[code] + if err := expandParameterOrResponse(&response, resolver, basePath); resolver.shouldStopOnError(err) { + return err + } + responses.StatusCodeResponses[code] = response + } + + return nil +} + +// ExpandResponseWithRoot expands a response based on a root document, not a fetchable document +// +// Notice that it is impossible to reference a json schema in a different document other than root +// (use ExpandResponse to resolve external references). +// +// Setting the cache is optional and this parameter may safely be left to nil. +func ExpandResponseWithRoot(response *Response, root interface{}, cache ResolutionCache) error { + cache = cacheOrDefault(cache) + opts := &ExpandOptions{ + RelativeBase: baseForRoot(root, cache), + } + resolver := defaultSchemaLoader(root, opts, cache, nil) + + return expandParameterOrResponse(response, resolver, opts.RelativeBase) +} + +// ExpandResponse expands a response based on a basepath +// +// All refs inside response will be resolved relative to basePath +func ExpandResponse(response *Response, basePath string) error { + opts := optionsOrDefault(&ExpandOptions{ + RelativeBase: basePath, + }) + resolver := defaultSchemaLoader(nil, opts, nil, nil) + + return expandParameterOrResponse(response, resolver, opts.RelativeBase) +} + +// ExpandParameterWithRoot expands a parameter based on a root document, not a fetchable document. +// +// Notice that it is impossible to reference a json schema in a different document other than root +// (use ExpandParameter to resolve external references). +func ExpandParameterWithRoot(parameter *Parameter, root interface{}, cache ResolutionCache) error { + cache = cacheOrDefault(cache) + + opts := &ExpandOptions{ + RelativeBase: baseForRoot(root, cache), + } + resolver := defaultSchemaLoader(root, opts, cache, nil) + + return expandParameterOrResponse(parameter, resolver, opts.RelativeBase) +} + +// ExpandParameter expands a parameter based on a basepath. +// This is the exported version of expandParameter +// all refs inside parameter will be resolved relative to basePath +func ExpandParameter(parameter *Parameter, basePath string) error { + opts := optionsOrDefault(&ExpandOptions{ + RelativeBase: basePath, + }) + resolver := defaultSchemaLoader(nil, opts, nil, nil) + + return expandParameterOrResponse(parameter, resolver, opts.RelativeBase) +} + +func getRefAndSchema(input interface{}) (*Ref, *Schema, error) { + var ( + ref *Ref + sch *Schema + ) + + switch refable := input.(type) { + case *Parameter: + if refable == nil { + return nil, nil, nil + } + ref = &refable.Ref + sch = refable.Schema + case *Response: + if refable == nil { + return nil, nil, nil + } + ref = &refable.Ref + sch = refable.Schema + default: + return nil, nil, fmt.Errorf("unsupported type: %T: %w", input, ErrExpandUnsupportedType) + } + + return ref, sch, nil +} + +func expandParameterOrResponse(input interface{}, resolver *schemaLoader, basePath string) error { + ref, _, err := getRefAndSchema(input) + if err != nil { + return err + } + + if ref == nil { + return nil + } + + parentRefs := make([]string, 0, 10) + if err = resolver.deref(input, parentRefs, basePath); resolver.shouldStopOnError(err) { + return err + } + + ref, sch, _ := getRefAndSchema(input) + if ref.String() != "" { + transitiveResolver := resolver.transitiveResolver(basePath, *ref) + basePath = resolver.updateBasePath(transitiveResolver, basePath) + resolver = transitiveResolver + } + + if sch == nil { + // nothing to be expanded + if ref != nil { + *ref = Ref{} + } + return nil + } + + if sch.Ref.String() != "" { + rebasedRef, ern := NewRef(normalizeURI(sch.Ref.String(), basePath)) + if ern != nil { + return ern + } + + switch { + case resolver.isCircular(&rebasedRef, basePath, parentRefs...): + // this is a circular $ref: stop expansion + if !resolver.options.AbsoluteCircularRef { + sch.Ref = denormalizeRef(&rebasedRef, resolver.context.basePath, resolver.context.rootID) + } else { + sch.Ref = rebasedRef + } + case !resolver.options.SkipSchemas: + // schema expanded to a $ref in another root + sch.Ref = rebasedRef + debugLog("rebased to: %s", sch.Ref.String()) + default: + // skip schema expansion but rebase $ref to schema + sch.Ref = denormalizeRef(&rebasedRef, resolver.context.basePath, resolver.context.rootID) + } + } + + if ref != nil { + *ref = Ref{} + } + + // expand schema + if !resolver.options.SkipSchemas { + s, err := expandSchema(*sch, parentRefs, resolver, basePath) + if resolver.shouldStopOnError(err) { + return err + } + if s == nil { + // guard for when continuing on error + return nil + } + *sch = *s + } + + return nil +} diff --git a/vendor/github.com/go-openapi/spec/external_docs.go b/vendor/github.com/go-openapi/spec/external_docs.go new file mode 100644 index 00000000000..88add91b2b8 --- /dev/null +++ b/vendor/github.com/go-openapi/spec/external_docs.go @@ -0,0 +1,24 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package spec + +// ExternalDocumentation allows referencing an external resource for +// extended documentation. +// +// For more information: http://goo.gl/8us55a#externalDocumentationObject +type ExternalDocumentation struct { + Description string `json:"description,omitempty"` + URL string `json:"url,omitempty"` +} diff --git a/vendor/github.com/go-openapi/spec/header.go b/vendor/github.com/go-openapi/spec/header.go new file mode 100644 index 00000000000..9dfd17b185f --- /dev/null +++ b/vendor/github.com/go-openapi/spec/header.go @@ -0,0 +1,203 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package spec + +import ( + "encoding/json" + "strings" + + "github.com/go-openapi/jsonpointer" + "github.com/go-openapi/swag" +) + +const ( + jsonArray = "array" +) + +// HeaderProps describes a response header +type HeaderProps struct { + Description string `json:"description,omitempty"` +} + +// Header describes a header for a response of the API +// +// For more information: http://goo.gl/8us55a#headerObject +type Header struct { + CommonValidations + SimpleSchema + VendorExtensible + HeaderProps +} + +// ResponseHeader creates a new header instance for use in a response +func ResponseHeader() *Header { + return new(Header) +} + +// WithDescription sets the description on this response, allows for chaining +func (h *Header) WithDescription(description string) *Header { + h.Description = description + return h +} + +// Typed a fluent builder method for the type of parameter +func (h *Header) Typed(tpe, format string) *Header { + h.Type = tpe + h.Format = format + return h +} + +// CollectionOf a fluent builder method for an array item +func (h *Header) CollectionOf(items *Items, format string) *Header { + h.Type = jsonArray + h.Items = items + h.CollectionFormat = format + return h +} + +// WithDefault sets the default value on this item +func (h *Header) WithDefault(defaultValue interface{}) *Header { + h.Default = defaultValue + return h +} + +// WithMaxLength sets a max length value +func (h *Header) WithMaxLength(max int64) *Header { + h.MaxLength = &max + return h +} + +// WithMinLength sets a min length value +func (h *Header) WithMinLength(min int64) *Header { + h.MinLength = &min + return h +} + +// WithPattern sets a pattern value +func (h *Header) WithPattern(pattern string) *Header { + h.Pattern = pattern + return h +} + +// WithMultipleOf sets a multiple of value +func (h *Header) WithMultipleOf(number float64) *Header { + h.MultipleOf = &number + return h +} + +// WithMaximum sets a maximum number value +func (h *Header) WithMaximum(max float64, exclusive bool) *Header { + h.Maximum = &max + h.ExclusiveMaximum = exclusive + return h +} + +// WithMinimum sets a minimum number value +func (h *Header) WithMinimum(min float64, exclusive bool) *Header { + h.Minimum = &min + h.ExclusiveMinimum = exclusive + return h +} + +// WithEnum sets a the enum values (replace) +func (h *Header) WithEnum(values ...interface{}) *Header { + h.Enum = append([]interface{}{}, values...) + return h +} + +// WithMaxItems sets the max items +func (h *Header) WithMaxItems(size int64) *Header { + h.MaxItems = &size + return h +} + +// WithMinItems sets the min items +func (h *Header) WithMinItems(size int64) *Header { + h.MinItems = &size + return h +} + +// UniqueValues dictates that this array can only have unique items +func (h *Header) UniqueValues() *Header { + h.UniqueItems = true + return h +} + +// AllowDuplicates this array can have duplicates +func (h *Header) AllowDuplicates() *Header { + h.UniqueItems = false + return h +} + +// WithValidations is a fluent method to set header validations +func (h *Header) WithValidations(val CommonValidations) *Header { + h.SetValidations(SchemaValidations{CommonValidations: val}) + return h +} + +// MarshalJSON marshal this to JSON +func (h Header) MarshalJSON() ([]byte, error) { + b1, err := json.Marshal(h.CommonValidations) + if err != nil { + return nil, err + } + b2, err := json.Marshal(h.SimpleSchema) + if err != nil { + return nil, err + } + b3, err := json.Marshal(h.HeaderProps) + if err != nil { + return nil, err + } + return swag.ConcatJSON(b1, b2, b3), nil +} + +// UnmarshalJSON unmarshals this header from JSON +func (h *Header) UnmarshalJSON(data []byte) error { + if err := json.Unmarshal(data, &h.CommonValidations); err != nil { + return err + } + if err := json.Unmarshal(data, &h.SimpleSchema); err != nil { + return err + } + if err := json.Unmarshal(data, &h.VendorExtensible); err != nil { + return err + } + return json.Unmarshal(data, &h.HeaderProps) +} + +// JSONLookup look up a value by the json property name +func (h Header) JSONLookup(token string) (interface{}, error) { + if ex, ok := h.Extensions[token]; ok { + return &ex, nil + } + + r, _, err := jsonpointer.GetForToken(h.CommonValidations, token) + if err != nil && !strings.HasPrefix(err.Error(), "object has no field") { + return nil, err + } + if r != nil { + return r, nil + } + r, _, err = jsonpointer.GetForToken(h.SimpleSchema, token) + if err != nil && !strings.HasPrefix(err.Error(), "object has no field") { + return nil, err + } + if r != nil { + return r, nil + } + r, _, err = jsonpointer.GetForToken(h.HeaderProps, token) + return r, err +} diff --git a/vendor/github.com/go-openapi/spec/info.go b/vendor/github.com/go-openapi/spec/info.go new file mode 100644 index 00000000000..c458b49b216 --- /dev/null +++ b/vendor/github.com/go-openapi/spec/info.go @@ -0,0 +1,165 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package spec + +import ( + "encoding/json" + "strings" + + "github.com/go-openapi/jsonpointer" + "github.com/go-openapi/swag" +) + +// Extensions vendor specific extensions +type Extensions map[string]interface{} + +// Add adds a value to these extensions +func (e Extensions) Add(key string, value interface{}) { + realKey := strings.ToLower(key) + e[realKey] = value +} + +// GetString gets a string value from the extensions +func (e Extensions) GetString(key string) (string, bool) { + if v, ok := e[strings.ToLower(key)]; ok { + str, ok := v.(string) + return str, ok + } + return "", false +} + +// GetBool gets a string value from the extensions +func (e Extensions) GetBool(key string) (bool, bool) { + if v, ok := e[strings.ToLower(key)]; ok { + str, ok := v.(bool) + return str, ok + } + return false, false +} + +// GetStringSlice gets a string value from the extensions +func (e Extensions) GetStringSlice(key string) ([]string, bool) { + if v, ok := e[strings.ToLower(key)]; ok { + arr, isSlice := v.([]interface{}) + if !isSlice { + return nil, false + } + var strs []string + for _, iface := range arr { + str, isString := iface.(string) + if !isString { + return nil, false + } + strs = append(strs, str) + } + return strs, ok + } + return nil, false +} + +// VendorExtensible composition block. +type VendorExtensible struct { + Extensions Extensions +} + +// AddExtension adds an extension to this extensible object +func (v *VendorExtensible) AddExtension(key string, value interface{}) { + if value == nil { + return + } + if v.Extensions == nil { + v.Extensions = make(map[string]interface{}) + } + v.Extensions.Add(key, value) +} + +// MarshalJSON marshals the extensions to json +func (v VendorExtensible) MarshalJSON() ([]byte, error) { + toser := make(map[string]interface{}) + for k, v := range v.Extensions { + lk := strings.ToLower(k) + if strings.HasPrefix(lk, "x-") { + toser[k] = v + } + } + return json.Marshal(toser) +} + +// UnmarshalJSON for this extensible object +func (v *VendorExtensible) UnmarshalJSON(data []byte) error { + var d map[string]interface{} + if err := json.Unmarshal(data, &d); err != nil { + return err + } + for k, vv := range d { + lk := strings.ToLower(k) + if strings.HasPrefix(lk, "x-") { + if v.Extensions == nil { + v.Extensions = map[string]interface{}{} + } + v.Extensions[k] = vv + } + } + return nil +} + +// InfoProps the properties for an info definition +type InfoProps struct { + Description string `json:"description,omitempty"` + Title string `json:"title,omitempty"` + TermsOfService string `json:"termsOfService,omitempty"` + Contact *ContactInfo `json:"contact,omitempty"` + License *License `json:"license,omitempty"` + Version string `json:"version,omitempty"` +} + +// Info object provides metadata about the API. +// The metadata can be used by the clients if needed, and can be presented in the Swagger-UI for convenience. +// +// For more information: http://goo.gl/8us55a#infoObject +type Info struct { + VendorExtensible + InfoProps +} + +// JSONLookup look up a value by the json property name +func (i Info) JSONLookup(token string) (interface{}, error) { + if ex, ok := i.Extensions[token]; ok { + return &ex, nil + } + r, _, err := jsonpointer.GetForToken(i.InfoProps, token) + return r, err +} + +// MarshalJSON marshal this to JSON +func (i Info) MarshalJSON() ([]byte, error) { + b1, err := json.Marshal(i.InfoProps) + if err != nil { + return nil, err + } + b2, err := json.Marshal(i.VendorExtensible) + if err != nil { + return nil, err + } + return swag.ConcatJSON(b1, b2), nil +} + +// UnmarshalJSON marshal this from JSON +func (i *Info) UnmarshalJSON(data []byte) error { + if err := json.Unmarshal(data, &i.InfoProps); err != nil { + return err + } + return json.Unmarshal(data, &i.VendorExtensible) +} diff --git a/vendor/github.com/go-openapi/spec/items.go b/vendor/github.com/go-openapi/spec/items.go new file mode 100644 index 00000000000..e2afb2133b9 --- /dev/null +++ b/vendor/github.com/go-openapi/spec/items.go @@ -0,0 +1,234 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package spec + +import ( + "encoding/json" + "strings" + + "github.com/go-openapi/jsonpointer" + "github.com/go-openapi/swag" +) + +const ( + jsonRef = "$ref" +) + +// SimpleSchema describe swagger simple schemas for parameters and headers +type SimpleSchema struct { + Type string `json:"type,omitempty"` + Nullable bool `json:"nullable,omitempty"` + Format string `json:"format,omitempty"` + Items *Items `json:"items,omitempty"` + CollectionFormat string `json:"collectionFormat,omitempty"` + Default interface{} `json:"default,omitempty"` + Example interface{} `json:"example,omitempty"` +} + +// TypeName return the type (or format) of a simple schema +func (s *SimpleSchema) TypeName() string { + if s.Format != "" { + return s.Format + } + return s.Type +} + +// ItemsTypeName yields the type of items in a simple schema array +func (s *SimpleSchema) ItemsTypeName() string { + if s.Items == nil { + return "" + } + return s.Items.TypeName() +} + +// Items a limited subset of JSON-Schema's items object. +// It is used by parameter definitions that are not located in "body". +// +// For more information: http://goo.gl/8us55a#items-object +type Items struct { + Refable + CommonValidations + SimpleSchema + VendorExtensible +} + +// NewItems creates a new instance of items +func NewItems() *Items { + return &Items{} +} + +// Typed a fluent builder method for the type of item +func (i *Items) Typed(tpe, format string) *Items { + i.Type = tpe + i.Format = format + return i +} + +// AsNullable flags this schema as nullable. +func (i *Items) AsNullable() *Items { + i.Nullable = true + return i +} + +// CollectionOf a fluent builder method for an array item +func (i *Items) CollectionOf(items *Items, format string) *Items { + i.Type = jsonArray + i.Items = items + i.CollectionFormat = format + return i +} + +// WithDefault sets the default value on this item +func (i *Items) WithDefault(defaultValue interface{}) *Items { + i.Default = defaultValue + return i +} + +// WithMaxLength sets a max length value +func (i *Items) WithMaxLength(max int64) *Items { + i.MaxLength = &max + return i +} + +// WithMinLength sets a min length value +func (i *Items) WithMinLength(min int64) *Items { + i.MinLength = &min + return i +} + +// WithPattern sets a pattern value +func (i *Items) WithPattern(pattern string) *Items { + i.Pattern = pattern + return i +} + +// WithMultipleOf sets a multiple of value +func (i *Items) WithMultipleOf(number float64) *Items { + i.MultipleOf = &number + return i +} + +// WithMaximum sets a maximum number value +func (i *Items) WithMaximum(max float64, exclusive bool) *Items { + i.Maximum = &max + i.ExclusiveMaximum = exclusive + return i +} + +// WithMinimum sets a minimum number value +func (i *Items) WithMinimum(min float64, exclusive bool) *Items { + i.Minimum = &min + i.ExclusiveMinimum = exclusive + return i +} + +// WithEnum sets a the enum values (replace) +func (i *Items) WithEnum(values ...interface{}) *Items { + i.Enum = append([]interface{}{}, values...) + return i +} + +// WithMaxItems sets the max items +func (i *Items) WithMaxItems(size int64) *Items { + i.MaxItems = &size + return i +} + +// WithMinItems sets the min items +func (i *Items) WithMinItems(size int64) *Items { + i.MinItems = &size + return i +} + +// UniqueValues dictates that this array can only have unique items +func (i *Items) UniqueValues() *Items { + i.UniqueItems = true + return i +} + +// AllowDuplicates this array can have duplicates +func (i *Items) AllowDuplicates() *Items { + i.UniqueItems = false + return i +} + +// WithValidations is a fluent method to set Items validations +func (i *Items) WithValidations(val CommonValidations) *Items { + i.SetValidations(SchemaValidations{CommonValidations: val}) + return i +} + +// UnmarshalJSON hydrates this items instance with the data from JSON +func (i *Items) UnmarshalJSON(data []byte) error { + var validations CommonValidations + if err := json.Unmarshal(data, &validations); err != nil { + return err + } + var ref Refable + if err := json.Unmarshal(data, &ref); err != nil { + return err + } + var simpleSchema SimpleSchema + if err := json.Unmarshal(data, &simpleSchema); err != nil { + return err + } + var vendorExtensible VendorExtensible + if err := json.Unmarshal(data, &vendorExtensible); err != nil { + return err + } + i.Refable = ref + i.CommonValidations = validations + i.SimpleSchema = simpleSchema + i.VendorExtensible = vendorExtensible + return nil +} + +// MarshalJSON converts this items object to JSON +func (i Items) MarshalJSON() ([]byte, error) { + b1, err := json.Marshal(i.CommonValidations) + if err != nil { + return nil, err + } + b2, err := json.Marshal(i.SimpleSchema) + if err != nil { + return nil, err + } + b3, err := json.Marshal(i.Refable) + if err != nil { + return nil, err + } + b4, err := json.Marshal(i.VendorExtensible) + if err != nil { + return nil, err + } + return swag.ConcatJSON(b4, b3, b1, b2), nil +} + +// JSONLookup look up a value by the json property name +func (i Items) JSONLookup(token string) (interface{}, error) { + if token == jsonRef { + return &i.Ref, nil + } + + r, _, err := jsonpointer.GetForToken(i.CommonValidations, token) + if err != nil && !strings.HasPrefix(err.Error(), "object has no field") { + return nil, err + } + if r != nil { + return r, nil + } + r, _, err = jsonpointer.GetForToken(i.SimpleSchema, token) + return r, err +} diff --git a/vendor/github.com/go-openapi/spec/license.go b/vendor/github.com/go-openapi/spec/license.go new file mode 100644 index 00000000000..b42f80368ec --- /dev/null +++ b/vendor/github.com/go-openapi/spec/license.go @@ -0,0 +1,56 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package spec + +import ( + "encoding/json" + + "github.com/go-openapi/swag" +) + +// License information for the exposed API. +// +// For more information: http://goo.gl/8us55a#licenseObject +type License struct { + LicenseProps + VendorExtensible +} + +// LicenseProps holds the properties of a License object +type LicenseProps struct { + Name string `json:"name,omitempty"` + URL string `json:"url,omitempty"` +} + +// UnmarshalJSON hydrates License from json +func (l *License) UnmarshalJSON(data []byte) error { + if err := json.Unmarshal(data, &l.LicenseProps); err != nil { + return err + } + return json.Unmarshal(data, &l.VendorExtensible) +} + +// MarshalJSON produces License as json +func (l License) MarshalJSON() ([]byte, error) { + b1, err := json.Marshal(l.LicenseProps) + if err != nil { + return nil, err + } + b2, err := json.Marshal(l.VendorExtensible) + if err != nil { + return nil, err + } + return swag.ConcatJSON(b1, b2), nil +} diff --git a/vendor/github.com/go-openapi/spec/normalizer.go b/vendor/github.com/go-openapi/spec/normalizer.go new file mode 100644 index 00000000000..d6c48397128 --- /dev/null +++ b/vendor/github.com/go-openapi/spec/normalizer.go @@ -0,0 +1,203 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package spec + +import ( + "net/url" + "path" + "strings" +) + +const fileScheme = "file" + +// normalizeURI ensures that all $ref paths used internally by the expander are canonicalized. +// +// NOTE(windows): there is a tolerance over the strict URI format on windows. +// +// The normalizer accepts relative file URLs like 'Path\File.JSON' as well as absolute file URLs like +// 'C:\Path\file.Yaml'. +// +// Both are canonicalized with a "file://" scheme, slashes and a lower-cased path: +// 'file:///c:/path/file.yaml' +// +// URLs can be specified with a file scheme, like in 'file:///folder/file.json' or +// 'file:///c:\folder\File.json'. +// +// URLs like file://C:\folder are considered invalid (i.e. there is no host 'c:\folder') and a "repair" +// is attempted. +// +// The base path argument is assumed to be canonicalized (e.g. using normalizeBase()). +func normalizeURI(refPath, base string) string { + refURL, err := url.Parse(refPath) + if err != nil { + specLogger.Printf("warning: invalid URI in $ref %q: %v", refPath, err) + refURL, refPath = repairURI(refPath) + } + + fixWindowsURI(refURL, refPath) // noop on non-windows OS + + refURL.Path = path.Clean(refURL.Path) + if refURL.Path == "." { + refURL.Path = "" + } + + r := MustCreateRef(refURL.String()) + if r.IsCanonical() { + return refURL.String() + } + + baseURL, _ := url.Parse(base) + if path.IsAbs(refURL.Path) { + baseURL.Path = refURL.Path + } else if refURL.Path != "" { + baseURL.Path = path.Join(path.Dir(baseURL.Path), refURL.Path) + } + // copying fragment from ref to base + baseURL.Fragment = refURL.Fragment + + return baseURL.String() +} + +// denormalizeRef returns the simplest notation for a normalized $ref, given the path of the original root document. +// +// When calling this, we assume that: +// * $ref is a canonical URI +// * originalRelativeBase is a canonical URI +// +// denormalizeRef is currently used when we rewrite a $ref after a circular $ref has been detected. +// In this case, expansion stops and normally renders the internal canonical $ref. +// +// This internal $ref is eventually rebased to the original RelativeBase used for the expansion. +// +// There is a special case for schemas that are anchored with an "id": +// in that case, the rebasing is performed // against the id only if this is an anchor for the initial root document. +// All other intermediate "id"'s found along the way are ignored for the purpose of rebasing. +// +func denormalizeRef(ref *Ref, originalRelativeBase, id string) Ref { + debugLog("denormalizeRef called:\n$ref: %q\noriginal: %s\nroot ID:%s", ref.String(), originalRelativeBase, id) + + if ref.String() == "" || ref.IsRoot() || ref.HasFragmentOnly { + // short circuit: $ref to current doc + return *ref + } + + if id != "" { + idBaseURL, err := url.Parse(id) + if err == nil { // if the schema id is not usable as a URI, ignore it + if ref, ok := rebase(ref, idBaseURL, true); ok { // rebase, but keep references to root unchaged (do not want $ref: "") + // $ref relative to the ID of the schema in the root document + return ref + } + } + } + + originalRelativeBaseURL, _ := url.Parse(originalRelativeBase) + + r, _ := rebase(ref, originalRelativeBaseURL, false) + + return r +} + +func rebase(ref *Ref, v *url.URL, notEqual bool) (Ref, bool) { + var newBase url.URL + + u := ref.GetURL() + + if u.Scheme != v.Scheme || u.Host != v.Host { + return *ref, false + } + + docPath := v.Path + v.Path = path.Dir(v.Path) + + if v.Path == "." { + v.Path = "" + } else if !strings.HasSuffix(v.Path, "/") { + v.Path += "/" + } + + newBase.Fragment = u.Fragment + + if strings.HasPrefix(u.Path, docPath) { + newBase.Path = strings.TrimPrefix(u.Path, docPath) + } else { + newBase.Path = strings.TrimPrefix(u.Path, v.Path) + } + + if notEqual && newBase.Path == "" && newBase.Fragment == "" { + // do not want rebasing to end up in an empty $ref + return *ref, false + } + + if path.IsAbs(newBase.Path) { + // whenever we end up with an absolute path, specify the scheme and host + newBase.Scheme = v.Scheme + newBase.Host = v.Host + } + + return MustCreateRef(newBase.String()), true +} + +// normalizeRef canonicalize a Ref, using a canonical relativeBase as its absolute anchor +func normalizeRef(ref *Ref, relativeBase string) *Ref { + r := MustCreateRef(normalizeURI(ref.String(), relativeBase)) + return &r +} + +// normalizeBase performs a normalization of the input base path. +// +// This always yields a canonical URI (absolute), usable for the document cache. +// +// It ensures that all further internal work on basePath may safely assume +// a non-empty, cross-platform, canonical URI (i.e. absolute). +// +// This normalization tolerates windows paths (e.g. C:\x\y\File.dat) and transform this +// in a file:// URL with lower cased drive letter and path. +// +// See also: https://en.wikipedia.org/wiki/File_URI_scheme +func normalizeBase(in string) string { + u, err := url.Parse(in) + if err != nil { + specLogger.Printf("warning: invalid URI in RelativeBase %q: %v", in, err) + u, in = repairURI(in) + } + + u.Fragment = "" // any fragment in the base is irrelevant + + fixWindowsURI(u, in) // noop on non-windows OS + + u.Path = path.Clean(u.Path) + if u.Path == "." { // empty after Clean() + u.Path = "" + } + + if u.Scheme != "" { + if path.IsAbs(u.Path) || u.Scheme != fileScheme { + // this is absolute or explicitly not a local file: we're good + return u.String() + } + } + + // no scheme or file scheme with relative path: assume file and make it absolute + // enforce scheme file://... with absolute path. + // + // If the input path is relative, we anchor the path to the current working directory. + // NOTE: we may end up with a host component. Leave it unchanged: e.g. file://host/folder/file.json + + u.Scheme = fileScheme + u.Path = absPath(u.Path) // platform-dependent + u.RawQuery = "" // any query component is irrelevant for a base + return u.String() +} diff --git a/vendor/github.com/go-openapi/spec/normalizer_nonwindows.go b/vendor/github.com/go-openapi/spec/normalizer_nonwindows.go new file mode 100644 index 00000000000..c8a06453474 --- /dev/null +++ b/vendor/github.com/go-openapi/spec/normalizer_nonwindows.go @@ -0,0 +1,43 @@ +// +build !windows + +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package spec + +import ( + "net/url" + "path/filepath" +) + +// absPath makes a file path absolute and compatible with a URI path component. +// +// The parameter must be a path, not an URI. +func absPath(in string) string { + anchored, err := filepath.Abs(in) + if err != nil { + specLogger.Printf("warning: could not resolve current working directory: %v", err) + return in + } + return anchored +} + +func repairURI(in string) (*url.URL, string) { + u, _ := url.Parse("") + debugLog("repaired URI: original: %q, repaired: %q", in, "") + return u, "" +} + +func fixWindowsURI(u *url.URL, in string) { +} diff --git a/vendor/github.com/go-openapi/spec/normalizer_windows.go b/vendor/github.com/go-openapi/spec/normalizer_windows.go new file mode 100644 index 00000000000..fe2d1ecd43e --- /dev/null +++ b/vendor/github.com/go-openapi/spec/normalizer_windows.go @@ -0,0 +1,154 @@ +// -build windows + +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package spec + +import ( + "net/url" + "os" + "path" + "path/filepath" + "strings" +) + +// absPath makes a file path absolute and compatible with a URI path component +// +// The parameter must be a path, not an URI. +func absPath(in string) string { + // NOTE(windows): filepath.Abs exhibits a special behavior on windows for empty paths. + // See https://github.com/golang/go/issues/24441 + if in == "" { + in = "." + } + + anchored, err := filepath.Abs(in) + if err != nil { + specLogger.Printf("warning: could not resolve current working directory: %v", err) + return in + } + + pth := strings.ReplaceAll(strings.ToLower(anchored), `\`, `/`) + if !strings.HasPrefix(pth, "/") { + pth = "/" + pth + } + + return path.Clean(pth) +} + +// repairURI tolerates invalid file URIs with common typos +// such as 'file://E:\folder\file', that break the regular URL parser. +// +// Adopting the same defaults as for unixes (e.g. return an empty path) would +// result into a counter-intuitive result for that case (e.g. E:\folder\file is +// eventually resolved as the current directory). The repair will detect the missing "/". +// +// Note that this only works for the file scheme. +func repairURI(in string) (*url.URL, string) { + const prefix = fileScheme + "://" + if !strings.HasPrefix(in, prefix) { + // giving up: resolve to empty path + u, _ := url.Parse("") + + return u, "" + } + + // attempt the repair, stripping the scheme should be sufficient + u, _ := url.Parse(strings.TrimPrefix(in, prefix)) + debugLog("repaired URI: original: %q, repaired: %q", in, u.String()) + + return u, u.String() +} + +// fixWindowsURI tolerates an absolute file path on windows such as C:\Base\File.yaml or \\host\share\Base\File.yaml +// and makes it a canonical URI: file:///c:/base/file.yaml +// +// Catch 22 notes for Windows: +// +// * There may be a drive letter on windows (it is lower-cased) +// * There may be a share UNC, e.g. \\server\folder\data.xml +// * Paths are case insensitive +// * Paths may already contain slashes +// * Paths must be slashed +// +// NOTE: there is no escaping. "/" may be valid separators just like "\". +// We don't use ToSlash() (which escapes everything) because windows now also +// tolerates the use of "/". Hence, both C:\File.yaml and C:/File.yaml will work. +func fixWindowsURI(u *url.URL, in string) { + drive := filepath.VolumeName(in) + + if len(drive) > 0 { + if len(u.Scheme) == 1 && strings.EqualFold(u.Scheme, drive[:1]) { // a path with a drive letter + u.Scheme = fileScheme + u.Host = "" + u.Path = strings.Join([]string{drive, u.Opaque, u.Path}, `/`) // reconstruct the full path component (no fragment, no query) + } else if u.Host == "" && strings.HasPrefix(u.Path, drive) { // a path with a \\host volume + // NOTE: the special host@port syntax for UNC is not supported (yet) + u.Scheme = fileScheme + + // this is a modified version of filepath.Dir() to apply on the VolumeName itself + i := len(drive) - 1 + for i >= 0 && !os.IsPathSeparator(drive[i]) { + i-- + } + host := drive[:i] // \\host\share => host + + u.Path = strings.TrimPrefix(u.Path, host) + u.Host = strings.TrimPrefix(host, `\\`) + } + + u.Opaque = "" + u.Path = strings.ReplaceAll(strings.ToLower(u.Path), `\`, `/`) + + // ensure we form an absolute path + if !strings.HasPrefix(u.Path, "/") { + u.Path = "/" + u.Path + } + + u.Path = path.Clean(u.Path) + + return + } + + if u.Scheme == fileScheme { + // Handle dodgy cases for file://{...} URIs on windows. + // A canonical URI should always be followed by an absolute path. + // + // Examples: + // * file:///folder/file => valid, unchanged + // * file:///c:\folder\file => slashed + // * file:///./folder/file => valid, cleaned to remove the dot + // * file:///.\folder\file => remapped to cwd + // * file:///. => dodgy, remapped to / (consistent with the behavior on unix) + // * file:///.. => dodgy, remapped to / (consistent with the behavior on unix) + if (!path.IsAbs(u.Path) && !filepath.IsAbs(u.Path)) || (strings.HasPrefix(u.Path, `/.`) && strings.Contains(u.Path, `\`)) { + // ensure we form an absolute path + u.Path, _ = filepath.Abs(strings.TrimLeft(u.Path, `/`)) + if !strings.HasPrefix(u.Path, "/") { + u.Path = "/" + u.Path + } + } + u.Path = strings.ToLower(u.Path) + } + + // NOTE: lower case normalization does not propagate to inner resources, + // generated when rebasing: when joining a relative URI with a file to an absolute base, + // only the base is currently lower-cased. + // + // For now, we assume this is good enough for most use cases + // and try not to generate too many differences + // between the output produced on different platforms. + u.Path = path.Clean(strings.ReplaceAll(u.Path, `\`, `/`)) +} diff --git a/vendor/github.com/go-openapi/spec/operation.go b/vendor/github.com/go-openapi/spec/operation.go new file mode 100644 index 00000000000..995ce6acb17 --- /dev/null +++ b/vendor/github.com/go-openapi/spec/operation.go @@ -0,0 +1,397 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package spec + +import ( + "bytes" + "encoding/gob" + "encoding/json" + "sort" + + "github.com/go-openapi/jsonpointer" + "github.com/go-openapi/swag" +) + +func init() { + gob.Register(map[string]interface{}{}) + gob.Register([]interface{}{}) +} + +// OperationProps describes an operation +// +// NOTES: +// - schemes, when present must be from [http, https, ws, wss]: see validate +// - Security is handled as a special case: see MarshalJSON function +type OperationProps struct { + Description string `json:"description,omitempty"` + Consumes []string `json:"consumes,omitempty"` + Produces []string `json:"produces,omitempty"` + Schemes []string `json:"schemes,omitempty"` + Tags []string `json:"tags,omitempty"` + Summary string `json:"summary,omitempty"` + ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"` + ID string `json:"operationId,omitempty"` + Deprecated bool `json:"deprecated,omitempty"` + Security []map[string][]string `json:"security,omitempty"` + Parameters []Parameter `json:"parameters,omitempty"` + Responses *Responses `json:"responses,omitempty"` +} + +// MarshalJSON takes care of serializing operation properties to JSON +// +// We use a custom marhaller here to handle a special cases related to +// the Security field. We need to preserve zero length slice +// while omitting the field when the value is nil/unset. +func (op OperationProps) MarshalJSON() ([]byte, error) { + type Alias OperationProps + if op.Security == nil { + return json.Marshal(&struct { + Security []map[string][]string `json:"security,omitempty"` + *Alias + }{ + Security: op.Security, + Alias: (*Alias)(&op), + }) + } + return json.Marshal(&struct { + Security []map[string][]string `json:"security"` + *Alias + }{ + Security: op.Security, + Alias: (*Alias)(&op), + }) +} + +// Operation describes a single API operation on a path. +// +// For more information: http://goo.gl/8us55a#operationObject +type Operation struct { + VendorExtensible + OperationProps +} + +// SuccessResponse gets a success response model +func (o *Operation) SuccessResponse() (*Response, int, bool) { + if o.Responses == nil { + return nil, 0, false + } + + responseCodes := make([]int, 0, len(o.Responses.StatusCodeResponses)) + for k := range o.Responses.StatusCodeResponses { + if k >= 200 && k < 300 { + responseCodes = append(responseCodes, k) + } + } + if len(responseCodes) > 0 { + sort.Ints(responseCodes) + v := o.Responses.StatusCodeResponses[responseCodes[0]] + return &v, responseCodes[0], true + } + + return o.Responses.Default, 0, false +} + +// JSONLookup look up a value by the json property name +func (o Operation) JSONLookup(token string) (interface{}, error) { + if ex, ok := o.Extensions[token]; ok { + return &ex, nil + } + r, _, err := jsonpointer.GetForToken(o.OperationProps, token) + return r, err +} + +// UnmarshalJSON hydrates this items instance with the data from JSON +func (o *Operation) UnmarshalJSON(data []byte) error { + if err := json.Unmarshal(data, &o.OperationProps); err != nil { + return err + } + return json.Unmarshal(data, &o.VendorExtensible) +} + +// MarshalJSON converts this items object to JSON +func (o Operation) MarshalJSON() ([]byte, error) { + b1, err := json.Marshal(o.OperationProps) + if err != nil { + return nil, err + } + b2, err := json.Marshal(o.VendorExtensible) + if err != nil { + return nil, err + } + concated := swag.ConcatJSON(b1, b2) + return concated, nil +} + +// NewOperation creates a new operation instance. +// It expects an ID as parameter but not passing an ID is also valid. +func NewOperation(id string) *Operation { + op := new(Operation) + op.ID = id + return op +} + +// WithID sets the ID property on this operation, allows for chaining. +func (o *Operation) WithID(id string) *Operation { + o.ID = id + return o +} + +// WithDescription sets the description on this operation, allows for chaining +func (o *Operation) WithDescription(description string) *Operation { + o.Description = description + return o +} + +// WithSummary sets the summary on this operation, allows for chaining +func (o *Operation) WithSummary(summary string) *Operation { + o.Summary = summary + return o +} + +// WithExternalDocs sets/removes the external docs for/from this operation. +// When you pass empty strings as params the external documents will be removed. +// When you pass non-empty string as one value then those values will be used on the external docs object. +// So when you pass a non-empty description, you should also pass the url and vice versa. +func (o *Operation) WithExternalDocs(description, url string) *Operation { + if description == "" && url == "" { + o.ExternalDocs = nil + return o + } + + if o.ExternalDocs == nil { + o.ExternalDocs = &ExternalDocumentation{} + } + o.ExternalDocs.Description = description + o.ExternalDocs.URL = url + return o +} + +// Deprecate marks the operation as deprecated +func (o *Operation) Deprecate() *Operation { + o.Deprecated = true + return o +} + +// Undeprecate marks the operation as not deprected +func (o *Operation) Undeprecate() *Operation { + o.Deprecated = false + return o +} + +// WithConsumes adds media types for incoming body values +func (o *Operation) WithConsumes(mediaTypes ...string) *Operation { + o.Consumes = append(o.Consumes, mediaTypes...) + return o +} + +// WithProduces adds media types for outgoing body values +func (o *Operation) WithProduces(mediaTypes ...string) *Operation { + o.Produces = append(o.Produces, mediaTypes...) + return o +} + +// WithTags adds tags for this operation +func (o *Operation) WithTags(tags ...string) *Operation { + o.Tags = append(o.Tags, tags...) + return o +} + +// AddParam adds a parameter to this operation, when a parameter for that location +// and with that name already exists it will be replaced +func (o *Operation) AddParam(param *Parameter) *Operation { + if param == nil { + return o + } + + for i, p := range o.Parameters { + if p.Name == param.Name && p.In == param.In { + params := append(o.Parameters[:i], *param) + params = append(params, o.Parameters[i+1:]...) + o.Parameters = params + return o + } + } + + o.Parameters = append(o.Parameters, *param) + return o +} + +// RemoveParam removes a parameter from the operation +func (o *Operation) RemoveParam(name, in string) *Operation { + for i, p := range o.Parameters { + if p.Name == name && p.In == in { + o.Parameters = append(o.Parameters[:i], o.Parameters[i+1:]...) + return o + } + } + return o +} + +// SecuredWith adds a security scope to this operation. +func (o *Operation) SecuredWith(name string, scopes ...string) *Operation { + o.Security = append(o.Security, map[string][]string{name: scopes}) + return o +} + +// WithDefaultResponse adds a default response to the operation. +// Passing a nil value will remove the response +func (o *Operation) WithDefaultResponse(response *Response) *Operation { + return o.RespondsWith(0, response) +} + +// RespondsWith adds a status code response to the operation. +// When the code is 0 the value of the response will be used as default response value. +// When the value of the response is nil it will be removed from the operation +func (o *Operation) RespondsWith(code int, response *Response) *Operation { + if o.Responses == nil { + o.Responses = new(Responses) + } + if code == 0 { + o.Responses.Default = response + return o + } + if response == nil { + delete(o.Responses.StatusCodeResponses, code) + return o + } + if o.Responses.StatusCodeResponses == nil { + o.Responses.StatusCodeResponses = make(map[int]Response) + } + o.Responses.StatusCodeResponses[code] = *response + return o +} + +type opsAlias OperationProps + +type gobAlias struct { + Security []map[string]struct { + List []string + Pad bool + } + Alias *opsAlias + SecurityIsEmpty bool +} + +// GobEncode provides a safe gob encoder for Operation, including empty security requirements +func (o Operation) GobEncode() ([]byte, error) { + raw := struct { + Ext VendorExtensible + Props OperationProps + }{ + Ext: o.VendorExtensible, + Props: o.OperationProps, + } + var b bytes.Buffer + err := gob.NewEncoder(&b).Encode(raw) + return b.Bytes(), err +} + +// GobDecode provides a safe gob decoder for Operation, including empty security requirements +func (o *Operation) GobDecode(b []byte) error { + var raw struct { + Ext VendorExtensible + Props OperationProps + } + + buf := bytes.NewBuffer(b) + err := gob.NewDecoder(buf).Decode(&raw) + if err != nil { + return err + } + o.VendorExtensible = raw.Ext + o.OperationProps = raw.Props + return nil +} + +// GobEncode provides a safe gob encoder for Operation, including empty security requirements +func (op OperationProps) GobEncode() ([]byte, error) { + raw := gobAlias{ + Alias: (*opsAlias)(&op), + } + + var b bytes.Buffer + if op.Security == nil { + // nil security requirement + err := gob.NewEncoder(&b).Encode(raw) + return b.Bytes(), err + } + + if len(op.Security) == 0 { + // empty, but non-nil security requirement + raw.SecurityIsEmpty = true + raw.Alias.Security = nil + err := gob.NewEncoder(&b).Encode(raw) + return b.Bytes(), err + } + + raw.Security = make([]map[string]struct { + List []string + Pad bool + }, 0, len(op.Security)) + for _, req := range op.Security { + v := make(map[string]struct { + List []string + Pad bool + }, len(req)) + for k, val := range req { + v[k] = struct { + List []string + Pad bool + }{ + List: val, + } + } + raw.Security = append(raw.Security, v) + } + + err := gob.NewEncoder(&b).Encode(raw) + return b.Bytes(), err +} + +// GobDecode provides a safe gob decoder for Operation, including empty security requirements +func (op *OperationProps) GobDecode(b []byte) error { + var raw gobAlias + + buf := bytes.NewBuffer(b) + err := gob.NewDecoder(buf).Decode(&raw) + if err != nil { + return err + } + if raw.Alias == nil { + return nil + } + + switch { + case raw.SecurityIsEmpty: + // empty, but non-nil security requirement + raw.Alias.Security = []map[string][]string{} + case len(raw.Alias.Security) == 0: + // nil security requirement + raw.Alias.Security = nil + default: + raw.Alias.Security = make([]map[string][]string, 0, len(raw.Security)) + for _, req := range raw.Security { + v := make(map[string][]string, len(req)) + for k, val := range req { + v[k] = make([]string, 0, len(val.List)) + v[k] = append(v[k], val.List...) + } + raw.Alias.Security = append(raw.Alias.Security, v) + } + } + + *op = *(*OperationProps)(raw.Alias) + return nil +} diff --git a/vendor/github.com/go-openapi/spec/parameter.go b/vendor/github.com/go-openapi/spec/parameter.go new file mode 100644 index 00000000000..2b2b89b67bf --- /dev/null +++ b/vendor/github.com/go-openapi/spec/parameter.go @@ -0,0 +1,326 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package spec + +import ( + "encoding/json" + "strings" + + "github.com/go-openapi/jsonpointer" + "github.com/go-openapi/swag" +) + +// QueryParam creates a query parameter +func QueryParam(name string) *Parameter { + return &Parameter{ParamProps: ParamProps{Name: name, In: "query"}} +} + +// HeaderParam creates a header parameter, this is always required by default +func HeaderParam(name string) *Parameter { + return &Parameter{ParamProps: ParamProps{Name: name, In: "header", Required: true}} +} + +// PathParam creates a path parameter, this is always required +func PathParam(name string) *Parameter { + return &Parameter{ParamProps: ParamProps{Name: name, In: "path", Required: true}} +} + +// BodyParam creates a body parameter +func BodyParam(name string, schema *Schema) *Parameter { + return &Parameter{ParamProps: ParamProps{Name: name, In: "body", Schema: schema}} +} + +// FormDataParam creates a body parameter +func FormDataParam(name string) *Parameter { + return &Parameter{ParamProps: ParamProps{Name: name, In: "formData"}} +} + +// FileParam creates a body parameter +func FileParam(name string) *Parameter { + return &Parameter{ParamProps: ParamProps{Name: name, In: "formData"}, + SimpleSchema: SimpleSchema{Type: "file"}} +} + +// SimpleArrayParam creates a param for a simple array (string, int, date etc) +func SimpleArrayParam(name, tpe, fmt string) *Parameter { + return &Parameter{ParamProps: ParamProps{Name: name}, + SimpleSchema: SimpleSchema{Type: jsonArray, CollectionFormat: "csv", + Items: &Items{SimpleSchema: SimpleSchema{Type: tpe, Format: fmt}}}} +} + +// ParamRef creates a parameter that's a json reference +func ParamRef(uri string) *Parameter { + p := new(Parameter) + p.Ref = MustCreateRef(uri) + return p +} + +// ParamProps describes the specific attributes of an operation parameter +// +// NOTE: +// - Schema is defined when "in" == "body": see validate +// - AllowEmptyValue is allowed where "in" == "query" || "formData" +type ParamProps struct { + Description string `json:"description,omitempty"` + Name string `json:"name,omitempty"` + In string `json:"in,omitempty"` + Required bool `json:"required,omitempty"` + Schema *Schema `json:"schema,omitempty"` + AllowEmptyValue bool `json:"allowEmptyValue,omitempty"` +} + +// Parameter a unique parameter is defined by a combination of a [name](#parameterName) and [location](#parameterIn). +// +// There are five possible parameter types. +// * Path - Used together with [Path Templating](#pathTemplating), where the parameter value is actually part +// of the operation's URL. This does not include the host or base path of the API. For example, in `/items/{itemId}`, +// the path parameter is `itemId`. +// * Query - Parameters that are appended to the URL. For example, in `/items?id=###`, the query parameter is `id`. +// * Header - Custom headers that are expected as part of the request. +// * Body - The payload that's appended to the HTTP request. Since there can only be one payload, there can only be +// _one_ body parameter. The name of the body parameter has no effect on the parameter itself and is used for +// documentation purposes only. Since Form parameters are also in the payload, body and form parameters cannot exist +// together for the same operation. +// * Form - Used to describe the payload of an HTTP request when either `application/x-www-form-urlencoded` or +// `multipart/form-data` are used as the content type of the request (in Swagger's definition, +// the [`consumes`](#operationConsumes) property of an operation). This is the only parameter type that can be used +// to send files, thus supporting the `file` type. Since form parameters are sent in the payload, they cannot be +// declared together with a body parameter for the same operation. Form parameters have a different format based on +// the content-type used (for further details, consult http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4). +// * `application/x-www-form-urlencoded` - Similar to the format of Query parameters but as a payload. +// For example, `foo=1&bar=swagger` - both `foo` and `bar` are form parameters. This is normally used for simple +// parameters that are being transferred. +// * `multipart/form-data` - each parameter takes a section in the payload with an internal header. +// For example, for the header `Content-Disposition: form-data; name="submit-name"` the name of the parameter is +// `submit-name`. This type of form parameters is more commonly used for file transfers. +// +// For more information: http://goo.gl/8us55a#parameterObject +type Parameter struct { + Refable + CommonValidations + SimpleSchema + VendorExtensible + ParamProps +} + +// JSONLookup look up a value by the json property name +func (p Parameter) JSONLookup(token string) (interface{}, error) { + if ex, ok := p.Extensions[token]; ok { + return &ex, nil + } + if token == jsonRef { + return &p.Ref, nil + } + + r, _, err := jsonpointer.GetForToken(p.CommonValidations, token) + if err != nil && !strings.HasPrefix(err.Error(), "object has no field") { + return nil, err + } + if r != nil { + return r, nil + } + r, _, err = jsonpointer.GetForToken(p.SimpleSchema, token) + if err != nil && !strings.HasPrefix(err.Error(), "object has no field") { + return nil, err + } + if r != nil { + return r, nil + } + r, _, err = jsonpointer.GetForToken(p.ParamProps, token) + return r, err +} + +// WithDescription a fluent builder method for the description of the parameter +func (p *Parameter) WithDescription(description string) *Parameter { + p.Description = description + return p +} + +// Named a fluent builder method to override the name of the parameter +func (p *Parameter) Named(name string) *Parameter { + p.Name = name + return p +} + +// WithLocation a fluent builder method to override the location of the parameter +func (p *Parameter) WithLocation(in string) *Parameter { + p.In = in + return p +} + +// Typed a fluent builder method for the type of the parameter value +func (p *Parameter) Typed(tpe, format string) *Parameter { + p.Type = tpe + p.Format = format + return p +} + +// CollectionOf a fluent builder method for an array parameter +func (p *Parameter) CollectionOf(items *Items, format string) *Parameter { + p.Type = jsonArray + p.Items = items + p.CollectionFormat = format + return p +} + +// WithDefault sets the default value on this parameter +func (p *Parameter) WithDefault(defaultValue interface{}) *Parameter { + p.AsOptional() // with default implies optional + p.Default = defaultValue + return p +} + +// AllowsEmptyValues flags this parameter as being ok with empty values +func (p *Parameter) AllowsEmptyValues() *Parameter { + p.AllowEmptyValue = true + return p +} + +// NoEmptyValues flags this parameter as not liking empty values +func (p *Parameter) NoEmptyValues() *Parameter { + p.AllowEmptyValue = false + return p +} + +// AsOptional flags this parameter as optional +func (p *Parameter) AsOptional() *Parameter { + p.Required = false + return p +} + +// AsRequired flags this parameter as required +func (p *Parameter) AsRequired() *Parameter { + if p.Default != nil { // with a default required makes no sense + return p + } + p.Required = true + return p +} + +// WithMaxLength sets a max length value +func (p *Parameter) WithMaxLength(max int64) *Parameter { + p.MaxLength = &max + return p +} + +// WithMinLength sets a min length value +func (p *Parameter) WithMinLength(min int64) *Parameter { + p.MinLength = &min + return p +} + +// WithPattern sets a pattern value +func (p *Parameter) WithPattern(pattern string) *Parameter { + p.Pattern = pattern + return p +} + +// WithMultipleOf sets a multiple of value +func (p *Parameter) WithMultipleOf(number float64) *Parameter { + p.MultipleOf = &number + return p +} + +// WithMaximum sets a maximum number value +func (p *Parameter) WithMaximum(max float64, exclusive bool) *Parameter { + p.Maximum = &max + p.ExclusiveMaximum = exclusive + return p +} + +// WithMinimum sets a minimum number value +func (p *Parameter) WithMinimum(min float64, exclusive bool) *Parameter { + p.Minimum = &min + p.ExclusiveMinimum = exclusive + return p +} + +// WithEnum sets a the enum values (replace) +func (p *Parameter) WithEnum(values ...interface{}) *Parameter { + p.Enum = append([]interface{}{}, values...) + return p +} + +// WithMaxItems sets the max items +func (p *Parameter) WithMaxItems(size int64) *Parameter { + p.MaxItems = &size + return p +} + +// WithMinItems sets the min items +func (p *Parameter) WithMinItems(size int64) *Parameter { + p.MinItems = &size + return p +} + +// UniqueValues dictates that this array can only have unique items +func (p *Parameter) UniqueValues() *Parameter { + p.UniqueItems = true + return p +} + +// AllowDuplicates this array can have duplicates +func (p *Parameter) AllowDuplicates() *Parameter { + p.UniqueItems = false + return p +} + +// WithValidations is a fluent method to set parameter validations +func (p *Parameter) WithValidations(val CommonValidations) *Parameter { + p.SetValidations(SchemaValidations{CommonValidations: val}) + return p +} + +// UnmarshalJSON hydrates this items instance with the data from JSON +func (p *Parameter) UnmarshalJSON(data []byte) error { + if err := json.Unmarshal(data, &p.CommonValidations); err != nil { + return err + } + if err := json.Unmarshal(data, &p.Refable); err != nil { + return err + } + if err := json.Unmarshal(data, &p.SimpleSchema); err != nil { + return err + } + if err := json.Unmarshal(data, &p.VendorExtensible); err != nil { + return err + } + return json.Unmarshal(data, &p.ParamProps) +} + +// MarshalJSON converts this items object to JSON +func (p Parameter) MarshalJSON() ([]byte, error) { + b1, err := json.Marshal(p.CommonValidations) + if err != nil { + return nil, err + } + b2, err := json.Marshal(p.SimpleSchema) + if err != nil { + return nil, err + } + b3, err := json.Marshal(p.Refable) + if err != nil { + return nil, err + } + b4, err := json.Marshal(p.VendorExtensible) + if err != nil { + return nil, err + } + b5, err := json.Marshal(p.ParamProps) + if err != nil { + return nil, err + } + return swag.ConcatJSON(b3, b1, b2, b4, b5), nil +} diff --git a/vendor/github.com/go-openapi/spec/path_item.go b/vendor/github.com/go-openapi/spec/path_item.go new file mode 100644 index 00000000000..68fc8e90144 --- /dev/null +++ b/vendor/github.com/go-openapi/spec/path_item.go @@ -0,0 +1,87 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package spec + +import ( + "encoding/json" + + "github.com/go-openapi/jsonpointer" + "github.com/go-openapi/swag" +) + +// PathItemProps the path item specific properties +type PathItemProps struct { + Get *Operation `json:"get,omitempty"` + Put *Operation `json:"put,omitempty"` + Post *Operation `json:"post,omitempty"` + Delete *Operation `json:"delete,omitempty"` + Options *Operation `json:"options,omitempty"` + Head *Operation `json:"head,omitempty"` + Patch *Operation `json:"patch,omitempty"` + Parameters []Parameter `json:"parameters,omitempty"` +} + +// PathItem describes the operations available on a single path. +// A Path Item may be empty, due to [ACL constraints](http://goo.gl/8us55a#securityFiltering). +// The path itself is still exposed to the documentation viewer but they will +// not know which operations and parameters are available. +// +// For more information: http://goo.gl/8us55a#pathItemObject +type PathItem struct { + Refable + VendorExtensible + PathItemProps +} + +// JSONLookup look up a value by the json property name +func (p PathItem) JSONLookup(token string) (interface{}, error) { + if ex, ok := p.Extensions[token]; ok { + return &ex, nil + } + if token == jsonRef { + return &p.Ref, nil + } + r, _, err := jsonpointer.GetForToken(p.PathItemProps, token) + return r, err +} + +// UnmarshalJSON hydrates this items instance with the data from JSON +func (p *PathItem) UnmarshalJSON(data []byte) error { + if err := json.Unmarshal(data, &p.Refable); err != nil { + return err + } + if err := json.Unmarshal(data, &p.VendorExtensible); err != nil { + return err + } + return json.Unmarshal(data, &p.PathItemProps) +} + +// MarshalJSON converts this items object to JSON +func (p PathItem) MarshalJSON() ([]byte, error) { + b3, err := json.Marshal(p.Refable) + if err != nil { + return nil, err + } + b4, err := json.Marshal(p.VendorExtensible) + if err != nil { + return nil, err + } + b5, err := json.Marshal(p.PathItemProps) + if err != nil { + return nil, err + } + concated := swag.ConcatJSON(b3, b4, b5) + return concated, nil +} diff --git a/vendor/github.com/go-openapi/spec/paths.go b/vendor/github.com/go-openapi/spec/paths.go new file mode 100644 index 00000000000..9dc82a2901d --- /dev/null +++ b/vendor/github.com/go-openapi/spec/paths.go @@ -0,0 +1,97 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package spec + +import ( + "encoding/json" + "fmt" + "strings" + + "github.com/go-openapi/swag" +) + +// Paths holds the relative paths to the individual endpoints. +// The path is appended to the [`basePath`](http://goo.gl/8us55a#swaggerBasePath) in order +// to construct the full URL. +// The Paths may be empty, due to [ACL constraints](http://goo.gl/8us55a#securityFiltering). +// +// For more information: http://goo.gl/8us55a#pathsObject +type Paths struct { + VendorExtensible + Paths map[string]PathItem `json:"-"` // custom serializer to flatten this, each entry must start with "/" +} + +// JSONLookup look up a value by the json property name +func (p Paths) JSONLookup(token string) (interface{}, error) { + if pi, ok := p.Paths[token]; ok { + return &pi, nil + } + if ex, ok := p.Extensions[token]; ok { + return &ex, nil + } + return nil, fmt.Errorf("object has no field %q", token) +} + +// UnmarshalJSON hydrates this items instance with the data from JSON +func (p *Paths) UnmarshalJSON(data []byte) error { + var res map[string]json.RawMessage + if err := json.Unmarshal(data, &res); err != nil { + return err + } + for k, v := range res { + if strings.HasPrefix(strings.ToLower(k), "x-") { + if p.Extensions == nil { + p.Extensions = make(map[string]interface{}) + } + var d interface{} + if err := json.Unmarshal(v, &d); err != nil { + return err + } + p.Extensions[k] = d + } + if strings.HasPrefix(k, "/") { + if p.Paths == nil { + p.Paths = make(map[string]PathItem) + } + var pi PathItem + if err := json.Unmarshal(v, &pi); err != nil { + return err + } + p.Paths[k] = pi + } + } + return nil +} + +// MarshalJSON converts this items object to JSON +func (p Paths) MarshalJSON() ([]byte, error) { + b1, err := json.Marshal(p.VendorExtensible) + if err != nil { + return nil, err + } + + pths := make(map[string]PathItem) + for k, v := range p.Paths { + if strings.HasPrefix(k, "/") { + pths[k] = v + } + } + b2, err := json.Marshal(pths) + if err != nil { + return nil, err + } + concated := swag.ConcatJSON(b1, b2) + return concated, nil +} diff --git a/vendor/github.com/go-openapi/spec/properties.go b/vendor/github.com/go-openapi/spec/properties.go new file mode 100644 index 00000000000..2af13787ab1 --- /dev/null +++ b/vendor/github.com/go-openapi/spec/properties.go @@ -0,0 +1,91 @@ +package spec + +import ( + "bytes" + "encoding/json" + "reflect" + "sort" +) + +// OrderSchemaItem holds a named schema (e.g. from a property of an object) +type OrderSchemaItem struct { + Name string + Schema +} + +// OrderSchemaItems is a sortable slice of named schemas. +// The ordering is defined by the x-order schema extension. +type OrderSchemaItems []OrderSchemaItem + +// MarshalJSON produces a json object with keys defined by the name schemas +// of the OrderSchemaItems slice, keeping the original order of the slice. +func (items OrderSchemaItems) MarshalJSON() ([]byte, error) { + buf := bytes.NewBuffer(nil) + buf.WriteString("{") + for i := range items { + if i > 0 { + buf.WriteString(",") + } + buf.WriteString("\"") + buf.WriteString(items[i].Name) + buf.WriteString("\":") + bs, err := json.Marshal(&items[i].Schema) + if err != nil { + return nil, err + } + buf.Write(bs) + } + buf.WriteString("}") + return buf.Bytes(), nil +} + +func (items OrderSchemaItems) Len() int { return len(items) } +func (items OrderSchemaItems) Swap(i, j int) { items[i], items[j] = items[j], items[i] } +func (items OrderSchemaItems) Less(i, j int) (ret bool) { + ii, oki := items[i].Extensions.GetString("x-order") + ij, okj := items[j].Extensions.GetString("x-order") + if oki { + if okj { + defer func() { + if err := recover(); err != nil { + defer func() { + if err = recover(); err != nil { + ret = items[i].Name < items[j].Name + } + }() + ret = reflect.ValueOf(ii).String() < reflect.ValueOf(ij).String() + } + }() + return reflect.ValueOf(ii).Int() < reflect.ValueOf(ij).Int() + } + return true + } else if okj { + return false + } + return items[i].Name < items[j].Name +} + +// SchemaProperties is a map representing the properties of a Schema object. +// It knows how to transform its keys into an ordered slice. +type SchemaProperties map[string]Schema + +// ToOrderedSchemaItems transforms the map of properties into a sortable slice +func (properties SchemaProperties) ToOrderedSchemaItems() OrderSchemaItems { + items := make(OrderSchemaItems, 0, len(properties)) + for k, v := range properties { + items = append(items, OrderSchemaItem{ + Name: k, + Schema: v, + }) + } + sort.Sort(items) + return items +} + +// MarshalJSON produces properties as json, keeping their order. +func (properties SchemaProperties) MarshalJSON() ([]byte, error) { + if properties == nil { + return []byte("null"), nil + } + return json.Marshal(properties.ToOrderedSchemaItems()) +} diff --git a/vendor/github.com/go-openapi/spec/ref.go b/vendor/github.com/go-openapi/spec/ref.go new file mode 100644 index 00000000000..b0ef9bd9c9b --- /dev/null +++ b/vendor/github.com/go-openapi/spec/ref.go @@ -0,0 +1,193 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package spec + +import ( + "bytes" + "encoding/gob" + "encoding/json" + "net/http" + "os" + "path/filepath" + + "github.com/go-openapi/jsonreference" +) + +// Refable is a struct for things that accept a $ref property +type Refable struct { + Ref Ref +} + +// MarshalJSON marshals the ref to json +func (r Refable) MarshalJSON() ([]byte, error) { + return r.Ref.MarshalJSON() +} + +// UnmarshalJSON unmarshalss the ref from json +func (r *Refable) UnmarshalJSON(d []byte) error { + return json.Unmarshal(d, &r.Ref) +} + +// Ref represents a json reference that is potentially resolved +type Ref struct { + jsonreference.Ref +} + +// RemoteURI gets the remote uri part of the ref +func (r *Ref) RemoteURI() string { + if r.String() == "" { + return "" + } + + u := *r.GetURL() + u.Fragment = "" + return u.String() +} + +// IsValidURI returns true when the url the ref points to can be found +func (r *Ref) IsValidURI(basepaths ...string) bool { + if r.String() == "" { + return true + } + + v := r.RemoteURI() + if v == "" { + return true + } + + if r.HasFullURL { + //nolint:noctx,gosec + rr, err := http.Get(v) + if err != nil { + return false + } + defer rr.Body.Close() + + return rr.StatusCode/100 == 2 + } + + if !(r.HasFileScheme || r.HasFullFilePath || r.HasURLPathOnly) { + return false + } + + // check for local file + pth := v + if r.HasURLPathOnly { + base := "." + if len(basepaths) > 0 { + base = filepath.Dir(filepath.Join(basepaths...)) + } + p, e := filepath.Abs(filepath.ToSlash(filepath.Join(base, pth))) + if e != nil { + return false + } + pth = p + } + + fi, err := os.Stat(filepath.ToSlash(pth)) + if err != nil { + return false + } + + return !fi.IsDir() +} + +// Inherits creates a new reference from a parent and a child +// If the child cannot inherit from the parent, an error is returned +func (r *Ref) Inherits(child Ref) (*Ref, error) { + ref, err := r.Ref.Inherits(child.Ref) + if err != nil { + return nil, err + } + return &Ref{Ref: *ref}, nil +} + +// NewRef creates a new instance of a ref object +// returns an error when the reference uri is an invalid uri +func NewRef(refURI string) (Ref, error) { + ref, err := jsonreference.New(refURI) + if err != nil { + return Ref{}, err + } + return Ref{Ref: ref}, nil +} + +// MustCreateRef creates a ref object but panics when refURI is invalid. +// Use the NewRef method for a version that returns an error. +func MustCreateRef(refURI string) Ref { + return Ref{Ref: jsonreference.MustCreateRef(refURI)} +} + +// MarshalJSON marshals this ref into a JSON object +func (r Ref) MarshalJSON() ([]byte, error) { + str := r.String() + if str == "" { + if r.IsRoot() { + return []byte(`{"$ref":""}`), nil + } + return []byte("{}"), nil + } + v := map[string]interface{}{"$ref": str} + return json.Marshal(v) +} + +// UnmarshalJSON unmarshals this ref from a JSON object +func (r *Ref) UnmarshalJSON(d []byte) error { + var v map[string]interface{} + if err := json.Unmarshal(d, &v); err != nil { + return err + } + return r.fromMap(v) +} + +// GobEncode provides a safe gob encoder for Ref +func (r Ref) GobEncode() ([]byte, error) { + var b bytes.Buffer + raw, err := r.MarshalJSON() + if err != nil { + return nil, err + } + err = gob.NewEncoder(&b).Encode(raw) + return b.Bytes(), err +} + +// GobDecode provides a safe gob decoder for Ref +func (r *Ref) GobDecode(b []byte) error { + var raw []byte + buf := bytes.NewBuffer(b) + err := gob.NewDecoder(buf).Decode(&raw) + if err != nil { + return err + } + return json.Unmarshal(raw, r) +} + +func (r *Ref) fromMap(v map[string]interface{}) error { + if v == nil { + return nil + } + + if vv, ok := v["$ref"]; ok { + if str, ok := vv.(string); ok { + ref, err := jsonreference.New(str) + if err != nil { + return err + } + *r = Ref{Ref: ref} + } + } + + return nil +} diff --git a/vendor/github.com/go-openapi/spec/resolver.go b/vendor/github.com/go-openapi/spec/resolver.go new file mode 100644 index 00000000000..47d1ee13fc7 --- /dev/null +++ b/vendor/github.com/go-openapi/spec/resolver.go @@ -0,0 +1,127 @@ +package spec + +import ( + "fmt" + + "github.com/go-openapi/swag" +) + +func resolveAnyWithBase(root interface{}, ref *Ref, result interface{}, options *ExpandOptions) error { + options = optionsOrDefault(options) + resolver := defaultSchemaLoader(root, options, nil, nil) + + if err := resolver.Resolve(ref, result, options.RelativeBase); err != nil { + return err + } + + return nil +} + +// ResolveRefWithBase resolves a reference against a context root with preservation of base path +func ResolveRefWithBase(root interface{}, ref *Ref, options *ExpandOptions) (*Schema, error) { + result := new(Schema) + + if err := resolveAnyWithBase(root, ref, result, options); err != nil { + return nil, err + } + + return result, nil +} + +// ResolveRef resolves a reference for a schema against a context root +// ref is guaranteed to be in root (no need to go to external files) +// +// ResolveRef is ONLY called from the code generation module +func ResolveRef(root interface{}, ref *Ref) (*Schema, error) { + res, _, err := ref.GetPointer().Get(root) + if err != nil { + return nil, err + } + + switch sch := res.(type) { + case Schema: + return &sch, nil + case *Schema: + return sch, nil + case map[string]interface{}: + newSch := new(Schema) + if err = swag.DynamicJSONToStruct(sch, newSch); err != nil { + return nil, err + } + return newSch, nil + default: + return nil, fmt.Errorf("type: %T: %w", sch, ErrUnknownTypeForReference) + } +} + +// ResolveParameterWithBase resolves a parameter reference against a context root and base path +func ResolveParameterWithBase(root interface{}, ref Ref, options *ExpandOptions) (*Parameter, error) { + result := new(Parameter) + + if err := resolveAnyWithBase(root, &ref, result, options); err != nil { + return nil, err + } + + return result, nil +} + +// ResolveParameter resolves a parameter reference against a context root +func ResolveParameter(root interface{}, ref Ref) (*Parameter, error) { + return ResolveParameterWithBase(root, ref, nil) +} + +// ResolveResponseWithBase resolves response a reference against a context root and base path +func ResolveResponseWithBase(root interface{}, ref Ref, options *ExpandOptions) (*Response, error) { + result := new(Response) + + err := resolveAnyWithBase(root, &ref, result, options) + if err != nil { + return nil, err + } + + return result, nil +} + +// ResolveResponse resolves response a reference against a context root +func ResolveResponse(root interface{}, ref Ref) (*Response, error) { + return ResolveResponseWithBase(root, ref, nil) +} + +// ResolvePathItemWithBase resolves response a path item against a context root and base path +func ResolvePathItemWithBase(root interface{}, ref Ref, options *ExpandOptions) (*PathItem, error) { + result := new(PathItem) + + if err := resolveAnyWithBase(root, &ref, result, options); err != nil { + return nil, err + } + + return result, nil +} + +// ResolvePathItem resolves response a path item against a context root and base path +// +// Deprecated: use ResolvePathItemWithBase instead +func ResolvePathItem(root interface{}, ref Ref, options *ExpandOptions) (*PathItem, error) { + return ResolvePathItemWithBase(root, ref, options) +} + +// ResolveItemsWithBase resolves parameter items reference against a context root and base path. +// +// NOTE: stricly speaking, this construct is not supported by Swagger 2.0. +// Similarly, $ref are forbidden in response headers. +func ResolveItemsWithBase(root interface{}, ref Ref, options *ExpandOptions) (*Items, error) { + result := new(Items) + + if err := resolveAnyWithBase(root, &ref, result, options); err != nil { + return nil, err + } + + return result, nil +} + +// ResolveItems resolves parameter items reference against a context root and base path. +// +// Deprecated: use ResolveItemsWithBase instead +func ResolveItems(root interface{}, ref Ref, options *ExpandOptions) (*Items, error) { + return ResolveItemsWithBase(root, ref, options) +} diff --git a/vendor/github.com/go-openapi/spec/response.go b/vendor/github.com/go-openapi/spec/response.go new file mode 100644 index 00000000000..0340b60d845 --- /dev/null +++ b/vendor/github.com/go-openapi/spec/response.go @@ -0,0 +1,152 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package spec + +import ( + "encoding/json" + + "github.com/go-openapi/jsonpointer" + "github.com/go-openapi/swag" +) + +// ResponseProps properties specific to a response +type ResponseProps struct { + Description string `json:"description"` + Schema *Schema `json:"schema,omitempty"` + Headers map[string]Header `json:"headers,omitempty"` + Examples map[string]interface{} `json:"examples,omitempty"` +} + +// Response describes a single response from an API Operation. +// +// For more information: http://goo.gl/8us55a#responseObject +type Response struct { + Refable + ResponseProps + VendorExtensible +} + +// JSONLookup look up a value by the json property name +func (r Response) JSONLookup(token string) (interface{}, error) { + if ex, ok := r.Extensions[token]; ok { + return &ex, nil + } + if token == "$ref" { + return &r.Ref, nil + } + ptr, _, err := jsonpointer.GetForToken(r.ResponseProps, token) + return ptr, err +} + +// UnmarshalJSON hydrates this items instance with the data from JSON +func (r *Response) UnmarshalJSON(data []byte) error { + if err := json.Unmarshal(data, &r.ResponseProps); err != nil { + return err + } + if err := json.Unmarshal(data, &r.Refable); err != nil { + return err + } + return json.Unmarshal(data, &r.VendorExtensible) +} + +// MarshalJSON converts this items object to JSON +func (r Response) MarshalJSON() ([]byte, error) { + var ( + b1 []byte + err error + ) + + if r.Ref.String() == "" { + // when there is no $ref, empty description is rendered as an empty string + b1, err = json.Marshal(r.ResponseProps) + } else { + // when there is $ref inside the schema, description should be omitempty-ied + b1, err = json.Marshal(struct { + Description string `json:"description,omitempty"` + Schema *Schema `json:"schema,omitempty"` + Headers map[string]Header `json:"headers,omitempty"` + Examples map[string]interface{} `json:"examples,omitempty"` + }{ + Description: r.ResponseProps.Description, + Schema: r.ResponseProps.Schema, + Examples: r.ResponseProps.Examples, + }) + } + if err != nil { + return nil, err + } + + b2, err := json.Marshal(r.Refable) + if err != nil { + return nil, err + } + b3, err := json.Marshal(r.VendorExtensible) + if err != nil { + return nil, err + } + return swag.ConcatJSON(b1, b2, b3), nil +} + +// NewResponse creates a new response instance +func NewResponse() *Response { + return new(Response) +} + +// ResponseRef creates a response as a json reference +func ResponseRef(url string) *Response { + resp := NewResponse() + resp.Ref = MustCreateRef(url) + return resp +} + +// WithDescription sets the description on this response, allows for chaining +func (r *Response) WithDescription(description string) *Response { + r.Description = description + return r +} + +// WithSchema sets the schema on this response, allows for chaining. +// Passing a nil argument removes the schema from this response +func (r *Response) WithSchema(schema *Schema) *Response { + r.Schema = schema + return r +} + +// AddHeader adds a header to this response +func (r *Response) AddHeader(name string, header *Header) *Response { + if header == nil { + return r.RemoveHeader(name) + } + if r.Headers == nil { + r.Headers = make(map[string]Header) + } + r.Headers[name] = *header + return r +} + +// RemoveHeader removes a header from this response +func (r *Response) RemoveHeader(name string) *Response { + delete(r.Headers, name) + return r +} + +// AddExample adds an example to this response +func (r *Response) AddExample(mediaType string, example interface{}) *Response { + if r.Examples == nil { + r.Examples = make(map[string]interface{}) + } + r.Examples[mediaType] = example + return r +} diff --git a/vendor/github.com/go-openapi/spec/responses.go b/vendor/github.com/go-openapi/spec/responses.go new file mode 100644 index 00000000000..4efb6f868bd --- /dev/null +++ b/vendor/github.com/go-openapi/spec/responses.go @@ -0,0 +1,127 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package spec + +import ( + "encoding/json" + "fmt" + "reflect" + "strconv" + + "github.com/go-openapi/swag" +) + +// Responses is a container for the expected responses of an operation. +// The container maps a HTTP response code to the expected response. +// It is not expected from the documentation to necessarily cover all possible HTTP response codes, +// since they may not be known in advance. However, it is expected from the documentation to cover +// a successful operation response and any known errors. +// +// The `default` can be used a default response object for all HTTP codes that are not covered +// individually by the specification. +// +// The `Responses Object` MUST contain at least one response code, and it SHOULD be the response +// for a successful operation call. +// +// For more information: http://goo.gl/8us55a#responsesObject +type Responses struct { + VendorExtensible + ResponsesProps +} + +// JSONLookup implements an interface to customize json pointer lookup +func (r Responses) JSONLookup(token string) (interface{}, error) { + if token == "default" { + return r.Default, nil + } + if ex, ok := r.Extensions[token]; ok { + return &ex, nil + } + if i, err := strconv.Atoi(token); err == nil { + if scr, ok := r.StatusCodeResponses[i]; ok { + return scr, nil + } + } + return nil, fmt.Errorf("object has no field %q", token) +} + +// UnmarshalJSON hydrates this items instance with the data from JSON +func (r *Responses) UnmarshalJSON(data []byte) error { + if err := json.Unmarshal(data, &r.ResponsesProps); err != nil { + return err + } + if err := json.Unmarshal(data, &r.VendorExtensible); err != nil { + return err + } + if reflect.DeepEqual(ResponsesProps{}, r.ResponsesProps) { + r.ResponsesProps = ResponsesProps{} + } + return nil +} + +// MarshalJSON converts this items object to JSON +func (r Responses) MarshalJSON() ([]byte, error) { + b1, err := json.Marshal(r.ResponsesProps) + if err != nil { + return nil, err + } + b2, err := json.Marshal(r.VendorExtensible) + if err != nil { + return nil, err + } + concated := swag.ConcatJSON(b1, b2) + return concated, nil +} + +// ResponsesProps describes all responses for an operation. +// It tells what is the default response and maps all responses with a +// HTTP status code. +type ResponsesProps struct { + Default *Response + StatusCodeResponses map[int]Response +} + +// MarshalJSON marshals responses as JSON +func (r ResponsesProps) MarshalJSON() ([]byte, error) { + toser := map[string]Response{} + if r.Default != nil { + toser["default"] = *r.Default + } + for k, v := range r.StatusCodeResponses { + toser[strconv.Itoa(k)] = v + } + return json.Marshal(toser) +} + +// UnmarshalJSON unmarshals responses from JSON +func (r *ResponsesProps) UnmarshalJSON(data []byte) error { + var res map[string]Response + if err := json.Unmarshal(data, &res); err != nil { + return nil + } + if v, ok := res["default"]; ok { + r.Default = &v + delete(res, "default") + } + for k, v := range res { + if nk, err := strconv.Atoi(k); err == nil { + if r.StatusCodeResponses == nil { + r.StatusCodeResponses = map[int]Response{} + } + r.StatusCodeResponses[nk] = v + } + } + return nil +} diff --git a/vendor/github.com/go-openapi/spec/schema.go b/vendor/github.com/go-openapi/spec/schema.go new file mode 100644 index 00000000000..a8d0f737a7a --- /dev/null +++ b/vendor/github.com/go-openapi/spec/schema.go @@ -0,0 +1,646 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package spec + +import ( + "encoding/json" + "fmt" + "net/url" + "strings" + + "github.com/go-openapi/jsonpointer" + "github.com/go-openapi/swag" +) + +// BooleanProperty creates a boolean property +func BooleanProperty() *Schema { + return &Schema{SchemaProps: SchemaProps{Type: []string{"boolean"}}} +} + +// BoolProperty creates a boolean property +func BoolProperty() *Schema { return BooleanProperty() } + +// StringProperty creates a string property +func StringProperty() *Schema { + return &Schema{SchemaProps: SchemaProps{Type: []string{"string"}}} +} + +// CharProperty creates a string property +func CharProperty() *Schema { + return &Schema{SchemaProps: SchemaProps{Type: []string{"string"}}} +} + +// Float64Property creates a float64/double property +func Float64Property() *Schema { + return &Schema{SchemaProps: SchemaProps{Type: []string{"number"}, Format: "double"}} +} + +// Float32Property creates a float32/float property +func Float32Property() *Schema { + return &Schema{SchemaProps: SchemaProps{Type: []string{"number"}, Format: "float"}} +} + +// Int8Property creates an int8 property +func Int8Property() *Schema { + return &Schema{SchemaProps: SchemaProps{Type: []string{"integer"}, Format: "int8"}} +} + +// Int16Property creates an int16 property +func Int16Property() *Schema { + return &Schema{SchemaProps: SchemaProps{Type: []string{"integer"}, Format: "int16"}} +} + +// Int32Property creates an int32 property +func Int32Property() *Schema { + return &Schema{SchemaProps: SchemaProps{Type: []string{"integer"}, Format: "int32"}} +} + +// Int64Property creates an int64 property +func Int64Property() *Schema { + return &Schema{SchemaProps: SchemaProps{Type: []string{"integer"}, Format: "int64"}} +} + +// StrFmtProperty creates a property for the named string format +func StrFmtProperty(format string) *Schema { + return &Schema{SchemaProps: SchemaProps{Type: []string{"string"}, Format: format}} +} + +// DateProperty creates a date property +func DateProperty() *Schema { + return &Schema{SchemaProps: SchemaProps{Type: []string{"string"}, Format: "date"}} +} + +// DateTimeProperty creates a date time property +func DateTimeProperty() *Schema { + return &Schema{SchemaProps: SchemaProps{Type: []string{"string"}, Format: "date-time"}} +} + +// MapProperty creates a map property +func MapProperty(property *Schema) *Schema { + return &Schema{SchemaProps: SchemaProps{Type: []string{"object"}, + AdditionalProperties: &SchemaOrBool{Allows: true, Schema: property}}} +} + +// RefProperty creates a ref property +func RefProperty(name string) *Schema { + return &Schema{SchemaProps: SchemaProps{Ref: MustCreateRef(name)}} +} + +// RefSchema creates a ref property +func RefSchema(name string) *Schema { + return &Schema{SchemaProps: SchemaProps{Ref: MustCreateRef(name)}} +} + +// ArrayProperty creates an array property +func ArrayProperty(items *Schema) *Schema { + if items == nil { + return &Schema{SchemaProps: SchemaProps{Type: []string{"array"}}} + } + return &Schema{SchemaProps: SchemaProps{Items: &SchemaOrArray{Schema: items}, Type: []string{"array"}}} +} + +// ComposedSchema creates a schema with allOf +func ComposedSchema(schemas ...Schema) *Schema { + s := new(Schema) + s.AllOf = schemas + return s +} + +// SchemaURL represents a schema url +type SchemaURL string + +// MarshalJSON marshal this to JSON +func (r SchemaURL) MarshalJSON() ([]byte, error) { + if r == "" { + return []byte("{}"), nil + } + v := map[string]interface{}{"$schema": string(r)} + return json.Marshal(v) +} + +// UnmarshalJSON unmarshal this from JSON +func (r *SchemaURL) UnmarshalJSON(data []byte) error { + var v map[string]interface{} + if err := json.Unmarshal(data, &v); err != nil { + return err + } + return r.fromMap(v) +} + +func (r *SchemaURL) fromMap(v map[string]interface{}) error { + if v == nil { + return nil + } + if vv, ok := v["$schema"]; ok { + if str, ok := vv.(string); ok { + u, err := url.Parse(str) + if err != nil { + return err + } + + *r = SchemaURL(u.String()) + } + } + return nil +} + +// SchemaProps describes a JSON schema (draft 4) +type SchemaProps struct { + ID string `json:"id,omitempty"` + Ref Ref `json:"-"` + Schema SchemaURL `json:"-"` + Description string `json:"description,omitempty"` + Type StringOrArray `json:"type,omitempty"` + Nullable bool `json:"nullable,omitempty"` + Format string `json:"format,omitempty"` + Title string `json:"title,omitempty"` + Default interface{} `json:"default,omitempty"` + Maximum *float64 `json:"maximum,omitempty"` + ExclusiveMaximum bool `json:"exclusiveMaximum,omitempty"` + Minimum *float64 `json:"minimum,omitempty"` + ExclusiveMinimum bool `json:"exclusiveMinimum,omitempty"` + MaxLength *int64 `json:"maxLength,omitempty"` + MinLength *int64 `json:"minLength,omitempty"` + Pattern string `json:"pattern,omitempty"` + MaxItems *int64 `json:"maxItems,omitempty"` + MinItems *int64 `json:"minItems,omitempty"` + UniqueItems bool `json:"uniqueItems,omitempty"` + MultipleOf *float64 `json:"multipleOf,omitempty"` + Enum []interface{} `json:"enum,omitempty"` + MaxProperties *int64 `json:"maxProperties,omitempty"` + MinProperties *int64 `json:"minProperties,omitempty"` + Required []string `json:"required,omitempty"` + Items *SchemaOrArray `json:"items,omitempty"` + AllOf []Schema `json:"allOf,omitempty"` + OneOf []Schema `json:"oneOf,omitempty"` + AnyOf []Schema `json:"anyOf,omitempty"` + Not *Schema `json:"not,omitempty"` + Properties SchemaProperties `json:"properties,omitempty"` + AdditionalProperties *SchemaOrBool `json:"additionalProperties,omitempty"` + PatternProperties SchemaProperties `json:"patternProperties,omitempty"` + Dependencies Dependencies `json:"dependencies,omitempty"` + AdditionalItems *SchemaOrBool `json:"additionalItems,omitempty"` + Definitions Definitions `json:"definitions,omitempty"` +} + +// SwaggerSchemaProps are additional properties supported by swagger schemas, but not JSON-schema (draft 4) +type SwaggerSchemaProps struct { + Discriminator string `json:"discriminator,omitempty"` + ReadOnly bool `json:"readOnly,omitempty"` + XML *XMLObject `json:"xml,omitempty"` + ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"` + Example interface{} `json:"example,omitempty"` +} + +// Schema the schema object allows the definition of input and output data types. +// These types can be objects, but also primitives and arrays. +// This object is based on the [JSON Schema Specification Draft 4](http://json-schema.org/) +// and uses a predefined subset of it. +// On top of this subset, there are extensions provided by this specification to allow for more complete documentation. +// +// For more information: http://goo.gl/8us55a#schemaObject +type Schema struct { + VendorExtensible + SchemaProps + SwaggerSchemaProps + ExtraProps map[string]interface{} `json:"-"` +} + +// JSONLookup implements an interface to customize json pointer lookup +func (s Schema) JSONLookup(token string) (interface{}, error) { + if ex, ok := s.Extensions[token]; ok { + return &ex, nil + } + + if ex, ok := s.ExtraProps[token]; ok { + return &ex, nil + } + + r, _, err := jsonpointer.GetForToken(s.SchemaProps, token) + if r != nil || (err != nil && !strings.HasPrefix(err.Error(), "object has no field")) { + return r, err + } + r, _, err = jsonpointer.GetForToken(s.SwaggerSchemaProps, token) + return r, err +} + +// WithID sets the id for this schema, allows for chaining +func (s *Schema) WithID(id string) *Schema { + s.ID = id + return s +} + +// WithTitle sets the title for this schema, allows for chaining +func (s *Schema) WithTitle(title string) *Schema { + s.Title = title + return s +} + +// WithDescription sets the description for this schema, allows for chaining +func (s *Schema) WithDescription(description string) *Schema { + s.Description = description + return s +} + +// WithProperties sets the properties for this schema +func (s *Schema) WithProperties(schemas map[string]Schema) *Schema { + s.Properties = schemas + return s +} + +// SetProperty sets a property on this schema +func (s *Schema) SetProperty(name string, schema Schema) *Schema { + if s.Properties == nil { + s.Properties = make(map[string]Schema) + } + s.Properties[name] = schema + return s +} + +// WithAllOf sets the all of property +func (s *Schema) WithAllOf(schemas ...Schema) *Schema { + s.AllOf = schemas + return s +} + +// WithMaxProperties sets the max number of properties an object can have +func (s *Schema) WithMaxProperties(max int64) *Schema { + s.MaxProperties = &max + return s +} + +// WithMinProperties sets the min number of properties an object must have +func (s *Schema) WithMinProperties(min int64) *Schema { + s.MinProperties = &min + return s +} + +// Typed sets the type of this schema for a single value item +func (s *Schema) Typed(tpe, format string) *Schema { + s.Type = []string{tpe} + s.Format = format + return s +} + +// AddType adds a type with potential format to the types for this schema +func (s *Schema) AddType(tpe, format string) *Schema { + s.Type = append(s.Type, tpe) + if format != "" { + s.Format = format + } + return s +} + +// AsNullable flags this schema as nullable. +func (s *Schema) AsNullable() *Schema { + s.Nullable = true + return s +} + +// CollectionOf a fluent builder method for an array parameter +func (s *Schema) CollectionOf(items Schema) *Schema { + s.Type = []string{jsonArray} + s.Items = &SchemaOrArray{Schema: &items} + return s +} + +// WithDefault sets the default value on this parameter +func (s *Schema) WithDefault(defaultValue interface{}) *Schema { + s.Default = defaultValue + return s +} + +// WithRequired flags this parameter as required +func (s *Schema) WithRequired(items ...string) *Schema { + s.Required = items + return s +} + +// AddRequired adds field names to the required properties array +func (s *Schema) AddRequired(items ...string) *Schema { + s.Required = append(s.Required, items...) + return s +} + +// WithMaxLength sets a max length value +func (s *Schema) WithMaxLength(max int64) *Schema { + s.MaxLength = &max + return s +} + +// WithMinLength sets a min length value +func (s *Schema) WithMinLength(min int64) *Schema { + s.MinLength = &min + return s +} + +// WithPattern sets a pattern value +func (s *Schema) WithPattern(pattern string) *Schema { + s.Pattern = pattern + return s +} + +// WithMultipleOf sets a multiple of value +func (s *Schema) WithMultipleOf(number float64) *Schema { + s.MultipleOf = &number + return s +} + +// WithMaximum sets a maximum number value +func (s *Schema) WithMaximum(max float64, exclusive bool) *Schema { + s.Maximum = &max + s.ExclusiveMaximum = exclusive + return s +} + +// WithMinimum sets a minimum number value +func (s *Schema) WithMinimum(min float64, exclusive bool) *Schema { + s.Minimum = &min + s.ExclusiveMinimum = exclusive + return s +} + +// WithEnum sets a the enum values (replace) +func (s *Schema) WithEnum(values ...interface{}) *Schema { + s.Enum = append([]interface{}{}, values...) + return s +} + +// WithMaxItems sets the max items +func (s *Schema) WithMaxItems(size int64) *Schema { + s.MaxItems = &size + return s +} + +// WithMinItems sets the min items +func (s *Schema) WithMinItems(size int64) *Schema { + s.MinItems = &size + return s +} + +// UniqueValues dictates that this array can only have unique items +func (s *Schema) UniqueValues() *Schema { + s.UniqueItems = true + return s +} + +// AllowDuplicates this array can have duplicates +func (s *Schema) AllowDuplicates() *Schema { + s.UniqueItems = false + return s +} + +// AddToAllOf adds a schema to the allOf property +func (s *Schema) AddToAllOf(schemas ...Schema) *Schema { + s.AllOf = append(s.AllOf, schemas...) + return s +} + +// WithDiscriminator sets the name of the discriminator field +func (s *Schema) WithDiscriminator(discriminator string) *Schema { + s.Discriminator = discriminator + return s +} + +// AsReadOnly flags this schema as readonly +func (s *Schema) AsReadOnly() *Schema { + s.ReadOnly = true + return s +} + +// AsWritable flags this schema as writeable (not read-only) +func (s *Schema) AsWritable() *Schema { + s.ReadOnly = false + return s +} + +// WithExample sets the example for this schema +func (s *Schema) WithExample(example interface{}) *Schema { + s.Example = example + return s +} + +// WithExternalDocs sets/removes the external docs for/from this schema. +// When you pass empty strings as params the external documents will be removed. +// When you pass non-empty string as one value then those values will be used on the external docs object. +// So when you pass a non-empty description, you should also pass the url and vice versa. +func (s *Schema) WithExternalDocs(description, url string) *Schema { + if description == "" && url == "" { + s.ExternalDocs = nil + return s + } + + if s.ExternalDocs == nil { + s.ExternalDocs = &ExternalDocumentation{} + } + s.ExternalDocs.Description = description + s.ExternalDocs.URL = url + return s +} + +// WithXMLName sets the xml name for the object +func (s *Schema) WithXMLName(name string) *Schema { + if s.XML == nil { + s.XML = new(XMLObject) + } + s.XML.Name = name + return s +} + +// WithXMLNamespace sets the xml namespace for the object +func (s *Schema) WithXMLNamespace(namespace string) *Schema { + if s.XML == nil { + s.XML = new(XMLObject) + } + s.XML.Namespace = namespace + return s +} + +// WithXMLPrefix sets the xml prefix for the object +func (s *Schema) WithXMLPrefix(prefix string) *Schema { + if s.XML == nil { + s.XML = new(XMLObject) + } + s.XML.Prefix = prefix + return s +} + +// AsXMLAttribute flags this object as xml attribute +func (s *Schema) AsXMLAttribute() *Schema { + if s.XML == nil { + s.XML = new(XMLObject) + } + s.XML.Attribute = true + return s +} + +// AsXMLElement flags this object as an xml node +func (s *Schema) AsXMLElement() *Schema { + if s.XML == nil { + s.XML = new(XMLObject) + } + s.XML.Attribute = false + return s +} + +// AsWrappedXML flags this object as wrapped, this is mostly useful for array types +func (s *Schema) AsWrappedXML() *Schema { + if s.XML == nil { + s.XML = new(XMLObject) + } + s.XML.Wrapped = true + return s +} + +// AsUnwrappedXML flags this object as an xml node +func (s *Schema) AsUnwrappedXML() *Schema { + if s.XML == nil { + s.XML = new(XMLObject) + } + s.XML.Wrapped = false + return s +} + +// SetValidations defines all schema validations. +// +// NOTE: Required, ReadOnly, AllOf, AnyOf, OneOf and Not are not considered. +func (s *Schema) SetValidations(val SchemaValidations) { + s.Maximum = val.Maximum + s.ExclusiveMaximum = val.ExclusiveMaximum + s.Minimum = val.Minimum + s.ExclusiveMinimum = val.ExclusiveMinimum + s.MaxLength = val.MaxLength + s.MinLength = val.MinLength + s.Pattern = val.Pattern + s.MaxItems = val.MaxItems + s.MinItems = val.MinItems + s.UniqueItems = val.UniqueItems + s.MultipleOf = val.MultipleOf + s.Enum = val.Enum + s.MinProperties = val.MinProperties + s.MaxProperties = val.MaxProperties + s.PatternProperties = val.PatternProperties +} + +// WithValidations is a fluent method to set schema validations +func (s *Schema) WithValidations(val SchemaValidations) *Schema { + s.SetValidations(val) + return s +} + +// Validations returns a clone of the validations for this schema +func (s Schema) Validations() SchemaValidations { + return SchemaValidations{ + CommonValidations: CommonValidations{ + Maximum: s.Maximum, + ExclusiveMaximum: s.ExclusiveMaximum, + Minimum: s.Minimum, + ExclusiveMinimum: s.ExclusiveMinimum, + MaxLength: s.MaxLength, + MinLength: s.MinLength, + Pattern: s.Pattern, + MaxItems: s.MaxItems, + MinItems: s.MinItems, + UniqueItems: s.UniqueItems, + MultipleOf: s.MultipleOf, + Enum: s.Enum, + }, + MinProperties: s.MinProperties, + MaxProperties: s.MaxProperties, + PatternProperties: s.PatternProperties, + } +} + +// MarshalJSON marshal this to JSON +func (s Schema) MarshalJSON() ([]byte, error) { + b1, err := json.Marshal(s.SchemaProps) + if err != nil { + return nil, fmt.Errorf("schema props %v", err) + } + b2, err := json.Marshal(s.VendorExtensible) + if err != nil { + return nil, fmt.Errorf("vendor props %v", err) + } + b3, err := s.Ref.MarshalJSON() + if err != nil { + return nil, fmt.Errorf("ref prop %v", err) + } + b4, err := s.Schema.MarshalJSON() + if err != nil { + return nil, fmt.Errorf("schema prop %v", err) + } + b5, err := json.Marshal(s.SwaggerSchemaProps) + if err != nil { + return nil, fmt.Errorf("common validations %v", err) + } + var b6 []byte + if s.ExtraProps != nil { + jj, err := json.Marshal(s.ExtraProps) + if err != nil { + return nil, fmt.Errorf("extra props %v", err) + } + b6 = jj + } + return swag.ConcatJSON(b1, b2, b3, b4, b5, b6), nil +} + +// UnmarshalJSON marshal this from JSON +func (s *Schema) UnmarshalJSON(data []byte) error { + props := struct { + SchemaProps + SwaggerSchemaProps + }{} + if err := json.Unmarshal(data, &props); err != nil { + return err + } + + sch := Schema{ + SchemaProps: props.SchemaProps, + SwaggerSchemaProps: props.SwaggerSchemaProps, + } + + var d map[string]interface{} + if err := json.Unmarshal(data, &d); err != nil { + return err + } + + _ = sch.Ref.fromMap(d) + _ = sch.Schema.fromMap(d) + + delete(d, "$ref") + delete(d, "$schema") + for _, pn := range swag.DefaultJSONNameProvider.GetJSONNames(s) { + delete(d, pn) + } + + for k, vv := range d { + lk := strings.ToLower(k) + if strings.HasPrefix(lk, "x-") { + if sch.Extensions == nil { + sch.Extensions = map[string]interface{}{} + } + sch.Extensions[k] = vv + continue + } + if sch.ExtraProps == nil { + sch.ExtraProps = map[string]interface{}{} + } + sch.ExtraProps[k] = vv + } + + *s = sch + + return nil +} diff --git a/vendor/github.com/go-openapi/spec/schema_loader.go b/vendor/github.com/go-openapi/spec/schema_loader.go new file mode 100644 index 00000000000..b81175afdf4 --- /dev/null +++ b/vendor/github.com/go-openapi/spec/schema_loader.go @@ -0,0 +1,338 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package spec + +import ( + "encoding/json" + "fmt" + "log" + "net/url" + "reflect" + "strings" + + "github.com/go-openapi/swag" +) + +// PathLoader is a function to use when loading remote refs. +// +// This is a package level default. It may be overridden or bypassed by +// specifying the loader in ExpandOptions. +// +// NOTE: if you are using the go-openapi/loads package, it will override +// this value with its own default (a loader to retrieve YAML documents as +// well as JSON ones). +var PathLoader = func(pth string) (json.RawMessage, error) { + data, err := swag.LoadFromFileOrHTTP(pth) + if err != nil { + return nil, err + } + return json.RawMessage(data), nil +} + +// resolverContext allows to share a context during spec processing. +// At the moment, it just holds the index of circular references found. +type resolverContext struct { + // circulars holds all visited circular references, to shortcircuit $ref resolution. + // + // This structure is privately instantiated and needs not be locked against + // concurrent access, unless we chose to implement a parallel spec walking. + circulars map[string]bool + basePath string + loadDoc func(string) (json.RawMessage, error) + rootID string +} + +func newResolverContext(options *ExpandOptions) *resolverContext { + expandOptions := optionsOrDefault(options) + + // path loader may be overridden by options + var loader func(string) (json.RawMessage, error) + if expandOptions.PathLoader == nil { + loader = PathLoader + } else { + loader = expandOptions.PathLoader + } + + return &resolverContext{ + circulars: make(map[string]bool), + basePath: expandOptions.RelativeBase, // keep the root base path in context + loadDoc: loader, + } +} + +type schemaLoader struct { + root interface{} + options *ExpandOptions + cache ResolutionCache + context *resolverContext +} + +func (r *schemaLoader) transitiveResolver(basePath string, ref Ref) *schemaLoader { + if ref.IsRoot() || ref.HasFragmentOnly { + return r + } + + baseRef := MustCreateRef(basePath) + currentRef := normalizeRef(&ref, basePath) + if strings.HasPrefix(currentRef.String(), baseRef.String()) { + return r + } + + // set a new root against which to resolve + rootURL := currentRef.GetURL() + rootURL.Fragment = "" + root, _ := r.cache.Get(rootURL.String()) + + // shallow copy of resolver options to set a new RelativeBase when + // traversing multiple documents + newOptions := r.options + newOptions.RelativeBase = rootURL.String() + + return defaultSchemaLoader(root, newOptions, r.cache, r.context) +} + +func (r *schemaLoader) updateBasePath(transitive *schemaLoader, basePath string) string { + if transitive != r { + if transitive.options != nil && transitive.options.RelativeBase != "" { + return normalizeBase(transitive.options.RelativeBase) + } + } + + return basePath +} + +func (r *schemaLoader) resolveRef(ref *Ref, target interface{}, basePath string) error { + tgt := reflect.ValueOf(target) + if tgt.Kind() != reflect.Ptr { + return ErrResolveRefNeedsAPointer + } + + if ref.GetURL() == nil { + return nil + } + + var ( + res interface{} + data interface{} + err error + ) + + // Resolve against the root if it isn't nil, and if ref is pointing at the root, or has a fragment only which means + // it is pointing somewhere in the root. + root := r.root + if (ref.IsRoot() || ref.HasFragmentOnly) && root == nil && basePath != "" { + if baseRef, erb := NewRef(basePath); erb == nil { + root, _, _, _ = r.load(baseRef.GetURL()) + } + } + + if (ref.IsRoot() || ref.HasFragmentOnly) && root != nil { + data = root + } else { + baseRef := normalizeRef(ref, basePath) + data, _, _, err = r.load(baseRef.GetURL()) + if err != nil { + return err + } + } + + res = data + if ref.String() != "" { + res, _, err = ref.GetPointer().Get(data) + if err != nil { + return err + } + } + return swag.DynamicJSONToStruct(res, target) +} + +func (r *schemaLoader) load(refURL *url.URL) (interface{}, url.URL, bool, error) { + debugLog("loading schema from url: %s", refURL) + toFetch := *refURL + toFetch.Fragment = "" + + var err error + pth := toFetch.String() + normalized := normalizeBase(pth) + debugLog("loading doc from: %s", normalized) + + unescaped, err := url.PathUnescape(normalized) + if err != nil { + return nil, url.URL{}, false, err + } + + u := url.URL{Path: unescaped} + + data, fromCache := r.cache.Get(u.RequestURI()) + if fromCache { + return data, toFetch, fromCache, nil + } + + b, err := r.context.loadDoc(normalized) + if err != nil { + return nil, url.URL{}, false, err + } + + var doc interface{} + if err := json.Unmarshal(b, &doc); err != nil { + return nil, url.URL{}, false, err + } + r.cache.Set(normalized, doc) + + return doc, toFetch, fromCache, nil +} + +// isCircular detects cycles in sequences of $ref. +// +// It relies on a private context (which needs not be locked). +func (r *schemaLoader) isCircular(ref *Ref, basePath string, parentRefs ...string) (foundCycle bool) { + normalizedRef := normalizeURI(ref.String(), basePath) + if _, ok := r.context.circulars[normalizedRef]; ok { + // circular $ref has been already detected in another explored cycle + foundCycle = true + return + } + foundCycle = swag.ContainsStrings(parentRefs, normalizedRef) // normalized windows url's are lower cased + if foundCycle { + r.context.circulars[normalizedRef] = true + } + return +} + +// Resolve resolves a reference against basePath and stores the result in target. +// +// Resolve is not in charge of following references: it only resolves ref by following its URL. +// +// If the schema the ref is referring to holds nested refs, Resolve doesn't resolve them. +// +// If basePath is an empty string, ref is resolved against the root schema stored in the schemaLoader struct +func (r *schemaLoader) Resolve(ref *Ref, target interface{}, basePath string) error { + return r.resolveRef(ref, target, basePath) +} + +func (r *schemaLoader) deref(input interface{}, parentRefs []string, basePath string) error { + var ref *Ref + switch refable := input.(type) { + case *Schema: + ref = &refable.Ref + case *Parameter: + ref = &refable.Ref + case *Response: + ref = &refable.Ref + case *PathItem: + ref = &refable.Ref + default: + return fmt.Errorf("unsupported type: %T: %w", input, ErrDerefUnsupportedType) + } + + curRef := ref.String() + if curRef == "" { + return nil + } + + normalizedRef := normalizeRef(ref, basePath) + normalizedBasePath := normalizedRef.RemoteURI() + + if r.isCircular(normalizedRef, basePath, parentRefs...) { + return nil + } + + if err := r.resolveRef(ref, input, basePath); r.shouldStopOnError(err) { + return err + } + + if ref.String() == "" || ref.String() == curRef { + // done with rereferencing + return nil + } + + parentRefs = append(parentRefs, normalizedRef.String()) + return r.deref(input, parentRefs, normalizedBasePath) +} + +func (r *schemaLoader) shouldStopOnError(err error) bool { + if err != nil && !r.options.ContinueOnError { + return true + } + + if err != nil { + log.Println(err) + } + + return false +} + +func (r *schemaLoader) setSchemaID(target interface{}, id, basePath string) (string, string) { + debugLog("schema has ID: %s", id) + + // handling the case when id is a folder + // remember that basePath has to point to a file + var refPath string + if strings.HasSuffix(id, "/") { + // ensure this is detected as a file, not a folder + refPath = fmt.Sprintf("%s%s", id, "placeholder.json") + } else { + refPath = id + } + + // updates the current base path + // * important: ID can be a relative path + // * registers target to be fetchable from the new base proposed by this id + newBasePath := normalizeURI(refPath, basePath) + + // store found IDs for possible future reuse in $ref + r.cache.Set(newBasePath, target) + + // the root document has an ID: all $ref relative to that ID may + // be rebased relative to the root document + if basePath == r.context.basePath { + debugLog("root document is a schema with ID: %s (normalized as:%s)", id, newBasePath) + r.context.rootID = newBasePath + } + + return newBasePath, refPath +} + +func defaultSchemaLoader( + root interface{}, + expandOptions *ExpandOptions, + cache ResolutionCache, + context *resolverContext) *schemaLoader { + + if expandOptions == nil { + expandOptions = &ExpandOptions{} + } + + cache = cacheOrDefault(cache) + + if expandOptions.RelativeBase == "" { + // if no relative base is provided, assume the root document + // contains all $ref, or at least, that the relative documents + // may be resolved from the current working directory. + expandOptions.RelativeBase = baseForRoot(root, cache) + } + debugLog("effective expander options: %#v", expandOptions) + + if context == nil { + context = newResolverContext(expandOptions) + } + + return &schemaLoader{ + root: root, + options: expandOptions, + cache: cache, + context: context, + } +} diff --git a/vendor/github.com/go-openapi/spec/security_scheme.go b/vendor/github.com/go-openapi/spec/security_scheme.go new file mode 100644 index 00000000000..9d0bdae9081 --- /dev/null +++ b/vendor/github.com/go-openapi/spec/security_scheme.go @@ -0,0 +1,170 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package spec + +import ( + "encoding/json" + + "github.com/go-openapi/jsonpointer" + "github.com/go-openapi/swag" +) + +const ( + basic = "basic" + apiKey = "apiKey" + oauth2 = "oauth2" + implicit = "implicit" + password = "password" + application = "application" + accessCode = "accessCode" +) + +// BasicAuth creates a basic auth security scheme +func BasicAuth() *SecurityScheme { + return &SecurityScheme{SecuritySchemeProps: SecuritySchemeProps{Type: basic}} +} + +// APIKeyAuth creates an api key auth security scheme +func APIKeyAuth(fieldName, valueSource string) *SecurityScheme { + return &SecurityScheme{SecuritySchemeProps: SecuritySchemeProps{Type: apiKey, Name: fieldName, In: valueSource}} +} + +// OAuth2Implicit creates an implicit flow oauth2 security scheme +func OAuth2Implicit(authorizationURL string) *SecurityScheme { + return &SecurityScheme{SecuritySchemeProps: SecuritySchemeProps{ + Type: oauth2, + Flow: implicit, + AuthorizationURL: authorizationURL, + }} +} + +// OAuth2Password creates a password flow oauth2 security scheme +func OAuth2Password(tokenURL string) *SecurityScheme { + return &SecurityScheme{SecuritySchemeProps: SecuritySchemeProps{ + Type: oauth2, + Flow: password, + TokenURL: tokenURL, + }} +} + +// OAuth2Application creates an application flow oauth2 security scheme +func OAuth2Application(tokenURL string) *SecurityScheme { + return &SecurityScheme{SecuritySchemeProps: SecuritySchemeProps{ + Type: oauth2, + Flow: application, + TokenURL: tokenURL, + }} +} + +// OAuth2AccessToken creates an access token flow oauth2 security scheme +func OAuth2AccessToken(authorizationURL, tokenURL string) *SecurityScheme { + return &SecurityScheme{SecuritySchemeProps: SecuritySchemeProps{ + Type: oauth2, + Flow: accessCode, + AuthorizationURL: authorizationURL, + TokenURL: tokenURL, + }} +} + +// SecuritySchemeProps describes a swagger security scheme in the securityDefinitions section +type SecuritySchemeProps struct { + Description string `json:"description,omitempty"` + Type string `json:"type"` + Name string `json:"name,omitempty"` // api key + In string `json:"in,omitempty"` // api key + Flow string `json:"flow,omitempty"` // oauth2 + AuthorizationURL string `json:"authorizationUrl"` // oauth2 + TokenURL string `json:"tokenUrl,omitempty"` // oauth2 + Scopes map[string]string `json:"scopes,omitempty"` // oauth2 +} + +// AddScope adds a scope to this security scheme +func (s *SecuritySchemeProps) AddScope(scope, description string) { + if s.Scopes == nil { + s.Scopes = make(map[string]string) + } + s.Scopes[scope] = description +} + +// SecurityScheme allows the definition of a security scheme that can be used by the operations. +// Supported schemes are basic authentication, an API key (either as a header or as a query parameter) +// and OAuth2's common flows (implicit, password, application and access code). +// +// For more information: http://goo.gl/8us55a#securitySchemeObject +type SecurityScheme struct { + VendorExtensible + SecuritySchemeProps +} + +// JSONLookup implements an interface to customize json pointer lookup +func (s SecurityScheme) JSONLookup(token string) (interface{}, error) { + if ex, ok := s.Extensions[token]; ok { + return &ex, nil + } + + r, _, err := jsonpointer.GetForToken(s.SecuritySchemeProps, token) + return r, err +} + +// MarshalJSON marshal this to JSON +func (s SecurityScheme) MarshalJSON() ([]byte, error) { + var ( + b1 []byte + err error + ) + + if s.Type == oauth2 && (s.Flow == "implicit" || s.Flow == "accessCode") { + // when oauth2 for implicit or accessCode flows, empty AuthorizationURL is added as empty string + b1, err = json.Marshal(s.SecuritySchemeProps) + } else { + // when not oauth2, empty AuthorizationURL should be omitted + b1, err = json.Marshal(struct { + Description string `json:"description,omitempty"` + Type string `json:"type"` + Name string `json:"name,omitempty"` // api key + In string `json:"in,omitempty"` // api key + Flow string `json:"flow,omitempty"` // oauth2 + AuthorizationURL string `json:"authorizationUrl,omitempty"` // oauth2 + TokenURL string `json:"tokenUrl,omitempty"` // oauth2 + Scopes map[string]string `json:"scopes,omitempty"` // oauth2 + }{ + Description: s.Description, + Type: s.Type, + Name: s.Name, + In: s.In, + Flow: s.Flow, + AuthorizationURL: s.AuthorizationURL, + TokenURL: s.TokenURL, + Scopes: s.Scopes, + }) + } + if err != nil { + return nil, err + } + + b2, err := json.Marshal(s.VendorExtensible) + if err != nil { + return nil, err + } + return swag.ConcatJSON(b1, b2), nil +} + +// UnmarshalJSON marshal this from JSON +func (s *SecurityScheme) UnmarshalJSON(data []byte) error { + if err := json.Unmarshal(data, &s.SecuritySchemeProps); err != nil { + return err + } + return json.Unmarshal(data, &s.VendorExtensible) +} diff --git a/vendor/github.com/go-openapi/spec/spec.go b/vendor/github.com/go-openapi/spec/spec.go new file mode 100644 index 00000000000..7d38b6e6251 --- /dev/null +++ b/vendor/github.com/go-openapi/spec/spec.go @@ -0,0 +1,78 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package spec + +import ( + "encoding/json" +) + +//go:generate curl -L --progress -o ./schemas/v2/schema.json http://swagger.io/v2/schema.json +//go:generate curl -L --progress -o ./schemas/jsonschema-draft-04.json http://json-schema.org/draft-04/schema +//go:generate go-bindata -pkg=spec -prefix=./schemas -ignore=.*\.md ./schemas/... +//go:generate perl -pi -e s,Json,JSON,g bindata.go + +const ( + // SwaggerSchemaURL the url for the swagger 2.0 schema to validate specs + SwaggerSchemaURL = "http://swagger.io/v2/schema.json#" + // JSONSchemaURL the url for the json schema schema + JSONSchemaURL = "http://json-schema.org/draft-04/schema#" +) + +// MustLoadJSONSchemaDraft04 panics when Swagger20Schema returns an error +func MustLoadJSONSchemaDraft04() *Schema { + d, e := JSONSchemaDraft04() + if e != nil { + panic(e) + } + return d +} + +// JSONSchemaDraft04 loads the json schema document for json shema draft04 +func JSONSchemaDraft04() (*Schema, error) { + b, err := Asset("jsonschema-draft-04.json") + if err != nil { + return nil, err + } + + schema := new(Schema) + if err := json.Unmarshal(b, schema); err != nil { + return nil, err + } + return schema, nil +} + +// MustLoadSwagger20Schema panics when Swagger20Schema returns an error +func MustLoadSwagger20Schema() *Schema { + d, e := Swagger20Schema() + if e != nil { + panic(e) + } + return d +} + +// Swagger20Schema loads the swagger 2.0 schema from the embedded assets +func Swagger20Schema() (*Schema, error) { + + b, err := Asset("v2/schema.json") + if err != nil { + return nil, err + } + + schema := new(Schema) + if err := json.Unmarshal(b, schema); err != nil { + return nil, err + } + return schema, nil +} diff --git a/vendor/github.com/go-openapi/spec/swagger.go b/vendor/github.com/go-openapi/spec/swagger.go new file mode 100644 index 00000000000..44722ffd5ad --- /dev/null +++ b/vendor/github.com/go-openapi/spec/swagger.go @@ -0,0 +1,448 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package spec + +import ( + "bytes" + "encoding/gob" + "encoding/json" + "fmt" + "strconv" + + "github.com/go-openapi/jsonpointer" + "github.com/go-openapi/swag" +) + +// Swagger this is the root document object for the API specification. +// It combines what previously was the Resource Listing and API Declaration (version 1.2 and earlier) +// together into one document. +// +// For more information: http://goo.gl/8us55a#swagger-object- +type Swagger struct { + VendorExtensible + SwaggerProps +} + +// JSONLookup look up a value by the json property name +func (s Swagger) JSONLookup(token string) (interface{}, error) { + if ex, ok := s.Extensions[token]; ok { + return &ex, nil + } + r, _, err := jsonpointer.GetForToken(s.SwaggerProps, token) + return r, err +} + +// MarshalJSON marshals this swagger structure to json +func (s Swagger) MarshalJSON() ([]byte, error) { + b1, err := json.Marshal(s.SwaggerProps) + if err != nil { + return nil, err + } + b2, err := json.Marshal(s.VendorExtensible) + if err != nil { + return nil, err + } + return swag.ConcatJSON(b1, b2), nil +} + +// UnmarshalJSON unmarshals a swagger spec from json +func (s *Swagger) UnmarshalJSON(data []byte) error { + var sw Swagger + if err := json.Unmarshal(data, &sw.SwaggerProps); err != nil { + return err + } + if err := json.Unmarshal(data, &sw.VendorExtensible); err != nil { + return err + } + *s = sw + return nil +} + +// GobEncode provides a safe gob encoder for Swagger, including extensions +func (s Swagger) GobEncode() ([]byte, error) { + var b bytes.Buffer + raw := struct { + Props SwaggerProps + Ext VendorExtensible + }{ + Props: s.SwaggerProps, + Ext: s.VendorExtensible, + } + err := gob.NewEncoder(&b).Encode(raw) + return b.Bytes(), err +} + +// GobDecode provides a safe gob decoder for Swagger, including extensions +func (s *Swagger) GobDecode(b []byte) error { + var raw struct { + Props SwaggerProps + Ext VendorExtensible + } + buf := bytes.NewBuffer(b) + err := gob.NewDecoder(buf).Decode(&raw) + if err != nil { + return err + } + s.SwaggerProps = raw.Props + s.VendorExtensible = raw.Ext + return nil +} + +// SwaggerProps captures the top-level properties of an Api specification +// +// NOTE: validation rules +// - the scheme, when present must be from [http, https, ws, wss] +// - BasePath must start with a leading "/" +// - Paths is required +type SwaggerProps struct { + ID string `json:"id,omitempty"` + Consumes []string `json:"consumes,omitempty"` + Produces []string `json:"produces,omitempty"` + Schemes []string `json:"schemes,omitempty"` + Swagger string `json:"swagger,omitempty"` + Info *Info `json:"info,omitempty"` + Host string `json:"host,omitempty"` + BasePath string `json:"basePath,omitempty"` + Paths *Paths `json:"paths"` + Definitions Definitions `json:"definitions,omitempty"` + Parameters map[string]Parameter `json:"parameters,omitempty"` + Responses map[string]Response `json:"responses,omitempty"` + SecurityDefinitions SecurityDefinitions `json:"securityDefinitions,omitempty"` + Security []map[string][]string `json:"security,omitempty"` + Tags []Tag `json:"tags,omitempty"` + ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"` +} + +type swaggerPropsAlias SwaggerProps + +type gobSwaggerPropsAlias struct { + Security []map[string]struct { + List []string + Pad bool + } + Alias *swaggerPropsAlias + SecurityIsEmpty bool +} + +// GobEncode provides a safe gob encoder for SwaggerProps, including empty security requirements +func (o SwaggerProps) GobEncode() ([]byte, error) { + raw := gobSwaggerPropsAlias{ + Alias: (*swaggerPropsAlias)(&o), + } + + var b bytes.Buffer + if o.Security == nil { + // nil security requirement + err := gob.NewEncoder(&b).Encode(raw) + return b.Bytes(), err + } + + if len(o.Security) == 0 { + // empty, but non-nil security requirement + raw.SecurityIsEmpty = true + raw.Alias.Security = nil + err := gob.NewEncoder(&b).Encode(raw) + return b.Bytes(), err + } + + raw.Security = make([]map[string]struct { + List []string + Pad bool + }, 0, len(o.Security)) + for _, req := range o.Security { + v := make(map[string]struct { + List []string + Pad bool + }, len(req)) + for k, val := range req { + v[k] = struct { + List []string + Pad bool + }{ + List: val, + } + } + raw.Security = append(raw.Security, v) + } + + err := gob.NewEncoder(&b).Encode(raw) + return b.Bytes(), err +} + +// GobDecode provides a safe gob decoder for SwaggerProps, including empty security requirements +func (o *SwaggerProps) GobDecode(b []byte) error { + var raw gobSwaggerPropsAlias + + buf := bytes.NewBuffer(b) + err := gob.NewDecoder(buf).Decode(&raw) + if err != nil { + return err + } + if raw.Alias == nil { + return nil + } + + switch { + case raw.SecurityIsEmpty: + // empty, but non-nil security requirement + raw.Alias.Security = []map[string][]string{} + case len(raw.Alias.Security) == 0: + // nil security requirement + raw.Alias.Security = nil + default: + raw.Alias.Security = make([]map[string][]string, 0, len(raw.Security)) + for _, req := range raw.Security { + v := make(map[string][]string, len(req)) + for k, val := range req { + v[k] = make([]string, 0, len(val.List)) + v[k] = append(v[k], val.List...) + } + raw.Alias.Security = append(raw.Alias.Security, v) + } + } + + *o = *(*SwaggerProps)(raw.Alias) + return nil +} + +// Dependencies represent a dependencies property +type Dependencies map[string]SchemaOrStringArray + +// SchemaOrBool represents a schema or boolean value, is biased towards true for the boolean property +type SchemaOrBool struct { + Allows bool + Schema *Schema +} + +// JSONLookup implements an interface to customize json pointer lookup +func (s SchemaOrBool) JSONLookup(token string) (interface{}, error) { + if token == "allows" { + return s.Allows, nil + } + r, _, err := jsonpointer.GetForToken(s.Schema, token) + return r, err +} + +var jsTrue = []byte("true") +var jsFalse = []byte("false") + +// MarshalJSON convert this object to JSON +func (s SchemaOrBool) MarshalJSON() ([]byte, error) { + if s.Schema != nil { + return json.Marshal(s.Schema) + } + + if s.Schema == nil && !s.Allows { + return jsFalse, nil + } + return jsTrue, nil +} + +// UnmarshalJSON converts this bool or schema object from a JSON structure +func (s *SchemaOrBool) UnmarshalJSON(data []byte) error { + var nw SchemaOrBool + if len(data) >= 4 { + if data[0] == '{' { + var sch Schema + if err := json.Unmarshal(data, &sch); err != nil { + return err + } + nw.Schema = &sch + } + nw.Allows = !(data[0] == 'f' && data[1] == 'a' && data[2] == 'l' && data[3] == 's' && data[4] == 'e') + } + *s = nw + return nil +} + +// SchemaOrStringArray represents a schema or a string array +type SchemaOrStringArray struct { + Schema *Schema + Property []string +} + +// JSONLookup implements an interface to customize json pointer lookup +func (s SchemaOrStringArray) JSONLookup(token string) (interface{}, error) { + r, _, err := jsonpointer.GetForToken(s.Schema, token) + return r, err +} + +// MarshalJSON converts this schema object or array into JSON structure +func (s SchemaOrStringArray) MarshalJSON() ([]byte, error) { + if len(s.Property) > 0 { + return json.Marshal(s.Property) + } + if s.Schema != nil { + return json.Marshal(s.Schema) + } + return []byte("null"), nil +} + +// UnmarshalJSON converts this schema object or array from a JSON structure +func (s *SchemaOrStringArray) UnmarshalJSON(data []byte) error { + var first byte + if len(data) > 1 { + first = data[0] + } + var nw SchemaOrStringArray + if first == '{' { + var sch Schema + if err := json.Unmarshal(data, &sch); err != nil { + return err + } + nw.Schema = &sch + } + if first == '[' { + if err := json.Unmarshal(data, &nw.Property); err != nil { + return err + } + } + *s = nw + return nil +} + +// Definitions contains the models explicitly defined in this spec +// An object to hold data types that can be consumed and produced by operations. +// These data types can be primitives, arrays or models. +// +// For more information: http://goo.gl/8us55a#definitionsObject +type Definitions map[string]Schema + +// SecurityDefinitions a declaration of the security schemes available to be used in the specification. +// This does not enforce the security schemes on the operations and only serves to provide +// the relevant details for each scheme. +// +// For more information: http://goo.gl/8us55a#securityDefinitionsObject +type SecurityDefinitions map[string]*SecurityScheme + +// StringOrArray represents a value that can either be a string +// or an array of strings. Mainly here for serialization purposes +type StringOrArray []string + +// Contains returns true when the value is contained in the slice +func (s StringOrArray) Contains(value string) bool { + for _, str := range s { + if str == value { + return true + } + } + return false +} + +// JSONLookup implements an interface to customize json pointer lookup +func (s SchemaOrArray) JSONLookup(token string) (interface{}, error) { + if _, err := strconv.Atoi(token); err == nil { + r, _, err := jsonpointer.GetForToken(s.Schemas, token) + return r, err + } + r, _, err := jsonpointer.GetForToken(s.Schema, token) + return r, err +} + +// UnmarshalJSON unmarshals this string or array object from a JSON array or JSON string +func (s *StringOrArray) UnmarshalJSON(data []byte) error { + var first byte + if len(data) > 1 { + first = data[0] + } + + if first == '[' { + var parsed []string + if err := json.Unmarshal(data, &parsed); err != nil { + return err + } + *s = StringOrArray(parsed) + return nil + } + + var single interface{} + if err := json.Unmarshal(data, &single); err != nil { + return err + } + if single == nil { + return nil + } + switch v := single.(type) { + case string: + *s = StringOrArray([]string{v}) + return nil + default: + return fmt.Errorf("only string or array is allowed, not %T", single) + } +} + +// MarshalJSON converts this string or array to a JSON array or JSON string +func (s StringOrArray) MarshalJSON() ([]byte, error) { + if len(s) == 1 { + return json.Marshal([]string(s)[0]) + } + return json.Marshal([]string(s)) +} + +// SchemaOrArray represents a value that can either be a Schema +// or an array of Schema. Mainly here for serialization purposes +type SchemaOrArray struct { + Schema *Schema + Schemas []Schema +} + +// Len returns the number of schemas in this property +func (s SchemaOrArray) Len() int { + if s.Schema != nil { + return 1 + } + return len(s.Schemas) +} + +// ContainsType returns true when one of the schemas is of the specified type +func (s *SchemaOrArray) ContainsType(name string) bool { + if s.Schema != nil { + return s.Schema.Type != nil && s.Schema.Type.Contains(name) + } + return false +} + +// MarshalJSON converts this schema object or array into JSON structure +func (s SchemaOrArray) MarshalJSON() ([]byte, error) { + if len(s.Schemas) > 0 { + return json.Marshal(s.Schemas) + } + return json.Marshal(s.Schema) +} + +// UnmarshalJSON converts this schema object or array from a JSON structure +func (s *SchemaOrArray) UnmarshalJSON(data []byte) error { + var nw SchemaOrArray + var first byte + if len(data) > 1 { + first = data[0] + } + if first == '{' { + var sch Schema + if err := json.Unmarshal(data, &sch); err != nil { + return err + } + nw.Schema = &sch + } + if first == '[' { + if err := json.Unmarshal(data, &nw.Schemas); err != nil { + return err + } + } + *s = nw + return nil +} + +// vim:set ft=go noet sts=2 sw=2 ts=2: diff --git a/vendor/github.com/go-openapi/spec/tag.go b/vendor/github.com/go-openapi/spec/tag.go new file mode 100644 index 00000000000..faa3d3de1eb --- /dev/null +++ b/vendor/github.com/go-openapi/spec/tag.go @@ -0,0 +1,75 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package spec + +import ( + "encoding/json" + + "github.com/go-openapi/jsonpointer" + "github.com/go-openapi/swag" +) + +// TagProps describe a tag entry in the top level tags section of a swagger spec +type TagProps struct { + Description string `json:"description,omitempty"` + Name string `json:"name,omitempty"` + ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"` +} + +// NewTag creates a new tag +func NewTag(name, description string, externalDocs *ExternalDocumentation) Tag { + return Tag{TagProps: TagProps{Description: description, Name: name, ExternalDocs: externalDocs}} +} + +// Tag allows adding meta data to a single tag that is used by the +// [Operation Object](http://goo.gl/8us55a#operationObject). +// It is not mandatory to have a Tag Object per tag used there. +// +// For more information: http://goo.gl/8us55a#tagObject +type Tag struct { + VendorExtensible + TagProps +} + +// JSONLookup implements an interface to customize json pointer lookup +func (t Tag) JSONLookup(token string) (interface{}, error) { + if ex, ok := t.Extensions[token]; ok { + return &ex, nil + } + + r, _, err := jsonpointer.GetForToken(t.TagProps, token) + return r, err +} + +// MarshalJSON marshal this to JSON +func (t Tag) MarshalJSON() ([]byte, error) { + b1, err := json.Marshal(t.TagProps) + if err != nil { + return nil, err + } + b2, err := json.Marshal(t.VendorExtensible) + if err != nil { + return nil, err + } + return swag.ConcatJSON(b1, b2), nil +} + +// UnmarshalJSON marshal this from JSON +func (t *Tag) UnmarshalJSON(data []byte) error { + if err := json.Unmarshal(data, &t.TagProps); err != nil { + return err + } + return json.Unmarshal(data, &t.VendorExtensible) +} diff --git a/vendor/github.com/go-openapi/spec/validations.go b/vendor/github.com/go-openapi/spec/validations.go new file mode 100644 index 00000000000..6360a8ea774 --- /dev/null +++ b/vendor/github.com/go-openapi/spec/validations.go @@ -0,0 +1,215 @@ +package spec + +// CommonValidations describe common JSON-schema validations +type CommonValidations struct { + Maximum *float64 `json:"maximum,omitempty"` + ExclusiveMaximum bool `json:"exclusiveMaximum,omitempty"` + Minimum *float64 `json:"minimum,omitempty"` + ExclusiveMinimum bool `json:"exclusiveMinimum,omitempty"` + MaxLength *int64 `json:"maxLength,omitempty"` + MinLength *int64 `json:"minLength,omitempty"` + Pattern string `json:"pattern,omitempty"` + MaxItems *int64 `json:"maxItems,omitempty"` + MinItems *int64 `json:"minItems,omitempty"` + UniqueItems bool `json:"uniqueItems,omitempty"` + MultipleOf *float64 `json:"multipleOf,omitempty"` + Enum []interface{} `json:"enum,omitempty"` +} + +// SetValidations defines all validations for a simple schema. +// +// NOTE: the input is the larger set of validations available for schemas. +// For simple schemas, MinProperties and MaxProperties are ignored. +func (v *CommonValidations) SetValidations(val SchemaValidations) { + v.Maximum = val.Maximum + v.ExclusiveMaximum = val.ExclusiveMaximum + v.Minimum = val.Minimum + v.ExclusiveMinimum = val.ExclusiveMinimum + v.MaxLength = val.MaxLength + v.MinLength = val.MinLength + v.Pattern = val.Pattern + v.MaxItems = val.MaxItems + v.MinItems = val.MinItems + v.UniqueItems = val.UniqueItems + v.MultipleOf = val.MultipleOf + v.Enum = val.Enum +} + +type clearedValidation struct { + Validation string + Value interface{} +} + +type clearedValidations []clearedValidation + +func (c clearedValidations) apply(cbs []func(string, interface{})) { + for _, cb := range cbs { + for _, cleared := range c { + cb(cleared.Validation, cleared.Value) + } + } +} + +// ClearNumberValidations clears all number validations. +// +// Some callbacks may be set by the caller to capture changed values. +func (v *CommonValidations) ClearNumberValidations(cbs ...func(string, interface{})) { + done := make(clearedValidations, 0, 5) + defer func() { + done.apply(cbs) + }() + + if v.Minimum != nil { + done = append(done, clearedValidation{Validation: "minimum", Value: v.Minimum}) + v.Minimum = nil + } + if v.Maximum != nil { + done = append(done, clearedValidation{Validation: "maximum", Value: v.Maximum}) + v.Maximum = nil + } + if v.ExclusiveMaximum { + done = append(done, clearedValidation{Validation: "exclusiveMaximum", Value: v.ExclusiveMaximum}) + v.ExclusiveMaximum = false + } + if v.ExclusiveMinimum { + done = append(done, clearedValidation{Validation: "exclusiveMinimum", Value: v.ExclusiveMinimum}) + v.ExclusiveMinimum = false + } + if v.MultipleOf != nil { + done = append(done, clearedValidation{Validation: "multipleOf", Value: v.MultipleOf}) + v.MultipleOf = nil + } +} + +// ClearStringValidations clears all string validations. +// +// Some callbacks may be set by the caller to capture changed values. +func (v *CommonValidations) ClearStringValidations(cbs ...func(string, interface{})) { + done := make(clearedValidations, 0, 3) + defer func() { + done.apply(cbs) + }() + + if v.Pattern != "" { + done = append(done, clearedValidation{Validation: "pattern", Value: v.Pattern}) + v.Pattern = "" + } + if v.MinLength != nil { + done = append(done, clearedValidation{Validation: "minLength", Value: v.MinLength}) + v.MinLength = nil + } + if v.MaxLength != nil { + done = append(done, clearedValidation{Validation: "maxLength", Value: v.MaxLength}) + v.MaxLength = nil + } +} + +// ClearArrayValidations clears all array validations. +// +// Some callbacks may be set by the caller to capture changed values. +func (v *CommonValidations) ClearArrayValidations(cbs ...func(string, interface{})) { + done := make(clearedValidations, 0, 3) + defer func() { + done.apply(cbs) + }() + + if v.MaxItems != nil { + done = append(done, clearedValidation{Validation: "maxItems", Value: v.MaxItems}) + v.MaxItems = nil + } + if v.MinItems != nil { + done = append(done, clearedValidation{Validation: "minItems", Value: v.MinItems}) + v.MinItems = nil + } + if v.UniqueItems { + done = append(done, clearedValidation{Validation: "uniqueItems", Value: v.UniqueItems}) + v.UniqueItems = false + } +} + +// Validations returns a clone of the validations for a simple schema. +// +// NOTE: in the context of simple schema objects, MinProperties, MaxProperties +// and PatternProperties remain unset. +func (v CommonValidations) Validations() SchemaValidations { + return SchemaValidations{ + CommonValidations: v, + } +} + +// HasNumberValidations indicates if the validations are for numbers or integers +func (v CommonValidations) HasNumberValidations() bool { + return v.Maximum != nil || v.Minimum != nil || v.MultipleOf != nil +} + +// HasStringValidations indicates if the validations are for strings +func (v CommonValidations) HasStringValidations() bool { + return v.MaxLength != nil || v.MinLength != nil || v.Pattern != "" +} + +// HasArrayValidations indicates if the validations are for arrays +func (v CommonValidations) HasArrayValidations() bool { + return v.MaxItems != nil || v.MinItems != nil || v.UniqueItems +} + +// HasEnum indicates if the validation includes some enum constraint +func (v CommonValidations) HasEnum() bool { + return len(v.Enum) > 0 +} + +// SchemaValidations describes the validation properties of a schema +// +// NOTE: at this moment, this is not embedded in SchemaProps because this would induce a breaking change +// in the exported members: all initializers using litterals would fail. +type SchemaValidations struct { + CommonValidations + + PatternProperties SchemaProperties `json:"patternProperties,omitempty"` + MaxProperties *int64 `json:"maxProperties,omitempty"` + MinProperties *int64 `json:"minProperties,omitempty"` +} + +// HasObjectValidations indicates if the validations are for objects +func (v SchemaValidations) HasObjectValidations() bool { + return v.MaxProperties != nil || v.MinProperties != nil || v.PatternProperties != nil +} + +// SetValidations for schema validations +func (v *SchemaValidations) SetValidations(val SchemaValidations) { + v.CommonValidations.SetValidations(val) + v.PatternProperties = val.PatternProperties + v.MaxProperties = val.MaxProperties + v.MinProperties = val.MinProperties +} + +// Validations for a schema +func (v SchemaValidations) Validations() SchemaValidations { + val := v.CommonValidations.Validations() + val.PatternProperties = v.PatternProperties + val.MinProperties = v.MinProperties + val.MaxProperties = v.MaxProperties + return val +} + +// ClearObjectValidations returns a clone of the validations with all object validations cleared. +// +// Some callbacks may be set by the caller to capture changed values. +func (v *SchemaValidations) ClearObjectValidations(cbs ...func(string, interface{})) { + done := make(clearedValidations, 0, 3) + defer func() { + done.apply(cbs) + }() + + if v.MaxProperties != nil { + done = append(done, clearedValidation{Validation: "maxProperties", Value: v.MaxProperties}) + v.MaxProperties = nil + } + if v.MinProperties != nil { + done = append(done, clearedValidation{Validation: "minProperties", Value: v.MinProperties}) + v.MinProperties = nil + } + if v.PatternProperties != nil { + done = append(done, clearedValidation{Validation: "patternProperties", Value: v.PatternProperties}) + v.PatternProperties = nil + } +} diff --git a/vendor/github.com/go-openapi/spec/xml_object.go b/vendor/github.com/go-openapi/spec/xml_object.go new file mode 100644 index 00000000000..945a46703d5 --- /dev/null +++ b/vendor/github.com/go-openapi/spec/xml_object.go @@ -0,0 +1,68 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package spec + +// XMLObject a metadata object that allows for more fine-tuned XML model definitions. +// +// For more information: http://goo.gl/8us55a#xmlObject +type XMLObject struct { + Name string `json:"name,omitempty"` + Namespace string `json:"namespace,omitempty"` + Prefix string `json:"prefix,omitempty"` + Attribute bool `json:"attribute,omitempty"` + Wrapped bool `json:"wrapped,omitempty"` +} + +// WithName sets the xml name for the object +func (x *XMLObject) WithName(name string) *XMLObject { + x.Name = name + return x +} + +// WithNamespace sets the xml namespace for the object +func (x *XMLObject) WithNamespace(namespace string) *XMLObject { + x.Namespace = namespace + return x +} + +// WithPrefix sets the xml prefix for the object +func (x *XMLObject) WithPrefix(prefix string) *XMLObject { + x.Prefix = prefix + return x +} + +// AsAttribute flags this object as xml attribute +func (x *XMLObject) AsAttribute() *XMLObject { + x.Attribute = true + return x +} + +// AsElement flags this object as an xml node +func (x *XMLObject) AsElement() *XMLObject { + x.Attribute = false + return x +} + +// AsWrapped flags this object as wrapped, this is mostly useful for array types +func (x *XMLObject) AsWrapped() *XMLObject { + x.Wrapped = true + return x +} + +// AsUnwrapped flags this object as an xml node +func (x *XMLObject) AsUnwrapped() *XMLObject { + x.Wrapped = false + return x +} diff --git a/vendor/github.com/go-openapi/strfmt/.gitattributes b/vendor/github.com/go-openapi/strfmt/.gitattributes new file mode 100644 index 00000000000..d020be8ea4e --- /dev/null +++ b/vendor/github.com/go-openapi/strfmt/.gitattributes @@ -0,0 +1,2 @@ +*.go text eol=lf + diff --git a/vendor/github.com/go-openapi/strfmt/.golangci.yml b/vendor/github.com/go-openapi/strfmt/.golangci.yml index 7ffaa32b9b4..da12d5e3b75 100644 --- a/vendor/github.com/go-openapi/strfmt/.golangci.yml +++ b/vendor/github.com/go-openapi/strfmt/.golangci.yml @@ -35,6 +35,8 @@ linters: - godot - exhaustivestruct - paralleltest + - varnamelen + - ireturn #- thelper issues: diff --git a/vendor/github.com/go-openapi/strfmt/.travis.yml b/vendor/github.com/go-openapi/strfmt/.travis.yml deleted file mode 100644 index eaee5b65a93..00000000000 --- a/vendor/github.com/go-openapi/strfmt/.travis.yml +++ /dev/null @@ -1,31 +0,0 @@ -after_success: -- bash <(curl -s https://codecov.io/bash) -go: -- 1.14.x -- 1.x -arch: -- amd64 -jobs: - include: - # only run fast tests on ppc64le - - go: 1.x - arch: ppc64le - script: - - gotestsum -f short-verbose -- ./... - - # include linting job, but only for latest go version and amd64 arch - - go: 1.x - arch: amd64 - install: - go get github.com/golangci/golangci-lint/cmd/golangci-lint - script: - - golangci-lint run --new-from-rev master - -install: -- GO111MODULE=off go get -u gotest.tools/gotestsum -language: go -notifications: - slack: - secure: zE5AtIYTpYfQPnTzP+EaQPN7JKtfFAGv6PrJqoIZLOXa8B6zGb6+J1JRNNxWi7faWbyJOxa4FSSsuPsKZMycUK6wlLFIdhDxwqeo7Ew8r6rdZKdfUHQggfNS9wO79ARoNYUDHtmnaBUS+eWSM1YqSc4i99QxyyfuURLOeAaA/q14YbdlTlaw3lrZ0qT92ot1FnVGNOx064zuHtFeUf+jAVRMZ6Q3rvqllwIlPszE6rmHGXBt2VoJxRaBetdwd7FgkcYw9FPXKHhadwC7/75ZAdmxIukhxNMw4Tr5NuPcqNcnbYLenDP7B3lssGVIrP4BRSqekS1d/tqvdvnnFWHMwrNCkSnSc065G5+qWTlXKAemIclgiXXqE2furBNLm05MDdG8fn5epS0UNarkjD+zX336RiqwBlOX4KbF+vPyqcO98CsN0lnd+H6loc9reiTHs37orFFpQ+309av9be2GGsHUsRB9ssIyrewmhAccOmkRtr2dVTZJNFQwa5Kph5TNJuTjnZEwG/xUkEX2YSfwShOsb062JWiflV6PJdnl80pc9Tn7D5sO5Bf9DbijGRJwwP+YiiJtwtr+vsvS+n4sM0b5eqm4UoRo+JJO8ffoJtHS7ItuyRbVQCwEPJ4221WLcf5PquEEDdAPwR+K4Gj8qTXqTDdxOiES1xFUKVgmzhI= -script: -- gotestsum -f short-verbose -- -race -coverprofile=coverage.txt -covermode=atomic ./... diff --git a/vendor/github.com/go-openapi/strfmt/bson.go b/vendor/github.com/go-openapi/strfmt/bson.go index c1496122182..8740b150599 100644 --- a/vendor/github.com/go-openapi/strfmt/bson.go +++ b/vendor/github.com/go-openapi/strfmt/bson.go @@ -39,10 +39,10 @@ func IsBSONObjectID(str string) bool { // ObjectId represents a BSON object ID (alias to go.mongodb.org/mongo-driver/bson/primitive.ObjectID) // // swagger:strfmt bsonobjectid -type ObjectId bsonprim.ObjectID +type ObjectId bsonprim.ObjectID //nolint:revive // NewObjectId creates a ObjectId from a Hex String -func NewObjectId(hex string) ObjectId { +func NewObjectId(hex string) ObjectId { //nolint:revive oid, err := bsonprim.ObjectIDFromHex(hex) if err != nil { panic(err) @@ -95,7 +95,7 @@ func (id ObjectId) Value() (driver.Value, error) { } func (id ObjectId) String() string { - return bsonprim.ObjectID(id).String() + return bsonprim.ObjectID(id).Hex() } // MarshalJSON returns the ObjectId as JSON diff --git a/vendor/github.com/go-openapi/strfmt/format.go b/vendor/github.com/go-openapi/strfmt/format.go index 13a1626fa4a..172055d22da 100644 --- a/vendor/github.com/go-openapi/strfmt/format.go +++ b/vendor/github.com/go-openapi/strfmt/format.go @@ -76,6 +76,7 @@ type defaultFormats struct { // NewFormats creates a new formats registry seeded with the values from the default func NewFormats() Registry { + //nolint:forcetypeassert return NewSeededFormats(Default.(*defaultFormats).data, nil) } @@ -93,75 +94,80 @@ func NewSeededFormats(seeds []knownFormat, normalizer NameNormalizer) Registry { } // MapStructureHookFunc is a decode hook function for mapstructure -func (f *defaultFormats) MapStructureHookFunc() mapstructure.DecodeHookFunc { - return func(from reflect.Type, to reflect.Type, data interface{}) (interface{}, error) { +func (f *defaultFormats) MapStructureHookFunc() mapstructure.DecodeHookFunc { //nolint:gocyclo,cyclop + return func(from reflect.Type, to reflect.Type, obj interface{}) (interface{}, error) { if from.Kind() != reflect.String { - return data, nil + return obj, nil } + data, ok := obj.(string) + if !ok { + return nil, fmt.Errorf("failed to cast %+v to string", obj) + } + for _, v := range f.data { tpe, _ := f.GetType(v.Name) if to == tpe { switch v.Name { case "date": - d, err := time.Parse(RFC3339FullDate, data.(string)) + d, err := time.Parse(RFC3339FullDate, data) if err != nil { return nil, err } return Date(d), nil case "datetime": - input := data.(string) + input := data if len(input) == 0 { return nil, fmt.Errorf("empty string is an invalid datetime format") } return ParseDateTime(input) case "duration": - dur, err := ParseDuration(data.(string)) + dur, err := ParseDuration(data) if err != nil { return nil, err } return Duration(dur), nil case "uri": - return URI(data.(string)), nil + return URI(data), nil case "email": - return Email(data.(string)), nil + return Email(data), nil case "uuid": - return UUID(data.(string)), nil + return UUID(data), nil case "uuid3": - return UUID3(data.(string)), nil + return UUID3(data), nil case "uuid4": - return UUID4(data.(string)), nil + return UUID4(data), nil case "uuid5": - return UUID5(data.(string)), nil + return UUID5(data), nil case "hostname": - return Hostname(data.(string)), nil + return Hostname(data), nil case "ipv4": - return IPv4(data.(string)), nil + return IPv4(data), nil case "ipv6": - return IPv6(data.(string)), nil + return IPv6(data), nil case "cidr": - return CIDR(data.(string)), nil + return CIDR(data), nil case "mac": - return MAC(data.(string)), nil + return MAC(data), nil case "isbn": - return ISBN(data.(string)), nil + return ISBN(data), nil case "isbn10": - return ISBN10(data.(string)), nil + return ISBN10(data), nil case "isbn13": - return ISBN13(data.(string)), nil + return ISBN13(data), nil case "creditcard": - return CreditCard(data.(string)), nil + return CreditCard(data), nil case "ssn": - return SSN(data.(string)), nil + return SSN(data), nil case "hexcolor": - return HexColor(data.(string)), nil + return HexColor(data), nil case "rgbcolor": - return RGBColor(data.(string)), nil + return RGBColor(data), nil case "byte": - return Base64(data.(string)), nil + return Base64(data), nil case "password": - return Password(data.(string)), nil + return Password(data), nil case "ulid": - ulid, err := ParseULID(data.(string)) + ulid, err := ParseULID(data) if err != nil { return nil, err } diff --git a/vendor/github.com/go-openapi/strfmt/time.go b/vendor/github.com/go-openapi/strfmt/time.go index 425413f7ec9..023676e6c97 100644 --- a/vendor/github.com/go-openapi/strfmt/time.go +++ b/vendor/github.com/go-openapi/strfmt/time.go @@ -18,6 +18,7 @@ import ( "database/sql/driver" "encoding/binary" "encoding/json" + "errors" "fmt" "regexp" "strings" @@ -210,9 +211,12 @@ func (t *DateTime) UnmarshalBSON(data []byte) error { // Marshals a DateTime as a bsontype.DateTime, an int64 representing // milliseconds since epoch. func (t DateTime) MarshalBSONValue() (bsontype.Type, []byte, error) { - // UnixNano cannot be used, the result of calling UnixNano on the zero - // Time is undefined. - i64 := NormalizeTimeForMarshal(time.Time(t)).Unix() * 1000 + // UnixNano cannot be used directly, the result of calling UnixNano on the zero + // Time is undefined. Thats why we use time.Nanosecond() instead. + + tNorm := NormalizeTimeForMarshal(time.Time(t)) + i64 := tNorm.Unix()*1000 + int64(tNorm.Nanosecond())/1e6 + buf := make([]byte, 8) binary.LittleEndian.PutUint64(buf, uint64(i64)) @@ -224,6 +228,15 @@ func (t DateTime) MarshalBSONValue() (bsontype.Type, []byte, error) { // assumed to be valid. UnmarshalBSONValue must copy the BSON value bytes if it // wishes to retain the data after returning. func (t *DateTime) UnmarshalBSONValue(tpe bsontype.Type, data []byte) error { + if tpe == bsontype.Null { + *t = DateTime{} + return nil + } + + if len(data) != 8 { + return errors.New("bson date field length not exactly 8 bytes") + } + i64 := int64(binary.LittleEndian.Uint64(data)) // TODO: Use bsonprim.DateTime.Time() method *t = DateTime(time.Unix(i64/1000, i64%1000*1000000)) diff --git a/vendor/github.com/go-openapi/strfmt/ulid.go b/vendor/github.com/go-openapi/strfmt/ulid.go index 6ea2e35c366..4bd2ccd8f66 100644 --- a/vendor/github.com/go-openapi/strfmt/ulid.go +++ b/vendor/github.com/go-openapi/strfmt/ulid.go @@ -32,7 +32,7 @@ var ( } ULIDScanDefaultFunc = func(raw interface{}) (ULID, error) { - var u ULID = NewULIDZero() + u := NewULIDZero() switch x := raw.(type) { case nil: // zerp ulid @@ -90,7 +90,11 @@ func NewULIDZero() ULID { // NewULID generates new unique ULID value and a error if any func NewULID() (u ULID, err error) { - entropy := ulidEntropyPool.Get().(io.Reader) + obj := ulidEntropyPool.Get() + entropy, ok := obj.(io.Reader) + if !ok { + return u, fmt.Errorf("failed to cast %+v to io.Reader", obj) + } id, err := ulid.New(ulid.Now(), entropy) if err != nil { diff --git a/vendor/github.com/go-openapi/swag/.editorconfig b/vendor/github.com/go-openapi/swag/.editorconfig new file mode 100644 index 00000000000..3152da69a5d --- /dev/null +++ b/vendor/github.com/go-openapi/swag/.editorconfig @@ -0,0 +1,26 @@ +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true + +# Set default charset +[*.{js,py,go,scala,rb,java,html,css,less,sass,md}] +charset = utf-8 + +# Tab indentation (no size specified) +[*.go] +indent_style = tab + +[*.md] +trim_trailing_whitespace = false + +# Matches the exact files either package.json or .travis.yml +[{package.json,.travis.yml}] +indent_style = space +indent_size = 2 diff --git a/vendor/github.com/go-openapi/swag/.gitattributes b/vendor/github.com/go-openapi/swag/.gitattributes new file mode 100644 index 00000000000..49ad52766ab --- /dev/null +++ b/vendor/github.com/go-openapi/swag/.gitattributes @@ -0,0 +1,2 @@ +# gofmt always uses LF, whereas Git uses CRLF on Windows. +*.go text eol=lf diff --git a/vendor/github.com/go-openapi/swag/.gitignore b/vendor/github.com/go-openapi/swag/.gitignore new file mode 100644 index 00000000000..d69b53accc5 --- /dev/null +++ b/vendor/github.com/go-openapi/swag/.gitignore @@ -0,0 +1,4 @@ +secrets.yml +vendor +Godeps +.idea diff --git a/vendor/github.com/go-openapi/swag/.golangci.yml b/vendor/github.com/go-openapi/swag/.golangci.yml new file mode 100644 index 00000000000..2a4a71f3a85 --- /dev/null +++ b/vendor/github.com/go-openapi/swag/.golangci.yml @@ -0,0 +1,50 @@ +linters-settings: + govet: + check-shadowing: true + golint: + min-confidence: 0 + gocyclo: + min-complexity: 25 + maligned: + suggest-new: true + dupl: + threshold: 100 + goconst: + min-len: 3 + min-occurrences: 2 + +linters: + enable-all: true + disable: + - maligned + - lll + - gochecknoinits + - gochecknoglobals + - nlreturn + - testpackage + - wrapcheck + - gomnd + - exhaustive + - exhaustivestruct + - goerr113 + - wsl + - whitespace + - gofumpt + - godot + - nestif + - godox + - funlen + - gci + - gocognit + - paralleltest + - thelper + - ifshort + - gomoddirectives + - cyclop + - forcetypeassert + - ireturn + - tagliatelle + - varnamelen + - goimports + - tenv + - golint diff --git a/vendor/github.com/go-openapi/swag/CODE_OF_CONDUCT.md b/vendor/github.com/go-openapi/swag/CODE_OF_CONDUCT.md new file mode 100644 index 00000000000..9322b065e37 --- /dev/null +++ b/vendor/github.com/go-openapi/swag/CODE_OF_CONDUCT.md @@ -0,0 +1,74 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or +advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at ivan+abuse@flanders.co.nz. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/vendor/github.com/go-openapi/swag/LICENSE b/vendor/github.com/go-openapi/swag/LICENSE new file mode 100644 index 00000000000..d6456956733 --- /dev/null +++ b/vendor/github.com/go-openapi/swag/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/go-openapi/swag/README.md b/vendor/github.com/go-openapi/swag/README.md new file mode 100644 index 00000000000..217f6fa5054 --- /dev/null +++ b/vendor/github.com/go-openapi/swag/README.md @@ -0,0 +1,21 @@ +# Swag [![Build Status](https://travis-ci.org/go-openapi/swag.svg?branch=master)](https://travis-ci.org/go-openapi/swag) [![codecov](https://codecov.io/gh/go-openapi/swag/branch/master/graph/badge.svg)](https://codecov.io/gh/go-openapi/swag) [![Slack Status](https://slackin.goswagger.io/badge.svg)](https://slackin.goswagger.io) + +[![license](http://img.shields.io/badge/license-Apache%20v2-orange.svg)](https://raw.githubusercontent.com/go-openapi/swag/master/LICENSE) +[![GoDoc](https://godoc.org/github.com/go-openapi/swag?status.svg)](http://godoc.org/github.com/go-openapi/swag) +[![Go Report Card](https://goreportcard.com/badge/github.com/go-openapi/swag)](https://goreportcard.com/report/github.com/go-openapi/swag) + +Contains a bunch of helper functions for go-openapi and go-swagger projects. + +You may also use it standalone for your projects. + +* convert between value and pointers for builtin types +* convert from string to builtin types (wraps strconv) +* fast json concatenation +* search in path +* load from file or http +* name mangling + + +This repo has only few dependencies outside of the standard library: + +* YAML utilities depend on gopkg.in/yaml.v2 diff --git a/vendor/github.com/go-openapi/swag/convert.go b/vendor/github.com/go-openapi/swag/convert.go new file mode 100644 index 00000000000..fc085aeb8ea --- /dev/null +++ b/vendor/github.com/go-openapi/swag/convert.go @@ -0,0 +1,208 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package swag + +import ( + "math" + "strconv" + "strings" +) + +// same as ECMA Number.MAX_SAFE_INTEGER and Number.MIN_SAFE_INTEGER +const ( + maxJSONFloat = float64(1<<53 - 1) // 9007199254740991.0 2^53 - 1 + minJSONFloat = -float64(1<<53 - 1) //-9007199254740991.0 -2^53 - 1 + epsilon float64 = 1e-9 +) + +// IsFloat64AJSONInteger allow for integers [-2^53, 2^53-1] inclusive +func IsFloat64AJSONInteger(f float64) bool { + if math.IsNaN(f) || math.IsInf(f, 0) || f < minJSONFloat || f > maxJSONFloat { + return false + } + fa := math.Abs(f) + g := float64(uint64(f)) + ga := math.Abs(g) + + diff := math.Abs(f - g) + + // more info: https://floating-point-gui.de/errors/comparison/#look-out-for-edge-cases + switch { + case f == g: // best case + return true + case f == float64(int64(f)) || f == float64(uint64(f)): // optimistic case + return true + case f == 0 || g == 0 || diff < math.SmallestNonzeroFloat64: // very close to 0 values + return diff < (epsilon * math.SmallestNonzeroFloat64) + } + // check the relative error + return diff/math.Min(fa+ga, math.MaxFloat64) < epsilon +} + +var evaluatesAsTrue map[string]struct{} + +func init() { + evaluatesAsTrue = map[string]struct{}{ + "true": {}, + "1": {}, + "yes": {}, + "ok": {}, + "y": {}, + "on": {}, + "selected": {}, + "checked": {}, + "t": {}, + "enabled": {}, + } +} + +// ConvertBool turn a string into a boolean +func ConvertBool(str string) (bool, error) { + _, ok := evaluatesAsTrue[strings.ToLower(str)] + return ok, nil +} + +// ConvertFloat32 turn a string into a float32 +func ConvertFloat32(str string) (float32, error) { + f, err := strconv.ParseFloat(str, 32) + if err != nil { + return 0, err + } + return float32(f), nil +} + +// ConvertFloat64 turn a string into a float64 +func ConvertFloat64(str string) (float64, error) { + return strconv.ParseFloat(str, 64) +} + +// ConvertInt8 turn a string into an int8 +func ConvertInt8(str string) (int8, error) { + i, err := strconv.ParseInt(str, 10, 8) + if err != nil { + return 0, err + } + return int8(i), nil +} + +// ConvertInt16 turn a string into an int16 +func ConvertInt16(str string) (int16, error) { + i, err := strconv.ParseInt(str, 10, 16) + if err != nil { + return 0, err + } + return int16(i), nil +} + +// ConvertInt32 turn a string into an int32 +func ConvertInt32(str string) (int32, error) { + i, err := strconv.ParseInt(str, 10, 32) + if err != nil { + return 0, err + } + return int32(i), nil +} + +// ConvertInt64 turn a string into an int64 +func ConvertInt64(str string) (int64, error) { + return strconv.ParseInt(str, 10, 64) +} + +// ConvertUint8 turn a string into an uint8 +func ConvertUint8(str string) (uint8, error) { + i, err := strconv.ParseUint(str, 10, 8) + if err != nil { + return 0, err + } + return uint8(i), nil +} + +// ConvertUint16 turn a string into an uint16 +func ConvertUint16(str string) (uint16, error) { + i, err := strconv.ParseUint(str, 10, 16) + if err != nil { + return 0, err + } + return uint16(i), nil +} + +// ConvertUint32 turn a string into an uint32 +func ConvertUint32(str string) (uint32, error) { + i, err := strconv.ParseUint(str, 10, 32) + if err != nil { + return 0, err + } + return uint32(i), nil +} + +// ConvertUint64 turn a string into an uint64 +func ConvertUint64(str string) (uint64, error) { + return strconv.ParseUint(str, 10, 64) +} + +// FormatBool turns a boolean into a string +func FormatBool(value bool) string { + return strconv.FormatBool(value) +} + +// FormatFloat32 turns a float32 into a string +func FormatFloat32(value float32) string { + return strconv.FormatFloat(float64(value), 'f', -1, 32) +} + +// FormatFloat64 turns a float64 into a string +func FormatFloat64(value float64) string { + return strconv.FormatFloat(value, 'f', -1, 64) +} + +// FormatInt8 turns an int8 into a string +func FormatInt8(value int8) string { + return strconv.FormatInt(int64(value), 10) +} + +// FormatInt16 turns an int16 into a string +func FormatInt16(value int16) string { + return strconv.FormatInt(int64(value), 10) +} + +// FormatInt32 turns an int32 into a string +func FormatInt32(value int32) string { + return strconv.Itoa(int(value)) +} + +// FormatInt64 turns an int64 into a string +func FormatInt64(value int64) string { + return strconv.FormatInt(value, 10) +} + +// FormatUint8 turns an uint8 into a string +func FormatUint8(value uint8) string { + return strconv.FormatUint(uint64(value), 10) +} + +// FormatUint16 turns an uint16 into a string +func FormatUint16(value uint16) string { + return strconv.FormatUint(uint64(value), 10) +} + +// FormatUint32 turns an uint32 into a string +func FormatUint32(value uint32) string { + return strconv.FormatUint(uint64(value), 10) +} + +// FormatUint64 turns an uint64 into a string +func FormatUint64(value uint64) string { + return strconv.FormatUint(value, 10) +} diff --git a/vendor/github.com/go-openapi/swag/convert_types.go b/vendor/github.com/go-openapi/swag/convert_types.go new file mode 100644 index 00000000000..c49cc473a8c --- /dev/null +++ b/vendor/github.com/go-openapi/swag/convert_types.go @@ -0,0 +1,730 @@ +package swag + +import "time" + +// This file was taken from the aws go sdk + +// String returns a pointer to of the string value passed in. +func String(v string) *string { + return &v +} + +// StringValue returns the value of the string pointer passed in or +// "" if the pointer is nil. +func StringValue(v *string) string { + if v != nil { + return *v + } + return "" +} + +// StringSlice converts a slice of string values into a slice of +// string pointers +func StringSlice(src []string) []*string { + dst := make([]*string, len(src)) + for i := 0; i < len(src); i++ { + dst[i] = &(src[i]) + } + return dst +} + +// StringValueSlice converts a slice of string pointers into a slice of +// string values +func StringValueSlice(src []*string) []string { + dst := make([]string, len(src)) + for i := 0; i < len(src); i++ { + if src[i] != nil { + dst[i] = *(src[i]) + } + } + return dst +} + +// StringMap converts a string map of string values into a string +// map of string pointers +func StringMap(src map[string]string) map[string]*string { + dst := make(map[string]*string) + for k, val := range src { + v := val + dst[k] = &v + } + return dst +} + +// StringValueMap converts a string map of string pointers into a string +// map of string values +func StringValueMap(src map[string]*string) map[string]string { + dst := make(map[string]string) + for k, val := range src { + if val != nil { + dst[k] = *val + } + } + return dst +} + +// Bool returns a pointer to of the bool value passed in. +func Bool(v bool) *bool { + return &v +} + +// BoolValue returns the value of the bool pointer passed in or +// false if the pointer is nil. +func BoolValue(v *bool) bool { + if v != nil { + return *v + } + return false +} + +// BoolSlice converts a slice of bool values into a slice of +// bool pointers +func BoolSlice(src []bool) []*bool { + dst := make([]*bool, len(src)) + for i := 0; i < len(src); i++ { + dst[i] = &(src[i]) + } + return dst +} + +// BoolValueSlice converts a slice of bool pointers into a slice of +// bool values +func BoolValueSlice(src []*bool) []bool { + dst := make([]bool, len(src)) + for i := 0; i < len(src); i++ { + if src[i] != nil { + dst[i] = *(src[i]) + } + } + return dst +} + +// BoolMap converts a string map of bool values into a string +// map of bool pointers +func BoolMap(src map[string]bool) map[string]*bool { + dst := make(map[string]*bool) + for k, val := range src { + v := val + dst[k] = &v + } + return dst +} + +// BoolValueMap converts a string map of bool pointers into a string +// map of bool values +func BoolValueMap(src map[string]*bool) map[string]bool { + dst := make(map[string]bool) + for k, val := range src { + if val != nil { + dst[k] = *val + } + } + return dst +} + +// Int returns a pointer to of the int value passed in. +func Int(v int) *int { + return &v +} + +// IntValue returns the value of the int pointer passed in or +// 0 if the pointer is nil. +func IntValue(v *int) int { + if v != nil { + return *v + } + return 0 +} + +// IntSlice converts a slice of int values into a slice of +// int pointers +func IntSlice(src []int) []*int { + dst := make([]*int, len(src)) + for i := 0; i < len(src); i++ { + dst[i] = &(src[i]) + } + return dst +} + +// IntValueSlice converts a slice of int pointers into a slice of +// int values +func IntValueSlice(src []*int) []int { + dst := make([]int, len(src)) + for i := 0; i < len(src); i++ { + if src[i] != nil { + dst[i] = *(src[i]) + } + } + return dst +} + +// IntMap converts a string map of int values into a string +// map of int pointers +func IntMap(src map[string]int) map[string]*int { + dst := make(map[string]*int) + for k, val := range src { + v := val + dst[k] = &v + } + return dst +} + +// IntValueMap converts a string map of int pointers into a string +// map of int values +func IntValueMap(src map[string]*int) map[string]int { + dst := make(map[string]int) + for k, val := range src { + if val != nil { + dst[k] = *val + } + } + return dst +} + +// Int32 returns a pointer to of the int32 value passed in. +func Int32(v int32) *int32 { + return &v +} + +// Int32Value returns the value of the int32 pointer passed in or +// 0 if the pointer is nil. +func Int32Value(v *int32) int32 { + if v != nil { + return *v + } + return 0 +} + +// Int32Slice converts a slice of int32 values into a slice of +// int32 pointers +func Int32Slice(src []int32) []*int32 { + dst := make([]*int32, len(src)) + for i := 0; i < len(src); i++ { + dst[i] = &(src[i]) + } + return dst +} + +// Int32ValueSlice converts a slice of int32 pointers into a slice of +// int32 values +func Int32ValueSlice(src []*int32) []int32 { + dst := make([]int32, len(src)) + for i := 0; i < len(src); i++ { + if src[i] != nil { + dst[i] = *(src[i]) + } + } + return dst +} + +// Int32Map converts a string map of int32 values into a string +// map of int32 pointers +func Int32Map(src map[string]int32) map[string]*int32 { + dst := make(map[string]*int32) + for k, val := range src { + v := val + dst[k] = &v + } + return dst +} + +// Int32ValueMap converts a string map of int32 pointers into a string +// map of int32 values +func Int32ValueMap(src map[string]*int32) map[string]int32 { + dst := make(map[string]int32) + for k, val := range src { + if val != nil { + dst[k] = *val + } + } + return dst +} + +// Int64 returns a pointer to of the int64 value passed in. +func Int64(v int64) *int64 { + return &v +} + +// Int64Value returns the value of the int64 pointer passed in or +// 0 if the pointer is nil. +func Int64Value(v *int64) int64 { + if v != nil { + return *v + } + return 0 +} + +// Int64Slice converts a slice of int64 values into a slice of +// int64 pointers +func Int64Slice(src []int64) []*int64 { + dst := make([]*int64, len(src)) + for i := 0; i < len(src); i++ { + dst[i] = &(src[i]) + } + return dst +} + +// Int64ValueSlice converts a slice of int64 pointers into a slice of +// int64 values +func Int64ValueSlice(src []*int64) []int64 { + dst := make([]int64, len(src)) + for i := 0; i < len(src); i++ { + if src[i] != nil { + dst[i] = *(src[i]) + } + } + return dst +} + +// Int64Map converts a string map of int64 values into a string +// map of int64 pointers +func Int64Map(src map[string]int64) map[string]*int64 { + dst := make(map[string]*int64) + for k, val := range src { + v := val + dst[k] = &v + } + return dst +} + +// Int64ValueMap converts a string map of int64 pointers into a string +// map of int64 values +func Int64ValueMap(src map[string]*int64) map[string]int64 { + dst := make(map[string]int64) + for k, val := range src { + if val != nil { + dst[k] = *val + } + } + return dst +} + +// Uint16 returns a pointer to of the uint16 value passed in. +func Uint16(v uint16) *uint16 { + return &v +} + +// Uint16Value returns the value of the uint16 pointer passed in or +// 0 if the pointer is nil. +func Uint16Value(v *uint16) uint16 { + if v != nil { + return *v + } + + return 0 +} + +// Uint16Slice converts a slice of uint16 values into a slice of +// uint16 pointers +func Uint16Slice(src []uint16) []*uint16 { + dst := make([]*uint16, len(src)) + for i := 0; i < len(src); i++ { + dst[i] = &(src[i]) + } + + return dst +} + +// Uint16ValueSlice converts a slice of uint16 pointers into a slice of +// uint16 values +func Uint16ValueSlice(src []*uint16) []uint16 { + dst := make([]uint16, len(src)) + + for i := 0; i < len(src); i++ { + if src[i] != nil { + dst[i] = *(src[i]) + } + } + + return dst +} + +// Uint16Map converts a string map of uint16 values into a string +// map of uint16 pointers +func Uint16Map(src map[string]uint16) map[string]*uint16 { + dst := make(map[string]*uint16) + + for k, val := range src { + v := val + dst[k] = &v + } + + return dst +} + +// Uint16ValueMap converts a string map of uint16 pointers into a string +// map of uint16 values +func Uint16ValueMap(src map[string]*uint16) map[string]uint16 { + dst := make(map[string]uint16) + + for k, val := range src { + if val != nil { + dst[k] = *val + } + } + + return dst +} + +// Uint returns a pointer to of the uint value passed in. +func Uint(v uint) *uint { + return &v +} + +// UintValue returns the value of the uint pointer passed in or +// 0 if the pointer is nil. +func UintValue(v *uint) uint { + if v != nil { + return *v + } + return 0 +} + +// UintSlice converts a slice of uint values into a slice of +// uint pointers +func UintSlice(src []uint) []*uint { + dst := make([]*uint, len(src)) + for i := 0; i < len(src); i++ { + dst[i] = &(src[i]) + } + return dst +} + +// UintValueSlice converts a slice of uint pointers into a slice of +// uint values +func UintValueSlice(src []*uint) []uint { + dst := make([]uint, len(src)) + for i := 0; i < len(src); i++ { + if src[i] != nil { + dst[i] = *(src[i]) + } + } + return dst +} + +// UintMap converts a string map of uint values into a string +// map of uint pointers +func UintMap(src map[string]uint) map[string]*uint { + dst := make(map[string]*uint) + for k, val := range src { + v := val + dst[k] = &v + } + return dst +} + +// UintValueMap converts a string map of uint pointers into a string +// map of uint values +func UintValueMap(src map[string]*uint) map[string]uint { + dst := make(map[string]uint) + for k, val := range src { + if val != nil { + dst[k] = *val + } + } + return dst +} + +// Uint32 returns a pointer to of the uint32 value passed in. +func Uint32(v uint32) *uint32 { + return &v +} + +// Uint32Value returns the value of the uint32 pointer passed in or +// 0 if the pointer is nil. +func Uint32Value(v *uint32) uint32 { + if v != nil { + return *v + } + return 0 +} + +// Uint32Slice converts a slice of uint32 values into a slice of +// uint32 pointers +func Uint32Slice(src []uint32) []*uint32 { + dst := make([]*uint32, len(src)) + for i := 0; i < len(src); i++ { + dst[i] = &(src[i]) + } + return dst +} + +// Uint32ValueSlice converts a slice of uint32 pointers into a slice of +// uint32 values +func Uint32ValueSlice(src []*uint32) []uint32 { + dst := make([]uint32, len(src)) + for i := 0; i < len(src); i++ { + if src[i] != nil { + dst[i] = *(src[i]) + } + } + return dst +} + +// Uint32Map converts a string map of uint32 values into a string +// map of uint32 pointers +func Uint32Map(src map[string]uint32) map[string]*uint32 { + dst := make(map[string]*uint32) + for k, val := range src { + v := val + dst[k] = &v + } + return dst +} + +// Uint32ValueMap converts a string map of uint32 pointers into a string +// map of uint32 values +func Uint32ValueMap(src map[string]*uint32) map[string]uint32 { + dst := make(map[string]uint32) + for k, val := range src { + if val != nil { + dst[k] = *val + } + } + return dst +} + +// Uint64 returns a pointer to of the uint64 value passed in. +func Uint64(v uint64) *uint64 { + return &v +} + +// Uint64Value returns the value of the uint64 pointer passed in or +// 0 if the pointer is nil. +func Uint64Value(v *uint64) uint64 { + if v != nil { + return *v + } + return 0 +} + +// Uint64Slice converts a slice of uint64 values into a slice of +// uint64 pointers +func Uint64Slice(src []uint64) []*uint64 { + dst := make([]*uint64, len(src)) + for i := 0; i < len(src); i++ { + dst[i] = &(src[i]) + } + return dst +} + +// Uint64ValueSlice converts a slice of uint64 pointers into a slice of +// uint64 values +func Uint64ValueSlice(src []*uint64) []uint64 { + dst := make([]uint64, len(src)) + for i := 0; i < len(src); i++ { + if src[i] != nil { + dst[i] = *(src[i]) + } + } + return dst +} + +// Uint64Map converts a string map of uint64 values into a string +// map of uint64 pointers +func Uint64Map(src map[string]uint64) map[string]*uint64 { + dst := make(map[string]*uint64) + for k, val := range src { + v := val + dst[k] = &v + } + return dst +} + +// Uint64ValueMap converts a string map of uint64 pointers into a string +// map of uint64 values +func Uint64ValueMap(src map[string]*uint64) map[string]uint64 { + dst := make(map[string]uint64) + for k, val := range src { + if val != nil { + dst[k] = *val + } + } + return dst +} + +// Float32 returns a pointer to of the float32 value passed in. +func Float32(v float32) *float32 { + return &v +} + +// Float32Value returns the value of the float32 pointer passed in or +// 0 if the pointer is nil. +func Float32Value(v *float32) float32 { + if v != nil { + return *v + } + + return 0 +} + +// Float32Slice converts a slice of float32 values into a slice of +// float32 pointers +func Float32Slice(src []float32) []*float32 { + dst := make([]*float32, len(src)) + + for i := 0; i < len(src); i++ { + dst[i] = &(src[i]) + } + + return dst +} + +// Float32ValueSlice converts a slice of float32 pointers into a slice of +// float32 values +func Float32ValueSlice(src []*float32) []float32 { + dst := make([]float32, len(src)) + + for i := 0; i < len(src); i++ { + if src[i] != nil { + dst[i] = *(src[i]) + } + } + + return dst +} + +// Float32Map converts a string map of float32 values into a string +// map of float32 pointers +func Float32Map(src map[string]float32) map[string]*float32 { + dst := make(map[string]*float32) + + for k, val := range src { + v := val + dst[k] = &v + } + + return dst +} + +// Float32ValueMap converts a string map of float32 pointers into a string +// map of float32 values +func Float32ValueMap(src map[string]*float32) map[string]float32 { + dst := make(map[string]float32) + + for k, val := range src { + if val != nil { + dst[k] = *val + } + } + + return dst +} + +// Float64 returns a pointer to of the float64 value passed in. +func Float64(v float64) *float64 { + return &v +} + +// Float64Value returns the value of the float64 pointer passed in or +// 0 if the pointer is nil. +func Float64Value(v *float64) float64 { + if v != nil { + return *v + } + return 0 +} + +// Float64Slice converts a slice of float64 values into a slice of +// float64 pointers +func Float64Slice(src []float64) []*float64 { + dst := make([]*float64, len(src)) + for i := 0; i < len(src); i++ { + dst[i] = &(src[i]) + } + return dst +} + +// Float64ValueSlice converts a slice of float64 pointers into a slice of +// float64 values +func Float64ValueSlice(src []*float64) []float64 { + dst := make([]float64, len(src)) + for i := 0; i < len(src); i++ { + if src[i] != nil { + dst[i] = *(src[i]) + } + } + return dst +} + +// Float64Map converts a string map of float64 values into a string +// map of float64 pointers +func Float64Map(src map[string]float64) map[string]*float64 { + dst := make(map[string]*float64) + for k, val := range src { + v := val + dst[k] = &v + } + return dst +} + +// Float64ValueMap converts a string map of float64 pointers into a string +// map of float64 values +func Float64ValueMap(src map[string]*float64) map[string]float64 { + dst := make(map[string]float64) + for k, val := range src { + if val != nil { + dst[k] = *val + } + } + return dst +} + +// Time returns a pointer to of the time.Time value passed in. +func Time(v time.Time) *time.Time { + return &v +} + +// TimeValue returns the value of the time.Time pointer passed in or +// time.Time{} if the pointer is nil. +func TimeValue(v *time.Time) time.Time { + if v != nil { + return *v + } + return time.Time{} +} + +// TimeSlice converts a slice of time.Time values into a slice of +// time.Time pointers +func TimeSlice(src []time.Time) []*time.Time { + dst := make([]*time.Time, len(src)) + for i := 0; i < len(src); i++ { + dst[i] = &(src[i]) + } + return dst +} + +// TimeValueSlice converts a slice of time.Time pointers into a slice of +// time.Time values +func TimeValueSlice(src []*time.Time) []time.Time { + dst := make([]time.Time, len(src)) + for i := 0; i < len(src); i++ { + if src[i] != nil { + dst[i] = *(src[i]) + } + } + return dst +} + +// TimeMap converts a string map of time.Time values into a string +// map of time.Time pointers +func TimeMap(src map[string]time.Time) map[string]*time.Time { + dst := make(map[string]*time.Time) + for k, val := range src { + v := val + dst[k] = &v + } + return dst +} + +// TimeValueMap converts a string map of time.Time pointers into a string +// map of time.Time values +func TimeValueMap(src map[string]*time.Time) map[string]time.Time { + dst := make(map[string]time.Time) + for k, val := range src { + if val != nil { + dst[k] = *val + } + } + return dst +} diff --git a/vendor/github.com/go-openapi/swag/doc.go b/vendor/github.com/go-openapi/swag/doc.go new file mode 100644 index 00000000000..8d2c8c5014e --- /dev/null +++ b/vendor/github.com/go-openapi/swag/doc.go @@ -0,0 +1,32 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/* +Package swag contains a bunch of helper functions for go-openapi and go-swagger projects. + +You may also use it standalone for your projects. + + * convert between value and pointers for builtin types + * convert from string to builtin types (wraps strconv) + * fast json concatenation + * search in path + * load from file or http + * name mangling + + +This repo has only few dependencies outside of the standard library: + + * YAML utilities depend on gopkg.in/yaml.v2 +*/ +package swag diff --git a/vendor/github.com/go-openapi/swag/file.go b/vendor/github.com/go-openapi/swag/file.go new file mode 100644 index 00000000000..16accc55f82 --- /dev/null +++ b/vendor/github.com/go-openapi/swag/file.go @@ -0,0 +1,33 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package swag + +import "mime/multipart" + +// File represents an uploaded file. +type File struct { + Data multipart.File + Header *multipart.FileHeader +} + +// Read bytes from the file +func (f *File) Read(p []byte) (n int, err error) { + return f.Data.Read(p) +} + +// Close the file +func (f *File) Close() error { + return f.Data.Close() +} diff --git a/vendor/github.com/go-openapi/swag/json.go b/vendor/github.com/go-openapi/swag/json.go new file mode 100644 index 00000000000..7e9902ca314 --- /dev/null +++ b/vendor/github.com/go-openapi/swag/json.go @@ -0,0 +1,312 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package swag + +import ( + "bytes" + "encoding/json" + "log" + "reflect" + "strings" + "sync" + + "github.com/mailru/easyjson/jlexer" + "github.com/mailru/easyjson/jwriter" +) + +// nullJSON represents a JSON object with null type +var nullJSON = []byte("null") + +// DefaultJSONNameProvider the default cache for types +var DefaultJSONNameProvider = NewNameProvider() + +const comma = byte(',') + +var closers map[byte]byte + +func init() { + closers = map[byte]byte{ + '{': '}', + '[': ']', + } +} + +type ejMarshaler interface { + MarshalEasyJSON(w *jwriter.Writer) +} + +type ejUnmarshaler interface { + UnmarshalEasyJSON(w *jlexer.Lexer) +} + +// WriteJSON writes json data, prefers finding an appropriate interface to short-circuit the marshaler +// so it takes the fastest option available. +func WriteJSON(data interface{}) ([]byte, error) { + if d, ok := data.(ejMarshaler); ok { + jw := new(jwriter.Writer) + d.MarshalEasyJSON(jw) + return jw.BuildBytes() + } + if d, ok := data.(json.Marshaler); ok { + return d.MarshalJSON() + } + return json.Marshal(data) +} + +// ReadJSON reads json data, prefers finding an appropriate interface to short-circuit the unmarshaler +// so it takes the fastest option available +func ReadJSON(data []byte, value interface{}) error { + trimmedData := bytes.Trim(data, "\x00") + if d, ok := value.(ejUnmarshaler); ok { + jl := &jlexer.Lexer{Data: trimmedData} + d.UnmarshalEasyJSON(jl) + return jl.Error() + } + if d, ok := value.(json.Unmarshaler); ok { + return d.UnmarshalJSON(trimmedData) + } + return json.Unmarshal(trimmedData, value) +} + +// DynamicJSONToStruct converts an untyped json structure into a struct +func DynamicJSONToStruct(data interface{}, target interface{}) error { + // TODO: convert straight to a json typed map (mergo + iterate?) + b, err := WriteJSON(data) + if err != nil { + return err + } + return ReadJSON(b, target) +} + +// ConcatJSON concatenates multiple json objects efficiently +func ConcatJSON(blobs ...[]byte) []byte { + if len(blobs) == 0 { + return nil + } + + last := len(blobs) - 1 + for blobs[last] == nil || bytes.Equal(blobs[last], nullJSON) { + // strips trailing null objects + last-- + if last < 0 { + // there was nothing but "null"s or nil... + return nil + } + } + if last == 0 { + return blobs[0] + } + + var opening, closing byte + var idx, a int + buf := bytes.NewBuffer(nil) + + for i, b := range blobs[:last+1] { + if b == nil || bytes.Equal(b, nullJSON) { + // a null object is in the list: skip it + continue + } + if len(b) > 0 && opening == 0 { // is this an array or an object? + opening, closing = b[0], closers[b[0]] + } + + if opening != '{' && opening != '[' { + continue // don't know how to concatenate non container objects + } + + if len(b) < 3 { // yep empty but also the last one, so closing this thing + if i == last && a > 0 { + if err := buf.WriteByte(closing); err != nil { + log.Println(err) + } + } + continue + } + + idx = 0 + if a > 0 { // we need to join with a comma for everything beyond the first non-empty item + if err := buf.WriteByte(comma); err != nil { + log.Println(err) + } + idx = 1 // this is not the first or the last so we want to drop the leading bracket + } + + if i != last { // not the last one, strip brackets + if _, err := buf.Write(b[idx : len(b)-1]); err != nil { + log.Println(err) + } + } else { // last one, strip only the leading bracket + if _, err := buf.Write(b[idx:]); err != nil { + log.Println(err) + } + } + a++ + } + // somehow it ended up being empty, so provide a default value + if buf.Len() == 0 { + if err := buf.WriteByte(opening); err != nil { + log.Println(err) + } + if err := buf.WriteByte(closing); err != nil { + log.Println(err) + } + } + return buf.Bytes() +} + +// ToDynamicJSON turns an object into a properly JSON typed structure +func ToDynamicJSON(data interface{}) interface{} { + // TODO: convert straight to a json typed map (mergo + iterate?) + b, err := json.Marshal(data) + if err != nil { + log.Println(err) + } + var res interface{} + if err := json.Unmarshal(b, &res); err != nil { + log.Println(err) + } + return res +} + +// FromDynamicJSON turns an object into a properly JSON typed structure +func FromDynamicJSON(data, target interface{}) error { + b, err := json.Marshal(data) + if err != nil { + log.Println(err) + } + return json.Unmarshal(b, target) +} + +// NameProvider represents an object capable of translating from go property names +// to json property names +// This type is thread-safe. +type NameProvider struct { + lock *sync.Mutex + index map[reflect.Type]nameIndex +} + +type nameIndex struct { + jsonNames map[string]string + goNames map[string]string +} + +// NewNameProvider creates a new name provider +func NewNameProvider() *NameProvider { + return &NameProvider{ + lock: &sync.Mutex{}, + index: make(map[reflect.Type]nameIndex), + } +} + +func buildnameIndex(tpe reflect.Type, idx, reverseIdx map[string]string) { + for i := 0; i < tpe.NumField(); i++ { + targetDes := tpe.Field(i) + + if targetDes.PkgPath != "" { // unexported + continue + } + + if targetDes.Anonymous { // walk embedded structures tree down first + buildnameIndex(targetDes.Type, idx, reverseIdx) + continue + } + + if tag := targetDes.Tag.Get("json"); tag != "" { + + parts := strings.Split(tag, ",") + if len(parts) == 0 { + continue + } + + nm := parts[0] + if nm == "-" { + continue + } + if nm == "" { // empty string means we want to use the Go name + nm = targetDes.Name + } + + idx[nm] = targetDes.Name + reverseIdx[targetDes.Name] = nm + } + } +} + +func newNameIndex(tpe reflect.Type) nameIndex { + var idx = make(map[string]string, tpe.NumField()) + var reverseIdx = make(map[string]string, tpe.NumField()) + + buildnameIndex(tpe, idx, reverseIdx) + return nameIndex{jsonNames: idx, goNames: reverseIdx} +} + +// GetJSONNames gets all the json property names for a type +func (n *NameProvider) GetJSONNames(subject interface{}) []string { + n.lock.Lock() + defer n.lock.Unlock() + tpe := reflect.Indirect(reflect.ValueOf(subject)).Type() + names, ok := n.index[tpe] + if !ok { + names = n.makeNameIndex(tpe) + } + + res := make([]string, 0, len(names.jsonNames)) + for k := range names.jsonNames { + res = append(res, k) + } + return res +} + +// GetJSONName gets the json name for a go property name +func (n *NameProvider) GetJSONName(subject interface{}, name string) (string, bool) { + tpe := reflect.Indirect(reflect.ValueOf(subject)).Type() + return n.GetJSONNameForType(tpe, name) +} + +// GetJSONNameForType gets the json name for a go property name on a given type +func (n *NameProvider) GetJSONNameForType(tpe reflect.Type, name string) (string, bool) { + n.lock.Lock() + defer n.lock.Unlock() + names, ok := n.index[tpe] + if !ok { + names = n.makeNameIndex(tpe) + } + nme, ok := names.goNames[name] + return nme, ok +} + +func (n *NameProvider) makeNameIndex(tpe reflect.Type) nameIndex { + names := newNameIndex(tpe) + n.index[tpe] = names + return names +} + +// GetGoName gets the go name for a json property name +func (n *NameProvider) GetGoName(subject interface{}, name string) (string, bool) { + tpe := reflect.Indirect(reflect.ValueOf(subject)).Type() + return n.GetGoNameForType(tpe, name) +} + +// GetGoNameForType gets the go name for a given type for a json property name +func (n *NameProvider) GetGoNameForType(tpe reflect.Type, name string) (string, bool) { + n.lock.Lock() + defer n.lock.Unlock() + names, ok := n.index[tpe] + if !ok { + names = n.makeNameIndex(tpe) + } + nme, ok := names.jsonNames[name] + return nme, ok +} diff --git a/vendor/github.com/go-openapi/swag/loading.go b/vendor/github.com/go-openapi/swag/loading.go new file mode 100644 index 00000000000..9a60409725e --- /dev/null +++ b/vendor/github.com/go-openapi/swag/loading.go @@ -0,0 +1,120 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package swag + +import ( + "fmt" + "io/ioutil" + "log" + "net/http" + "net/url" + "path/filepath" + "runtime" + "strings" + "time" +) + +// LoadHTTPTimeout the default timeout for load requests +var LoadHTTPTimeout = 30 * time.Second + +// LoadHTTPBasicAuthUsername the username to use when load requests require basic auth +var LoadHTTPBasicAuthUsername = "" + +// LoadHTTPBasicAuthPassword the password to use when load requests require basic auth +var LoadHTTPBasicAuthPassword = "" + +// LoadHTTPCustomHeaders an optional collection of custom HTTP headers for load requests +var LoadHTTPCustomHeaders = map[string]string{} + +// LoadFromFileOrHTTP loads the bytes from a file or a remote http server based on the path passed in +func LoadFromFileOrHTTP(path string) ([]byte, error) { + return LoadStrategy(path, ioutil.ReadFile, loadHTTPBytes(LoadHTTPTimeout))(path) +} + +// LoadFromFileOrHTTPWithTimeout loads the bytes from a file or a remote http server based on the path passed in +// timeout arg allows for per request overriding of the request timeout +func LoadFromFileOrHTTPWithTimeout(path string, timeout time.Duration) ([]byte, error) { + return LoadStrategy(path, ioutil.ReadFile, loadHTTPBytes(timeout))(path) +} + +// LoadStrategy returns a loader function for a given path or uri +func LoadStrategy(path string, local, remote func(string) ([]byte, error)) func(string) ([]byte, error) { + if strings.HasPrefix(path, "http") { + return remote + } + return func(pth string) ([]byte, error) { + upth, err := pathUnescape(pth) + if err != nil { + return nil, err + } + + if strings.HasPrefix(pth, `file://`) { + if runtime.GOOS == "windows" { + // support for canonical file URIs on windows. + // Zero tolerance here for dodgy URIs. + u, _ := url.Parse(upth) + if u.Host != "" { + // assume UNC name (volume share) + // file://host/share/folder\... ==> \\host\share\path\folder + // NOTE: UNC port not yet supported + upth = strings.Join([]string{`\`, u.Host, u.Path}, `\`) + } else { + // file:///c:/folder/... ==> just remove the leading slash + upth = strings.TrimPrefix(upth, `file:///`) + } + } else { + upth = strings.TrimPrefix(upth, `file://`) + } + } + + return local(filepath.FromSlash(upth)) + } +} + +func loadHTTPBytes(timeout time.Duration) func(path string) ([]byte, error) { + return func(path string) ([]byte, error) { + client := &http.Client{Timeout: timeout} + req, err := http.NewRequest("GET", path, nil) // nolint: noctx + if err != nil { + return nil, err + } + + if LoadHTTPBasicAuthUsername != "" && LoadHTTPBasicAuthPassword != "" { + req.SetBasicAuth(LoadHTTPBasicAuthUsername, LoadHTTPBasicAuthPassword) + } + + for key, val := range LoadHTTPCustomHeaders { + req.Header.Set(key, val) + } + + resp, err := client.Do(req) + defer func() { + if resp != nil { + if e := resp.Body.Close(); e != nil { + log.Println(e) + } + } + }() + if err != nil { + return nil, err + } + + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("could not access document at %q [%s] ", path, resp.Status) + } + + return ioutil.ReadAll(resp.Body) + } +} diff --git a/vendor/github.com/go-openapi/swag/name_lexem.go b/vendor/github.com/go-openapi/swag/name_lexem.go new file mode 100644 index 00000000000..aa7f6a9bb8e --- /dev/null +++ b/vendor/github.com/go-openapi/swag/name_lexem.go @@ -0,0 +1,87 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package swag + +import "unicode" + +type ( + nameLexem interface { + GetUnsafeGoName() string + GetOriginal() string + IsInitialism() bool + } + + initialismNameLexem struct { + original string + matchedInitialism string + } + + casualNameLexem struct { + original string + } +) + +func newInitialismNameLexem(original, matchedInitialism string) *initialismNameLexem { + return &initialismNameLexem{ + original: original, + matchedInitialism: matchedInitialism, + } +} + +func newCasualNameLexem(original string) *casualNameLexem { + return &casualNameLexem{ + original: original, + } +} + +func (l *initialismNameLexem) GetUnsafeGoName() string { + return l.matchedInitialism +} + +func (l *casualNameLexem) GetUnsafeGoName() string { + var first rune + var rest string + for i, orig := range l.original { + if i == 0 { + first = orig + continue + } + if i > 0 { + rest = l.original[i:] + break + } + } + if len(l.original) > 1 { + return string(unicode.ToUpper(first)) + lower(rest) + } + + return l.original +} + +func (l *initialismNameLexem) GetOriginal() string { + return l.original +} + +func (l *casualNameLexem) GetOriginal() string { + return l.original +} + +func (l *initialismNameLexem) IsInitialism() bool { + return true +} + +func (l *casualNameLexem) IsInitialism() bool { + return false +} diff --git a/vendor/github.com/go-openapi/swag/net.go b/vendor/github.com/go-openapi/swag/net.go new file mode 100644 index 00000000000..821235f84d4 --- /dev/null +++ b/vendor/github.com/go-openapi/swag/net.go @@ -0,0 +1,38 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package swag + +import ( + "net" + "strconv" +) + +// SplitHostPort splits a network address into a host and a port. +// The port is -1 when there is no port to be found +func SplitHostPort(addr string) (host string, port int, err error) { + h, p, err := net.SplitHostPort(addr) + if err != nil { + return "", -1, err + } + if p == "" { + return "", -1, &net.AddrError{Err: "missing port in address", Addr: addr} + } + + pi, err := strconv.Atoi(p) + if err != nil { + return "", -1, err + } + return h, pi, nil +} diff --git a/vendor/github.com/go-openapi/swag/path.go b/vendor/github.com/go-openapi/swag/path.go new file mode 100644 index 00000000000..941bd0176b0 --- /dev/null +++ b/vendor/github.com/go-openapi/swag/path.go @@ -0,0 +1,59 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package swag + +import ( + "os" + "path/filepath" + "runtime" + "strings" +) + +const ( + // GOPATHKey represents the env key for gopath + GOPATHKey = "GOPATH" +) + +// FindInSearchPath finds a package in a provided lists of paths +func FindInSearchPath(searchPath, pkg string) string { + pathsList := filepath.SplitList(searchPath) + for _, path := range pathsList { + if evaluatedPath, err := filepath.EvalSymlinks(filepath.Join(path, "src", pkg)); err == nil { + if _, err := os.Stat(evaluatedPath); err == nil { + return evaluatedPath + } + } + } + return "" +} + +// FindInGoSearchPath finds a package in the $GOPATH:$GOROOT +func FindInGoSearchPath(pkg string) string { + return FindInSearchPath(FullGoSearchPath(), pkg) +} + +// FullGoSearchPath gets the search paths for finding packages +func FullGoSearchPath() string { + allPaths := os.Getenv(GOPATHKey) + if allPaths == "" { + allPaths = filepath.Join(os.Getenv("HOME"), "go") + } + if allPaths != "" { + allPaths = strings.Join([]string{allPaths, runtime.GOROOT()}, ":") + } else { + allPaths = runtime.GOROOT() + } + return allPaths +} diff --git a/vendor/github.com/go-openapi/swag/post_go18.go b/vendor/github.com/go-openapi/swag/post_go18.go new file mode 100644 index 00000000000..f5228b82c0f --- /dev/null +++ b/vendor/github.com/go-openapi/swag/post_go18.go @@ -0,0 +1,24 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build go1.8 +// +build go1.8 + +package swag + +import "net/url" + +func pathUnescape(path string) (string, error) { + return url.PathUnescape(path) +} diff --git a/vendor/github.com/go-openapi/swag/post_go19.go b/vendor/github.com/go-openapi/swag/post_go19.go new file mode 100644 index 00000000000..7c7da9c0880 --- /dev/null +++ b/vendor/github.com/go-openapi/swag/post_go19.go @@ -0,0 +1,68 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build go1.9 +// +build go1.9 + +package swag + +import ( + "sort" + "sync" +) + +// indexOfInitialisms is a thread-safe implementation of the sorted index of initialisms. +// Since go1.9, this may be implemented with sync.Map. +type indexOfInitialisms struct { + sortMutex *sync.Mutex + index *sync.Map +} + +func newIndexOfInitialisms() *indexOfInitialisms { + return &indexOfInitialisms{ + sortMutex: new(sync.Mutex), + index: new(sync.Map), + } +} + +func (m *indexOfInitialisms) load(initial map[string]bool) *indexOfInitialisms { + m.sortMutex.Lock() + defer m.sortMutex.Unlock() + for k, v := range initial { + m.index.Store(k, v) + } + return m +} + +func (m *indexOfInitialisms) isInitialism(key string) bool { + _, ok := m.index.Load(key) + return ok +} + +func (m *indexOfInitialisms) add(key string) *indexOfInitialisms { + m.index.Store(key, true) + return m +} + +func (m *indexOfInitialisms) sorted() (result []string) { + m.sortMutex.Lock() + defer m.sortMutex.Unlock() + m.index.Range(func(key, value interface{}) bool { + k := key.(string) + result = append(result, k) + return true + }) + sort.Sort(sort.Reverse(byInitialism(result))) + return +} diff --git a/vendor/github.com/go-openapi/swag/pre_go18.go b/vendor/github.com/go-openapi/swag/pre_go18.go new file mode 100644 index 00000000000..2757d9b95f8 --- /dev/null +++ b/vendor/github.com/go-openapi/swag/pre_go18.go @@ -0,0 +1,24 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build !go1.8 +// +build !go1.8 + +package swag + +import "net/url" + +func pathUnescape(path string) (string, error) { + return url.QueryUnescape(path) +} diff --git a/vendor/github.com/go-openapi/swag/pre_go19.go b/vendor/github.com/go-openapi/swag/pre_go19.go new file mode 100644 index 00000000000..0565db377be --- /dev/null +++ b/vendor/github.com/go-openapi/swag/pre_go19.go @@ -0,0 +1,70 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build !go1.9 +// +build !go1.9 + +package swag + +import ( + "sort" + "sync" +) + +// indexOfInitialisms is a thread-safe implementation of the sorted index of initialisms. +// Before go1.9, this may be implemented with a mutex on the map. +type indexOfInitialisms struct { + getMutex *sync.Mutex + index map[string]bool +} + +func newIndexOfInitialisms() *indexOfInitialisms { + return &indexOfInitialisms{ + getMutex: new(sync.Mutex), + index: make(map[string]bool, 50), + } +} + +func (m *indexOfInitialisms) load(initial map[string]bool) *indexOfInitialisms { + m.getMutex.Lock() + defer m.getMutex.Unlock() + for k, v := range initial { + m.index[k] = v + } + return m +} + +func (m *indexOfInitialisms) isInitialism(key string) bool { + m.getMutex.Lock() + defer m.getMutex.Unlock() + _, ok := m.index[key] + return ok +} + +func (m *indexOfInitialisms) add(key string) *indexOfInitialisms { + m.getMutex.Lock() + defer m.getMutex.Unlock() + m.index[key] = true + return m +} + +func (m *indexOfInitialisms) sorted() (result []string) { + m.getMutex.Lock() + defer m.getMutex.Unlock() + for k := range m.index { + result = append(result, k) + } + sort.Sort(sort.Reverse(byInitialism(result))) + return +} diff --git a/vendor/github.com/go-openapi/swag/split.go b/vendor/github.com/go-openapi/swag/split.go new file mode 100644 index 00000000000..a1825fb7dc9 --- /dev/null +++ b/vendor/github.com/go-openapi/swag/split.go @@ -0,0 +1,262 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package swag + +import ( + "unicode" +) + +var nameReplaceTable = map[rune]string{ + '@': "At ", + '&': "And ", + '|': "Pipe ", + '$': "Dollar ", + '!': "Bang ", + '-': "", + '_': "", +} + +type ( + splitter struct { + postSplitInitialismCheck bool + initialisms []string + } + + splitterOption func(*splitter) *splitter +) + +// split calls the splitter; splitter provides more control and post options +func split(str string) []string { + lexems := newSplitter().split(str) + result := make([]string, 0, len(lexems)) + + for _, lexem := range lexems { + result = append(result, lexem.GetOriginal()) + } + + return result + +} + +func (s *splitter) split(str string) []nameLexem { + return s.toNameLexems(str) +} + +func newSplitter(options ...splitterOption) *splitter { + splitter := &splitter{ + postSplitInitialismCheck: false, + initialisms: initialisms, + } + + for _, option := range options { + splitter = option(splitter) + } + + return splitter +} + +// withPostSplitInitialismCheck allows to catch initialisms after main split process +func withPostSplitInitialismCheck(s *splitter) *splitter { + s.postSplitInitialismCheck = true + return s +} + +type ( + initialismMatch struct { + start, end int + body []rune + complete bool + } + initialismMatches []*initialismMatch +) + +func (s *splitter) toNameLexems(name string) []nameLexem { + nameRunes := []rune(name) + matches := s.gatherInitialismMatches(nameRunes) + return s.mapMatchesToNameLexems(nameRunes, matches) +} + +func (s *splitter) gatherInitialismMatches(nameRunes []rune) initialismMatches { + matches := make(initialismMatches, 0) + + for currentRunePosition, currentRune := range nameRunes { + newMatches := make(initialismMatches, 0, len(matches)) + + // check current initialism matches + for _, match := range matches { + if keepCompleteMatch := match.complete; keepCompleteMatch { + newMatches = append(newMatches, match) + continue + } + + // drop failed match + currentMatchRune := match.body[currentRunePosition-match.start] + if !s.initialismRuneEqual(currentMatchRune, currentRune) { + continue + } + + // try to complete ongoing match + if currentRunePosition-match.start == len(match.body)-1 { + // we are close; the next step is to check the symbol ahead + // if it is a small letter, then it is not the end of match + // but beginning of the next word + + if currentRunePosition < len(nameRunes)-1 { + nextRune := nameRunes[currentRunePosition+1] + if newWord := unicode.IsLower(nextRune); newWord { + // oh ok, it was the start of a new word + continue + } + } + + match.complete = true + match.end = currentRunePosition + } + + newMatches = append(newMatches, match) + } + + // check for new initialism matches + for _, initialism := range s.initialisms { + initialismRunes := []rune(initialism) + if s.initialismRuneEqual(initialismRunes[0], currentRune) { + newMatches = append(newMatches, &initialismMatch{ + start: currentRunePosition, + body: initialismRunes, + complete: false, + }) + } + } + + matches = newMatches + } + + return matches +} + +func (s *splitter) mapMatchesToNameLexems(nameRunes []rune, matches initialismMatches) []nameLexem { + nameLexems := make([]nameLexem, 0) + + var lastAcceptedMatch *initialismMatch + for _, match := range matches { + if !match.complete { + continue + } + + if firstMatch := lastAcceptedMatch == nil; firstMatch { + nameLexems = append(nameLexems, s.breakCasualString(nameRunes[:match.start])...) + nameLexems = append(nameLexems, s.breakInitialism(string(match.body))) + + lastAcceptedMatch = match + + continue + } + + if overlappedMatch := match.start <= lastAcceptedMatch.end; overlappedMatch { + continue + } + + middle := nameRunes[lastAcceptedMatch.end+1 : match.start] + nameLexems = append(nameLexems, s.breakCasualString(middle)...) + nameLexems = append(nameLexems, s.breakInitialism(string(match.body))) + + lastAcceptedMatch = match + } + + // we have not found any accepted matches + if lastAcceptedMatch == nil { + return s.breakCasualString(nameRunes) + } + + if lastAcceptedMatch.end+1 != len(nameRunes) { + rest := nameRunes[lastAcceptedMatch.end+1:] + nameLexems = append(nameLexems, s.breakCasualString(rest)...) + } + + return nameLexems +} + +func (s *splitter) initialismRuneEqual(a, b rune) bool { + return a == b +} + +func (s *splitter) breakInitialism(original string) nameLexem { + return newInitialismNameLexem(original, original) +} + +func (s *splitter) breakCasualString(str []rune) []nameLexem { + segments := make([]nameLexem, 0) + currentSegment := "" + + addCasualNameLexem := func(original string) { + segments = append(segments, newCasualNameLexem(original)) + } + + addInitialismNameLexem := func(original, match string) { + segments = append(segments, newInitialismNameLexem(original, match)) + } + + addNameLexem := func(original string) { + if s.postSplitInitialismCheck { + for _, initialism := range s.initialisms { + if upper(initialism) == upper(original) { + addInitialismNameLexem(original, initialism) + return + } + } + } + + addCasualNameLexem(original) + } + + for _, rn := range string(str) { + if replace, found := nameReplaceTable[rn]; found { + if currentSegment != "" { + addNameLexem(currentSegment) + currentSegment = "" + } + + if replace != "" { + addNameLexem(replace) + } + + continue + } + + if !unicode.In(rn, unicode.L, unicode.M, unicode.N, unicode.Pc) { + if currentSegment != "" { + addNameLexem(currentSegment) + currentSegment = "" + } + + continue + } + + if unicode.IsUpper(rn) { + if currentSegment != "" { + addNameLexem(currentSegment) + } + currentSegment = "" + } + + currentSegment += string(rn) + } + + if currentSegment != "" { + addNameLexem(currentSegment) + } + + return segments +} diff --git a/vendor/github.com/go-openapi/swag/util.go b/vendor/github.com/go-openapi/swag/util.go new file mode 100644 index 00000000000..193702f2cec --- /dev/null +++ b/vendor/github.com/go-openapi/swag/util.go @@ -0,0 +1,385 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package swag + +import ( + "reflect" + "strings" + "unicode" +) + +// commonInitialisms are common acronyms that are kept as whole uppercased words. +var commonInitialisms *indexOfInitialisms + +// initialisms is a slice of sorted initialisms +var initialisms []string + +var isInitialism func(string) bool + +// GoNamePrefixFunc sets an optional rule to prefix go names +// which do not start with a letter. +// +// e.g. to help convert "123" into "{prefix}123" +// +// The default is to prefix with "X" +var GoNamePrefixFunc func(string) string + +func init() { + // Taken from https://github.com/golang/lint/blob/3390df4df2787994aea98de825b964ac7944b817/lint.go#L732-L769 + var configuredInitialisms = map[string]bool{ + "ACL": true, + "API": true, + "ASCII": true, + "CPU": true, + "CSS": true, + "DNS": true, + "EOF": true, + "GUID": true, + "HTML": true, + "HTTPS": true, + "HTTP": true, + "ID": true, + "IP": true, + "IPv4": true, + "IPv6": true, + "JSON": true, + "LHS": true, + "OAI": true, + "QPS": true, + "RAM": true, + "RHS": true, + "RPC": true, + "SLA": true, + "SMTP": true, + "SQL": true, + "SSH": true, + "TCP": true, + "TLS": true, + "TTL": true, + "UDP": true, + "UI": true, + "UID": true, + "UUID": true, + "URI": true, + "URL": true, + "UTF8": true, + "VM": true, + "XML": true, + "XMPP": true, + "XSRF": true, + "XSS": true, + } + + // a thread-safe index of initialisms + commonInitialisms = newIndexOfInitialisms().load(configuredInitialisms) + initialisms = commonInitialisms.sorted() + + // a test function + isInitialism = commonInitialisms.isInitialism +} + +const ( + // collectionFormatComma = "csv" + collectionFormatSpace = "ssv" + collectionFormatTab = "tsv" + collectionFormatPipe = "pipes" + collectionFormatMulti = "multi" +) + +// JoinByFormat joins a string array by a known format (e.g. swagger's collectionFormat attribute): +// ssv: space separated value +// tsv: tab separated value +// pipes: pipe (|) separated value +// csv: comma separated value (default) +func JoinByFormat(data []string, format string) []string { + if len(data) == 0 { + return data + } + var sep string + switch format { + case collectionFormatSpace: + sep = " " + case collectionFormatTab: + sep = "\t" + case collectionFormatPipe: + sep = "|" + case collectionFormatMulti: + return data + default: + sep = "," + } + return []string{strings.Join(data, sep)} +} + +// SplitByFormat splits a string by a known format: +// ssv: space separated value +// tsv: tab separated value +// pipes: pipe (|) separated value +// csv: comma separated value (default) +// +func SplitByFormat(data, format string) []string { + if data == "" { + return nil + } + var sep string + switch format { + case collectionFormatSpace: + sep = " " + case collectionFormatTab: + sep = "\t" + case collectionFormatPipe: + sep = "|" + case collectionFormatMulti: + return nil + default: + sep = "," + } + var result []string + for _, s := range strings.Split(data, sep) { + if ts := strings.TrimSpace(s); ts != "" { + result = append(result, ts) + } + } + return result +} + +type byInitialism []string + +func (s byInitialism) Len() int { + return len(s) +} +func (s byInitialism) Swap(i, j int) { + s[i], s[j] = s[j], s[i] +} +func (s byInitialism) Less(i, j int) bool { + if len(s[i]) != len(s[j]) { + return len(s[i]) < len(s[j]) + } + + return strings.Compare(s[i], s[j]) > 0 +} + +// Removes leading whitespaces +func trim(str string) string { + return strings.Trim(str, " ") +} + +// Shortcut to strings.ToUpper() +func upper(str string) string { + return strings.ToUpper(trim(str)) +} + +// Shortcut to strings.ToLower() +func lower(str string) string { + return strings.ToLower(trim(str)) +} + +// Camelize an uppercased word +func Camelize(word string) (camelized string) { + for pos, ru := range []rune(word) { + if pos > 0 { + camelized += string(unicode.ToLower(ru)) + } else { + camelized += string(unicode.ToUpper(ru)) + } + } + return +} + +// ToFileName lowercases and underscores a go type name +func ToFileName(name string) string { + in := split(name) + out := make([]string, 0, len(in)) + + for _, w := range in { + out = append(out, lower(w)) + } + + return strings.Join(out, "_") +} + +// ToCommandName lowercases and underscores a go type name +func ToCommandName(name string) string { + in := split(name) + out := make([]string, 0, len(in)) + + for _, w := range in { + out = append(out, lower(w)) + } + return strings.Join(out, "-") +} + +// ToHumanNameLower represents a code name as a human series of words +func ToHumanNameLower(name string) string { + in := newSplitter(withPostSplitInitialismCheck).split(name) + out := make([]string, 0, len(in)) + + for _, w := range in { + if !w.IsInitialism() { + out = append(out, lower(w.GetOriginal())) + } else { + out = append(out, w.GetOriginal()) + } + } + + return strings.Join(out, " ") +} + +// ToHumanNameTitle represents a code name as a human series of words with the first letters titleized +func ToHumanNameTitle(name string) string { + in := newSplitter(withPostSplitInitialismCheck).split(name) + + out := make([]string, 0, len(in)) + for _, w := range in { + original := w.GetOriginal() + if !w.IsInitialism() { + out = append(out, Camelize(original)) + } else { + out = append(out, original) + } + } + return strings.Join(out, " ") +} + +// ToJSONName camelcases a name which can be underscored or pascal cased +func ToJSONName(name string) string { + in := split(name) + out := make([]string, 0, len(in)) + + for i, w := range in { + if i == 0 { + out = append(out, lower(w)) + continue + } + out = append(out, Camelize(w)) + } + return strings.Join(out, "") +} + +// ToVarName camelcases a name which can be underscored or pascal cased +func ToVarName(name string) string { + res := ToGoName(name) + if isInitialism(res) { + return lower(res) + } + if len(res) <= 1 { + return lower(res) + } + return lower(res[:1]) + res[1:] +} + +// ToGoName translates a swagger name which can be underscored or camel cased to a name that golint likes +func ToGoName(name string) string { + lexems := newSplitter(withPostSplitInitialismCheck).split(name) + + result := "" + for _, lexem := range lexems { + goName := lexem.GetUnsafeGoName() + + // to support old behavior + if lexem.IsInitialism() { + goName = upper(goName) + } + result += goName + } + + if len(result) > 0 { + // Only prefix with X when the first character isn't an ascii letter + first := []rune(result)[0] + if !unicode.IsLetter(first) || (first > unicode.MaxASCII && !unicode.IsUpper(first)) { + if GoNamePrefixFunc == nil { + return "X" + result + } + result = GoNamePrefixFunc(name) + result + } + first = []rune(result)[0] + if unicode.IsLetter(first) && !unicode.IsUpper(first) { + result = string(append([]rune{unicode.ToUpper(first)}, []rune(result)[1:]...)) + } + } + + return result +} + +// ContainsStrings searches a slice of strings for a case-sensitive match +func ContainsStrings(coll []string, item string) bool { + for _, a := range coll { + if a == item { + return true + } + } + return false +} + +// ContainsStringsCI searches a slice of strings for a case-insensitive match +func ContainsStringsCI(coll []string, item string) bool { + for _, a := range coll { + if strings.EqualFold(a, item) { + return true + } + } + return false +} + +type zeroable interface { + IsZero() bool +} + +// IsZero returns true when the value passed into the function is a zero value. +// This allows for safer checking of interface values. +func IsZero(data interface{}) bool { + // check for things that have an IsZero method instead + if vv, ok := data.(zeroable); ok { + return vv.IsZero() + } + // continue with slightly more complex reflection + v := reflect.ValueOf(data) + switch v.Kind() { + case reflect.String: + return v.Len() == 0 + case reflect.Bool: + return !v.Bool() + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return v.Int() == 0 + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + return v.Uint() == 0 + case reflect.Float32, reflect.Float64: + return v.Float() == 0 + case reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice: + return v.IsNil() + case reflect.Struct, reflect.Array: + return reflect.DeepEqual(data, reflect.Zero(v.Type()).Interface()) + case reflect.Invalid: + return true + } + return false +} + +// AddInitialisms add additional initialisms +func AddInitialisms(words ...string) { + for _, word := range words { + // commonInitialisms[upper(word)] = true + commonInitialisms.add(upper(word)) + } + // sort again + initialisms = commonInitialisms.sorted() +} + +// CommandLineOptionsGroup represents a group of user-defined command line options +type CommandLineOptionsGroup struct { + ShortDescription string + LongDescription string + Options interface{} +} diff --git a/vendor/github.com/go-openapi/swag/yaml.go b/vendor/github.com/go-openapi/swag/yaml.go new file mode 100644 index 00000000000..ec96914405b --- /dev/null +++ b/vendor/github.com/go-openapi/swag/yaml.go @@ -0,0 +1,246 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package swag + +import ( + "encoding/json" + "fmt" + "path/filepath" + "strconv" + + "github.com/mailru/easyjson/jlexer" + "github.com/mailru/easyjson/jwriter" + yaml "gopkg.in/yaml.v2" +) + +// YAMLMatcher matches yaml +func YAMLMatcher(path string) bool { + ext := filepath.Ext(path) + return ext == ".yaml" || ext == ".yml" +} + +// YAMLToJSON converts YAML unmarshaled data into json compatible data +func YAMLToJSON(data interface{}) (json.RawMessage, error) { + jm, err := transformData(data) + if err != nil { + return nil, err + } + b, err := WriteJSON(jm) + return json.RawMessage(b), err +} + +// BytesToYAMLDoc converts a byte slice into a YAML document +func BytesToYAMLDoc(data []byte) (interface{}, error) { + var canary map[interface{}]interface{} // validate this is an object and not a different type + if err := yaml.Unmarshal(data, &canary); err != nil { + return nil, err + } + + var document yaml.MapSlice // preserve order that is present in the document + if err := yaml.Unmarshal(data, &document); err != nil { + return nil, err + } + return document, nil +} + +// JSONMapSlice represent a JSON object, with the order of keys maintained +type JSONMapSlice []JSONMapItem + +// MarshalJSON renders a JSONMapSlice as JSON +func (s JSONMapSlice) MarshalJSON() ([]byte, error) { + w := &jwriter.Writer{Flags: jwriter.NilMapAsEmpty | jwriter.NilSliceAsEmpty} + s.MarshalEasyJSON(w) + return w.BuildBytes() +} + +// MarshalEasyJSON renders a JSONMapSlice as JSON, using easyJSON +func (s JSONMapSlice) MarshalEasyJSON(w *jwriter.Writer) { + w.RawByte('{') + + ln := len(s) + last := ln - 1 + for i := 0; i < ln; i++ { + s[i].MarshalEasyJSON(w) + if i != last { // last item + w.RawByte(',') + } + } + + w.RawByte('}') +} + +// UnmarshalJSON makes a JSONMapSlice from JSON +func (s *JSONMapSlice) UnmarshalJSON(data []byte) error { + l := jlexer.Lexer{Data: data} + s.UnmarshalEasyJSON(&l) + return l.Error() +} + +// UnmarshalEasyJSON makes a JSONMapSlice from JSON, using easyJSON +func (s *JSONMapSlice) UnmarshalEasyJSON(in *jlexer.Lexer) { + if in.IsNull() { + in.Skip() + return + } + + var result JSONMapSlice + in.Delim('{') + for !in.IsDelim('}') { + var mi JSONMapItem + mi.UnmarshalEasyJSON(in) + result = append(result, mi) + } + *s = result +} + +// JSONMapItem represents the value of a key in a JSON object held by JSONMapSlice +type JSONMapItem struct { + Key string + Value interface{} +} + +// MarshalJSON renders a JSONMapItem as JSON +func (s JSONMapItem) MarshalJSON() ([]byte, error) { + w := &jwriter.Writer{Flags: jwriter.NilMapAsEmpty | jwriter.NilSliceAsEmpty} + s.MarshalEasyJSON(w) + return w.BuildBytes() +} + +// MarshalEasyJSON renders a JSONMapItem as JSON, using easyJSON +func (s JSONMapItem) MarshalEasyJSON(w *jwriter.Writer) { + w.String(s.Key) + w.RawByte(':') + w.Raw(WriteJSON(s.Value)) +} + +// UnmarshalJSON makes a JSONMapItem from JSON +func (s *JSONMapItem) UnmarshalJSON(data []byte) error { + l := jlexer.Lexer{Data: data} + s.UnmarshalEasyJSON(&l) + return l.Error() +} + +// UnmarshalEasyJSON makes a JSONMapItem from JSON, using easyJSON +func (s *JSONMapItem) UnmarshalEasyJSON(in *jlexer.Lexer) { + key := in.UnsafeString() + in.WantColon() + value := in.Interface() + in.WantComma() + s.Key = key + s.Value = value +} + +func transformData(input interface{}) (out interface{}, err error) { + format := func(t interface{}) (string, error) { + switch k := t.(type) { + case string: + return k, nil + case uint: + return strconv.FormatUint(uint64(k), 10), nil + case uint8: + return strconv.FormatUint(uint64(k), 10), nil + case uint16: + return strconv.FormatUint(uint64(k), 10), nil + case uint32: + return strconv.FormatUint(uint64(k), 10), nil + case uint64: + return strconv.FormatUint(k, 10), nil + case int: + return strconv.Itoa(k), nil + case int8: + return strconv.FormatInt(int64(k), 10), nil + case int16: + return strconv.FormatInt(int64(k), 10), nil + case int32: + return strconv.FormatInt(int64(k), 10), nil + case int64: + return strconv.FormatInt(k, 10), nil + default: + return "", fmt.Errorf("unexpected map key type, got: %T", k) + } + } + + switch in := input.(type) { + case yaml.MapSlice: + + o := make(JSONMapSlice, len(in)) + for i, mi := range in { + var nmi JSONMapItem + if nmi.Key, err = format(mi.Key); err != nil { + return nil, err + } + + v, ert := transformData(mi.Value) + if ert != nil { + return nil, ert + } + nmi.Value = v + o[i] = nmi + } + return o, nil + case map[interface{}]interface{}: + o := make(JSONMapSlice, 0, len(in)) + for ke, va := range in { + var nmi JSONMapItem + if nmi.Key, err = format(ke); err != nil { + return nil, err + } + + v, ert := transformData(va) + if ert != nil { + return nil, ert + } + nmi.Value = v + o = append(o, nmi) + } + return o, nil + case []interface{}: + len1 := len(in) + o := make([]interface{}, len1) + for i := 0; i < len1; i++ { + o[i], err = transformData(in[i]) + if err != nil { + return nil, err + } + } + return o, nil + } + return input, nil +} + +// YAMLDoc loads a yaml document from either http or a file and converts it to json +func YAMLDoc(path string) (json.RawMessage, error) { + yamlDoc, err := YAMLData(path) + if err != nil { + return nil, err + } + + data, err := YAMLToJSON(yamlDoc) + if err != nil { + return nil, err + } + + return data, nil +} + +// YAMLData loads a yaml document from either http or a file +func YAMLData(path string) (interface{}, error) { + data, err := LoadFromFileOrHTTP(path) + if err != nil { + return nil, err + } + + return BytesToYAMLDoc(data) +} diff --git a/vendor/github.com/go-openapi/validate/.editorconfig b/vendor/github.com/go-openapi/validate/.editorconfig new file mode 100644 index 00000000000..3152da69a5d --- /dev/null +++ b/vendor/github.com/go-openapi/validate/.editorconfig @@ -0,0 +1,26 @@ +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true + +# Set default charset +[*.{js,py,go,scala,rb,java,html,css,less,sass,md}] +charset = utf-8 + +# Tab indentation (no size specified) +[*.go] +indent_style = tab + +[*.md] +trim_trailing_whitespace = false + +# Matches the exact files either package.json or .travis.yml +[{package.json,.travis.yml}] +indent_style = space +indent_size = 2 diff --git a/vendor/github.com/go-openapi/validate/.gitignore b/vendor/github.com/go-openapi/validate/.gitignore new file mode 100644 index 00000000000..fea8b84eca9 --- /dev/null +++ b/vendor/github.com/go-openapi/validate/.gitignore @@ -0,0 +1,5 @@ +secrets.yml +coverage.out +*.cov +*.out +playground diff --git a/vendor/github.com/go-openapi/validate/.golangci.yml b/vendor/github.com/go-openapi/validate/.golangci.yml new file mode 100644 index 00000000000..7dbddddfec2 --- /dev/null +++ b/vendor/github.com/go-openapi/validate/.golangci.yml @@ -0,0 +1,42 @@ +linters-settings: + govet: + check-shadowing: true + golint: + min-confidence: 0 + gocyclo: + min-complexity: 50 + maligned: + suggest-new: true + dupl: + threshold: 100 + goconst: + min-len: 2 + min-occurrences: 3 + +linters: + enable-all: true + disable: + - maligned + - lll + - godox + - gocognit + - whitespace + - wsl + - funlen + - gochecknoglobals + - gochecknoinits + - scopelint + - wrapcheck + - exhaustivestruct + - exhaustive + - nlreturn + - testpackage + - gci + - gofumpt + - goerr113 + - gomnd + - tparallel + - nestif + - godot + - tparallel + - paralleltest diff --git a/vendor/github.com/go-openapi/validate/.travis.yml b/vendor/github.com/go-openapi/validate/.travis.yml new file mode 100644 index 00000000000..6fb3fb00563 --- /dev/null +++ b/vendor/github.com/go-openapi/validate/.travis.yml @@ -0,0 +1,52 @@ +after_success: +- bash <(curl -s https://codecov.io/bash) +go: +- 1.14.x +- 1.x +arch: +- amd64 +jobs: + include: + # only run fast tests on ppc64le + - go: 1.x + arch: ppc64le + script: + - gotestsum -f short-verbose -- ./... + + # include large spec validation sample (run once) + - go: 1.x + arch: amd64 + script: + - gotestsum -f short-verbose -- -timeout=30m -args -enable-go-swagger ./... + + # include linting job, but only for latest go version and amd64 arch (run once) + - go: 1.x + arch: amd64 + install: + - GO111MODULE=off go get -u gotest.tools/gotestsum + - go get -u github.com/go-openapi/runtime@master + script: + - gotestsum -f short-verbose -- -timeout=30m github.com/go-openapi/runtime/... + + # include go-openapi/runtime non reg job (run once) + - go: 1.x + arch: amd64 + install: + go get github.com/golangci/golangci-lint/cmd/golangci-lint + script: + - golangci-lint run --new-from-rev master + + # include -race test on short tests only (run once) + - go: 1.x + arch: amd64 + script: + - gotestsum -f short-verbose -- -race ./... + +install: +- GO111MODULE=off go get -u gotest.tools/gotestsum +language: go +notifications: + slack: + secure: EmObnQuM9Mw8J9vpFaKKHqSMN4Wsr/A9+v7ewAD5cEhA0T1P4m7MbJMiJOhxUhj/X+BFh2DamW+P2lT8mybj5wg8wnkQ2BteKA8Tawi6f9PRw2NRheO8tAi8o/npLnlmet0kc93mn+oLuqHw36w4+j5mkOl2FghkfGiUVhwrhkCP7KXQN+3TU87e+/HzQumlJ3nsE+6terVxkH3PmaUTsS5ONaODZfuxFpfb7RsoEl3skHf6d+tr+1nViLxxly7558Nc33C+W1mr0qiEvMLZ+kJ/CpGWBJ6CUJM3jm6hNe2eMuIPwEK2hxZob8c7n22VPap4K6a0bBRoydoDXaba+2sD7Ym6ivDO/DVyL44VeBBLyIiIBylDGQdZH+6SoWm90Qe/i7tnY/T5Ao5igT8f3cfQY1c3EsTfqmlDfrhmACBmwSlgkdVBLTprHL63JMY24LWmh4jhxsmMRZhCL4dze8su1w6pLN/pD1pGHtKYCEVbdTmaM3PblNRFf12XB7qosmQsgUndH4Vq3bTbU0s1pKjeDhRyLvFzvR0TBbo0pDLEoF1A/i5GVFWa7yLZNUDudQERRh7qv/xBl2excIaQ1sV4DSVm7bAE9l6Kp+yeHQJW2uN6Y3X8wu9gB9nv9l5HBze7wh8KE6PyWAOLYYqZg9/sAtsv/2GcQqXcKFF1zcA= +script: +- gotestsum -f short-verbose -- -timeout=20m -coverprofile=coverage.txt -covermode=atomic -args -enable-long ./... diff --git a/vendor/github.com/go-openapi/validate/CODE_OF_CONDUCT.md b/vendor/github.com/go-openapi/validate/CODE_OF_CONDUCT.md new file mode 100644 index 00000000000..9322b065e37 --- /dev/null +++ b/vendor/github.com/go-openapi/validate/CODE_OF_CONDUCT.md @@ -0,0 +1,74 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or +advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at ivan+abuse@flanders.co.nz. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/vendor/github.com/go-openapi/validate/LICENSE b/vendor/github.com/go-openapi/validate/LICENSE new file mode 100644 index 00000000000..d6456956733 --- /dev/null +++ b/vendor/github.com/go-openapi/validate/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/go-openapi/validate/README.md b/vendor/github.com/go-openapi/validate/README.md new file mode 100644 index 00000000000..ea2d68cb683 --- /dev/null +++ b/vendor/github.com/go-openapi/validate/README.md @@ -0,0 +1,38 @@ +# Validation helpers +[![Build Status](https://travis-ci.org/go-openapi/validate.svg?branch=master)](https://travis-ci.org/go-openapi/validate) +[![Build status](https://ci.appveyor.com/api/projects/status/d6epy6vipueyh5fs/branch/master?svg=true)](https://ci.appveyor.com/project/fredbi/validate/branch/master) +[![codecov](https://codecov.io/gh/go-openapi/validate/branch/master/graph/badge.svg)](https://codecov.io/gh/go-openapi/validate) +[![Slack Status](https://slackin.goswagger.io/badge.svg)](https://slackin.goswagger.io) +[![license](http://img.shields.io/badge/license-Apache%20v2-orange.svg)](https://raw.githubusercontent.com/go-openapi/validate/master/LICENSE) +[![Go Reference](https://pkg.go.dev/badge/github.com/go-openapi/validate.svg)](https://pkg.go.dev/github.com/go-openapi/validate) +[![Go Report Card](https://goreportcard.com/badge/github.com/go-openapi/validate)](https://goreportcard.com/report/github.com/go-openapi/validate) + +This package provides helpers to validate Swagger 2.0. specification (aka OpenAPI 2.0). + +Reference can be found here: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md. + +## What's inside? + +* A validator for Swagger specifications +* A validator for JSON schemas draft4 +* Helper functions to validate individual values (used by code generated by [go-swagger](https://github.com/go-swagger/go-swagger)). + * Required, RequiredNumber, RequiredString + * ReadOnly + * UniqueItems, MaxItems, MinItems + * Enum, EnumCase + * Pattern, MinLength, MaxLength + * Minimum, Maximum, MultipleOf + * FormatOf + +[Documentation](https://godoc.org/github.com/go-openapi/validate) + +## FAQ + +* Does this library support OpenAPI 3? + +> No. +> This package currently only supports OpenAPI 2.0 (aka Swagger 2.0). +> There is no plan to make it evolve toward supporting OpenAPI 3.x. +> This [discussion thread](https://github.com/go-openapi/spec/issues/21) relates the full story. +> +> An early attempt to support Swagger 3 may be found at: https://github.com/go-openapi/spec3 diff --git a/vendor/github.com/go-openapi/validate/appveyor.yml b/vendor/github.com/go-openapi/validate/appveyor.yml new file mode 100644 index 00000000000..89e5bccb3a5 --- /dev/null +++ b/vendor/github.com/go-openapi/validate/appveyor.yml @@ -0,0 +1,32 @@ +version: "0.1.{build}" + +clone_folder: C:\go-openapi\validate +shallow_clone: true # for startup speed +pull_requests: + do_not_increment_build_number: true + +#skip_tags: true +#skip_branch_with_pr: true + +# appveyor.yml +build: off + +environment: + GOPATH: c:\gopath + +stack: go 1.15 + +test_script: + - go test -v -timeout 20m -args -enable-long ./... + +deploy: off + +notifications: + - provider: Slack + incoming_webhook: https://hooks.slack.com/services/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 + auth_token: + secure: Sf7kZf7ZGbnwWUMpffHwMu5A0cHkLK2MYY32LNTPj4+/3qC3Ghl7+9v4TSLOqOlCwdRNjOGblAq7s+GDJed6/xgRQl1JtCi1klzZNrYX4q01pgTPvvGcwbBkIYgeMaPeIRcK9OZnud7sRXdttozgTOpytps2U6Js32ip7uj5mHSg2ub0FwoSJwlS6dbezZ8+eDhoha0F/guY99BEwx8Bd+zROrT2TFGsSGOFGN6wFc7moCqTHO/YkWib13a2QNXqOxCCVBy/lt76Wp+JkeFppjHlzs/2lP3EAk13RIUAaesdEUHvIHrzCyNJEd3/+KO2DzsWOYfpktd+KBCvgaYOsoo7ubdT3IROeAegZdCgo/6xgCEsmFc9ZcqCfN5yNx2A+BZ2Vwmpws+bQ1E1+B5HDzzaiLcYfG4X2O210QVGVDLWsv1jqD+uPYeHY2WRfh5ZsIUFvaqgUEnwHwrK44/8REAhQavt1QAj5uJpsRd7CkRVPWRNK+yIky+wgbVUFEchRNmS55E7QWf+W4+4QZkQi7vUTMc9nbTUu2Es9NfvfudOpM2wZbn98fjpb/qq/nRv6Bk+ca+7XD5/IgNLMbWp2ouDdzbiHLCOfDUiHiDJhLfFZx9Bwo7ZwfzeOlbrQX66bx7xRKYmOe4DLrXhNcpbsMa8qbfxlZRCmYbubB/Y8h4= + channel: bots + on_build_success: false + on_build_failure: true + on_build_status_changed: true diff --git a/vendor/github.com/go-openapi/validate/context.go b/vendor/github.com/go-openapi/validate/context.go new file mode 100644 index 00000000000..bf02e94629d --- /dev/null +++ b/vendor/github.com/go-openapi/validate/context.go @@ -0,0 +1,56 @@ +package validate + +import ( + "context" +) + +// validateCtxKey is the key type of context key in this pkg +type validateCtxKey string + +const ( + operationTypeKey validateCtxKey = "operationTypeKey" +) + +type operationType string + +const ( + request operationType = "request" + response operationType = "response" + none operationType = "none" // not specified in ctx +) + +var operationTypeEnum []operationType = []operationType{request, response, none} + +// WithOperationRequest returns a new context with operationType request +// in context value +func WithOperationRequest(ctx context.Context) context.Context { + return withOperation(ctx, request) +} + +// WithOperationRequest returns a new context with operationType response +// in context value +func WithOperationResponse(ctx context.Context) context.Context { + return withOperation(ctx, response) +} + +func withOperation(ctx context.Context, operation operationType) context.Context { + return context.WithValue(ctx, operationTypeKey, operation) +} + +// extractOperationType extracts the operation type from ctx +// if not specified or of unknown value, return none operation type +func extractOperationType(ctx context.Context) operationType { + v := ctx.Value(operationTypeKey) + if v == nil { + return none + } + res, ok := v.(operationType) + if !ok { + return none + } + // validate the value is in operation enum + if err := Enum("", "", res, operationTypeEnum); err != nil { + return none + } + return res +} diff --git a/vendor/github.com/go-openapi/validate/debug.go b/vendor/github.com/go-openapi/validate/debug.go new file mode 100644 index 00000000000..8815fd93597 --- /dev/null +++ b/vendor/github.com/go-openapi/validate/debug.go @@ -0,0 +1,47 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package validate + +import ( + "fmt" + "log" + "os" + "path/filepath" + "runtime" +) + +var ( + // Debug is true when the SWAGGER_DEBUG env var is not empty. + // It enables a more verbose logging of validators. + Debug = os.Getenv("SWAGGER_DEBUG") != "" + // validateLogger is a debug logger for this package + validateLogger *log.Logger +) + +func init() { + debugOptions() +} + +func debugOptions() { + validateLogger = log.New(os.Stdout, "validate:", log.LstdFlags) +} + +func debugLog(msg string, args ...interface{}) { + // A private, trivial trace logger, based on go-openapi/spec/expander.go:debugLog() + if Debug { + _, file1, pos1, _ := runtime.Caller(1) + validateLogger.Printf("%s:%d: %s", filepath.Base(file1), pos1, fmt.Sprintf(msg, args...)) + } +} diff --git a/vendor/github.com/go-openapi/validate/default_validator.go b/vendor/github.com/go-openapi/validate/default_validator.go new file mode 100644 index 00000000000..3e0d8c770d3 --- /dev/null +++ b/vendor/github.com/go-openapi/validate/default_validator.go @@ -0,0 +1,281 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package validate + +import ( + "fmt" + "strings" + + "github.com/go-openapi/spec" +) + +// defaultValidator validates default values in a spec. +// According to Swagger spec, default values MUST validate their schema. +type defaultValidator struct { + SpecValidator *SpecValidator + visitedSchemas map[string]bool +} + +// resetVisited resets the internal state of visited schemas +func (d *defaultValidator) resetVisited() { + d.visitedSchemas = map[string]bool{} +} + +func isVisited(path string, visitedSchemas map[string]bool) bool { + found := visitedSchemas[path] + if !found { + // search for overlapping paths + frags := strings.Split(path, ".") + if len(frags) < 2 { + // shortcut exit on smaller paths + return found + } + last := len(frags) - 1 + var currentFragStr, parent string + for i := range frags { + if i == 0 { + currentFragStr = frags[last] + } else { + currentFragStr = strings.Join([]string{frags[last-i], currentFragStr}, ".") + } + if i < last { + parent = strings.Join(frags[0:last-i], ".") + } else { + parent = "" + } + if strings.HasSuffix(parent, currentFragStr) { + found = true + break + } + } + } + return found +} + +// beingVisited asserts a schema is being visited +func (d *defaultValidator) beingVisited(path string) { + d.visitedSchemas[path] = true +} + +// isVisited tells if a path has already been visited +func (d *defaultValidator) isVisited(path string) bool { + return isVisited(path, d.visitedSchemas) +} + +// Validate validates the default values declared in the swagger spec +func (d *defaultValidator) Validate() (errs *Result) { + errs = new(Result) + if d == nil || d.SpecValidator == nil { + return errs + } + d.resetVisited() + errs.Merge(d.validateDefaultValueValidAgainstSchema()) // error - + return errs +} + +func (d *defaultValidator) validateDefaultValueValidAgainstSchema() *Result { + // every default value that is specified must validate against the schema for that property + // headers, items, parameters, schema + + res := new(Result) + s := d.SpecValidator + + for method, pathItem := range s.analyzer.Operations() { + for path, op := range pathItem { + // parameters + for _, param := range paramHelp.safeExpandedParamsFor(path, method, op.ID, res, s) { + if param.Default != nil && param.Required { + res.AddWarnings(requiredHasDefaultMsg(param.Name, param.In)) + } + + // reset explored schemas to get depth-first recursive-proof exploration + d.resetVisited() + + // Check simple parameters first + // default values provided must validate against their inline definition (no explicit schema) + if param.Default != nil && param.Schema == nil { + // check param default value is valid + red := NewParamValidator(¶m, s.KnownFormats).Validate(param.Default) //#nosec + if red.HasErrorsOrWarnings() { + res.AddErrors(defaultValueDoesNotValidateMsg(param.Name, param.In)) + res.Merge(red) + } + } + + // Recursively follows Items and Schemas + if param.Items != nil { + red := d.validateDefaultValueItemsAgainstSchema(param.Name, param.In, ¶m, param.Items) //#nosec + if red.HasErrorsOrWarnings() { + res.AddErrors(defaultValueItemsDoesNotValidateMsg(param.Name, param.In)) + res.Merge(red) + } + } + + if param.Schema != nil { + // Validate default value against schema + red := d.validateDefaultValueSchemaAgainstSchema(param.Name, param.In, param.Schema) + if red.HasErrorsOrWarnings() { + res.AddErrors(defaultValueDoesNotValidateMsg(param.Name, param.In)) + res.Merge(red) + } + } + } + + if op.Responses != nil { + if op.Responses.Default != nil { + // Same constraint on default Response + res.Merge(d.validateDefaultInResponse(op.Responses.Default, jsonDefault, path, 0, op.ID)) + } + // Same constraint on regular Responses + if op.Responses.StatusCodeResponses != nil { // Safeguard + for code, r := range op.Responses.StatusCodeResponses { + res.Merge(d.validateDefaultInResponse(&r, "response", path, code, op.ID)) //#nosec + } + } + } else if op.ID != "" { + // Empty op.ID means there is no meaningful operation: no need to report a specific message + res.AddErrors(noValidResponseMsg(op.ID)) + } + } + } + if s.spec.Spec().Definitions != nil { // Safeguard + // reset explored schemas to get depth-first recursive-proof exploration + d.resetVisited() + for nm, sch := range s.spec.Spec().Definitions { + res.Merge(d.validateDefaultValueSchemaAgainstSchema(fmt.Sprintf("definitions.%s", nm), "body", &sch)) //#nosec + } + } + return res +} + +func (d *defaultValidator) validateDefaultInResponse(resp *spec.Response, responseType, path string, responseCode int, operationID string) *Result { + s := d.SpecValidator + + response, res := responseHelp.expandResponseRef(resp, path, s) + if !res.IsValid() { + return res + } + + responseName, responseCodeAsStr := responseHelp.responseMsgVariants(responseType, responseCode) + + // nolint: dupl + if response.Headers != nil { // Safeguard + for nm, h := range response.Headers { + // reset explored schemas to get depth-first recursive-proof exploration + d.resetVisited() + + if h.Default != nil { + red := NewHeaderValidator(nm, &h, s.KnownFormats).Validate(h.Default) //#nosec + if red.HasErrorsOrWarnings() { + res.AddErrors(defaultValueHeaderDoesNotValidateMsg(operationID, nm, responseName)) + res.Merge(red) + } + } + + // Headers have inline definition, like params + if h.Items != nil { + red := d.validateDefaultValueItemsAgainstSchema(nm, "header", &h, h.Items) //#nosec + if red.HasErrorsOrWarnings() { + res.AddErrors(defaultValueHeaderItemsDoesNotValidateMsg(operationID, nm, responseName)) + res.Merge(red) + } + } + + if _, err := compileRegexp(h.Pattern); err != nil { + res.AddErrors(invalidPatternInHeaderMsg(operationID, nm, responseName, h.Pattern, err)) + } + + // Headers don't have schema + } + } + if response.Schema != nil { + // reset explored schemas to get depth-first recursive-proof exploration + d.resetVisited() + + red := d.validateDefaultValueSchemaAgainstSchema(responseCodeAsStr, "response", response.Schema) + if red.HasErrorsOrWarnings() { + // Additional message to make sure the context of the error is not lost + res.AddErrors(defaultValueInDoesNotValidateMsg(operationID, responseName)) + res.Merge(red) + } + } + return res +} + +func (d *defaultValidator) validateDefaultValueSchemaAgainstSchema(path, in string, schema *spec.Schema) *Result { + if schema == nil || d.isVisited(path) { + // Avoids recursing if we are already done with that check + return nil + } + d.beingVisited(path) + res := new(Result) + s := d.SpecValidator + + if schema.Default != nil { + res.Merge(NewSchemaValidator(schema, s.spec.Spec(), path+".default", s.KnownFormats, SwaggerSchema(true)).Validate(schema.Default)) + } + if schema.Items != nil { + if schema.Items.Schema != nil { + res.Merge(d.validateDefaultValueSchemaAgainstSchema(path+".items.default", in, schema.Items.Schema)) + } + // Multiple schemas in items + if schema.Items.Schemas != nil { // Safeguard + for i, sch := range schema.Items.Schemas { + res.Merge(d.validateDefaultValueSchemaAgainstSchema(fmt.Sprintf("%s.items[%d].default", path, i), in, &sch)) //#nosec + } + } + } + if _, err := compileRegexp(schema.Pattern); err != nil { + res.AddErrors(invalidPatternInMsg(path, in, schema.Pattern)) + } + if schema.AdditionalItems != nil && schema.AdditionalItems.Schema != nil { + // NOTE: we keep validating values, even though additionalItems is not supported by Swagger 2.0 (and 3.0 as well) + res.Merge(d.validateDefaultValueSchemaAgainstSchema(fmt.Sprintf("%s.additionalItems", path), in, schema.AdditionalItems.Schema)) + } + for propName, prop := range schema.Properties { + res.Merge(d.validateDefaultValueSchemaAgainstSchema(path+"."+propName, in, &prop)) //#nosec + } + for propName, prop := range schema.PatternProperties { + res.Merge(d.validateDefaultValueSchemaAgainstSchema(path+"."+propName, in, &prop)) //#nosec + } + if schema.AdditionalProperties != nil && schema.AdditionalProperties.Schema != nil { + res.Merge(d.validateDefaultValueSchemaAgainstSchema(fmt.Sprintf("%s.additionalProperties", path), in, schema.AdditionalProperties.Schema)) + } + if schema.AllOf != nil { + for i, aoSch := range schema.AllOf { + res.Merge(d.validateDefaultValueSchemaAgainstSchema(fmt.Sprintf("%s.allOf[%d]", path, i), in, &aoSch)) //#nosec + } + } + return res +} + +// TODO: Temporary duplicated code. Need to refactor with examples +// nolint: dupl +func (d *defaultValidator) validateDefaultValueItemsAgainstSchema(path, in string, root interface{}, items *spec.Items) *Result { + res := new(Result) + s := d.SpecValidator + if items != nil { + if items.Default != nil { + res.Merge(newItemsValidator(path, in, items, root, s.KnownFormats).Validate(0, items.Default)) + } + if items.Items != nil { + res.Merge(d.validateDefaultValueItemsAgainstSchema(path+"[0].default", in, root, items.Items)) + } + if _, err := compileRegexp(items.Pattern); err != nil { + res.AddErrors(invalidPatternInMsg(path, in, items.Pattern)) + } + } + return res +} diff --git a/vendor/github.com/go-openapi/validate/doc.go b/vendor/github.com/go-openapi/validate/doc.go new file mode 100644 index 00000000000..f5ca9a5d580 --- /dev/null +++ b/vendor/github.com/go-openapi/validate/doc.go @@ -0,0 +1,85 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/* +Package validate provides methods to validate a swagger specification, +as well as tools to validate data against their schema. + +This package follows Swagger 2.0. specification (aka OpenAPI 2.0). Reference +can be found here: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md. + +Validating a specification + +Validates a spec document (from JSON or YAML) against the JSON schema for swagger, +then checks a number of extra rules that can't be expressed in JSON schema. + +Entry points: + - Spec() + - NewSpecValidator() + - SpecValidator.Validate() + +Reported as errors: + [x] definition can't declare a property that's already defined by one of its ancestors + [x] definition's ancestor can't be a descendant of the same model + [x] path uniqueness: each api path should be non-verbatim (account for path param names) unique per method + [x] each security reference should contain only unique scopes + [x] each security scope in a security definition should be unique + [x] parameters in path must be unique + [x] each path parameter must correspond to a parameter placeholder and vice versa + [x] each referenceable definition must have references + [x] each definition property listed in the required array must be defined in the properties of the model + [x] each parameter should have a unique `name` and `type` combination + [x] each operation should have only 1 parameter of type body + [x] each reference must point to a valid object + [x] every default value that is specified must validate against the schema for that property + [x] items property is required for all schemas/definitions of type `array` + [x] path parameters must be declared a required + [x] headers must not contain $ref + [x] schema and property examples provided must validate against their respective object's schema + [x] examples provided must validate their schema + +Reported as warnings: + [x] path parameters should not contain any of [{,},\w] + [x] empty path + [x] unused definitions + [x] unsupported validation of examples on non-JSON media types + [x] examples in response without schema + [x] readOnly properties should not be required + +Validating a schema + +The schema validation toolkit validates data against JSON-schema-draft 04 schema. + +It is tested against the full json-schema-testing-suite (https://github.com/json-schema-org/JSON-Schema-Test-Suite), +except for the optional part (bignum, ECMA regexp, ...). + +It supports the complete JSON-schema vocabulary, including keywords not supported by Swagger (e.g. additionalItems, ...) + +Entry points: + - AgainstSchema() + - ... + +Known limitations + +With the current version of this package, the following aspects of swagger are not yet supported: + [ ] errors and warnings are not reported with key/line number in spec + [ ] default values and examples on responses only support application/json producer type + [ ] invalid numeric constraints (such as Minimum, etc..) are not checked except for default and example values + [ ] rules for collectionFormat are not implemented + [ ] no validation rule for polymorphism support (discriminator) [not done here] + [ ] valid js ECMA regexp not supported by Go regexp engine are considered invalid + [ ] arbitrary large numbers are not supported: max is math.MaxFloat64 + +*/ +package validate diff --git a/vendor/github.com/go-openapi/validate/example_validator.go b/vendor/github.com/go-openapi/validate/example_validator.go new file mode 100644 index 00000000000..f4b7a2dfe98 --- /dev/null +++ b/vendor/github.com/go-openapi/validate/example_validator.go @@ -0,0 +1,270 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package validate + +import ( + "fmt" + + "github.com/go-openapi/spec" +) + +// ExampleValidator validates example values defined in a spec +type exampleValidator struct { + SpecValidator *SpecValidator + visitedSchemas map[string]bool +} + +// resetVisited resets the internal state of visited schemas +func (ex *exampleValidator) resetVisited() { + ex.visitedSchemas = map[string]bool{} +} + +// beingVisited asserts a schema is being visited +func (ex *exampleValidator) beingVisited(path string) { + ex.visitedSchemas[path] = true +} + +// isVisited tells if a path has already been visited +func (ex *exampleValidator) isVisited(path string) bool { + return isVisited(path, ex.visitedSchemas) +} + +// Validate validates the example values declared in the swagger spec +// Example values MUST conform to their schema. +// +// With Swagger 2.0, examples are supported in: +// - schemas +// - individual property +// - responses +// +func (ex *exampleValidator) Validate() (errs *Result) { + errs = new(Result) + if ex == nil || ex.SpecValidator == nil { + return errs + } + ex.resetVisited() + errs.Merge(ex.validateExampleValueValidAgainstSchema()) // error - + + return errs +} + +func (ex *exampleValidator) validateExampleValueValidAgainstSchema() *Result { + // every example value that is specified must validate against the schema for that property + // in: schemas, properties, object, items + // not in: headers, parameters without schema + + res := new(Result) + s := ex.SpecValidator + + for method, pathItem := range s.analyzer.Operations() { + for path, op := range pathItem { + // parameters + for _, param := range paramHelp.safeExpandedParamsFor(path, method, op.ID, res, s) { + + // As of swagger 2.0, Examples are not supported in simple parameters + // However, it looks like it is supported by go-openapi + + // reset explored schemas to get depth-first recursive-proof exploration + ex.resetVisited() + + // Check simple parameters first + // default values provided must validate against their inline definition (no explicit schema) + if param.Example != nil && param.Schema == nil { + // check param default value is valid + red := NewParamValidator(¶m, s.KnownFormats).Validate(param.Example) //#nosec + if red.HasErrorsOrWarnings() { + res.AddWarnings(exampleValueDoesNotValidateMsg(param.Name, param.In)) + res.MergeAsWarnings(red) + } + } + + // Recursively follows Items and Schemas + if param.Items != nil { + red := ex.validateExampleValueItemsAgainstSchema(param.Name, param.In, ¶m, param.Items) //#nosec + if red.HasErrorsOrWarnings() { + res.AddWarnings(exampleValueItemsDoesNotValidateMsg(param.Name, param.In)) + res.Merge(red) + } + } + + if param.Schema != nil { + // Validate example value against schema + red := ex.validateExampleValueSchemaAgainstSchema(param.Name, param.In, param.Schema) + if red.HasErrorsOrWarnings() { + res.AddWarnings(exampleValueDoesNotValidateMsg(param.Name, param.In)) + res.Merge(red) + } + } + } + + if op.Responses != nil { + if op.Responses.Default != nil { + // Same constraint on default Response + res.Merge(ex.validateExampleInResponse(op.Responses.Default, jsonDefault, path, 0, op.ID)) + } + // Same constraint on regular Responses + if op.Responses.StatusCodeResponses != nil { // Safeguard + for code, r := range op.Responses.StatusCodeResponses { + res.Merge(ex.validateExampleInResponse(&r, "response", path, code, op.ID)) //#nosec + } + } + } else if op.ID != "" { + // Empty op.ID means there is no meaningful operation: no need to report a specific message + res.AddErrors(noValidResponseMsg(op.ID)) + } + } + } + if s.spec.Spec().Definitions != nil { // Safeguard + // reset explored schemas to get depth-first recursive-proof exploration + ex.resetVisited() + for nm, sch := range s.spec.Spec().Definitions { + res.Merge(ex.validateExampleValueSchemaAgainstSchema(fmt.Sprintf("definitions.%s", nm), "body", &sch)) //#nosec + } + } + return res +} + +func (ex *exampleValidator) validateExampleInResponse(resp *spec.Response, responseType, path string, responseCode int, operationID string) *Result { + s := ex.SpecValidator + + response, res := responseHelp.expandResponseRef(resp, path, s) + if !res.IsValid() { // Safeguard + return res + } + + responseName, responseCodeAsStr := responseHelp.responseMsgVariants(responseType, responseCode) + + // nolint: dupl + if response.Headers != nil { // Safeguard + for nm, h := range response.Headers { + // reset explored schemas to get depth-first recursive-proof exploration + ex.resetVisited() + + if h.Example != nil { + red := NewHeaderValidator(nm, &h, s.KnownFormats).Validate(h.Example) //#nosec + if red.HasErrorsOrWarnings() { + res.AddWarnings(exampleValueHeaderDoesNotValidateMsg(operationID, nm, responseName)) + res.MergeAsWarnings(red) + } + } + + // Headers have inline definition, like params + if h.Items != nil { + red := ex.validateExampleValueItemsAgainstSchema(nm, "header", &h, h.Items) //#nosec + if red.HasErrorsOrWarnings() { + res.AddWarnings(exampleValueHeaderItemsDoesNotValidateMsg(operationID, nm, responseName)) + res.MergeAsWarnings(red) + } + } + + if _, err := compileRegexp(h.Pattern); err != nil { + res.AddErrors(invalidPatternInHeaderMsg(operationID, nm, responseName, h.Pattern, err)) + } + + // Headers don't have schema + } + } + if response.Schema != nil { + // reset explored schemas to get depth-first recursive-proof exploration + ex.resetVisited() + + red := ex.validateExampleValueSchemaAgainstSchema(responseCodeAsStr, "response", response.Schema) + if red.HasErrorsOrWarnings() { + // Additional message to make sure the context of the error is not lost + res.AddWarnings(exampleValueInDoesNotValidateMsg(operationID, responseName)) + res.Merge(red) + } + } + + if response.Examples != nil { + if response.Schema != nil { + if example, ok := response.Examples["application/json"]; ok { + res.MergeAsWarnings(NewSchemaValidator(response.Schema, s.spec.Spec(), path+".examples", s.KnownFormats, SwaggerSchema(true)).Validate(example)) + } else { + // TODO: validate other media types too + res.AddWarnings(examplesMimeNotSupportedMsg(operationID, responseName)) + } + } else { + res.AddWarnings(examplesWithoutSchemaMsg(operationID, responseName)) + } + } + return res +} + +func (ex *exampleValidator) validateExampleValueSchemaAgainstSchema(path, in string, schema *spec.Schema) *Result { + if schema == nil || ex.isVisited(path) { + // Avoids recursing if we are already done with that check + return nil + } + ex.beingVisited(path) + s := ex.SpecValidator + res := new(Result) + + if schema.Example != nil { + res.MergeAsWarnings(NewSchemaValidator(schema, s.spec.Spec(), path+".example", s.KnownFormats, SwaggerSchema(true)).Validate(schema.Example)) + } + if schema.Items != nil { + if schema.Items.Schema != nil { + res.Merge(ex.validateExampleValueSchemaAgainstSchema(path+".items.example", in, schema.Items.Schema)) + } + // Multiple schemas in items + if schema.Items.Schemas != nil { // Safeguard + for i, sch := range schema.Items.Schemas { + res.Merge(ex.validateExampleValueSchemaAgainstSchema(fmt.Sprintf("%s.items[%d].example", path, i), in, &sch)) //#nosec + } + } + } + if _, err := compileRegexp(schema.Pattern); err != nil { + res.AddErrors(invalidPatternInMsg(path, in, schema.Pattern)) + } + if schema.AdditionalItems != nil && schema.AdditionalItems.Schema != nil { + // NOTE: we keep validating values, even though additionalItems is unsupported in Swagger 2.0 (and 3.0 as well) + res.Merge(ex.validateExampleValueSchemaAgainstSchema(fmt.Sprintf("%s.additionalItems", path), in, schema.AdditionalItems.Schema)) + } + for propName, prop := range schema.Properties { + res.Merge(ex.validateExampleValueSchemaAgainstSchema(path+"."+propName, in, &prop)) //#nosec + } + for propName, prop := range schema.PatternProperties { + res.Merge(ex.validateExampleValueSchemaAgainstSchema(path+"."+propName, in, &prop)) //#nosec + } + if schema.AdditionalProperties != nil && schema.AdditionalProperties.Schema != nil { + res.Merge(ex.validateExampleValueSchemaAgainstSchema(fmt.Sprintf("%s.additionalProperties", path), in, schema.AdditionalProperties.Schema)) + } + if schema.AllOf != nil { + for i, aoSch := range schema.AllOf { + res.Merge(ex.validateExampleValueSchemaAgainstSchema(fmt.Sprintf("%s.allOf[%d]", path, i), in, &aoSch)) //#nosec + } + } + return res +} + +// TODO: Temporary duplicated code. Need to refactor with examples +// nolint: dupl +func (ex *exampleValidator) validateExampleValueItemsAgainstSchema(path, in string, root interface{}, items *spec.Items) *Result { + res := new(Result) + s := ex.SpecValidator + if items != nil { + if items.Example != nil { + res.MergeAsWarnings(newItemsValidator(path, in, items, root, s.KnownFormats).Validate(0, items.Example)) + } + if items.Items != nil { + res.Merge(ex.validateExampleValueItemsAgainstSchema(path+"[0].example", in, root, items.Items)) + } + if _, err := compileRegexp(items.Pattern); err != nil { + res.AddErrors(invalidPatternInMsg(path, in, items.Pattern)) + } + } + return res +} diff --git a/vendor/github.com/go-openapi/validate/formats.go b/vendor/github.com/go-openapi/validate/formats.go new file mode 100644 index 00000000000..0ad996cbbc2 --- /dev/null +++ b/vendor/github.com/go-openapi/validate/formats.go @@ -0,0 +1,69 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package validate + +import ( + "reflect" + + "github.com/go-openapi/spec" + "github.com/go-openapi/strfmt" +) + +type formatValidator struct { + Format string + Path string + In string + KnownFormats strfmt.Registry +} + +func (f *formatValidator) SetPath(path string) { + f.Path = path +} + +func (f *formatValidator) Applies(source interface{}, kind reflect.Kind) bool { + doit := func() bool { + if source == nil { + return false + } + switch source := source.(type) { + case *spec.Items: + return kind == reflect.String && f.KnownFormats.ContainsName(source.Format) + case *spec.Parameter: + return kind == reflect.String && f.KnownFormats.ContainsName(source.Format) + case *spec.Schema: + return kind == reflect.String && f.KnownFormats.ContainsName(source.Format) + case *spec.Header: + return kind == reflect.String && f.KnownFormats.ContainsName(source.Format) + } + return false + } + r := doit() + debugLog("format validator for %q applies %t for %T (kind: %v)\n", f.Path, r, source, kind) + return r +} + +func (f *formatValidator) Validate(val interface{}) *Result { + result := new(Result) + debugLog("validating \"%v\" against format: %s", val, f.Format) + + if err := FormatOf(f.Path, f.In, f.Format, val.(string), f.KnownFormats); err != nil { + result.AddErrors(err) + } + + if result.HasErrors() { + return result + } + return nil +} diff --git a/vendor/github.com/go-openapi/validate/helpers.go b/vendor/github.com/go-openapi/validate/helpers.go new file mode 100644 index 00000000000..5d901dda717 --- /dev/null +++ b/vendor/github.com/go-openapi/validate/helpers.go @@ -0,0 +1,324 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package validate + +// TODO: define this as package validate/internal +// This must be done while keeping CI intact with all tests and test coverage + +import ( + "reflect" + "strconv" + "strings" + + "github.com/go-openapi/errors" + "github.com/go-openapi/spec" +) + +const ( + swaggerBody = "body" + swaggerExample = "example" + swaggerExamples = "examples" +) + +const ( + objectType = "object" + arrayType = "array" + stringType = "string" + integerType = "integer" + numberType = "number" + booleanType = "boolean" + fileType = "file" + nullType = "null" +) + +const ( + jsonProperties = "properties" + jsonItems = "items" + jsonType = "type" + // jsonSchema = "schema" + jsonDefault = "default" +) + +const ( + stringFormatDate = "date" + stringFormatDateTime = "date-time" + stringFormatPassword = "password" + stringFormatByte = "byte" + // stringFormatBinary = "binary" + stringFormatCreditCard = "creditcard" + stringFormatDuration = "duration" + stringFormatEmail = "email" + stringFormatHexColor = "hexcolor" + stringFormatHostname = "hostname" + stringFormatIPv4 = "ipv4" + stringFormatIPv6 = "ipv6" + stringFormatISBN = "isbn" + stringFormatISBN10 = "isbn10" + stringFormatISBN13 = "isbn13" + stringFormatMAC = "mac" + stringFormatBSONObjectID = "bsonobjectid" + stringFormatRGBColor = "rgbcolor" + stringFormatSSN = "ssn" + stringFormatURI = "uri" + stringFormatUUID = "uuid" + stringFormatUUID3 = "uuid3" + stringFormatUUID4 = "uuid4" + stringFormatUUID5 = "uuid5" + + integerFormatInt32 = "int32" + integerFormatInt64 = "int64" + integerFormatUInt32 = "uint32" + integerFormatUInt64 = "uint64" + + numberFormatFloat32 = "float32" + numberFormatFloat64 = "float64" + numberFormatFloat = "float" + numberFormatDouble = "double" +) + +// Helpers available at the package level +var ( + pathHelp *pathHelper + valueHelp *valueHelper + errorHelp *errorHelper + paramHelp *paramHelper + responseHelp *responseHelper +) + +type errorHelper struct { + // A collection of unexported helpers for error construction +} + +func (h *errorHelper) sErr(err errors.Error) *Result { + // Builds a Result from standard errors.Error + return &Result{Errors: []error{err}} +} + +func (h *errorHelper) addPointerError(res *Result, err error, ref string, fromPath string) *Result { + // Provides more context on error messages + // reported by the jsoinpointer package by altering the passed Result + if err != nil { + res.AddErrors(cannotResolveRefMsg(fromPath, ref, err)) + } + return res +} + +type pathHelper struct { + // A collection of unexported helpers for path validation +} + +func (h *pathHelper) stripParametersInPath(path string) string { + // Returns a path stripped from all path parameters, with multiple or trailing slashes removed. + // + // Stripping is performed on a slash-separated basis, e.g '/a{/b}' remains a{/b} and not /a. + // - Trailing "/" make a difference, e.g. /a/ !~ /a (ex: canary/bitbucket.org/swagger.json) + // - presence or absence of a parameter makes a difference, e.g. /a/{log} !~ /a/ (ex: canary/kubernetes/swagger.json) + + // Regexp to extract parameters from path, with surrounding {}. + // NOTE: important non-greedy modifier + rexParsePathParam := mustCompileRegexp(`{[^{}]+?}`) + strippedSegments := []string{} + + for _, segment := range strings.Split(path, "/") { + strippedSegments = append(strippedSegments, rexParsePathParam.ReplaceAllString(segment, "X")) + } + return strings.Join(strippedSegments, "/") +} + +func (h *pathHelper) extractPathParams(path string) (params []string) { + // Extracts all params from a path, with surrounding "{}" + rexParsePathParam := mustCompileRegexp(`{[^{}]+?}`) + + for _, segment := range strings.Split(path, "/") { + for _, v := range rexParsePathParam.FindAllStringSubmatch(segment, -1) { + params = append(params, v...) + } + } + return +} + +type valueHelper struct { + // A collection of unexported helpers for value validation +} + +func (h *valueHelper) asInt64(val interface{}) int64 { + // Number conversion function for int64, without error checking + // (implements an implicit type upgrade). + v := reflect.ValueOf(val) + switch v.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return v.Int() + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + return int64(v.Uint()) + case reflect.Float32, reflect.Float64: + return int64(v.Float()) + default: + // panic("Non numeric value in asInt64()") + return 0 + } +} + +func (h *valueHelper) asUint64(val interface{}) uint64 { + // Number conversion function for uint64, without error checking + // (implements an implicit type upgrade). + v := reflect.ValueOf(val) + switch v.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return uint64(v.Int()) + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + return v.Uint() + case reflect.Float32, reflect.Float64: + return uint64(v.Float()) + default: + // panic("Non numeric value in asUint64()") + return 0 + } +} + +// Same for unsigned floats +func (h *valueHelper) asFloat64(val interface{}) float64 { + // Number conversion function for float64, without error checking + // (implements an implicit type upgrade). + v := reflect.ValueOf(val) + switch v.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return float64(v.Int()) + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + return float64(v.Uint()) + case reflect.Float32, reflect.Float64: + return v.Float() + default: + // panic("Non numeric value in asFloat64()") + return 0 + } +} + +type paramHelper struct { + // A collection of unexported helpers for parameters resolution +} + +func (h *paramHelper) safeExpandedParamsFor(path, method, operationID string, res *Result, s *SpecValidator) (params []spec.Parameter) { + operation, ok := s.analyzer.OperationFor(method, path) + if ok { + // expand parameters first if necessary + resolvedParams := []spec.Parameter{} + for _, ppr := range operation.Parameters { + resolvedParam, red := h.resolveParam(path, method, operationID, &ppr, s) //#nosec + res.Merge(red) + if resolvedParam != nil { + resolvedParams = append(resolvedParams, *resolvedParam) + } + } + // remove params with invalid expansion from Slice + operation.Parameters = resolvedParams + + for _, ppr := range s.analyzer.SafeParamsFor(method, path, + func(p spec.Parameter, err error) bool { + // since params have already been expanded, there are few causes for error + res.AddErrors(someParametersBrokenMsg(path, method, operationID)) + // original error from analyzer + res.AddErrors(err) + return true + }) { + params = append(params, ppr) + } + } + return +} + +func (h *paramHelper) resolveParam(path, method, operationID string, param *spec.Parameter, s *SpecValidator) (*spec.Parameter, *Result) { + // Ensure parameter is expanded + var err error + res := new(Result) + isRef := param.Ref.String() != "" + if s.spec.SpecFilePath() == "" { + err = spec.ExpandParameterWithRoot(param, s.spec.Spec(), nil) + } else { + err = spec.ExpandParameter(param, s.spec.SpecFilePath()) + + } + if err != nil { // Safeguard + // NOTE: we may enter enter here when the whole parameter is an unresolved $ref + refPath := strings.Join([]string{"\"" + path + "\"", method}, ".") + errorHelp.addPointerError(res, err, param.Ref.String(), refPath) + return nil, res + } + res.Merge(h.checkExpandedParam(param, param.Name, param.In, operationID, isRef)) + return param, res +} + +func (h *paramHelper) checkExpandedParam(pr *spec.Parameter, path, in, operation string, isRef bool) *Result { + // Secure parameter structure after $ref resolution + res := new(Result) + simpleZero := spec.SimpleSchema{} + // Try to explain why... best guess + switch { + case pr.In == swaggerBody && (pr.SimpleSchema != simpleZero && pr.SimpleSchema.Type != objectType): + if isRef { + // Most likely, a $ref with a sibling is an unwanted situation: in itself this is a warning... + // but we detect it because of the following error: + // schema took over Parameter for an unexplained reason + res.AddWarnings(refShouldNotHaveSiblingsMsg(path, operation)) + } + res.AddErrors(invalidParameterDefinitionMsg(path, in, operation)) + case pr.In != swaggerBody && pr.Schema != nil: + if isRef { + res.AddWarnings(refShouldNotHaveSiblingsMsg(path, operation)) + } + res.AddErrors(invalidParameterDefinitionAsSchemaMsg(path, in, operation)) + case (pr.In == swaggerBody && pr.Schema == nil) || (pr.In != swaggerBody && pr.SimpleSchema == simpleZero): + // Other unexpected mishaps + res.AddErrors(invalidParameterDefinitionMsg(path, in, operation)) + } + return res +} + +type responseHelper struct { + // A collection of unexported helpers for response resolution +} + +func (r *responseHelper) expandResponseRef( + response *spec.Response, + path string, s *SpecValidator) (*spec.Response, *Result) { + // Ensure response is expanded + var err error + res := new(Result) + if s.spec.SpecFilePath() == "" { + // there is no physical document to resolve $ref in response + err = spec.ExpandResponseWithRoot(response, s.spec.Spec(), nil) + } else { + err = spec.ExpandResponse(response, s.spec.SpecFilePath()) + } + if err != nil { // Safeguard + // NOTE: we may enter here when the whole response is an unresolved $ref. + errorHelp.addPointerError(res, err, response.Ref.String(), path) + return nil, res + } + return response, res +} + +func (r *responseHelper) responseMsgVariants( + responseType string, + responseCode int) (responseName, responseCodeAsStr string) { + // Path variants for messages + if responseType == jsonDefault { + responseCodeAsStr = jsonDefault + responseName = "default response" + } else { + responseCodeAsStr = strconv.Itoa(responseCode) + responseName = "response " + responseCodeAsStr + } + return +} diff --git a/vendor/github.com/go-openapi/validate/object_validator.go b/vendor/github.com/go-openapi/validate/object_validator.go new file mode 100644 index 00000000000..7bb12615d8e --- /dev/null +++ b/vendor/github.com/go-openapi/validate/object_validator.go @@ -0,0 +1,279 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package validate + +import ( + "reflect" + "regexp" + "strings" + + "github.com/go-openapi/errors" + "github.com/go-openapi/spec" + "github.com/go-openapi/strfmt" +) + +type objectValidator struct { + Path string + In string + MaxProperties *int64 + MinProperties *int64 + Required []string + Properties map[string]spec.Schema + AdditionalProperties *spec.SchemaOrBool + PatternProperties map[string]spec.Schema + Root interface{} + KnownFormats strfmt.Registry + Options SchemaValidatorOptions +} + +func (o *objectValidator) SetPath(path string) { + o.Path = path +} + +func (o *objectValidator) Applies(source interface{}, kind reflect.Kind) bool { + // TODO: this should also work for structs + // there is a problem in the type validator where it will be unhappy about null values + // so that requires more testing + r := reflect.TypeOf(source) == specSchemaType && (kind == reflect.Map || kind == reflect.Struct) + debugLog("object validator for %q applies %t for %T (kind: %v)\n", o.Path, r, source, kind) + return r +} + +func (o *objectValidator) isProperties() bool { + p := strings.Split(o.Path, ".") + return len(p) > 1 && p[len(p)-1] == jsonProperties && p[len(p)-2] != jsonProperties +} + +func (o *objectValidator) isDefault() bool { + p := strings.Split(o.Path, ".") + return len(p) > 1 && p[len(p)-1] == jsonDefault && p[len(p)-2] != jsonDefault +} + +func (o *objectValidator) isExample() bool { + p := strings.Split(o.Path, ".") + return len(p) > 1 && (p[len(p)-1] == swaggerExample || p[len(p)-1] == swaggerExamples) && p[len(p)-2] != swaggerExample +} + +func (o *objectValidator) checkArrayMustHaveItems(res *Result, val map[string]interface{}) { + // for swagger 2.0 schemas, there is an additional constraint to have array items defined explicitly. + // with pure jsonschema draft 4, one may have arrays with undefined items (i.e. any type). + if t, typeFound := val[jsonType]; typeFound { + if tpe, ok := t.(string); ok && tpe == arrayType { + if item, itemsKeyFound := val[jsonItems]; !itemsKeyFound { + res.AddErrors(errors.Required(jsonItems, o.Path, item)) + } + } + } +} + +func (o *objectValidator) checkItemsMustBeTypeArray(res *Result, val map[string]interface{}) { + if !o.isProperties() && !o.isDefault() && !o.isExample() { + if _, itemsKeyFound := val[jsonItems]; itemsKeyFound { + t, typeFound := val[jsonType] + if typeFound { + if tpe, ok := t.(string); !ok || tpe != arrayType { + res.AddErrors(errors.InvalidType(o.Path, o.In, arrayType, nil)) + } + } else { + // there is no type + res.AddErrors(errors.Required(jsonType, o.Path, t)) + } + } + } +} + +func (o *objectValidator) precheck(res *Result, val map[string]interface{}) { + if o.Options.EnableArrayMustHaveItemsCheck { + o.checkArrayMustHaveItems(res, val) + } + if o.Options.EnableObjectArrayTypeCheck { + o.checkItemsMustBeTypeArray(res, val) + } +} + +func (o *objectValidator) Validate(data interface{}) *Result { + val := data.(map[string]interface{}) + // TODO: guard against nil data + numKeys := int64(len(val)) + + if o.MinProperties != nil && numKeys < *o.MinProperties { + return errorHelp.sErr(errors.TooFewProperties(o.Path, o.In, *o.MinProperties)) + } + if o.MaxProperties != nil && numKeys > *o.MaxProperties { + return errorHelp.sErr(errors.TooManyProperties(o.Path, o.In, *o.MaxProperties)) + } + + res := new(Result) + + o.precheck(res, val) + + // check validity of field names + if o.AdditionalProperties != nil && !o.AdditionalProperties.Allows { + // Case: additionalProperties: false + for k := range val { + _, regularProperty := o.Properties[k] + matched := false + + for pk := range o.PatternProperties { + if matches, _ := regexp.MatchString(pk, k); matches { + matched = true + break + } + } + + if !regularProperty && k != "$schema" && k != "id" && !matched { + // Special properties "$schema" and "id" are ignored + res.AddErrors(errors.PropertyNotAllowed(o.Path, o.In, k)) + + // BUG(fredbi): This section should move to a part dedicated to spec validation as + // it will conflict with regular schemas where a property "headers" is defined. + + // + // Croaks a more explicit message on top of the standard one + // on some recognized cases. + // + // NOTE: edge cases with invalid type assertion are simply ignored here. + // NOTE: prefix your messages here by "IMPORTANT!" so there are not filtered + // by higher level callers (the IMPORTANT! tag will be eventually + // removed). + if k == "headers" && val[k] != nil { + // $ref is forbidden in header + if headers, mapOk := val[k].(map[string]interface{}); mapOk { + for headerKey, headerBody := range headers { + if headerBody != nil { + if headerSchema, mapOfMapOk := headerBody.(map[string]interface{}); mapOfMapOk { + if _, found := headerSchema["$ref"]; found { + var msg string + if refString, stringOk := headerSchema["$ref"].(string); stringOk { + msg = strings.Join([]string{", one may not use $ref=\":", refString, "\""}, "") + } + res.AddErrors(refNotAllowedInHeaderMsg(o.Path, headerKey, msg)) + } + } + } + } + } + /* + case "$ref": + if val[k] != nil { + // TODO: check context of that ref: warn about siblings, check against invalid context + } + */ + } + } + } + } else { + // Cases: no additionalProperties (implying: true), or additionalProperties: true, or additionalProperties: { <> } + for key, value := range val { + _, regularProperty := o.Properties[key] + + // Validates property against "patternProperties" if applicable + // BUG(fredbi): succeededOnce is always false + + // NOTE: how about regular properties which do not match patternProperties? + matched, succeededOnce, _ := o.validatePatternProperty(key, value, res) + + if !(regularProperty || matched || succeededOnce) { + + // Cases: properties which are not regular properties and have not been matched by the PatternProperties validator + if o.AdditionalProperties != nil && o.AdditionalProperties.Schema != nil { + // AdditionalProperties as Schema + r := NewSchemaValidator(o.AdditionalProperties.Schema, o.Root, o.Path+"."+key, o.KnownFormats, o.Options.Options()...).Validate(value) + res.mergeForField(data.(map[string]interface{}), key, r) + } else if regularProperty && !(matched || succeededOnce) { + // TODO: this is dead code since regularProperty=false here + res.AddErrors(errors.FailedAllPatternProperties(o.Path, o.In, key)) + } + } + } + // Valid cases: additionalProperties: true or undefined + } + + createdFromDefaults := map[string]bool{} + + // Property types: + // - regular Property + for pName := range o.Properties { + pSchema := o.Properties[pName] // one instance per iteration + rName := pName + if o.Path != "" { + rName = o.Path + "." + pName + } + + // Recursively validates each property against its schema + if v, ok := val[pName]; ok { + r := NewSchemaValidator(&pSchema, o.Root, rName, o.KnownFormats, o.Options.Options()...).Validate(v) + res.mergeForField(data.(map[string]interface{}), pName, r) + } else if pSchema.Default != nil { + // If a default value is defined, creates the property from defaults + // NOTE: JSON schema does not enforce default values to be valid against schema. Swagger does. + createdFromDefaults[pName] = true + res.addPropertySchemata(data.(map[string]interface{}), pName, &pSchema) + } + } + + // Check required properties + if len(o.Required) > 0 { + for _, k := range o.Required { + if v, ok := val[k]; !ok && !createdFromDefaults[k] { + res.AddErrors(errors.Required(o.Path+"."+k, o.In, v)) + continue + } + } + } + + // Check patternProperties + // TODO: it looks like we have done that twice in many cases + for key, value := range val { + _, regularProperty := o.Properties[key] + matched, _ /*succeededOnce*/, patterns := o.validatePatternProperty(key, value, res) + if !regularProperty && (matched /*|| succeededOnce*/) { + for _, pName := range patterns { + if v, ok := o.PatternProperties[pName]; ok { + r := NewSchemaValidator(&v, o.Root, o.Path+"."+key, o.KnownFormats, o.Options.Options()...).Validate(value) + res.mergeForField(data.(map[string]interface{}), key, r) + } + } + } + } + return res +} + +// TODO: succeededOnce is not used anywhere +func (o *objectValidator) validatePatternProperty(key string, value interface{}, result *Result) (bool, bool, []string) { + matched := false + succeededOnce := false + var patterns []string + + for k, schema := range o.PatternProperties { + sch := schema + if match, _ := regexp.MatchString(k, key); match { + patterns = append(patterns, k) + matched = true + validator := NewSchemaValidator(&sch, o.Root, o.Path+"."+key, o.KnownFormats, o.Options.Options()...) + + res := validator.Validate(value) + result.Merge(res) + } + } + + // BUG(fredbi): can't get to here. Should remove dead code (commented out). + + // if succeededOnce { + // result.Inc() + // } + + return matched, succeededOnce, patterns +} diff --git a/vendor/github.com/go-openapi/validate/options.go b/vendor/github.com/go-openapi/validate/options.go new file mode 100644 index 00000000000..deeec2f2ecc --- /dev/null +++ b/vendor/github.com/go-openapi/validate/options.go @@ -0,0 +1,43 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package validate + +import "sync" + +// Opts specifies validation options for a SpecValidator. +// +// NOTE: other options might be needed, for example a go-swagger specific mode. +type Opts struct { + ContinueOnErrors bool // true: continue reporting errors, even if spec is invalid +} + +var ( + defaultOpts = Opts{ContinueOnErrors: false} // default is to stop validation on errors + defaultOptsMutex = &sync.Mutex{} +) + +// SetContinueOnErrors sets global default behavior regarding spec validation errors reporting. +// +// For extended error reporting, you most likely want to set it to true. +// For faster validation, it's better to give up early when a spec is detected as invalid: set it to false (this is the default). +// +// Setting this mode does NOT affect the validation status. +// +// NOTE: this method affects global defaults. It is not suitable for a concurrent usage. +func SetContinueOnErrors(c bool) { + defer defaultOptsMutex.Unlock() + defaultOptsMutex.Lock() + defaultOpts.ContinueOnErrors = c +} diff --git a/vendor/github.com/go-openapi/validate/result.go b/vendor/github.com/go-openapi/validate/result.go new file mode 100644 index 00000000000..8f5f935e5d1 --- /dev/null +++ b/vendor/github.com/go-openapi/validate/result.go @@ -0,0 +1,486 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package validate + +import ( + "fmt" + "reflect" + "strings" + + "github.com/go-openapi/errors" + "github.com/go-openapi/spec" +) + +// Result represents a validation result set, composed of +// errors and warnings. +// +// It is used to keep track of all detected errors and warnings during +// the validation of a specification. +// +// Matchcount is used to determine +// which errors are relevant in the case of AnyOf, OneOf +// schema validation. Results from the validation branch +// with most matches get eventually selected. +// +// TODO: keep path of key originating the error +type Result struct { + Errors []error + Warnings []error + MatchCount int + + // the object data + data interface{} + + // Schemata for the root object + rootObjectSchemata schemata + // Schemata for object fields + fieldSchemata []fieldSchemata + // Schemata for slice items + itemSchemata []itemSchemata + + cachedFieldSchemta map[FieldKey][]*spec.Schema + cachedItemSchemata map[ItemKey][]*spec.Schema +} + +// FieldKey is a pair of an object and a field, usable as a key for a map. +type FieldKey struct { + object reflect.Value // actually a map[string]interface{}, but the latter cannot be a key + field string +} + +// ItemKey is a pair of a slice and an index, usable as a key for a map. +type ItemKey struct { + slice reflect.Value // actually a []interface{}, but the latter cannot be a key + index int +} + +// NewFieldKey returns a pair of an object and field usable as a key of a map. +func NewFieldKey(obj map[string]interface{}, field string) FieldKey { + return FieldKey{object: reflect.ValueOf(obj), field: field} +} + +// Object returns the underlying object of this key. +func (fk *FieldKey) Object() map[string]interface{} { + return fk.object.Interface().(map[string]interface{}) +} + +// Field returns the underlying field of this key. +func (fk *FieldKey) Field() string { + return fk.field +} + +// NewItemKey returns a pair of a slice and index usable as a key of a map. +func NewItemKey(slice interface{}, i int) ItemKey { + return ItemKey{slice: reflect.ValueOf(slice), index: i} +} + +// Slice returns the underlying slice of this key. +func (ik *ItemKey) Slice() []interface{} { + return ik.slice.Interface().([]interface{}) +} + +// Index returns the underlying index of this key. +func (ik *ItemKey) Index() int { + return ik.index +} + +type fieldSchemata struct { + obj map[string]interface{} + field string + schemata schemata +} + +type itemSchemata struct { + slice reflect.Value + index int + schemata schemata +} + +// Merge merges this result with the other one(s), preserving match counts etc. +func (r *Result) Merge(others ...*Result) *Result { + for _, other := range others { + if other == nil { + continue + } + r.mergeWithoutRootSchemata(other) + r.rootObjectSchemata.Append(other.rootObjectSchemata) + } + return r +} + +// Data returns the original data object used for validation. Mutating this renders +// the result invalid. +func (r *Result) Data() interface{} { + return r.data +} + +// RootObjectSchemata returns the schemata which apply to the root object. +func (r *Result) RootObjectSchemata() []*spec.Schema { + return r.rootObjectSchemata.Slice() +} + +// FieldSchemata returns the schemata which apply to fields in objects. +// nolint: dupl +func (r *Result) FieldSchemata() map[FieldKey][]*spec.Schema { + if r.cachedFieldSchemta != nil { + return r.cachedFieldSchemta + } + + ret := make(map[FieldKey][]*spec.Schema, len(r.fieldSchemata)) + for _, fs := range r.fieldSchemata { + key := NewFieldKey(fs.obj, fs.field) + if fs.schemata.one != nil { + ret[key] = append(ret[key], fs.schemata.one) + } else if len(fs.schemata.multiple) > 0 { + ret[key] = append(ret[key], fs.schemata.multiple...) + } + } + r.cachedFieldSchemta = ret + return ret +} + +// ItemSchemata returns the schemata which apply to items in slices. +// nolint: dupl +func (r *Result) ItemSchemata() map[ItemKey][]*spec.Schema { + if r.cachedItemSchemata != nil { + return r.cachedItemSchemata + } + + ret := make(map[ItemKey][]*spec.Schema, len(r.itemSchemata)) + for _, ss := range r.itemSchemata { + key := NewItemKey(ss.slice, ss.index) + if ss.schemata.one != nil { + ret[key] = append(ret[key], ss.schemata.one) + } else if len(ss.schemata.multiple) > 0 { + ret[key] = append(ret[key], ss.schemata.multiple...) + } + } + r.cachedItemSchemata = ret + return ret +} + +func (r *Result) resetCaches() { + r.cachedFieldSchemta = nil + r.cachedItemSchemata = nil +} + +// mergeForField merges other into r, assigning other's root schemata to the given Object and field name. +// nolint: unparam +func (r *Result) mergeForField(obj map[string]interface{}, field string, other *Result) *Result { + if other == nil { + return r + } + r.mergeWithoutRootSchemata(other) + + if other.rootObjectSchemata.Len() > 0 { + if r.fieldSchemata == nil { + r.fieldSchemata = make([]fieldSchemata, len(obj)) + } + r.fieldSchemata = append(r.fieldSchemata, fieldSchemata{ + obj: obj, + field: field, + schemata: other.rootObjectSchemata, + }) + } + + return r +} + +// mergeForSlice merges other into r, assigning other's root schemata to the given slice and index. +// nolint: unparam +func (r *Result) mergeForSlice(slice reflect.Value, i int, other *Result) *Result { + if other == nil { + return r + } + r.mergeWithoutRootSchemata(other) + + if other.rootObjectSchemata.Len() > 0 { + if r.itemSchemata == nil { + r.itemSchemata = make([]itemSchemata, slice.Len()) + } + r.itemSchemata = append(r.itemSchemata, itemSchemata{ + slice: slice, + index: i, + schemata: other.rootObjectSchemata, + }) + } + + return r +} + +// addRootObjectSchemata adds the given schemata for the root object of the result. +// The slice schemata might be reused. I.e. do not modify it after being added to a result. +func (r *Result) addRootObjectSchemata(s *spec.Schema) { + r.rootObjectSchemata.Append(schemata{one: s}) +} + +// addPropertySchemata adds the given schemata for the object and field. +// The slice schemata might be reused. I.e. do not modify it after being added to a result. +func (r *Result) addPropertySchemata(obj map[string]interface{}, fld string, schema *spec.Schema) { + if r.fieldSchemata == nil { + r.fieldSchemata = make([]fieldSchemata, 0, len(obj)) + } + r.fieldSchemata = append(r.fieldSchemata, fieldSchemata{obj: obj, field: fld, schemata: schemata{one: schema}}) +} + +/* +// addSliceSchemata adds the given schemata for the slice and index. +// The slice schemata might be reused. I.e. do not modify it after being added to a result. +func (r *Result) addSliceSchemata(slice reflect.Value, i int, schema *spec.Schema) { + if r.itemSchemata == nil { + r.itemSchemata = make([]itemSchemata, 0, slice.Len()) + } + r.itemSchemata = append(r.itemSchemata, itemSchemata{slice: slice, index: i, schemata: schemata{one: schema}}) +} +*/ + +// mergeWithoutRootSchemata merges other into r, ignoring the rootObject schemata. +func (r *Result) mergeWithoutRootSchemata(other *Result) { + r.resetCaches() + r.AddErrors(other.Errors...) + r.AddWarnings(other.Warnings...) + r.MatchCount += other.MatchCount + + if other.fieldSchemata != nil { + if r.fieldSchemata == nil { + r.fieldSchemata = other.fieldSchemata + } else { + r.fieldSchemata = append(r.fieldSchemata, other.fieldSchemata...) + } + } + + if other.itemSchemata != nil { + if r.itemSchemata == nil { + r.itemSchemata = other.itemSchemata + } else { + r.itemSchemata = append(r.itemSchemata, other.itemSchemata...) + } + } +} + +// MergeAsErrors merges this result with the other one(s), preserving match counts etc. +// +// Warnings from input are merged as Errors in the returned merged Result. +func (r *Result) MergeAsErrors(others ...*Result) *Result { + for _, other := range others { + if other != nil { + r.resetCaches() + r.AddErrors(other.Errors...) + r.AddErrors(other.Warnings...) + r.MatchCount += other.MatchCount + } + } + return r +} + +// MergeAsWarnings merges this result with the other one(s), preserving match counts etc. +// +// Errors from input are merged as Warnings in the returned merged Result. +func (r *Result) MergeAsWarnings(others ...*Result) *Result { + for _, other := range others { + if other != nil { + r.resetCaches() + r.AddWarnings(other.Errors...) + r.AddWarnings(other.Warnings...) + r.MatchCount += other.MatchCount + } + } + return r +} + +// AddErrors adds errors to this validation result (if not already reported). +// +// Since the same check may be passed several times while exploring the +// spec structure (via $ref, ...) reported messages are kept +// unique. +func (r *Result) AddErrors(errors ...error) { + for _, e := range errors { + found := false + if e != nil { + for _, isReported := range r.Errors { + if e.Error() == isReported.Error() { + found = true + break + } + } + if !found { + r.Errors = append(r.Errors, e) + } + } + } +} + +// AddWarnings adds warnings to this validation result (if not already reported). +func (r *Result) AddWarnings(warnings ...error) { + for _, e := range warnings { + found := false + if e != nil { + for _, isReported := range r.Warnings { + if e.Error() == isReported.Error() { + found = true + break + } + } + if !found { + r.Warnings = append(r.Warnings, e) + } + } + } +} + +func (r *Result) keepRelevantErrors() *Result { + // TODO: this one is going to disapear... + // keepRelevantErrors strips a result from standard errors and keeps + // the ones which are supposedly more accurate. + // + // The original result remains unaffected (creates a new instance of Result). + // This method is used to work around the "matchCount" filter which would otherwise + // strip our result from some accurate error reporting from lower level validators. + // + // NOTE: this implementation with a placeholder (IMPORTANT!) is neither clean nor + // very efficient. On the other hand, relying on go-openapi/errors to manipulate + // codes would require to change a lot here. So, for the moment, let's go with + // placeholders. + strippedErrors := []error{} + for _, e := range r.Errors { + if strings.HasPrefix(e.Error(), "IMPORTANT!") { + strippedErrors = append(strippedErrors, fmt.Errorf(strings.TrimPrefix(e.Error(), "IMPORTANT!"))) + } + } + strippedWarnings := []error{} + for _, e := range r.Warnings { + if strings.HasPrefix(e.Error(), "IMPORTANT!") { + strippedWarnings = append(strippedWarnings, fmt.Errorf(strings.TrimPrefix(e.Error(), "IMPORTANT!"))) + } + } + strippedResult := new(Result) + strippedResult.Errors = strippedErrors + strippedResult.Warnings = strippedWarnings + return strippedResult +} + +// IsValid returns true when this result is valid. +// +// Returns true on a nil *Result. +func (r *Result) IsValid() bool { + if r == nil { + return true + } + return len(r.Errors) == 0 +} + +// HasErrors returns true when this result is invalid. +// +// Returns false on a nil *Result. +func (r *Result) HasErrors() bool { + if r == nil { + return false + } + return !r.IsValid() +} + +// HasWarnings returns true when this result contains warnings. +// +// Returns false on a nil *Result. +func (r *Result) HasWarnings() bool { + if r == nil { + return false + } + return len(r.Warnings) > 0 +} + +// HasErrorsOrWarnings returns true when this result contains +// either errors or warnings. +// +// Returns false on a nil *Result. +func (r *Result) HasErrorsOrWarnings() bool { + if r == nil { + return false + } + return len(r.Errors) > 0 || len(r.Warnings) > 0 +} + +// Inc increments the match count +func (r *Result) Inc() { + r.MatchCount++ +} + +// AsError renders this result as an error interface +// +// TODO: reporting / pretty print with path ordered and indented +func (r *Result) AsError() error { + if r.IsValid() { + return nil + } + return errors.CompositeValidationError(r.Errors...) +} + +// schemata is an arbitrary number of schemata. It does a distinction between zero, +// one and many schemata to avoid slice allocations. +type schemata struct { + // one is set if there is exactly one schema. In that case multiple must be nil. + one *spec.Schema + // multiple is an arbitrary number of schemas. If it is set, one must be nil. + multiple []*spec.Schema +} + +func (s *schemata) Len() int { + if s.one != nil { + return 1 + } + return len(s.multiple) +} + +func (s *schemata) Slice() []*spec.Schema { + if s == nil { + return nil + } + if s.one != nil { + return []*spec.Schema{s.one} + } + return s.multiple +} + +// appendSchemata appends the schemata in other to s. It mutated s in-place. +func (s *schemata) Append(other schemata) { + if other.one == nil && len(other.multiple) == 0 { + return + } + if s.one == nil && len(s.multiple) == 0 { + *s = other + return + } + + if s.one != nil { + if other.one != nil { + s.multiple = []*spec.Schema{s.one, other.one} + } else { + t := make([]*spec.Schema, 0, 1+len(other.multiple)) + s.multiple = append(append(t, s.one), other.multiple...) + } + s.one = nil + } else { + if other.one != nil { + s.multiple = append(s.multiple, other.one) + } else { + if cap(s.multiple) >= len(s.multiple)+len(other.multiple) { + s.multiple = append(s.multiple, other.multiple...) + } else { + t := make([]*spec.Schema, 0, len(s.multiple)+len(other.multiple)) + s.multiple = append(append(t, s.multiple...), other.multiple...) + } + } + } +} diff --git a/vendor/github.com/go-openapi/validate/rexp.go b/vendor/github.com/go-openapi/validate/rexp.go new file mode 100644 index 00000000000..76de03e1f41 --- /dev/null +++ b/vendor/github.com/go-openapi/validate/rexp.go @@ -0,0 +1,71 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package validate + +import ( + re "regexp" + "sync" + "sync/atomic" +) + +// Cache for compiled regular expressions +var ( + cacheMutex = &sync.Mutex{} + reDict = atomic.Value{} // map[string]*re.Regexp +) + +func compileRegexp(pattern string) (*re.Regexp, error) { + if cache, ok := reDict.Load().(map[string]*re.Regexp); ok { + if r := cache[pattern]; r != nil { + return r, nil + } + } + + r, err := re.Compile(pattern) + if err != nil { + return nil, err + } + cacheRegexp(r) + return r, nil +} + +func mustCompileRegexp(pattern string) *re.Regexp { + if cache, ok := reDict.Load().(map[string]*re.Regexp); ok { + if r := cache[pattern]; r != nil { + return r + } + } + + r := re.MustCompile(pattern) + cacheRegexp(r) + return r +} + +func cacheRegexp(r *re.Regexp) { + cacheMutex.Lock() + defer cacheMutex.Unlock() + + if cache, ok := reDict.Load().(map[string]*re.Regexp); !ok || cache[r.String()] == nil { + newCache := map[string]*re.Regexp{ + r.String(): r, + } + + for k, v := range cache { + newCache[k] = v + } + + reDict.Store(newCache) + } +} diff --git a/vendor/github.com/go-openapi/validate/schema.go b/vendor/github.com/go-openapi/validate/schema.go new file mode 100644 index 00000000000..b817eb0ef30 --- /dev/null +++ b/vendor/github.com/go-openapi/validate/schema.go @@ -0,0 +1,260 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package validate + +import ( + "encoding/json" + "reflect" + + "github.com/go-openapi/errors" + "github.com/go-openapi/spec" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +var ( + specSchemaType = reflect.TypeOf(&spec.Schema{}) + specParameterType = reflect.TypeOf(&spec.Parameter{}) + specHeaderType = reflect.TypeOf(&spec.Header{}) + // specItemsType = reflect.TypeOf(&spec.Items{}) +) + +// SchemaValidator validates data against a JSON schema +type SchemaValidator struct { + Path string + in string + Schema *spec.Schema + validators []valueValidator + Root interface{} + KnownFormats strfmt.Registry + Options SchemaValidatorOptions +} + +// AgainstSchema validates the specified data against the provided schema, using a registry of supported formats. +// +// When no pre-parsed *spec.Schema structure is provided, it uses a JSON schema as default. See example. +func AgainstSchema(schema *spec.Schema, data interface{}, formats strfmt.Registry, options ...Option) error { + res := NewSchemaValidator(schema, nil, "", formats, options...).Validate(data) + if res.HasErrors() { + return errors.CompositeValidationError(res.Errors...) + } + return nil +} + +// NewSchemaValidator creates a new schema validator. +// +// Panics if the provided schema is invalid. +func NewSchemaValidator(schema *spec.Schema, rootSchema interface{}, root string, formats strfmt.Registry, options ...Option) *SchemaValidator { + if schema == nil { + return nil + } + + if rootSchema == nil { + rootSchema = schema + } + + if schema.ID != "" || schema.Ref.String() != "" || schema.Ref.IsRoot() { + err := spec.ExpandSchema(schema, rootSchema, nil) + if err != nil { + msg := invalidSchemaProvidedMsg(err).Error() + panic(msg) + } + } + s := SchemaValidator{ + Path: root, + in: "body", + Schema: schema, + Root: rootSchema, + KnownFormats: formats, + Options: SchemaValidatorOptions{}} + for _, o := range options { + o(&s.Options) + } + s.validators = []valueValidator{ + s.typeValidator(), + s.schemaPropsValidator(), + s.stringValidator(), + s.formatValidator(), + s.numberValidator(), + s.sliceValidator(), + s.commonValidator(), + s.objectValidator(), + } + return &s +} + +// SetPath sets the path for this schema valdiator +func (s *SchemaValidator) SetPath(path string) { + s.Path = path +} + +// Applies returns true when this schema validator applies +func (s *SchemaValidator) Applies(source interface{}, kind reflect.Kind) bool { + _, ok := source.(*spec.Schema) + return ok +} + +// Validate validates the data against the schema +func (s *SchemaValidator) Validate(data interface{}) *Result { + result := &Result{data: data} + if s == nil { + return result + } + if s.Schema != nil { + result.addRootObjectSchemata(s.Schema) + } + + if data == nil { + result.Merge(s.validators[0].Validate(data)) // type validator + result.Merge(s.validators[6].Validate(data)) // common validator + return result + } + + tpe := reflect.TypeOf(data) + kind := tpe.Kind() + for kind == reflect.Ptr { + tpe = tpe.Elem() + kind = tpe.Kind() + } + d := data + + if kind == reflect.Struct { + // NOTE: since reflect retrieves the true nature of types + // this means that all strfmt types passed here (e.g. strfmt.Datetime, etc..) + // are converted here to strings, and structs are systematically converted + // to map[string]interface{}. + d = swag.ToDynamicJSON(data) + } + + // TODO: this part should be handed over to type validator + // Handle special case of json.Number data (number marshalled as string) + isnumber := s.Schema.Type.Contains(numberType) || s.Schema.Type.Contains(integerType) + if num, ok := data.(json.Number); ok && isnumber { + if s.Schema.Type.Contains(integerType) { // avoid lossy conversion + in, erri := num.Int64() + if erri != nil { + result.AddErrors(invalidTypeConversionMsg(s.Path, erri)) + result.Inc() + return result + } + d = in + } else { + nf, errf := num.Float64() + if errf != nil { + result.AddErrors(invalidTypeConversionMsg(s.Path, errf)) + result.Inc() + return result + } + d = nf + } + + tpe = reflect.TypeOf(d) + kind = tpe.Kind() + } + + for _, v := range s.validators { + if !v.Applies(s.Schema, kind) { + debugLog("%T does not apply for %v", v, kind) + continue + } + + err := v.Validate(d) + result.Merge(err) + result.Inc() + } + result.Inc() + + return result +} + +func (s *SchemaValidator) typeValidator() valueValidator { + return &typeValidator{Type: s.Schema.Type, Nullable: s.Schema.Nullable, Format: s.Schema.Format, In: s.in, Path: s.Path} +} + +func (s *SchemaValidator) commonValidator() valueValidator { + return &basicCommonValidator{ + Path: s.Path, + In: s.in, + Enum: s.Schema.Enum, + } +} + +func (s *SchemaValidator) sliceValidator() valueValidator { + return &schemaSliceValidator{ + Path: s.Path, + In: s.in, + MaxItems: s.Schema.MaxItems, + MinItems: s.Schema.MinItems, + UniqueItems: s.Schema.UniqueItems, + AdditionalItems: s.Schema.AdditionalItems, + Items: s.Schema.Items, + Root: s.Root, + KnownFormats: s.KnownFormats, + Options: s.Options, + } +} + +func (s *SchemaValidator) numberValidator() valueValidator { + return &numberValidator{ + Path: s.Path, + In: s.in, + Default: s.Schema.Default, + MultipleOf: s.Schema.MultipleOf, + Maximum: s.Schema.Maximum, + ExclusiveMaximum: s.Schema.ExclusiveMaximum, + Minimum: s.Schema.Minimum, + ExclusiveMinimum: s.Schema.ExclusiveMinimum, + } +} + +func (s *SchemaValidator) stringValidator() valueValidator { + return &stringValidator{ + Path: s.Path, + In: s.in, + MaxLength: s.Schema.MaxLength, + MinLength: s.Schema.MinLength, + Pattern: s.Schema.Pattern, + } +} + +func (s *SchemaValidator) formatValidator() valueValidator { + return &formatValidator{ + Path: s.Path, + In: s.in, + Format: s.Schema.Format, + KnownFormats: s.KnownFormats, + } +} + +func (s *SchemaValidator) schemaPropsValidator() valueValidator { + sch := s.Schema + return newSchemaPropsValidator(s.Path, s.in, sch.AllOf, sch.OneOf, sch.AnyOf, sch.Not, sch.Dependencies, s.Root, s.KnownFormats, s.Options.Options()...) +} + +func (s *SchemaValidator) objectValidator() valueValidator { + return &objectValidator{ + Path: s.Path, + In: s.in, + MaxProperties: s.Schema.MaxProperties, + MinProperties: s.Schema.MinProperties, + Required: s.Schema.Required, + Properties: s.Schema.Properties, + AdditionalProperties: s.Schema.AdditionalProperties, + PatternProperties: s.Schema.PatternProperties, + Root: s.Root, + KnownFormats: s.KnownFormats, + Options: s.Options, + } +} diff --git a/vendor/github.com/go-openapi/validate/schema_messages.go b/vendor/github.com/go-openapi/validate/schema_messages.go new file mode 100644 index 00000000000..786e2e3554e --- /dev/null +++ b/vendor/github.com/go-openapi/validate/schema_messages.go @@ -0,0 +1,78 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package validate + +import ( + "github.com/go-openapi/errors" +) + +// Error messages related to schema validation and returned as results. +const ( + // ArrayDoesNotAllowAdditionalItemsError when an additionalItems construct is not verified by the array values provided. + // + // TODO: should move to package go-openapi/errors + ArrayDoesNotAllowAdditionalItemsError = "array doesn't allow for additional items" + + // HasDependencyError indicates that a dependencies construct was not verified + HasDependencyError = "%q has a dependency on %s" + + // InvalidSchemaProvidedError indicates that the schema provided to validate a value cannot be properly compiled + InvalidSchemaProvidedError = "Invalid schema provided to SchemaValidator: %v" + + // InvalidTypeConversionError indicates that a numerical conversion for the given type could not be carried on + InvalidTypeConversionError = "invalid type conversion in %s: %v " + + // MustValidateAtLeastOneSchemaError indicates that in a AnyOf construct, none of the schema constraints specified were verified + MustValidateAtLeastOneSchemaError = "%q must validate at least one schema (anyOf)" + + // MustValidateOnlyOneSchemaError indicates that in a OneOf construct, either none of the schema constraints specified were verified, or several were + MustValidateOnlyOneSchemaError = "%q must validate one and only one schema (oneOf). %s" + + // MustValidateAllSchemasError indicates that in a AllOf construct, at least one of the schema constraints specified were not verified + // + // TODO: punctuation in message + MustValidateAllSchemasError = "%q must validate all the schemas (allOf)%s" + + // MustNotValidateSchemaError indicates that in a Not construct, the schema constraint specified was verified + MustNotValidateSchemaError = "%q must not validate the schema (not)" +) + +// Warning messages related to schema validation and returned as results +const () + +func invalidSchemaProvidedMsg(err error) errors.Error { + return errors.New(InternalErrorCode, InvalidSchemaProvidedError, err) +} +func invalidTypeConversionMsg(path string, err error) errors.Error { + return errors.New(errors.CompositeErrorCode, InvalidTypeConversionError, path, err) +} +func mustValidateOnlyOneSchemaMsg(path, additionalMsg string) errors.Error { + return errors.New(errors.CompositeErrorCode, MustValidateOnlyOneSchemaError, path, additionalMsg) +} +func mustValidateAtLeastOneSchemaMsg(path string) errors.Error { + return errors.New(errors.CompositeErrorCode, MustValidateAtLeastOneSchemaError, path) +} +func mustValidateAllSchemasMsg(path, additionalMsg string) errors.Error { + return errors.New(errors.CompositeErrorCode, MustValidateAllSchemasError, path, additionalMsg) +} +func mustNotValidatechemaMsg(path string) errors.Error { + return errors.New(errors.CompositeErrorCode, MustNotValidateSchemaError, path) +} +func hasADependencyMsg(path, depkey string) errors.Error { + return errors.New(errors.CompositeErrorCode, HasDependencyError, path, depkey) +} +func arrayDoesNotAllowAdditionalItemsMsg() errors.Error { + return errors.New(errors.CompositeErrorCode, ArrayDoesNotAllowAdditionalItemsError) +} diff --git a/vendor/github.com/go-openapi/validate/schema_option.go b/vendor/github.com/go-openapi/validate/schema_option.go new file mode 100644 index 00000000000..4b4879de8b1 --- /dev/null +++ b/vendor/github.com/go-openapi/validate/schema_option.go @@ -0,0 +1,54 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package validate + +// SchemaValidatorOptions defines optional rules for schema validation +type SchemaValidatorOptions struct { + EnableObjectArrayTypeCheck bool + EnableArrayMustHaveItemsCheck bool +} + +// Option sets optional rules for schema validation +type Option func(*SchemaValidatorOptions) + +// EnableObjectArrayTypeCheck activates the swagger rule: an items must be in type: array +func EnableObjectArrayTypeCheck(enable bool) Option { + return func(svo *SchemaValidatorOptions) { + svo.EnableObjectArrayTypeCheck = enable + } +} + +// EnableArrayMustHaveItemsCheck activates the swagger rule: an array must have items defined +func EnableArrayMustHaveItemsCheck(enable bool) Option { + return func(svo *SchemaValidatorOptions) { + svo.EnableArrayMustHaveItemsCheck = enable + } +} + +// SwaggerSchema activates swagger schema validation rules +func SwaggerSchema(enable bool) Option { + return func(svo *SchemaValidatorOptions) { + svo.EnableObjectArrayTypeCheck = enable + svo.EnableArrayMustHaveItemsCheck = enable + } +} + +// Options returns current options +func (svo SchemaValidatorOptions) Options() []Option { + return []Option{ + EnableObjectArrayTypeCheck(svo.EnableObjectArrayTypeCheck), + EnableArrayMustHaveItemsCheck(svo.EnableArrayMustHaveItemsCheck), + } +} diff --git a/vendor/github.com/go-openapi/validate/schema_props.go b/vendor/github.com/go-openapi/validate/schema_props.go new file mode 100644 index 00000000000..1f6950788e6 --- /dev/null +++ b/vendor/github.com/go-openapi/validate/schema_props.go @@ -0,0 +1,240 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package validate + +import ( + "fmt" + "reflect" + + "github.com/go-openapi/spec" + "github.com/go-openapi/strfmt" +) + +type schemaPropsValidator struct { + Path string + In string + AllOf []spec.Schema + OneOf []spec.Schema + AnyOf []spec.Schema + Not *spec.Schema + Dependencies spec.Dependencies + anyOfValidators []SchemaValidator + allOfValidators []SchemaValidator + oneOfValidators []SchemaValidator + notValidator *SchemaValidator + Root interface{} + KnownFormats strfmt.Registry + Options SchemaValidatorOptions +} + +func (s *schemaPropsValidator) SetPath(path string) { + s.Path = path +} + +func newSchemaPropsValidator(path string, in string, allOf, oneOf, anyOf []spec.Schema, not *spec.Schema, deps spec.Dependencies, root interface{}, formats strfmt.Registry, options ...Option) *schemaPropsValidator { + anyValidators := make([]SchemaValidator, 0, len(anyOf)) + for _, v := range anyOf { + v := v + anyValidators = append(anyValidators, *NewSchemaValidator(&v, root, path, formats, options...)) + } + allValidators := make([]SchemaValidator, 0, len(allOf)) + for _, v := range allOf { + v := v + allValidators = append(allValidators, *NewSchemaValidator(&v, root, path, formats, options...)) + } + oneValidators := make([]SchemaValidator, 0, len(oneOf)) + for _, v := range oneOf { + v := v + oneValidators = append(oneValidators, *NewSchemaValidator(&v, root, path, formats, options...)) + } + + var notValidator *SchemaValidator + if not != nil { + notValidator = NewSchemaValidator(not, root, path, formats, options...) + } + + schOptions := &SchemaValidatorOptions{} + for _, o := range options { + o(schOptions) + } + return &schemaPropsValidator{ + Path: path, + In: in, + AllOf: allOf, + OneOf: oneOf, + AnyOf: anyOf, + Not: not, + Dependencies: deps, + anyOfValidators: anyValidators, + allOfValidators: allValidators, + oneOfValidators: oneValidators, + notValidator: notValidator, + Root: root, + KnownFormats: formats, + Options: *schOptions, + } +} + +func (s *schemaPropsValidator) Applies(source interface{}, kind reflect.Kind) bool { + r := reflect.TypeOf(source) == specSchemaType + debugLog("schema props validator for %q applies %t for %T (kind: %v)\n", s.Path, r, source, kind) + return r +} + +func (s *schemaPropsValidator) Validate(data interface{}) *Result { + mainResult := new(Result) + + // Intermediary error results + + // IMPORTANT! messages from underlying validators + keepResultAnyOf := new(Result) + keepResultOneOf := new(Result) + keepResultAllOf := new(Result) + + // Validates at least one in anyOf schemas + var firstSuccess *Result + if len(s.anyOfValidators) > 0 { + var bestFailures *Result + succeededOnce := false + for _, anyOfSchema := range s.anyOfValidators { + result := anyOfSchema.Validate(data) + // We keep inner IMPORTANT! errors no matter what MatchCount tells us + keepResultAnyOf.Merge(result.keepRelevantErrors()) + if result.IsValid() { + bestFailures = nil + succeededOnce = true + if firstSuccess == nil { + firstSuccess = result + } + keepResultAnyOf = new(Result) + break + } + // MatchCount is used to select errors from the schema with most positive checks + if bestFailures == nil || result.MatchCount > bestFailures.MatchCount { + bestFailures = result + } + } + + if !succeededOnce { + mainResult.AddErrors(mustValidateAtLeastOneSchemaMsg(s.Path)) + } + if bestFailures != nil { + mainResult.Merge(bestFailures) + } else if firstSuccess != nil { + mainResult.Merge(firstSuccess) + } + } + + // Validates exactly one in oneOf schemas + if len(s.oneOfValidators) > 0 { + var bestFailures *Result + var firstSuccess *Result + validated := 0 + + for _, oneOfSchema := range s.oneOfValidators { + result := oneOfSchema.Validate(data) + // We keep inner IMPORTANT! errors no matter what MatchCount tells us + keepResultOneOf.Merge(result.keepRelevantErrors()) + if result.IsValid() { + validated++ + bestFailures = nil + if firstSuccess == nil { + firstSuccess = result + } + keepResultOneOf = new(Result) + continue + } + // MatchCount is used to select errors from the schema with most positive checks + if validated == 0 && (bestFailures == nil || result.MatchCount > bestFailures.MatchCount) { + bestFailures = result + } + } + + if validated != 1 { + additionalMsg := "" + if validated == 0 { + additionalMsg = "Found none valid" + } else { + additionalMsg = fmt.Sprintf("Found %d valid alternatives", validated) + } + + mainResult.AddErrors(mustValidateOnlyOneSchemaMsg(s.Path, additionalMsg)) + if bestFailures != nil { + mainResult.Merge(bestFailures) + } + } else if firstSuccess != nil { + mainResult.Merge(firstSuccess) + } + } + + // Validates all of allOf schemas + if len(s.allOfValidators) > 0 { + validated := 0 + + for _, allOfSchema := range s.allOfValidators { + result := allOfSchema.Validate(data) + // We keep inner IMPORTANT! errors no matter what MatchCount tells us + keepResultAllOf.Merge(result.keepRelevantErrors()) + // keepResultAllOf.Merge(result) + if result.IsValid() { + validated++ + } + mainResult.Merge(result) + } + + if validated != len(s.allOfValidators) { + additionalMsg := "" + if validated == 0 { + additionalMsg = ". None validated" + } + + mainResult.AddErrors(mustValidateAllSchemasMsg(s.Path, additionalMsg)) + } + } + + if s.notValidator != nil { + result := s.notValidator.Validate(data) + // We keep inner IMPORTANT! errors no matter what MatchCount tells us + if result.IsValid() { + mainResult.AddErrors(mustNotValidatechemaMsg(s.Path)) + } + } + + if s.Dependencies != nil && len(s.Dependencies) > 0 && reflect.TypeOf(data).Kind() == reflect.Map { + val := data.(map[string]interface{}) + for key := range val { + if dep, ok := s.Dependencies[key]; ok { + + if dep.Schema != nil { + mainResult.Merge(NewSchemaValidator(dep.Schema, s.Root, s.Path+"."+key, s.KnownFormats, s.Options.Options()...).Validate(data)) + continue + } + + if len(dep.Property) > 0 { + for _, depKey := range dep.Property { + if _, ok := val[depKey]; !ok { + mainResult.AddErrors(hasADependencyMsg(s.Path, depKey)) + } + } + } + } + } + } + + mainResult.Inc() + // In the end we retain best failures for schema validation + // plus, if any, composite errors which may explain special cases (tagged as IMPORTANT!). + return mainResult.Merge(keepResultAllOf, keepResultOneOf, keepResultAnyOf) +} diff --git a/vendor/github.com/go-openapi/validate/slice_validator.go b/vendor/github.com/go-openapi/validate/slice_validator.go new file mode 100644 index 00000000000..aa429f5184e --- /dev/null +++ b/vendor/github.com/go-openapi/validate/slice_validator.go @@ -0,0 +1,105 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package validate + +import ( + "fmt" + "reflect" + + "github.com/go-openapi/spec" + "github.com/go-openapi/strfmt" +) + +type schemaSliceValidator struct { + Path string + In string + MaxItems *int64 + MinItems *int64 + UniqueItems bool + AdditionalItems *spec.SchemaOrBool + Items *spec.SchemaOrArray + Root interface{} + KnownFormats strfmt.Registry + Options SchemaValidatorOptions +} + +func (s *schemaSliceValidator) SetPath(path string) { + s.Path = path +} + +func (s *schemaSliceValidator) Applies(source interface{}, kind reflect.Kind) bool { + _, ok := source.(*spec.Schema) + r := ok && kind == reflect.Slice + return r +} + +func (s *schemaSliceValidator) Validate(data interface{}) *Result { + result := new(Result) + if data == nil { + return result + } + val := reflect.ValueOf(data) + size := val.Len() + + if s.Items != nil && s.Items.Schema != nil { + validator := NewSchemaValidator(s.Items.Schema, s.Root, s.Path, s.KnownFormats, s.Options.Options()...) + for i := 0; i < size; i++ { + validator.SetPath(fmt.Sprintf("%s.%d", s.Path, i)) + value := val.Index(i) + result.mergeForSlice(val, i, validator.Validate(value.Interface())) + } + } + + itemsSize := 0 + if s.Items != nil && len(s.Items.Schemas) > 0 { + itemsSize = len(s.Items.Schemas) + for i := 0; i < itemsSize; i++ { + validator := NewSchemaValidator(&s.Items.Schemas[i], s.Root, fmt.Sprintf("%s.%d", s.Path, i), s.KnownFormats, s.Options.Options()...) + if val.Len() <= i { + break + } + result.mergeForSlice(val, i, validator.Validate(val.Index(i).Interface())) + } + } + if s.AdditionalItems != nil && itemsSize < size { + if s.Items != nil && len(s.Items.Schemas) > 0 && !s.AdditionalItems.Allows { + result.AddErrors(arrayDoesNotAllowAdditionalItemsMsg()) + } + if s.AdditionalItems.Schema != nil { + for i := itemsSize; i < size-itemsSize+1; i++ { + validator := NewSchemaValidator(s.AdditionalItems.Schema, s.Root, fmt.Sprintf("%s.%d", s.Path, i), s.KnownFormats, s.Options.Options()...) + result.mergeForSlice(val, i, validator.Validate(val.Index(i).Interface())) + } + } + } + + if s.MinItems != nil { + if err := MinItems(s.Path, s.In, int64(size), *s.MinItems); err != nil { + result.AddErrors(err) + } + } + if s.MaxItems != nil { + if err := MaxItems(s.Path, s.In, int64(size), *s.MaxItems); err != nil { + result.AddErrors(err) + } + } + if s.UniqueItems { + if err := UniqueItems(s.Path, s.In, val.Interface()); err != nil { + result.AddErrors(err) + } + } + result.Inc() + return result +} diff --git a/vendor/github.com/go-openapi/validate/spec.go b/vendor/github.com/go-openapi/validate/spec.go new file mode 100644 index 00000000000..cdf5627a2c8 --- /dev/null +++ b/vendor/github.com/go-openapi/validate/spec.go @@ -0,0 +1,795 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package validate + +import ( + "encoding/json" + "fmt" + "sort" + "strings" + + "github.com/go-openapi/analysis" + "github.com/go-openapi/errors" + "github.com/go-openapi/jsonpointer" + "github.com/go-openapi/loads" + "github.com/go-openapi/spec" + "github.com/go-openapi/strfmt" +) + +// Spec validates an OpenAPI 2.0 specification document. +// +// Returns an error flattening in a single standard error, all validation messages. +// +// - TODO: $ref should not have siblings +// - TODO: make sure documentation reflects all checks and warnings +// - TODO: check on discriminators +// - TODO: explicit message on unsupported keywords (better than "forbidden property"...) +// - TODO: full list of unresolved refs +// - TODO: validate numeric constraints (issue#581): this should be handled like defaults and examples +// - TODO: option to determine if we validate for go-swagger or in a more general context +// - TODO: check on required properties to support anyOf, allOf, oneOf +// +// NOTE: SecurityScopes are maps: no need to check uniqueness +// +func Spec(doc *loads.Document, formats strfmt.Registry) error { + errs, _ /*warns*/ := NewSpecValidator(doc.Schema(), formats).Validate(doc) + if errs.HasErrors() { + return errors.CompositeValidationError(errs.Errors...) + } + return nil +} + +// SpecValidator validates a swagger 2.0 spec +type SpecValidator struct { + schema *spec.Schema // swagger 2.0 schema + spec *loads.Document + analyzer *analysis.Spec + expanded *loads.Document + KnownFormats strfmt.Registry + Options Opts // validation options +} + +// NewSpecValidator creates a new swagger spec validator instance +func NewSpecValidator(schema *spec.Schema, formats strfmt.Registry) *SpecValidator { + return &SpecValidator{ + schema: schema, + KnownFormats: formats, + Options: defaultOpts, + } +} + +// Validate validates the swagger spec +func (s *SpecValidator) Validate(data interface{}) (*Result, *Result) { + var sd *loads.Document + errs, warnings := new(Result), new(Result) + + if v, ok := data.(*loads.Document); ok { + sd = v + } + if sd == nil { + errs.AddErrors(invalidDocumentMsg()) + return errs, warnings // no point in continuing + } + s.spec = sd + s.analyzer = analysis.New(sd.Spec()) + + // Swagger schema validator + schv := NewSchemaValidator(s.schema, nil, "", s.KnownFormats, SwaggerSchema(true)) + var obj interface{} + + // Raw spec unmarshalling errors + if err := json.Unmarshal(sd.Raw(), &obj); err != nil { + // NOTE: under normal conditions, the *load.Document has been already unmarshalled + // So this one is just a paranoid check on the behavior of the spec package + panic(InvalidDocumentError) + } + + defer func() { + // errs holds all errors and warnings, + // warnings only warnings + errs.MergeAsWarnings(warnings) + warnings.AddErrors(errs.Warnings...) + }() + + errs.Merge(schv.Validate(obj)) // error - + // There may be a point in continuing to try and determine more accurate errors + if !s.Options.ContinueOnErrors && errs.HasErrors() { + return errs, warnings // no point in continuing + } + + errs.Merge(s.validateReferencesValid()) // error - + // There may be a point in continuing to try and determine more accurate errors + if !s.Options.ContinueOnErrors && errs.HasErrors() { + return errs, warnings // no point in continuing + } + + errs.Merge(s.validateDuplicateOperationIDs()) + errs.Merge(s.validateDuplicatePropertyNames()) // error - + errs.Merge(s.validateParameters()) // error - + errs.Merge(s.validateItems()) // error - + + // Properties in required definition MUST validate their schema + // Properties SHOULD NOT be declared as both required and readOnly (warning) + errs.Merge(s.validateRequiredDefinitions()) // error and warning + + // There may be a point in continuing to try and determine more accurate errors + if !s.Options.ContinueOnErrors && errs.HasErrors() { + return errs, warnings // no point in continuing + } + + // Values provided as default MUST validate their schema + df := &defaultValidator{SpecValidator: s} + errs.Merge(df.Validate()) + + // Values provided as examples MUST validate their schema + // Value provided as examples in a response without schema generate a warning + // Known limitations: examples in responses for mime type not application/json are ignored (warning) + ex := &exampleValidator{SpecValidator: s} + errs.Merge(ex.Validate()) + + errs.Merge(s.validateNonEmptyPathParamNames()) + + // errs.Merge(s.validateRefNoSibling()) // warning only + errs.Merge(s.validateReferenced()) // warning only + + return errs, warnings +} + +func (s *SpecValidator) validateNonEmptyPathParamNames() *Result { + res := new(Result) + if s.spec.Spec().Paths == nil { + // There is no Paths object: error + res.AddErrors(noValidPathMsg()) + } else { + if s.spec.Spec().Paths.Paths == nil { + // Paths may be empty: warning + res.AddWarnings(noValidPathMsg()) + } else { + for k := range s.spec.Spec().Paths.Paths { + if strings.Contains(k, "{}") { + res.AddErrors(emptyPathParameterMsg(k)) + } + } + } + } + return res +} + +func (s *SpecValidator) validateDuplicateOperationIDs() *Result { + // OperationID, if specified, must be unique across the board + var analyzer *analysis.Spec + if s.expanded != nil { + // $ref are valid: we can analyze operations on an expanded spec + analyzer = analysis.New(s.expanded.Spec()) + } else { + // fallback on possible incomplete picture because of previous errors + analyzer = s.analyzer + } + res := new(Result) + known := make(map[string]int) + for _, v := range analyzer.OperationIDs() { + if v != "" { + known[v]++ + } + } + for k, v := range known { + if v > 1 { + res.AddErrors(nonUniqueOperationIDMsg(k, v)) + } + } + return res +} + +type dupProp struct { + Name string + Definition string +} + +func (s *SpecValidator) validateDuplicatePropertyNames() *Result { + // definition can't declare a property that's already defined by one of its ancestors + res := new(Result) + for k, sch := range s.spec.Spec().Definitions { + if len(sch.AllOf) == 0 { + continue + } + + knownanc := map[string]struct{}{ + "#/definitions/" + k: {}, + } + + ancs, rec := s.validateCircularAncestry(k, sch, knownanc) + if rec != nil && (rec.HasErrors() || !rec.HasWarnings()) { + res.Merge(rec) + } + if len(ancs) > 0 { + res.AddErrors(circularAncestryDefinitionMsg(k, ancs)) + return res + } + + knowns := make(map[string]struct{}) + dups, rep := s.validateSchemaPropertyNames(k, sch, knowns) + if rep != nil && (rep.HasErrors() || rep.HasWarnings()) { + res.Merge(rep) + } + if len(dups) > 0 { + var pns []string + for _, v := range dups { + pns = append(pns, v.Definition+"."+v.Name) + } + res.AddErrors(duplicatePropertiesMsg(k, pns)) + } + + } + return res +} + +func (s *SpecValidator) resolveRef(ref *spec.Ref) (*spec.Schema, error) { + if s.spec.SpecFilePath() != "" { + return spec.ResolveRefWithBase(s.spec.Spec(), ref, &spec.ExpandOptions{RelativeBase: s.spec.SpecFilePath()}) + } + // NOTE: it looks like with the new spec resolver, this code is now unrecheable + return spec.ResolveRef(s.spec.Spec(), ref) +} + +func (s *SpecValidator) validateSchemaPropertyNames(nm string, sch spec.Schema, knowns map[string]struct{}) ([]dupProp, *Result) { + var dups []dupProp + + schn := nm + schc := &sch + res := new(Result) + + for schc.Ref.String() != "" { + // gather property names + reso, err := s.resolveRef(&schc.Ref) + if err != nil { + errorHelp.addPointerError(res, err, schc.Ref.String(), nm) + return dups, res + } + schc = reso + schn = sch.Ref.String() + } + + if len(schc.AllOf) > 0 { + for _, chld := range schc.AllOf { + dup, rep := s.validateSchemaPropertyNames(schn, chld, knowns) + if rep != nil && (rep.HasErrors() || rep.HasWarnings()) { + res.Merge(rep) + } + dups = append(dups, dup...) + } + return dups, res + } + + for k := range schc.Properties { + _, ok := knowns[k] + if ok { + dups = append(dups, dupProp{Name: k, Definition: schn}) + } else { + knowns[k] = struct{}{} + } + } + + return dups, res +} + +func (s *SpecValidator) validateCircularAncestry(nm string, sch spec.Schema, knowns map[string]struct{}) ([]string, *Result) { + res := new(Result) + + if sch.Ref.String() == "" && len(sch.AllOf) == 0 { // Safeguard. We should not be able to actually get there + return nil, res + } + var ancs []string + + schn := nm + schc := &sch + + for schc.Ref.String() != "" { + reso, err := s.resolveRef(&schc.Ref) + if err != nil { + errorHelp.addPointerError(res, err, schc.Ref.String(), nm) + return ancs, res + } + schc = reso + schn = sch.Ref.String() + } + + if schn != nm && schn != "" { + if _, ok := knowns[schn]; ok { + ancs = append(ancs, schn) + } + knowns[schn] = struct{}{} + + if len(ancs) > 0 { + return ancs, res + } + } + + if len(schc.AllOf) > 0 { + for _, chld := range schc.AllOf { + if chld.Ref.String() != "" || len(chld.AllOf) > 0 { + anc, rec := s.validateCircularAncestry(schn, chld, knowns) + if rec != nil && (rec.HasErrors() || !rec.HasWarnings()) { + res.Merge(rec) + } + ancs = append(ancs, anc...) + if len(ancs) > 0 { + return ancs, res + } + } + } + } + return ancs, res +} + +func (s *SpecValidator) validateItems() *Result { + // validate parameter, items, schema and response objects for presence of item if type is array + res := new(Result) + + for method, pi := range s.analyzer.Operations() { + for path, op := range pi { + for _, param := range paramHelp.safeExpandedParamsFor(path, method, op.ID, res, s) { + + if param.TypeName() == arrayType && param.ItemsTypeName() == "" { + res.AddErrors(arrayInParamRequiresItemsMsg(param.Name, op.ID)) + continue + } + if param.In != swaggerBody { + if param.Items != nil { + items := param.Items + for items.TypeName() == arrayType { + if items.ItemsTypeName() == "" { + res.AddErrors(arrayInParamRequiresItemsMsg(param.Name, op.ID)) + break + } + items = items.Items + } + } + } else { + // In: body + if param.Schema != nil { + res.Merge(s.validateSchemaItems(*param.Schema, fmt.Sprintf("body param %q", param.Name), op.ID)) + } + } + } + + var responses []spec.Response + if op.Responses != nil { + if op.Responses.Default != nil { + responses = append(responses, *op.Responses.Default) + } + if op.Responses.StatusCodeResponses != nil { + for _, v := range op.Responses.StatusCodeResponses { + responses = append(responses, v) + } + } + } + + for _, resp := range responses { + // Response headers with array + for hn, hv := range resp.Headers { + if hv.TypeName() == arrayType && hv.ItemsTypeName() == "" { + res.AddErrors(arrayInHeaderRequiresItemsMsg(hn, op.ID)) + } + } + if resp.Schema != nil { + res.Merge(s.validateSchemaItems(*resp.Schema, "response body", op.ID)) + } + } + } + } + return res +} + +// Verifies constraints on array type +func (s *SpecValidator) validateSchemaItems(schema spec.Schema, prefix, opID string) *Result { + res := new(Result) + if !schema.Type.Contains(arrayType) { + return res + } + + if schema.Items == nil || schema.Items.Len() == 0 { + res.AddErrors(arrayRequiresItemsMsg(prefix, opID)) + return res + } + + if schema.Items.Schema != nil { + schema = *schema.Items.Schema + if _, err := compileRegexp(schema.Pattern); err != nil { + res.AddErrors(invalidItemsPatternMsg(prefix, opID, schema.Pattern)) + } + + res.Merge(s.validateSchemaItems(schema, prefix, opID)) + } + return res +} + +func (s *SpecValidator) validatePathParamPresence(path string, fromPath, fromOperation []string) *Result { + // Each defined operation path parameters must correspond to a named element in the API's path pattern. + // (For example, you cannot have a path parameter named id for the following path /pets/{petId} but you must have a path parameter named petId.) + res := new(Result) + for _, l := range fromPath { + var matched bool + for _, r := range fromOperation { + if l == "{"+r+"}" { + matched = true + break + } + } + if !matched { + res.AddErrors(noParameterInPathMsg(l)) + } + } + + for _, p := range fromOperation { + var matched bool + for _, r := range fromPath { + if "{"+p+"}" == r { + matched = true + break + } + } + if !matched { + res.AddErrors(pathParamNotInPathMsg(path, p)) + } + } + + return res +} + +func (s *SpecValidator) validateReferenced() *Result { + var res Result + res.MergeAsWarnings(s.validateReferencedParameters()) + res.MergeAsWarnings(s.validateReferencedResponses()) + res.MergeAsWarnings(s.validateReferencedDefinitions()) + return &res +} + +// nolint: dupl +func (s *SpecValidator) validateReferencedParameters() *Result { + // Each referenceable definition should have references. + params := s.spec.Spec().Parameters + if len(params) == 0 { + return nil + } + + expected := make(map[string]struct{}) + for k := range params { + expected["#/parameters/"+jsonpointer.Escape(k)] = struct{}{} + } + for _, k := range s.analyzer.AllParameterReferences() { + delete(expected, k) + } + + if len(expected) == 0 { + return nil + } + result := new(Result) + for k := range expected { + result.AddWarnings(unusedParamMsg(k)) + } + return result +} + +// nolint: dupl +func (s *SpecValidator) validateReferencedResponses() *Result { + // Each referenceable definition should have references. + responses := s.spec.Spec().Responses + if len(responses) == 0 { + return nil + } + + expected := make(map[string]struct{}) + for k := range responses { + expected["#/responses/"+jsonpointer.Escape(k)] = struct{}{} + } + for _, k := range s.analyzer.AllResponseReferences() { + delete(expected, k) + } + + if len(expected) == 0 { + return nil + } + result := new(Result) + for k := range expected { + result.AddWarnings(unusedResponseMsg(k)) + } + return result +} + +// nolint: dupl +func (s *SpecValidator) validateReferencedDefinitions() *Result { + // Each referenceable definition must have references. + defs := s.spec.Spec().Definitions + if len(defs) == 0 { + return nil + } + + expected := make(map[string]struct{}) + for k := range defs { + expected["#/definitions/"+jsonpointer.Escape(k)] = struct{}{} + } + for _, k := range s.analyzer.AllDefinitionReferences() { + delete(expected, k) + } + + if len(expected) == 0 { + return nil + } + + result := new(Result) + for k := range expected { + result.AddWarnings(unusedDefinitionMsg(k)) + } + return result +} + +func (s *SpecValidator) validateRequiredDefinitions() *Result { + // Each property listed in the required array must be defined in the properties of the model + res := new(Result) + +DEFINITIONS: + for d, schema := range s.spec.Spec().Definitions { + if schema.Required != nil { // Safeguard + for _, pn := range schema.Required { + red := s.validateRequiredProperties(pn, d, &schema) //#nosec + res.Merge(red) + if !red.IsValid() && !s.Options.ContinueOnErrors { + break DEFINITIONS // there is an error, let's stop that bleeding + } + } + } + } + return res +} + +func (s *SpecValidator) validateRequiredProperties(path, in string, v *spec.Schema) *Result { + // Takes care of recursive property definitions, which may be nested in additionalProperties schemas + res := new(Result) + propertyMatch := false + patternMatch := false + additionalPropertiesMatch := false + isReadOnly := false + + // Regular properties + if _, ok := v.Properties[path]; ok { + propertyMatch = true + isReadOnly = v.Properties[path].ReadOnly + } + + // NOTE: patternProperties are not supported in swagger. Even though, we continue validation here + // We check all defined patterns: if one regexp is invalid, croaks an error + for pp, pv := range v.PatternProperties { + re, err := compileRegexp(pp) + if err != nil { + res.AddErrors(invalidPatternMsg(pp, in)) + } else if re.MatchString(path) { + patternMatch = true + if !propertyMatch { + isReadOnly = pv.ReadOnly + } + } + } + + if !(propertyMatch || patternMatch) { + if v.AdditionalProperties != nil { + if v.AdditionalProperties.Allows && v.AdditionalProperties.Schema == nil { + additionalPropertiesMatch = true + } else if v.AdditionalProperties.Schema != nil { + // additionalProperties as schema are upported in swagger + // recursively validates additionalProperties schema + // TODO : anyOf, allOf, oneOf like in schemaPropsValidator + red := s.validateRequiredProperties(path, in, v.AdditionalProperties.Schema) + if red.IsValid() { + additionalPropertiesMatch = true + if !propertyMatch && !patternMatch { + isReadOnly = v.AdditionalProperties.Schema.ReadOnly + } + } + res.Merge(red) + } + } + } + + if !(propertyMatch || patternMatch || additionalPropertiesMatch) { + res.AddErrors(requiredButNotDefinedMsg(path, in)) + } + + if isReadOnly { + res.AddWarnings(readOnlyAndRequiredMsg(in, path)) + } + return res +} + +func (s *SpecValidator) validateParameters() *Result { + // - for each method, path is unique, regardless of path parameters + // e.g. GET:/petstore/{id}, GET:/petstore/{pet}, GET:/petstore are + // considered duplicate paths + // - each parameter should have a unique `name` and `type` combination + // - each operation should have only 1 parameter of type body + // - there must be at most 1 parameter in body + // - parameters with pattern property must specify valid patterns + // - $ref in parameters must resolve + // - path param must be required + res := new(Result) + rexGarbledPathSegment := mustCompileRegexp(`.*[{}\s]+.*`) + for method, pi := range s.analyzer.Operations() { + methodPaths := make(map[string]map[string]string) + for path, op := range pi { + pathToAdd := pathHelp.stripParametersInPath(path) + + // Warn on garbled path afer param stripping + if rexGarbledPathSegment.MatchString(pathToAdd) { + res.AddWarnings(pathStrippedParamGarbledMsg(pathToAdd)) + } + + // Check uniqueness of stripped paths + if _, found := methodPaths[method][pathToAdd]; found { + + // Sort names for stable, testable output + if strings.Compare(path, methodPaths[method][pathToAdd]) < 0 { + res.AddErrors(pathOverlapMsg(path, methodPaths[method][pathToAdd])) + } else { + res.AddErrors(pathOverlapMsg(methodPaths[method][pathToAdd], path)) + } + } else { + if _, found := methodPaths[method]; !found { + methodPaths[method] = map[string]string{} + } + methodPaths[method][pathToAdd] = path // Original non stripped path + + } + + var bodyParams []string + var paramNames []string + var hasForm, hasBody bool + + // Check parameters names uniqueness for operation + // TODO: should be done after param expansion + res.Merge(s.checkUniqueParams(path, method, op)) + + for _, pr := range paramHelp.safeExpandedParamsFor(path, method, op.ID, res, s) { + // Validate pattern regexp for parameters with a Pattern property + if _, err := compileRegexp(pr.Pattern); err != nil { + res.AddErrors(invalidPatternInParamMsg(op.ID, pr.Name, pr.Pattern)) + } + + // There must be at most one parameter in body: list them all + if pr.In == swaggerBody { + bodyParams = append(bodyParams, fmt.Sprintf("%q", pr.Name)) + hasBody = true + } + + if pr.In == "path" { + paramNames = append(paramNames, pr.Name) + // Path declared in path must have the required: true property + if !pr.Required { + res.AddErrors(pathParamRequiredMsg(op.ID, pr.Name)) + } + } + + if pr.In == "formData" { + hasForm = true + } + + if !(pr.Type == numberType || pr.Type == integerType) && + (pr.Maximum != nil || pr.Minimum != nil || pr.MultipleOf != nil) { + // A non-numeric parameter has validation keywords for numeric instances (number and integer) + res.AddWarnings(parameterValidationTypeMismatchMsg(pr.Name, path, pr.Type)) + } + + if !(pr.Type == stringType) && + // A non-string parameter has validation keywords for strings + (pr.MaxLength != nil || pr.MinLength != nil || pr.Pattern != "") { + res.AddWarnings(parameterValidationTypeMismatchMsg(pr.Name, path, pr.Type)) + } + + if !(pr.Type == arrayType) && + // A non-array parameter has validation keywords for arrays + (pr.MaxItems != nil || pr.MinItems != nil || pr.UniqueItems) { + res.AddWarnings(parameterValidationTypeMismatchMsg(pr.Name, path, pr.Type)) + } + } + + // In:formData and In:body are mutually exclusive + if hasBody && hasForm { + res.AddErrors(bothFormDataAndBodyMsg(op.ID)) + } + // There must be at most one body param + // Accurately report situations when more than 1 body param is declared (possibly unnamed) + if len(bodyParams) > 1 { + sort.Strings(bodyParams) + res.AddErrors(multipleBodyParamMsg(op.ID, bodyParams)) + } + + // Check uniqueness of parameters in path + paramsInPath := pathHelp.extractPathParams(path) + for i, p := range paramsInPath { + for j, q := range paramsInPath { + if p == q && i > j { + res.AddErrors(pathParamNotUniqueMsg(path, p, q)) + break + } + } + } + + // Warns about possible malformed params in path + rexGarbledParam := mustCompileRegexp(`{.*[{}\s]+.*}`) + for _, p := range paramsInPath { + if rexGarbledParam.MatchString(p) { + res.AddWarnings(pathParamGarbledMsg(path, p)) + } + } + + // Match params from path vs params from params section + res.Merge(s.validatePathParamPresence(path, paramsInPath, paramNames)) + } + } + return res +} + +func (s *SpecValidator) validateReferencesValid() *Result { + // each reference must point to a valid object + res := new(Result) + for _, r := range s.analyzer.AllRefs() { + if !r.IsValidURI(s.spec.SpecFilePath()) { // Safeguard - spec should always yield a valid URI + res.AddErrors(invalidRefMsg(r.String())) + } + } + if !res.HasErrors() { + // NOTE: with default settings, loads.Document.Expanded() + // stops on first error. Anyhow, the expand option to continue + // on errors fails to report errors at all. + exp, err := s.spec.Expanded() + if err != nil { + res.AddErrors(unresolvedReferencesMsg(err)) + } + s.expanded = exp + } + return res +} + +func (s *SpecValidator) checkUniqueParams(path, method string, op *spec.Operation) *Result { + // Check for duplicate parameters declaration in param section. + // Each parameter should have a unique `name` and `type` combination + // NOTE: this could be factorized in analysis (when constructing the params map) + // However, there are some issues with such a factorization: + // - analysis does not seem to fully expand params + // - param keys may be altered by x-go-name + res := new(Result) + pnames := make(map[string]struct{}) + + if op.Parameters != nil { // Safeguard + for _, ppr := range op.Parameters { + var ok bool + pr, red := paramHelp.resolveParam(path, method, op.ID, &ppr, s) //#nosec + res.Merge(red) + + if pr != nil && pr.Name != "" { // params with empty name does no participate the check + key := fmt.Sprintf("%s#%s", pr.In, pr.Name) + + if _, ok = pnames[key]; ok { + res.AddErrors(duplicateParamNameMsg(pr.In, pr.Name, op.ID)) + } + pnames[key] = struct{}{} + } + } + } + return res +} + +// SetContinueOnErrors sets the ContinueOnErrors option for this validator. +func (s *SpecValidator) SetContinueOnErrors(c bool) { + s.Options.ContinueOnErrors = c +} diff --git a/vendor/github.com/go-openapi/validate/spec_messages.go b/vendor/github.com/go-openapi/validate/spec_messages.go new file mode 100644 index 00000000000..b3757adddbd --- /dev/null +++ b/vendor/github.com/go-openapi/validate/spec_messages.go @@ -0,0 +1,360 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package validate + +import ( + "net/http" + + "github.com/go-openapi/errors" +) + +// Error messages related to spec validation and returned as results. +const ( + // ArrayRequiresItemsError ... + ArrayRequiresItemsError = "%s for %q is a collection without an element type (array requires items definition)" + + // ArrayInParamRequiresItemsError ... + ArrayInParamRequiresItemsError = "param %q for %q is a collection without an element type (array requires item definition)" + + // ArrayInHeaderRequiresItemsError ... + ArrayInHeaderRequiresItemsError = "header %q for %q is a collection without an element type (array requires items definition)" + + // BothFormDataAndBodyError indicates that an operation specifies both a body and a formData parameter, which is forbidden + BothFormDataAndBodyError = "operation %q has both formData and body parameters. Only one such In: type may be used for a given operation" + + // CannotResolveRefError when a $ref could not be resolved + CannotResolveReferenceError = "could not resolve reference in %s to $ref %s: %v" + + // CircularAncestryDefinitionError ... + CircularAncestryDefinitionError = "definition %q has circular ancestry: %v" + + // DefaultValueDoesNotValidateError results from an invalid default value provided + DefaultValueDoesNotValidateError = "default value for %s in %s does not validate its schema" + + // DefaultValueItemsDoesNotValidateError results from an invalid default value provided for Items + DefaultValueItemsDoesNotValidateError = "default value for %s.items in %s does not validate its schema" + + // DefaultValueHeaderDoesNotValidateError results from an invalid default value provided in header + DefaultValueHeaderDoesNotValidateError = "in operation %q, default value in header %s for %s does not validate its schema" + + // DefaultValueHeaderItemsDoesNotValidateError results from an invalid default value provided in header.items + DefaultValueHeaderItemsDoesNotValidateError = "in operation %q, default value in header.items %s for %s does not validate its schema" + + // DefaultValueInDoesNotValidateError ... + DefaultValueInDoesNotValidateError = "in operation %q, default value in %s does not validate its schema" + + // DuplicateParamNameError ... + DuplicateParamNameError = "duplicate parameter name %q for %q in operation %q" + + // DuplicatePropertiesError ... + DuplicatePropertiesError = "definition %q contains duplicate properties: %v" + + // ExampleValueDoesNotValidateError results from an invalid example value provided + ExampleValueDoesNotValidateError = "example value for %s in %s does not validate its schema" + + // ExampleValueItemsDoesNotValidateError results from an invalid example value provided for Items + ExampleValueItemsDoesNotValidateError = "example value for %s.items in %s does not validate its schema" + + // ExampleValueHeaderDoesNotValidateError results from an invalid example value provided in header + ExampleValueHeaderDoesNotValidateError = "in operation %q, example value in header %s for %s does not validate its schema" + + // ExampleValueHeaderItemsDoesNotValidateError results from an invalid example value provided in header.items + ExampleValueHeaderItemsDoesNotValidateError = "in operation %q, example value in header.items %s for %s does not validate its schema" + + // ExampleValueInDoesNotValidateError ... + ExampleValueInDoesNotValidateError = "in operation %q, example value in %s does not validate its schema" + + // EmptyPathParameterError means that a path parameter was found empty (e.g. "{}") + EmptyPathParameterError = "%q contains an empty path parameter" + + // InvalidDocumentError states that spec validation only processes spec.Document objects + InvalidDocumentError = "spec validator can only validate spec.Document objects" + + // InvalidItemsPatternError indicates an Items definition with invalid pattern + InvalidItemsPatternError = "%s for %q has invalid items pattern: %q" + + // InvalidParameterDefinitionError indicates an error detected on a parameter definition + InvalidParameterDefinitionError = "invalid definition for parameter %s in %s in operation %q" + + // InvalidParameterDefinitionAsSchemaError indicates an error detected on a parameter definition, which was mistaken with a schema definition. + // Most likely, this situation is encountered whenever a $ref has been added as a sibling of the parameter definition. + InvalidParameterDefinitionAsSchemaError = "invalid definition as Schema for parameter %s in %s in operation %q" + + // InvalidPatternError ... + InvalidPatternError = "pattern %q is invalid in %s" + + // InvalidPatternInError indicates an invalid pattern in a schema or items definition + InvalidPatternInError = "%s in %s has invalid pattern: %q" + + // InvalidPatternInHeaderError indicates a header definition with an invalid pattern + InvalidPatternInHeaderError = "in operation %q, header %s for %s has invalid pattern %q: %v" + + // InvalidPatternInParamError ... + InvalidPatternInParamError = "operation %q has invalid pattern in param %q: %q" + + // InvalidReferenceError indicates that a $ref property could not be resolved + InvalidReferenceError = "invalid ref %q" + + // InvalidResponseDefinitionAsSchemaError indicates an error detected on a response definition, which was mistaken with a schema definition. + // Most likely, this situation is encountered whenever a $ref has been added as a sibling of the response definition. + InvalidResponseDefinitionAsSchemaError = "invalid definition as Schema for response %s in %s" + + // MultipleBodyParamError indicates that an operation specifies multiple parameter with in: body + MultipleBodyParamError = "operation %q has more than 1 body param: %v" + + // NonUniqueOperationIDError indicates that the same operationId has been specified several times + NonUniqueOperationIDError = "%q is defined %d times" + + // NoParameterInPathError indicates that a path was found without any parameter + NoParameterInPathError = "path param %q has no parameter definition" + + // NoValidPathErrorOrWarning indicates that no single path could be validated. If Paths is empty, this message is only a warning. + NoValidPathErrorOrWarning = "spec has no valid path defined" + + // NoValidResponseError indicates that no valid response description could be found for an operation + NoValidResponseError = "operation %q has no valid response" + + // PathOverlapError ... + PathOverlapError = "path %s overlaps with %s" + + // PathParamNotInPathError indicates that a parameter specified with in: path was not found in the path specification + PathParamNotInPathError = "path param %q is not present in path %q" + + // PathParamNotUniqueError ... + PathParamNotUniqueError = "params in path %q must be unique: %q conflicts with %q" + + // PathParamNotRequiredError ... + PathParamRequiredError = "in operation %q,path param %q must be declared as required" + + // RefNotAllowedInHeaderError indicates a $ref was found in a header definition, which is not allowed by Swagger + RefNotAllowedInHeaderError = "IMPORTANT!in %q: $ref are not allowed in headers. In context for header %q%s" + + // RequiredButNotDefinedError ... + RequiredButNotDefinedError = "%q is present in required but not defined as property in definition %q" + + // SomeParametersBrokenError indicates that some parameters could not be resolved, which might result in partial checks to be carried on + SomeParametersBrokenError = "some parameters definitions are broken in %q.%s. Cannot carry on full checks on parameters for operation %s" + + // UnresolvedReferencesError indicates that at least one $ref could not be resolved + UnresolvedReferencesError = "some references could not be resolved in spec. First found: %v" +) + +// Warning messages related to spec validation and returned as results +const ( + // ExamplesWithoutSchemaWarning indicates that examples are provided for a response,but not schema to validate the example against + ExamplesWithoutSchemaWarning = "Examples provided without schema in operation %q, %s" + + // ExamplesMimeNotSupportedWarning indicates that examples are provided with a mime type different than application/json, which + // the validator dos not support yetl + ExamplesMimeNotSupportedWarning = "No validation attempt for examples for media types other than application/json, in operation %q, %s" + + // PathParamGarbledWarning ... + PathParamGarbledWarning = "in path %q, param %q contains {,} or white space. Albeit not stricly illegal, this is probably no what you want" + + // ParamValidationTypeMismatch indicates that parameter has validation which does not match its type + ParamValidationTypeMismatch = "validation keywords of parameter %q in path %q don't match its type %s" + + // PathStrippedParamGarbledWarning ... + PathStrippedParamGarbledWarning = "path stripped from path parameters %s contains {,} or white space. This is probably no what you want." + + // ReadOnlyAndRequiredWarning ... + ReadOnlyAndRequiredWarning = "Required property %s in %q should not be marked as both required and readOnly" + + // RefShouldNotHaveSiblingsWarning indicates that a $ref was found with a sibling definition. This results in the $ref taking over its siblings, + // which is most likely not wanted. + RefShouldNotHaveSiblingsWarning = "$ref property should have no sibling in %q.%s" + + // RequiredHasDefaultWarning indicates that a required parameter property should not have a default + RequiredHasDefaultWarning = "%s in %s has a default value and is required as parameter" + + // UnusedDefinitionWarning ... + UnusedDefinitionWarning = "definition %q is not used anywhere" + + // UnusedParamWarning ... + UnusedParamWarning = "parameter %q is not used anywhere" + + // UnusedResponseWarning ... + UnusedResponseWarning = "response %q is not used anywhere" +) + +// Additional error codes +const ( + // InternalErrorCode reports an internal technical error + InternalErrorCode = http.StatusInternalServerError + // NotFoundErrorCode indicates that a resource (e.g. a $ref) could not be found + NotFoundErrorCode = http.StatusNotFound +) + +func invalidDocumentMsg() errors.Error { + return errors.New(InternalErrorCode, InvalidDocumentError) +} +func invalidRefMsg(path string) errors.Error { + return errors.New(NotFoundErrorCode, InvalidReferenceError, path) +} +func unresolvedReferencesMsg(err error) errors.Error { + return errors.New(errors.CompositeErrorCode, UnresolvedReferencesError, err) +} +func noValidPathMsg() errors.Error { + return errors.New(errors.CompositeErrorCode, NoValidPathErrorOrWarning) +} +func emptyPathParameterMsg(path string) errors.Error { + return errors.New(errors.CompositeErrorCode, EmptyPathParameterError, path) +} +func nonUniqueOperationIDMsg(path string, i int) errors.Error { + return errors.New(errors.CompositeErrorCode, NonUniqueOperationIDError, path, i) +} +func circularAncestryDefinitionMsg(path string, args interface{}) errors.Error { + return errors.New(errors.CompositeErrorCode, CircularAncestryDefinitionError, path, args) +} +func duplicatePropertiesMsg(path string, args interface{}) errors.Error { + return errors.New(errors.CompositeErrorCode, DuplicatePropertiesError, path, args) +} +func pathParamNotInPathMsg(path, param string) errors.Error { + return errors.New(errors.CompositeErrorCode, PathParamNotInPathError, param, path) +} +func arrayRequiresItemsMsg(path, operation string) errors.Error { + return errors.New(errors.CompositeErrorCode, ArrayRequiresItemsError, path, operation) +} +func arrayInParamRequiresItemsMsg(path, operation string) errors.Error { + return errors.New(errors.CompositeErrorCode, ArrayInParamRequiresItemsError, path, operation) +} +func arrayInHeaderRequiresItemsMsg(path, operation string) errors.Error { + return errors.New(errors.CompositeErrorCode, ArrayInHeaderRequiresItemsError, path, operation) +} +func invalidItemsPatternMsg(path, operation, pattern string) errors.Error { + return errors.New(errors.CompositeErrorCode, InvalidItemsPatternError, path, operation, pattern) +} +func invalidPatternMsg(pattern, path string) errors.Error { + return errors.New(errors.CompositeErrorCode, InvalidPatternError, pattern, path) +} +func requiredButNotDefinedMsg(path, definition string) errors.Error { + return errors.New(errors.CompositeErrorCode, RequiredButNotDefinedError, path, definition) +} +func pathParamGarbledMsg(path, param string) errors.Error { + return errors.New(errors.CompositeErrorCode, PathParamGarbledWarning, path, param) +} +func pathStrippedParamGarbledMsg(path string) errors.Error { + return errors.New(errors.CompositeErrorCode, PathStrippedParamGarbledWarning, path) +} +func pathOverlapMsg(path, arg string) errors.Error { + return errors.New(errors.CompositeErrorCode, PathOverlapError, path, arg) +} +func invalidPatternInParamMsg(operation, param, pattern string) errors.Error { + return errors.New(errors.CompositeErrorCode, InvalidPatternInParamError, operation, param, pattern) +} +func pathParamRequiredMsg(operation, param string) errors.Error { + return errors.New(errors.CompositeErrorCode, PathParamRequiredError, operation, param) +} +func bothFormDataAndBodyMsg(operation string) errors.Error { + return errors.New(errors.CompositeErrorCode, BothFormDataAndBodyError, operation) +} +func multipleBodyParamMsg(operation string, args interface{}) errors.Error { + return errors.New(errors.CompositeErrorCode, MultipleBodyParamError, operation, args) +} +func pathParamNotUniqueMsg(path, param, arg string) errors.Error { + return errors.New(errors.CompositeErrorCode, PathParamNotUniqueError, path, param, arg) +} +func duplicateParamNameMsg(path, param, operation string) errors.Error { + return errors.New(errors.CompositeErrorCode, DuplicateParamNameError, param, path, operation) +} +func unusedParamMsg(arg string) errors.Error { + return errors.New(errors.CompositeErrorCode, UnusedParamWarning, arg) +} +func unusedDefinitionMsg(arg string) errors.Error { + return errors.New(errors.CompositeErrorCode, UnusedDefinitionWarning, arg) +} +func unusedResponseMsg(arg string) errors.Error { + return errors.New(errors.CompositeErrorCode, UnusedResponseWarning, arg) +} +func readOnlyAndRequiredMsg(path, param string) errors.Error { + return errors.New(errors.CompositeErrorCode, ReadOnlyAndRequiredWarning, param, path) +} +func noParameterInPathMsg(param string) errors.Error { + return errors.New(errors.CompositeErrorCode, NoParameterInPathError, param) +} +func requiredHasDefaultMsg(param, path string) errors.Error { + return errors.New(errors.CompositeErrorCode, RequiredHasDefaultWarning, param, path) +} +func defaultValueDoesNotValidateMsg(param, path string) errors.Error { + return errors.New(errors.CompositeErrorCode, DefaultValueDoesNotValidateError, param, path) +} +func defaultValueItemsDoesNotValidateMsg(param, path string) errors.Error { + return errors.New(errors.CompositeErrorCode, DefaultValueItemsDoesNotValidateError, param, path) +} +func noValidResponseMsg(operation string) errors.Error { + return errors.New(errors.CompositeErrorCode, NoValidResponseError, operation) +} +func defaultValueHeaderDoesNotValidateMsg(operation, header, path string) errors.Error { + return errors.New(errors.CompositeErrorCode, DefaultValueHeaderDoesNotValidateError, operation, header, path) +} +func defaultValueHeaderItemsDoesNotValidateMsg(operation, header, path string) errors.Error { + return errors.New(errors.CompositeErrorCode, DefaultValueHeaderItemsDoesNotValidateError, operation, header, path) +} +func invalidPatternInHeaderMsg(operation, header, path, pattern string, args interface{}) errors.Error { + return errors.New(errors.CompositeErrorCode, InvalidPatternInHeaderError, operation, header, path, pattern, args) +} +func invalidPatternInMsg(path, in, pattern string) errors.Error { + return errors.New(errors.CompositeErrorCode, InvalidPatternInError, path, in, pattern) +} +func defaultValueInDoesNotValidateMsg(operation, path string) errors.Error { + return errors.New(errors.CompositeErrorCode, DefaultValueInDoesNotValidateError, operation, path) +} +func exampleValueDoesNotValidateMsg(param, path string) errors.Error { + return errors.New(errors.CompositeErrorCode, ExampleValueDoesNotValidateError, param, path) +} +func exampleValueItemsDoesNotValidateMsg(param, path string) errors.Error { + return errors.New(errors.CompositeErrorCode, ExampleValueItemsDoesNotValidateError, param, path) +} +func exampleValueHeaderDoesNotValidateMsg(operation, header, path string) errors.Error { + return errors.New(errors.CompositeErrorCode, ExampleValueHeaderDoesNotValidateError, operation, header, path) +} +func exampleValueHeaderItemsDoesNotValidateMsg(operation, header, path string) errors.Error { + return errors.New(errors.CompositeErrorCode, ExampleValueHeaderItemsDoesNotValidateError, operation, header, path) +} +func exampleValueInDoesNotValidateMsg(operation, path string) errors.Error { + return errors.New(errors.CompositeErrorCode, ExampleValueInDoesNotValidateError, operation, path) +} +func examplesWithoutSchemaMsg(operation, response string) errors.Error { + return errors.New(errors.CompositeErrorCode, ExamplesWithoutSchemaWarning, operation, response) +} +func examplesMimeNotSupportedMsg(operation, response string) errors.Error { + return errors.New(errors.CompositeErrorCode, ExamplesMimeNotSupportedWarning, operation, response) +} +func refNotAllowedInHeaderMsg(path, header, ref string) errors.Error { + return errors.New(errors.CompositeErrorCode, RefNotAllowedInHeaderError, path, header, ref) +} +func cannotResolveRefMsg(path, ref string, err error) errors.Error { + return errors.New(errors.CompositeErrorCode, CannotResolveReferenceError, path, ref, err) +} +func invalidParameterDefinitionMsg(path, method, operationID string) errors.Error { + return errors.New(errors.CompositeErrorCode, InvalidParameterDefinitionError, path, method, operationID) +} +func invalidParameterDefinitionAsSchemaMsg(path, method, operationID string) errors.Error { + return errors.New(errors.CompositeErrorCode, InvalidParameterDefinitionAsSchemaError, path, method, operationID) +} +func parameterValidationTypeMismatchMsg(param, path, typ string) errors.Error { + return errors.New(errors.CompositeErrorCode, ParamValidationTypeMismatch, param, path, typ) +} + +// disabled +// func invalidResponseDefinitionAsSchemaMsg(path, method string) errors.Error { +// return errors.New(errors.CompositeErrorCode, InvalidResponseDefinitionAsSchemaError, path, method) +// } +func someParametersBrokenMsg(path, method, operationID string) errors.Error { + return errors.New(errors.CompositeErrorCode, SomeParametersBrokenError, path, method, operationID) +} +func refShouldNotHaveSiblingsMsg(path, operationID string) errors.Error { + return errors.New(errors.CompositeErrorCode, RefShouldNotHaveSiblingsWarning, operationID, path) +} diff --git a/vendor/github.com/go-openapi/validate/type.go b/vendor/github.com/go-openapi/validate/type.go new file mode 100644 index 00000000000..dc77bff93b7 --- /dev/null +++ b/vendor/github.com/go-openapi/validate/type.go @@ -0,0 +1,178 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package validate + +import ( + "reflect" + "strings" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/spec" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +type typeValidator struct { + Type spec.StringOrArray + Nullable bool + Format string + In string + Path string +} + +func (t *typeValidator) schemaInfoForType(data interface{}) (string, string) { + // internal type to JSON type with swagger 2.0 format (with go-openapi/strfmt extensions), + // see https://github.com/go-openapi/strfmt/blob/master/README.md + // TODO: this switch really is some sort of reverse lookup for formats. It should be provided by strfmt. + switch data.(type) { + case []byte, strfmt.Base64, *strfmt.Base64: + return stringType, stringFormatByte + case strfmt.CreditCard, *strfmt.CreditCard: + return stringType, stringFormatCreditCard + case strfmt.Date, *strfmt.Date: + return stringType, stringFormatDate + case strfmt.DateTime, *strfmt.DateTime: + return stringType, stringFormatDateTime + case strfmt.Duration, *strfmt.Duration: + return stringType, stringFormatDuration + case runtime.File, *runtime.File: + return fileType, "" + case strfmt.Email, *strfmt.Email: + return stringType, stringFormatEmail + case strfmt.HexColor, *strfmt.HexColor: + return stringType, stringFormatHexColor + case strfmt.Hostname, *strfmt.Hostname: + return stringType, stringFormatHostname + case strfmt.IPv4, *strfmt.IPv4: + return stringType, stringFormatIPv4 + case strfmt.IPv6, *strfmt.IPv6: + return stringType, stringFormatIPv6 + case strfmt.ISBN, *strfmt.ISBN: + return stringType, stringFormatISBN + case strfmt.ISBN10, *strfmt.ISBN10: + return stringType, stringFormatISBN10 + case strfmt.ISBN13, *strfmt.ISBN13: + return stringType, stringFormatISBN13 + case strfmt.MAC, *strfmt.MAC: + return stringType, stringFormatMAC + case strfmt.ObjectId, *strfmt.ObjectId: + return stringType, stringFormatBSONObjectID + case strfmt.Password, *strfmt.Password: + return stringType, stringFormatPassword + case strfmt.RGBColor, *strfmt.RGBColor: + return stringType, stringFormatRGBColor + case strfmt.SSN, *strfmt.SSN: + return stringType, stringFormatSSN + case strfmt.URI, *strfmt.URI: + return stringType, stringFormatURI + case strfmt.UUID, *strfmt.UUID: + return stringType, stringFormatUUID + case strfmt.UUID3, *strfmt.UUID3: + return stringType, stringFormatUUID3 + case strfmt.UUID4, *strfmt.UUID4: + return stringType, stringFormatUUID4 + case strfmt.UUID5, *strfmt.UUID5: + return stringType, stringFormatUUID5 + // TODO: missing binary (io.ReadCloser) + // TODO: missing json.Number + default: + val := reflect.ValueOf(data) + tpe := val.Type() + switch tpe.Kind() { + case reflect.Bool: + return booleanType, "" + case reflect.String: + return stringType, "" + case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Uint8, reflect.Uint16, reflect.Uint32: + // NOTE: that is the spec. With go-openapi, is that not uint32 for unsigned integers? + return integerType, integerFormatInt32 + case reflect.Int, reflect.Int64, reflect.Uint, reflect.Uint64: + return integerType, integerFormatInt64 + case reflect.Float32: + // NOTE: is that not numberFormatFloat? + return numberType, numberFormatFloat32 + case reflect.Float64: + // NOTE: is that not "double"? + return numberType, numberFormatFloat64 + // NOTE: go arrays (reflect.Array) are not supported (fixed length) + case reflect.Slice: + return arrayType, "" + case reflect.Map, reflect.Struct: + return objectType, "" + case reflect.Interface: + // What to do here? + panic("dunno what to do here") + case reflect.Ptr: + return t.schemaInfoForType(reflect.Indirect(val).Interface()) + } + } + return "", "" +} + +func (t *typeValidator) SetPath(path string) { + t.Path = path +} + +func (t *typeValidator) Applies(source interface{}, kind reflect.Kind) bool { + // typeValidator applies to Schema, Parameter and Header objects + stpe := reflect.TypeOf(source) + r := (len(t.Type) > 0 || t.Format != "") && (stpe == specSchemaType || stpe == specParameterType || stpe == specHeaderType) + debugLog("type validator for %q applies %t for %T (kind: %v)\n", t.Path, r, source, kind) + return r +} + +func (t *typeValidator) Validate(data interface{}) *Result { + result := new(Result) + result.Inc() + if data == nil { + // nil or zero value for the passed structure require Type: null + if len(t.Type) > 0 && !t.Type.Contains(nullType) && !t.Nullable { // TODO: if a property is not required it also passes this + return errorHelp.sErr(errors.InvalidType(t.Path, t.In, strings.Join(t.Type, ","), nullType)) + } + return result + } + + // check if the type matches, should be used in every validator chain as first item + val := reflect.Indirect(reflect.ValueOf(data)) + kind := val.Kind() + + // infer schema type (JSON) and format from passed data type + schType, format := t.schemaInfoForType(data) + + debugLog("path: %s, schType: %s, format: %s, expType: %s, expFmt: %s, kind: %s", t.Path, schType, format, t.Type, t.Format, val.Kind().String()) + + // check numerical types + // TODO: check unsigned ints + // TODO: check json.Number (see schema.go) + isLowerInt := t.Format == integerFormatInt64 && format == integerFormatInt32 + isLowerFloat := t.Format == numberFormatFloat64 && format == numberFormatFloat32 + isFloatInt := schType == numberType && swag.IsFloat64AJSONInteger(val.Float()) && t.Type.Contains(integerType) + isIntFloat := schType == integerType && t.Type.Contains(numberType) + + if kind != reflect.String && kind != reflect.Slice && t.Format != "" && !(t.Type.Contains(schType) || format == t.Format || isFloatInt || isIntFloat || isLowerInt || isLowerFloat) { + // TODO: test case + return errorHelp.sErr(errors.InvalidType(t.Path, t.In, t.Format, format)) + } + + if !(t.Type.Contains(numberType) || t.Type.Contains(integerType)) && t.Format != "" && (kind == reflect.String || kind == reflect.Slice) { + return result + } + + if !(t.Type.Contains(schType) || isFloatInt || isIntFloat) { + return errorHelp.sErr(errors.InvalidType(t.Path, t.In, strings.Join(t.Type, ","), schType)) + } + return result +} diff --git a/vendor/github.com/go-openapi/validate/update-fixtures.sh b/vendor/github.com/go-openapi/validate/update-fixtures.sh new file mode 100644 index 00000000000..21b06e2b09a --- /dev/null +++ b/vendor/github.com/go-openapi/validate/update-fixtures.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -eu -o pipefail +dir=$(git rev-parse --show-toplevel) +scratch=$(mktemp -d -t tmp.XXXXXXXXXX) + +function finish { + rm -rf "$scratch" +} +trap finish EXIT SIGHUP SIGINT SIGTERM + +cd "$scratch" +git clone https://github.com/json-schema-org/JSON-Schema-Test-Suite Suite +cp -r Suite/tests/draft4/* "$dir/fixtures/jsonschema_suite" +cp -a Suite/remotes "$dir/fixtures/jsonschema_suite" diff --git a/vendor/github.com/go-openapi/validate/validator.go b/vendor/github.com/go-openapi/validate/validator.go new file mode 100644 index 00000000000..38cdb9bb6cc --- /dev/null +++ b/vendor/github.com/go-openapi/validate/validator.go @@ -0,0 +1,645 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package validate + +import ( + "fmt" + "reflect" + + "github.com/go-openapi/errors" + "github.com/go-openapi/spec" + "github.com/go-openapi/strfmt" +) + +// An EntityValidator is an interface for things that can validate entities +type EntityValidator interface { + Validate(interface{}) *Result +} + +type valueValidator interface { + SetPath(path string) + Applies(interface{}, reflect.Kind) bool + Validate(interface{}) *Result +} + +type itemsValidator struct { + items *spec.Items + root interface{} + path string + in string + validators []valueValidator + KnownFormats strfmt.Registry +} + +func newItemsValidator(path, in string, items *spec.Items, root interface{}, formats strfmt.Registry) *itemsValidator { + iv := &itemsValidator{path: path, in: in, items: items, root: root, KnownFormats: formats} + iv.validators = []valueValidator{ + &typeValidator{ + Type: spec.StringOrArray([]string{items.Type}), + Nullable: items.Nullable, + Format: items.Format, + In: in, + Path: path, + }, + iv.stringValidator(), + iv.formatValidator(), + iv.numberValidator(), + iv.sliceValidator(), + iv.commonValidator(), + } + return iv +} + +func (i *itemsValidator) Validate(index int, data interface{}) *Result { + tpe := reflect.TypeOf(data) + kind := tpe.Kind() + mainResult := new(Result) + path := fmt.Sprintf("%s.%d", i.path, index) + + for _, validator := range i.validators { + validator.SetPath(path) + if validator.Applies(i.root, kind) { + result := validator.Validate(data) + mainResult.Merge(result) + mainResult.Inc() + if result != nil && result.HasErrors() { + return mainResult + } + } + } + return mainResult +} + +func (i *itemsValidator) commonValidator() valueValidator { + return &basicCommonValidator{ + In: i.in, + Default: i.items.Default, + Enum: i.items.Enum, + } +} + +func (i *itemsValidator) sliceValidator() valueValidator { + return &basicSliceValidator{ + In: i.in, + Default: i.items.Default, + MaxItems: i.items.MaxItems, + MinItems: i.items.MinItems, + UniqueItems: i.items.UniqueItems, + Source: i.root, + Items: i.items.Items, + KnownFormats: i.KnownFormats, + } +} + +func (i *itemsValidator) numberValidator() valueValidator { + return &numberValidator{ + In: i.in, + Default: i.items.Default, + MultipleOf: i.items.MultipleOf, + Maximum: i.items.Maximum, + ExclusiveMaximum: i.items.ExclusiveMaximum, + Minimum: i.items.Minimum, + ExclusiveMinimum: i.items.ExclusiveMinimum, + Type: i.items.Type, + Format: i.items.Format, + } +} + +func (i *itemsValidator) stringValidator() valueValidator { + return &stringValidator{ + In: i.in, + Default: i.items.Default, + MaxLength: i.items.MaxLength, + MinLength: i.items.MinLength, + Pattern: i.items.Pattern, + AllowEmptyValue: false, + } +} + +func (i *itemsValidator) formatValidator() valueValidator { + return &formatValidator{ + In: i.in, + //Default: i.items.Default, + Format: i.items.Format, + KnownFormats: i.KnownFormats, + } +} + +type basicCommonValidator struct { + Path string + In string + Default interface{} + Enum []interface{} +} + +func (b *basicCommonValidator) SetPath(path string) { + b.Path = path +} + +func (b *basicCommonValidator) Applies(source interface{}, kind reflect.Kind) bool { + switch source.(type) { + case *spec.Parameter, *spec.Schema, *spec.Header: + return true + } + return false +} + +func (b *basicCommonValidator) Validate(data interface{}) (res *Result) { + if len(b.Enum) > 0 { + for _, enumValue := range b.Enum { + actualType := reflect.TypeOf(enumValue) + if actualType != nil { // Safeguard + expectedValue := reflect.ValueOf(data) + if expectedValue.IsValid() && expectedValue.Type().ConvertibleTo(actualType) { + if reflect.DeepEqual(expectedValue.Convert(actualType).Interface(), enumValue) { + return nil + } + } + } + } + return errorHelp.sErr(errors.EnumFail(b.Path, b.In, data, b.Enum)) + } + return nil +} + +// A HeaderValidator has very limited subset of validations to apply +type HeaderValidator struct { + name string + header *spec.Header + validators []valueValidator + KnownFormats strfmt.Registry +} + +// NewHeaderValidator creates a new header validator object +func NewHeaderValidator(name string, header *spec.Header, formats strfmt.Registry) *HeaderValidator { + p := &HeaderValidator{name: name, header: header, KnownFormats: formats} + p.validators = []valueValidator{ + &typeValidator{ + Type: spec.StringOrArray([]string{header.Type}), + Nullable: header.Nullable, + Format: header.Format, + In: "header", + Path: name, + }, + p.stringValidator(), + p.formatValidator(), + p.numberValidator(), + p.sliceValidator(), + p.commonValidator(), + } + return p +} + +// Validate the value of the header against its schema +func (p *HeaderValidator) Validate(data interface{}) *Result { + result := new(Result) + tpe := reflect.TypeOf(data) + kind := tpe.Kind() + + for _, validator := range p.validators { + if validator.Applies(p.header, kind) { + if err := validator.Validate(data); err != nil { + result.Merge(err) + if err.HasErrors() { + return result + } + } + } + } + return nil +} + +func (p *HeaderValidator) commonValidator() valueValidator { + return &basicCommonValidator{ + Path: p.name, + In: "response", + Default: p.header.Default, + Enum: p.header.Enum, + } +} + +func (p *HeaderValidator) sliceValidator() valueValidator { + return &basicSliceValidator{ + Path: p.name, + In: "response", + Default: p.header.Default, + MaxItems: p.header.MaxItems, + MinItems: p.header.MinItems, + UniqueItems: p.header.UniqueItems, + Items: p.header.Items, + Source: p.header, + KnownFormats: p.KnownFormats, + } +} + +func (p *HeaderValidator) numberValidator() valueValidator { + return &numberValidator{ + Path: p.name, + In: "response", + Default: p.header.Default, + MultipleOf: p.header.MultipleOf, + Maximum: p.header.Maximum, + ExclusiveMaximum: p.header.ExclusiveMaximum, + Minimum: p.header.Minimum, + ExclusiveMinimum: p.header.ExclusiveMinimum, + Type: p.header.Type, + Format: p.header.Format, + } +} + +func (p *HeaderValidator) stringValidator() valueValidator { + return &stringValidator{ + Path: p.name, + In: "response", + Default: p.header.Default, + Required: true, + MaxLength: p.header.MaxLength, + MinLength: p.header.MinLength, + Pattern: p.header.Pattern, + AllowEmptyValue: false, + } +} + +func (p *HeaderValidator) formatValidator() valueValidator { + return &formatValidator{ + Path: p.name, + In: "response", + //Default: p.header.Default, + Format: p.header.Format, + KnownFormats: p.KnownFormats, + } +} + +// A ParamValidator has very limited subset of validations to apply +type ParamValidator struct { + param *spec.Parameter + validators []valueValidator + KnownFormats strfmt.Registry +} + +// NewParamValidator creates a new param validator object +func NewParamValidator(param *spec.Parameter, formats strfmt.Registry) *ParamValidator { + p := &ParamValidator{param: param, KnownFormats: formats} + p.validators = []valueValidator{ + &typeValidator{ + Type: spec.StringOrArray([]string{param.Type}), + Nullable: param.Nullable, + Format: param.Format, + In: param.In, + Path: param.Name, + }, + p.stringValidator(), + p.formatValidator(), + p.numberValidator(), + p.sliceValidator(), + p.commonValidator(), + } + return p +} + +// Validate the data against the description of the parameter +func (p *ParamValidator) Validate(data interface{}) *Result { + result := new(Result) + tpe := reflect.TypeOf(data) + kind := tpe.Kind() + + // TODO: validate type + for _, validator := range p.validators { + if validator.Applies(p.param, kind) { + if err := validator.Validate(data); err != nil { + result.Merge(err) + if err.HasErrors() { + return result + } + } + } + } + return nil +} + +func (p *ParamValidator) commonValidator() valueValidator { + return &basicCommonValidator{ + Path: p.param.Name, + In: p.param.In, + Default: p.param.Default, + Enum: p.param.Enum, + } +} + +func (p *ParamValidator) sliceValidator() valueValidator { + return &basicSliceValidator{ + Path: p.param.Name, + In: p.param.In, + Default: p.param.Default, + MaxItems: p.param.MaxItems, + MinItems: p.param.MinItems, + UniqueItems: p.param.UniqueItems, + Items: p.param.Items, + Source: p.param, + KnownFormats: p.KnownFormats, + } +} + +func (p *ParamValidator) numberValidator() valueValidator { + return &numberValidator{ + Path: p.param.Name, + In: p.param.In, + Default: p.param.Default, + MultipleOf: p.param.MultipleOf, + Maximum: p.param.Maximum, + ExclusiveMaximum: p.param.ExclusiveMaximum, + Minimum: p.param.Minimum, + ExclusiveMinimum: p.param.ExclusiveMinimum, + Type: p.param.Type, + Format: p.param.Format, + } +} + +func (p *ParamValidator) stringValidator() valueValidator { + return &stringValidator{ + Path: p.param.Name, + In: p.param.In, + Default: p.param.Default, + AllowEmptyValue: p.param.AllowEmptyValue, + Required: p.param.Required, + MaxLength: p.param.MaxLength, + MinLength: p.param.MinLength, + Pattern: p.param.Pattern, + } +} + +func (p *ParamValidator) formatValidator() valueValidator { + return &formatValidator{ + Path: p.param.Name, + In: p.param.In, + //Default: p.param.Default, + Format: p.param.Format, + KnownFormats: p.KnownFormats, + } +} + +type basicSliceValidator struct { + Path string + In string + Default interface{} + MaxItems *int64 + MinItems *int64 + UniqueItems bool + Items *spec.Items + Source interface{} + itemsValidator *itemsValidator + KnownFormats strfmt.Registry +} + +func (s *basicSliceValidator) SetPath(path string) { + s.Path = path +} + +func (s *basicSliceValidator) Applies(source interface{}, kind reflect.Kind) bool { + switch source.(type) { + case *spec.Parameter, *spec.Items, *spec.Header: + return kind == reflect.Slice + } + return false +} + +func (s *basicSliceValidator) Validate(data interface{}) *Result { + val := reflect.ValueOf(data) + + size := int64(val.Len()) + if s.MinItems != nil { + if err := MinItems(s.Path, s.In, size, *s.MinItems); err != nil { + return errorHelp.sErr(err) + } + } + + if s.MaxItems != nil { + if err := MaxItems(s.Path, s.In, size, *s.MaxItems); err != nil { + return errorHelp.sErr(err) + } + } + + if s.UniqueItems { + if err := UniqueItems(s.Path, s.In, data); err != nil { + return errorHelp.sErr(err) + } + } + + if s.itemsValidator == nil && s.Items != nil { + s.itemsValidator = newItemsValidator(s.Path, s.In, s.Items, s.Source, s.KnownFormats) + } + + if s.itemsValidator != nil { + for i := 0; i < int(size); i++ { + ele := val.Index(i) + if err := s.itemsValidator.Validate(i, ele.Interface()); err != nil && err.HasErrors() { + return err + } + } + } + return nil +} + +/* unused +func (s *basicSliceValidator) hasDuplicates(value reflect.Value, size int) bool { + dict := make(map[interface{}]struct{}) + for i := 0; i < size; i++ { + ele := value.Index(i) + if _, ok := dict[ele.Interface()]; ok { + return true + } + dict[ele.Interface()] = struct{}{} + } + return false +} +*/ + +type numberValidator struct { + Path string + In string + Default interface{} + MultipleOf *float64 + Maximum *float64 + ExclusiveMaximum bool + Minimum *float64 + ExclusiveMinimum bool + // Allows for more accurate behavior regarding integers + Type string + Format string +} + +func (n *numberValidator) SetPath(path string) { + n.Path = path +} + +func (n *numberValidator) Applies(source interface{}, kind reflect.Kind) bool { + switch source.(type) { + case *spec.Parameter, *spec.Schema, *spec.Items, *spec.Header: + isInt := kind >= reflect.Int && kind <= reflect.Uint64 + isFloat := kind == reflect.Float32 || kind == reflect.Float64 + r := isInt || isFloat + debugLog("schema props validator for %q applies %t for %T (kind: %v) isInt=%t, isFloat=%t\n", n.Path, r, source, kind, isInt, isFloat) + return r + } + debugLog("schema props validator for %q applies %t for %T (kind: %v)\n", n.Path, false, source, kind) + return false +} + +// Validate provides a validator for generic JSON numbers, +// +// By default, numbers are internally represented as float64. +// Formats float, or float32 may alter this behavior by mapping to float32. +// A special validation process is followed for integers, with optional "format": +// this is an attempt to provide a validation with native types. +// +// NOTE: since the constraint specified (boundary, multipleOf) is unmarshalled +// as float64, loss of information remains possible (e.g. on very large integers). +// +// Since this value directly comes from the unmarshalling, it is not possible +// at this stage of processing to check further and guarantee the correctness of such values. +// +// Normally, the JSON Number.MAX_SAFE_INTEGER (resp. Number.MIN_SAFE_INTEGER) +// would check we do not get such a loss. +// +// If this is the case, replace AddErrors() by AddWarnings() and IsValid() by !HasWarnings(). +// +// TODO: consider replacing boundary check errors by simple warnings. +// +// TODO: default boundaries with MAX_SAFE_INTEGER are not checked (specific to json.Number?) +func (n *numberValidator) Validate(val interface{}) *Result { + res := new(Result) + + resMultiple := new(Result) + resMinimum := new(Result) + resMaximum := new(Result) + + // Used only to attempt to validate constraint on value, + // even though value or constraint specified do not match type and format + data := valueHelp.asFloat64(val) + + // Is the provided value within the range of the specified numeric type and format? + res.AddErrors(IsValueValidAgainstRange(val, n.Type, n.Format, "Checked", n.Path)) + + if n.MultipleOf != nil { + // Is the constraint specifier within the range of the specific numeric type and format? + resMultiple.AddErrors(IsValueValidAgainstRange(*n.MultipleOf, n.Type, n.Format, "MultipleOf", n.Path)) + if resMultiple.IsValid() { + // Constraint validated with compatible types + if err := MultipleOfNativeType(n.Path, n.In, val, *n.MultipleOf); err != nil { + resMultiple.Merge(errorHelp.sErr(err)) + } + } else { + // Constraint nevertheless validated, converted as general number + if err := MultipleOf(n.Path, n.In, data, *n.MultipleOf); err != nil { + resMultiple.Merge(errorHelp.sErr(err)) + } + } + } + + // nolint: dupl + if n.Maximum != nil { + // Is the constraint specifier within the range of the specific numeric type and format? + resMaximum.AddErrors(IsValueValidAgainstRange(*n.Maximum, n.Type, n.Format, "Maximum boundary", n.Path)) + if resMaximum.IsValid() { + // Constraint validated with compatible types + if err := MaximumNativeType(n.Path, n.In, val, *n.Maximum, n.ExclusiveMaximum); err != nil { + resMaximum.Merge(errorHelp.sErr(err)) + } + } else { + // Constraint nevertheless validated, converted as general number + if err := Maximum(n.Path, n.In, data, *n.Maximum, n.ExclusiveMaximum); err != nil { + resMaximum.Merge(errorHelp.sErr(err)) + } + } + } + + // nolint: dupl + if n.Minimum != nil { + // Is the constraint specifier within the range of the specific numeric type and format? + resMinimum.AddErrors(IsValueValidAgainstRange(*n.Minimum, n.Type, n.Format, "Minimum boundary", n.Path)) + if resMinimum.IsValid() { + // Constraint validated with compatible types + if err := MinimumNativeType(n.Path, n.In, val, *n.Minimum, n.ExclusiveMinimum); err != nil { + resMinimum.Merge(errorHelp.sErr(err)) + } + } else { + // Constraint nevertheless validated, converted as general number + if err := Minimum(n.Path, n.In, data, *n.Minimum, n.ExclusiveMinimum); err != nil { + resMinimum.Merge(errorHelp.sErr(err)) + } + } + } + res.Merge(resMultiple, resMinimum, resMaximum) + res.Inc() + return res +} + +type stringValidator struct { + Default interface{} + Required bool + AllowEmptyValue bool + MaxLength *int64 + MinLength *int64 + Pattern string + Path string + In string +} + +func (s *stringValidator) SetPath(path string) { + s.Path = path +} + +func (s *stringValidator) Applies(source interface{}, kind reflect.Kind) bool { + switch source.(type) { + case *spec.Parameter, *spec.Schema, *spec.Items, *spec.Header: + r := kind == reflect.String + debugLog("string validator for %q applies %t for %T (kind: %v)\n", s.Path, r, source, kind) + return r + } + debugLog("string validator for %q applies %t for %T (kind: %v)\n", s.Path, false, source, kind) + return false +} + +func (s *stringValidator) Validate(val interface{}) *Result { + data, ok := val.(string) + if !ok { + return errorHelp.sErr(errors.InvalidType(s.Path, s.In, stringType, val)) + } + + if s.Required && !s.AllowEmptyValue && (s.Default == nil || s.Default == "") { + if err := RequiredString(s.Path, s.In, data); err != nil { + return errorHelp.sErr(err) + } + } + + if s.MaxLength != nil { + if err := MaxLength(s.Path, s.In, data, *s.MaxLength); err != nil { + return errorHelp.sErr(err) + } + } + + if s.MinLength != nil { + if err := MinLength(s.Path, s.In, data, *s.MinLength); err != nil { + return errorHelp.sErr(err) + } + } + + if s.Pattern != "" { + if err := Pattern(s.Path, s.In, data, s.Pattern); err != nil { + return errorHelp.sErr(err) + } + } + return nil +} diff --git a/vendor/github.com/go-openapi/validate/values.go b/vendor/github.com/go-openapi/validate/values.go new file mode 100644 index 00000000000..321de673731 --- /dev/null +++ b/vendor/github.com/go-openapi/validate/values.go @@ -0,0 +1,446 @@ +// Copyright 2015 go-swagger maintainers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package validate + +import ( + "context" + "fmt" + "reflect" + "strings" + "unicode/utf8" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Enum validates if the data is a member of the enum +func Enum(path, in string, data interface{}, enum interface{}) *errors.Validation { + return EnumCase(path, in, data, enum, true) +} + +// EnumCase validates if the data is a member of the enum and may respect case-sensitivity for strings +func EnumCase(path, in string, data interface{}, enum interface{}, caseSensitive bool) *errors.Validation { + val := reflect.ValueOf(enum) + if val.Kind() != reflect.Slice { + return nil + } + + dataString := convertEnumCaseStringKind(data, caseSensitive) + var values []interface{} + for i := 0; i < val.Len(); i++ { + ele := val.Index(i) + enumValue := ele.Interface() + if data != nil { + if reflect.DeepEqual(data, enumValue) { + return nil + } + enumString := convertEnumCaseStringKind(enumValue, caseSensitive) + if dataString != nil && enumString != nil && strings.EqualFold(*dataString, *enumString) { + return nil + } + actualType := reflect.TypeOf(enumValue) + if actualType == nil { // Safeguard. Frankly, I don't know how we may get a nil + continue + } + expectedValue := reflect.ValueOf(data) + if expectedValue.IsValid() && expectedValue.Type().ConvertibleTo(actualType) { + // Attempt comparison after type conversion + if reflect.DeepEqual(expectedValue.Convert(actualType).Interface(), enumValue) { + return nil + } + } + } + values = append(values, enumValue) + } + return errors.EnumFail(path, in, data, values) +} + +// convertEnumCaseStringKind converts interface if it is kind of string and case insensitivity is set +func convertEnumCaseStringKind(value interface{}, caseSensitive bool) *string { + if caseSensitive { + return nil + } + + val := reflect.ValueOf(value) + if val.Kind() != reflect.String { + return nil + } + + str := fmt.Sprintf("%v", value) + return &str +} + +// MinItems validates that there are at least n items in a slice +func MinItems(path, in string, size, min int64) *errors.Validation { + if size < min { + return errors.TooFewItems(path, in, min, size) + } + return nil +} + +// MaxItems validates that there are at most n items in a slice +func MaxItems(path, in string, size, max int64) *errors.Validation { + if size > max { + return errors.TooManyItems(path, in, max, size) + } + return nil +} + +// UniqueItems validates that the provided slice has unique elements +func UniqueItems(path, in string, data interface{}) *errors.Validation { + val := reflect.ValueOf(data) + if val.Kind() != reflect.Slice { + return nil + } + var unique []interface{} + for i := 0; i < val.Len(); i++ { + v := val.Index(i).Interface() + for _, u := range unique { + if reflect.DeepEqual(v, u) { + return errors.DuplicateItems(path, in) + } + } + unique = append(unique, v) + } + return nil +} + +// MinLength validates a string for minimum length +func MinLength(path, in, data string, minLength int64) *errors.Validation { + strLen := int64(utf8.RuneCount([]byte(data))) + if strLen < minLength { + return errors.TooShort(path, in, minLength, data) + } + return nil +} + +// MaxLength validates a string for maximum length +func MaxLength(path, in, data string, maxLength int64) *errors.Validation { + strLen := int64(utf8.RuneCount([]byte(data))) + if strLen > maxLength { + return errors.TooLong(path, in, maxLength, data) + } + return nil +} + +// ReadOnly validates an interface for readonly +func ReadOnly(ctx context.Context, path, in string, data interface{}) *errors.Validation { + + // read only is only validated when operationType is request + if op := extractOperationType(ctx); op != request { + return nil + } + + // data must be of zero value of its type + val := reflect.ValueOf(data) + if val.IsValid() { + if reflect.DeepEqual(reflect.Zero(val.Type()).Interface(), val.Interface()) { + return nil + } + } else { + return nil + } + + return errors.ReadOnly(path, in, data) +} + +// Required validates an interface for requiredness +func Required(path, in string, data interface{}) *errors.Validation { + val := reflect.ValueOf(data) + if val.IsValid() { + if reflect.DeepEqual(reflect.Zero(val.Type()).Interface(), val.Interface()) { + return errors.Required(path, in, data) + } + return nil + } + return errors.Required(path, in, data) +} + +// RequiredString validates a string for requiredness +func RequiredString(path, in, data string) *errors.Validation { + if data == "" { + return errors.Required(path, in, data) + } + return nil +} + +// RequiredNumber validates a number for requiredness +func RequiredNumber(path, in string, data float64) *errors.Validation { + if data == 0 { + return errors.Required(path, in, data) + } + return nil +} + +// Pattern validates a string against a regular expression +func Pattern(path, in, data, pattern string) *errors.Validation { + re, err := compileRegexp(pattern) + if err != nil { + return errors.FailedPattern(path, in, fmt.Sprintf("%s, but pattern is invalid: %s", pattern, err.Error()), data) + } + if !re.MatchString(data) { + return errors.FailedPattern(path, in, pattern, data) + } + return nil +} + +// MaximumInt validates if a number is smaller than a given maximum +func MaximumInt(path, in string, data, max int64, exclusive bool) *errors.Validation { + if (!exclusive && data > max) || (exclusive && data >= max) { + return errors.ExceedsMaximumInt(path, in, max, exclusive, data) + } + return nil +} + +// MaximumUint validates if a number is smaller than a given maximum +func MaximumUint(path, in string, data, max uint64, exclusive bool) *errors.Validation { + if (!exclusive && data > max) || (exclusive && data >= max) { + return errors.ExceedsMaximumUint(path, in, max, exclusive, data) + } + return nil +} + +// Maximum validates if a number is smaller than a given maximum +func Maximum(path, in string, data, max float64, exclusive bool) *errors.Validation { + if (!exclusive && data > max) || (exclusive && data >= max) { + return errors.ExceedsMaximum(path, in, max, exclusive, data) + } + return nil +} + +// Minimum validates if a number is smaller than a given minimum +func Minimum(path, in string, data, min float64, exclusive bool) *errors.Validation { + if (!exclusive && data < min) || (exclusive && data <= min) { + return errors.ExceedsMinimum(path, in, min, exclusive, data) + } + return nil +} + +// MinimumInt validates if a number is smaller than a given minimum +func MinimumInt(path, in string, data, min int64, exclusive bool) *errors.Validation { + if (!exclusive && data < min) || (exclusive && data <= min) { + return errors.ExceedsMinimumInt(path, in, min, exclusive, data) + } + return nil +} + +// MinimumUint validates if a number is smaller than a given minimum +func MinimumUint(path, in string, data, min uint64, exclusive bool) *errors.Validation { + if (!exclusive && data < min) || (exclusive && data <= min) { + return errors.ExceedsMinimumUint(path, in, min, exclusive, data) + } + return nil +} + +// MultipleOf validates if the provided number is a multiple of the factor +func MultipleOf(path, in string, data, factor float64) *errors.Validation { + // multipleOf factor must be positive + if factor < 0 { + return errors.MultipleOfMustBePositive(path, in, factor) + } + var mult float64 + if factor < 1 { + mult = 1 / factor * data + } else { + mult = data / factor + } + if !swag.IsFloat64AJSONInteger(mult) { + return errors.NotMultipleOf(path, in, factor, data) + } + return nil +} + +// MultipleOfInt validates if the provided integer is a multiple of the factor +func MultipleOfInt(path, in string, data int64, factor int64) *errors.Validation { + // multipleOf factor must be positive + if factor < 0 { + return errors.MultipleOfMustBePositive(path, in, factor) + } + mult := data / factor + if mult*factor != data { + return errors.NotMultipleOf(path, in, factor, data) + } + return nil +} + +// MultipleOfUint validates if the provided unsigned integer is a multiple of the factor +func MultipleOfUint(path, in string, data, factor uint64) *errors.Validation { + mult := data / factor + if mult*factor != data { + return errors.NotMultipleOf(path, in, factor, data) + } + return nil +} + +// FormatOf validates if a string matches a format in the format registry +func FormatOf(path, in, format, data string, registry strfmt.Registry) *errors.Validation { + if registry == nil { + registry = strfmt.Default + } + if ok := registry.ContainsName(format); !ok { + return errors.InvalidTypeName(format) + } + if ok := registry.Validates(format, data); !ok { + return errors.InvalidType(path, in, format, data) + } + return nil +} + +// MaximumNativeType provides native type constraint validation as a facade +// to various numeric types versions of Maximum constraint check. +// +// Assumes that any possible loss conversion during conversion has been +// checked beforehand. +// +// NOTE: currently, the max value is marshalled as a float64, no matter what, +// which means there may be a loss during conversions (e.g. for very large integers) +// +// TODO: Normally, a JSON MAX_SAFE_INTEGER check would ensure conversion remains loss-free +func MaximumNativeType(path, in string, val interface{}, max float64, exclusive bool) *errors.Validation { + kind := reflect.ValueOf(val).Type().Kind() + switch kind { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + value := valueHelp.asInt64(val) + return MaximumInt(path, in, value, int64(max), exclusive) + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + value := valueHelp.asUint64(val) + if max < 0 { + return errors.ExceedsMaximum(path, in, max, exclusive, val) + } + return MaximumUint(path, in, value, uint64(max), exclusive) + case reflect.Float32, reflect.Float64: + fallthrough + default: + value := valueHelp.asFloat64(val) + return Maximum(path, in, value, max, exclusive) + } +} + +// MinimumNativeType provides native type constraint validation as a facade +// to various numeric types versions of Minimum constraint check. +// +// Assumes that any possible loss conversion during conversion has been +// checked beforehand. +// +// NOTE: currently, the min value is marshalled as a float64, no matter what, +// which means there may be a loss during conversions (e.g. for very large integers) +// +// TODO: Normally, a JSON MAX_SAFE_INTEGER check would ensure conversion remains loss-free +func MinimumNativeType(path, in string, val interface{}, min float64, exclusive bool) *errors.Validation { + kind := reflect.ValueOf(val).Type().Kind() + switch kind { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + value := valueHelp.asInt64(val) + return MinimumInt(path, in, value, int64(min), exclusive) + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + value := valueHelp.asUint64(val) + if min < 0 { + return nil + } + return MinimumUint(path, in, value, uint64(min), exclusive) + case reflect.Float32, reflect.Float64: + fallthrough + default: + value := valueHelp.asFloat64(val) + return Minimum(path, in, value, min, exclusive) + } +} + +// MultipleOfNativeType provides native type constraint validation as a facade +// to various numeric types version of MultipleOf constraint check. +// +// Assumes that any possible loss conversion during conversion has been +// checked beforehand. +// +// NOTE: currently, the multipleOf factor is marshalled as a float64, no matter what, +// which means there may be a loss during conversions (e.g. for very large integers) +// +// TODO: Normally, a JSON MAX_SAFE_INTEGER check would ensure conversion remains loss-free +func MultipleOfNativeType(path, in string, val interface{}, multipleOf float64) *errors.Validation { + kind := reflect.ValueOf(val).Type().Kind() + switch kind { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + value := valueHelp.asInt64(val) + return MultipleOfInt(path, in, value, int64(multipleOf)) + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + value := valueHelp.asUint64(val) + return MultipleOfUint(path, in, value, uint64(multipleOf)) + case reflect.Float32, reflect.Float64: + fallthrough + default: + value := valueHelp.asFloat64(val) + return MultipleOf(path, in, value, multipleOf) + } +} + +// IsValueValidAgainstRange checks that a numeric value is compatible with +// the range defined by Type and Format, that is, may be converted without loss. +// +// NOTE: this check is about type capacity and not formal verification such as: 1.0 != 1L +func IsValueValidAgainstRange(val interface{}, typeName, format, prefix, path string) error { + kind := reflect.ValueOf(val).Type().Kind() + + // What is the string representation of val + stringRep := "" + switch kind { + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + stringRep = swag.FormatUint64(valueHelp.asUint64(val)) + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + stringRep = swag.FormatInt64(valueHelp.asInt64(val)) + case reflect.Float32, reflect.Float64: + stringRep = swag.FormatFloat64(valueHelp.asFloat64(val)) + default: + return fmt.Errorf("%s value number range checking called with invalid (non numeric) val type in %s", prefix, path) + } + + var errVal error + + switch typeName { + case integerType: + switch format { + case integerFormatInt32: + _, errVal = swag.ConvertInt32(stringRep) + case integerFormatUInt32: + _, errVal = swag.ConvertUint32(stringRep) + case integerFormatUInt64: + _, errVal = swag.ConvertUint64(stringRep) + case integerFormatInt64: + fallthrough + default: + _, errVal = swag.ConvertInt64(stringRep) + } + case numberType: + fallthrough + default: + switch format { + case numberFormatFloat, numberFormatFloat32: + _, errVal = swag.ConvertFloat32(stringRep) + case numberFormatDouble, numberFormatFloat64: + fallthrough + default: + // No check can be performed here since + // no number beyond float64 is supported + } + } + if errVal != nil { // We don't report the actual errVal from strconv + if format != "" { + errVal = fmt.Errorf("%s value must be of type %s with format %s in %s", prefix, typeName, format, path) + } else { + errVal = fmt.Errorf("%s value must be of type %s (default format) in %s", prefix, typeName, path) + } + } + return errVal +} diff --git a/vendor/github.com/go-playground/locales/README.md b/vendor/github.com/go-playground/locales/README.md index ba1b0680c97..5b0694fd19a 100644 --- a/vendor/github.com/go-playground/locales/README.md +++ b/vendor/github.com/go-playground/locales/README.md @@ -1,5 +1,5 @@ ## locales -![Project status](https://img.shields.io/badge/version-0.13.0-green.svg) +![Project status](https://img.shields.io/badge/version-0.14.0-green.svg) [![Build Status](https://travis-ci.org/go-playground/locales.svg?branch=master)](https://travis-ci.org/go-playground/locales) [![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/locales)](https://goreportcard.com/report/github.com/go-playground/locales) [![GoDoc](https://godoc.org/github.com/go-playground/locales?status.svg)](https://godoc.org/github.com/go-playground/locales) @@ -11,7 +11,7 @@ an i18n package; these were built for use with, but not exclusive to, [Universal Features -------- -- [x] Rules generated from the latest [CLDR](http://cldr.unicode.org/index/downloads) data, v31.0.1 +- [x] Rules generated from the latest [CLDR](http://cldr.unicode.org/index/downloads) data, v36.0.1 - [x] Contains Cardinal, Ordinal and Range Plural Rules - [x] Contains Month, Weekday and Timezone translations built in - [x] Contains Date & Time formatting functions diff --git a/vendor/github.com/go-playground/locales/currency/currency.go b/vendor/github.com/go-playground/locales/currency/currency.go index cdaba596b62..b5a95fb0743 100644 --- a/vendor/github.com/go-playground/locales/currency/currency.go +++ b/vendor/github.com/go-playground/locales/currency/currency.go @@ -176,6 +176,7 @@ const ( MNT MOP MRO + MRU MTL MTP MUR @@ -262,9 +263,11 @@ const ( UYI UYP UYU + UYW UZS VEB VEF + VES VND VNN VUV diff --git a/vendor/github.com/go-playground/universal-translator/Makefile b/vendor/github.com/go-playground/universal-translator/Makefile new file mode 100644 index 00000000000..ec3455bd59c --- /dev/null +++ b/vendor/github.com/go-playground/universal-translator/Makefile @@ -0,0 +1,18 @@ +GOCMD=GO111MODULE=on go + +linters-install: + @golangci-lint --version >/dev/null 2>&1 || { \ + echo "installing linting tools..."; \ + curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v1.41.1; \ + } + +lint: linters-install + golangci-lint run + +test: + $(GOCMD) test -cover -race ./... + +bench: + $(GOCMD) test -bench=. -benchmem ./... + +.PHONY: test lint linters-install \ No newline at end of file diff --git a/vendor/github.com/go-playground/universal-translator/README.md b/vendor/github.com/go-playground/universal-translator/README.md index 071f33ab25a..46dec6d2b23 100644 --- a/vendor/github.com/go-playground/universal-translator/README.md +++ b/vendor/github.com/go-playground/universal-translator/README.md @@ -1,5 +1,5 @@ ## universal-translator -![Project status](https://img.shields.io/badge/version-0.17.0-green.svg) +![Project status](https://img.shields.io/badge/version-0.18.0-green.svg) [![Build Status](https://travis-ci.org/go-playground/universal-translator.svg?branch=master)](https://travis-ci.org/go-playground/universal-translator) [![Coverage Status](https://coveralls.io/repos/github/go-playground/universal-translator/badge.svg)](https://coveralls.io/github/go-playground/universal-translator) [![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/universal-translator)](https://goreportcard.com/report/github.com/go-playground/universal-translator) @@ -18,7 +18,7 @@ use in your applications. Features -------- -- [x] Rules generated from the [CLDR](http://cldr.unicode.org/index/downloads) data, v30.0.3 +- [x] Rules generated from the [CLDR](http://cldr.unicode.org/index/downloads) data, v36.0.1 - [x] Contains Cardinal, Ordinal and Range Plural Rules - [x] Contains Month, Weekday and Timezone translations built in - [x] Contains Date & Time formatting functions @@ -51,7 +51,7 @@ Please see https://godoc.org/github.com/go-playground/universal-translator for u File formatting -------------- -All types, Plain substitution, Cardinal, Ordinal and Range translations can all be contained withing the same file(s); +All types, Plain substitution, Cardinal, Ordinal and Range translations can all be contained within the same file(s); they are only separated for easy viewing. ##### Examples: diff --git a/vendor/github.com/go-playground/universal-translator/import_export.go b/vendor/github.com/go-playground/universal-translator/import_export.go index 7bd76f26b6f..1216f192372 100644 --- a/vendor/github.com/go-playground/universal-translator/import_export.go +++ b/vendor/github.com/go-playground/universal-translator/import_export.go @@ -257,6 +257,8 @@ func (t *UniversalTranslator) ImportByReader(format ImportExportFormat, reader i func stringToPR(s string) locales.PluralRule { switch s { + case "Zero": + return locales.PluralRuleZero case "One": return locales.PluralRuleOne case "Two": diff --git a/vendor/github.com/go-playground/universal-translator/translator.go b/vendor/github.com/go-playground/universal-translator/translator.go index cfafce8a09d..24b18db92a1 100644 --- a/vendor/github.com/go-playground/universal-translator/translator.go +++ b/vendor/github.com/go-playground/universal-translator/translator.go @@ -159,13 +159,13 @@ func (t *translator) AddCardinal(key interface{}, text string, rule locales.Plur } } else { - tarr = make([]*transText, 7, 7) + tarr = make([]*transText, 7) t.cardinalTanslations[key] = tarr } trans := &transText{ text: text, - indexes: make([]int, 2, 2), + indexes: make([]int, 2), } tarr[rule] = trans @@ -211,13 +211,13 @@ func (t *translator) AddOrdinal(key interface{}, text string, rule locales.Plura } } else { - tarr = make([]*transText, 7, 7) + tarr = make([]*transText, 7) t.ordinalTanslations[key] = tarr } trans := &transText{ text: text, - indexes: make([]int, 2, 2), + indexes: make([]int, 2), } tarr[rule] = trans @@ -261,13 +261,13 @@ func (t *translator) AddRange(key interface{}, text string, rule locales.PluralR } } else { - tarr = make([]*transText, 7, 7) + tarr = make([]*transText, 7) t.rangeTanslations[key] = tarr } trans := &transText{ text: text, - indexes: make([]int, 4, 4), + indexes: make([]int, 4), } tarr[rule] = trans diff --git a/vendor/github.com/go-stack/stack/.travis.yml b/vendor/github.com/go-stack/stack/.travis.yml deleted file mode 100644 index 5c5a2b516d3..00000000000 --- a/vendor/github.com/go-stack/stack/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -language: go -sudo: false -go: - - 1.7.x - - 1.8.x - - 1.9.x - - 1.10.x - - 1.11.x - - tip - -before_install: - - go get github.com/mattn/goveralls - -script: - - goveralls -service=travis-ci diff --git a/vendor/github.com/gobuffalo/flect/plural_rules.go b/vendor/github.com/gobuffalo/flect/plural_rules.go index 8cd3ba72e7a..ff67928438b 100644 --- a/vendor/github.com/gobuffalo/flect/plural_rules.go +++ b/vendor/github.com/gobuffalo/flect/plural_rules.go @@ -199,6 +199,7 @@ var singularToPluralSuffixList = []singularToPluralSuffix{ {"shoe", "shoes"}, {"stis", "stes"}, {"tive", "tives"}, + {"vice", "vices"}, {"wife", "wives"}, {"afe", "aves"}, {"bfe", "bves"}, diff --git a/vendor/github.com/google/gofuzz/.travis.yml b/vendor/github.com/google/gofuzz/.travis.yml index f8684d99fc4..061d72ae079 100644 --- a/vendor/github.com/google/gofuzz/.travis.yml +++ b/vendor/github.com/google/gofuzz/.travis.yml @@ -1,13 +1,10 @@ language: go go: - - 1.4 - - 1.3 - - 1.2 - - tip - -install: - - if ! go get code.google.com/p/go.tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi + - 1.11.x + - 1.12.x + - 1.13.x + - master script: - go test -cover diff --git a/vendor/github.com/google/gofuzz/CONTRIBUTING.md b/vendor/github.com/google/gofuzz/CONTRIBUTING.md index 51cf5cd1ada..97c1b34fd5e 100644 --- a/vendor/github.com/google/gofuzz/CONTRIBUTING.md +++ b/vendor/github.com/google/gofuzz/CONTRIBUTING.md @@ -1,7 +1,7 @@ # How to contribute # We'd love to accept your patches and contributions to this project. There are -a just a few small guidelines you need to follow. +just a few small guidelines you need to follow. ## Contributor License Agreement ## diff --git a/vendor/github.com/google/gofuzz/README.md b/vendor/github.com/google/gofuzz/README.md index 386c2a457a8..b503aae7d71 100644 --- a/vendor/github.com/google/gofuzz/README.md +++ b/vendor/github.com/google/gofuzz/README.md @@ -68,4 +68,22 @@ f.Fuzz(&myObject) // Type will correspond to whether A or B info is set. See more examples in ```example_test.go```. +You can use this library for easier [go-fuzz](https://github.com/dvyukov/go-fuzz)ing. +go-fuzz provides the user a byte-slice, which should be converted to different inputs +for the tested function. This library can help convert the byte slice. Consider for +example a fuzz test for a the function `mypackage.MyFunc` that takes an int arguments: +```go +// +build gofuzz +package mypackage + +import fuzz "github.com/google/gofuzz" + +func Fuzz(data []byte) int { + var i int + fuzz.NewFromGoFuzz(data).Fuzz(&i) + MyFunc(i) + return 0 +} +``` + Happy testing! diff --git a/vendor/github.com/google/gofuzz/bytesource/bytesource.go b/vendor/github.com/google/gofuzz/bytesource/bytesource.go new file mode 100644 index 00000000000..5bb36594969 --- /dev/null +++ b/vendor/github.com/google/gofuzz/bytesource/bytesource.go @@ -0,0 +1,81 @@ +/* +Copyright 2014 Google Inc. All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package bytesource provides a rand.Source64 that is determined by a slice of bytes. +package bytesource + +import ( + "bytes" + "encoding/binary" + "io" + "math/rand" +) + +// ByteSource implements rand.Source64 determined by a slice of bytes. The random numbers are +// generated from each 8 bytes in the slice, until the last bytes are consumed, from which a +// fallback pseudo random source is created in case more random numbers are required. +// It also exposes a `bytes.Reader` API, which lets callers consume the bytes directly. +type ByteSource struct { + *bytes.Reader + fallback rand.Source +} + +// New returns a new ByteSource from a given slice of bytes. +func New(input []byte) *ByteSource { + s := &ByteSource{ + Reader: bytes.NewReader(input), + fallback: rand.NewSource(0), + } + if len(input) > 0 { + s.fallback = rand.NewSource(int64(s.consumeUint64())) + } + return s +} + +func (s *ByteSource) Uint64() uint64 { + // Return from input if it was not exhausted. + if s.Len() > 0 { + return s.consumeUint64() + } + + // Input was exhausted, return random number from fallback (in this case fallback should not be + // nil). Try first having a Uint64 output (Should work in current rand implementation), + // otherwise return a conversion of Int63. + if s64, ok := s.fallback.(rand.Source64); ok { + return s64.Uint64() + } + return uint64(s.fallback.Int63()) +} + +func (s *ByteSource) Int63() int64 { + return int64(s.Uint64() >> 1) +} + +func (s *ByteSource) Seed(seed int64) { + s.fallback = rand.NewSource(seed) + s.Reader = bytes.NewReader(nil) +} + +// consumeUint64 reads 8 bytes from the input and convert them to a uint64. It assumes that the the +// bytes reader is not empty. +func (s *ByteSource) consumeUint64() uint64 { + var bytes [8]byte + _, err := s.Read(bytes[:]) + if err != nil && err != io.EOF { + panic("failed reading source") // Should not happen. + } + return binary.BigEndian.Uint64(bytes[:]) +} diff --git a/vendor/github.com/google/gofuzz/fuzz.go b/vendor/github.com/google/gofuzz/fuzz.go index da0a5f93800..761520a8cee 100644 --- a/vendor/github.com/google/gofuzz/fuzz.go +++ b/vendor/github.com/google/gofuzz/fuzz.go @@ -22,6 +22,9 @@ import ( "reflect" "regexp" "time" + + "github.com/google/gofuzz/bytesource" + "strings" ) // fuzzFuncMap is a map from a type to a fuzzFunc that handles that type. @@ -61,6 +64,34 @@ func NewWithSeed(seed int64) *Fuzzer { return f } +// NewFromGoFuzz is a helper function that enables using gofuzz (this +// project) with go-fuzz (https://github.com/dvyukov/go-fuzz) for continuous +// fuzzing. Essentially, it enables translating the fuzzing bytes from +// go-fuzz to any Go object using this library. +// +// This implementation promises a constant translation from a given slice of +// bytes to the fuzzed objects. This promise will remain over future +// versions of Go and of this library. +// +// Note: the returned Fuzzer should not be shared between multiple goroutines, +// as its deterministic output will no longer be available. +// +// Example: use go-fuzz to test the function `MyFunc(int)` in the package +// `mypackage`. Add the file: "mypacakge_fuzz.go" with the content: +// +// // +build gofuzz +// package mypacakge +// import fuzz "github.com/google/gofuzz" +// func Fuzz(data []byte) int { +// var i int +// fuzz.NewFromGoFuzz(data).Fuzz(&i) +// MyFunc(i) +// return 0 +// } +func NewFromGoFuzz(data []byte) *Fuzzer { + return New().RandSource(bytesource.New(data)) +} + // Funcs adds each entry in fuzzFuncs as a custom fuzzing function. // // Each entry in fuzzFuncs must be a function taking two parameters. @@ -141,7 +172,7 @@ func (f *Fuzzer) genElementCount() int { } func (f *Fuzzer) genShouldFill() bool { - return f.r.Float64() > f.nilChance + return f.r.Float64() >= f.nilChance } // MaxDepth sets the maximum number of recursive fuzz calls that will be made @@ -240,6 +271,7 @@ func (fc *fuzzerContext) doFuzz(v reflect.Value, flags uint64) { fn(v, fc.fuzzer.r) return } + switch v.Kind() { case reflect.Map: if fc.fuzzer.genShouldFill() { @@ -450,10 +482,10 @@ var fillFuncMap = map[reflect.Kind]func(reflect.Value, *rand.Rand){ v.SetFloat(r.Float64()) }, reflect.Complex64: func(v reflect.Value, r *rand.Rand) { - panic("unimplemented") + v.SetComplex(complex128(complex(r.Float32(), r.Float32()))) }, reflect.Complex128: func(v reflect.Value, r *rand.Rand) { - panic("unimplemented") + v.SetComplex(complex(r.Float64(), r.Float64())) }, reflect.String: func(v reflect.Value, r *rand.Rand) { v.SetString(randString(r)) @@ -465,38 +497,105 @@ var fillFuncMap = map[reflect.Kind]func(reflect.Value, *rand.Rand){ // randBool returns true or false randomly. func randBool(r *rand.Rand) bool { - if r.Int()&1 == 1 { - return true - } - return false + return r.Int31()&(1<<30) == 0 +} + +type int63nPicker interface { + Int63n(int64) int64 } -type charRange struct { - first, last rune +// UnicodeRange describes a sequential range of unicode characters. +// Last must be numerically greater than First. +type UnicodeRange struct { + First, Last rune } +// UnicodeRanges describes an arbitrary number of sequential ranges of unicode characters. +// To be useful, each range must have at least one character (First <= Last) and +// there must be at least one range. +type UnicodeRanges []UnicodeRange + // choose returns a random unicode character from the given range, using the // given randomness source. -func (r *charRange) choose(rand *rand.Rand) rune { - count := int64(r.last - r.first) - return r.first + rune(rand.Int63n(count)) +func (ur UnicodeRange) choose(r int63nPicker) rune { + count := int64(ur.Last - ur.First + 1) + return ur.First + rune(r.Int63n(count)) +} + +// CustomStringFuzzFunc constructs a FuzzFunc which produces random strings. +// Each character is selected from the range ur. If there are no characters +// in the range (cr.Last < cr.First), this will panic. +func (ur UnicodeRange) CustomStringFuzzFunc() func(s *string, c Continue) { + ur.check() + return func(s *string, c Continue) { + *s = ur.randString(c.Rand) + } } -var unicodeRanges = []charRange{ +// check is a function that used to check whether the first of ur(UnicodeRange) +// is greater than the last one. +func (ur UnicodeRange) check() { + if ur.Last < ur.First { + panic("The last encoding must be greater than the first one.") + } +} + +// randString of UnicodeRange makes a random string up to 20 characters long. +// Each character is selected form ur(UnicodeRange). +func (ur UnicodeRange) randString(r *rand.Rand) string { + n := r.Intn(20) + sb := strings.Builder{} + sb.Grow(n) + for i := 0; i < n; i++ { + sb.WriteRune(ur.choose(r)) + } + return sb.String() +} + +// defaultUnicodeRanges sets a default unicode range when user do not set +// CustomStringFuzzFunc() but wants fuzz string. +var defaultUnicodeRanges = UnicodeRanges{ {' ', '~'}, // ASCII characters {'\u00a0', '\u02af'}, // Multi-byte encoded characters {'\u4e00', '\u9fff'}, // Common CJK (even longer encodings) } +// CustomStringFuzzFunc constructs a FuzzFunc which produces random strings. +// Each character is selected from one of the ranges of ur(UnicodeRanges). +// Each range has an equal probability of being chosen. If there are no ranges, +// or a selected range has no characters (.Last < .First), this will panic. +// Do not modify any of the ranges in ur after calling this function. +func (ur UnicodeRanges) CustomStringFuzzFunc() func(s *string, c Continue) { + // Check unicode ranges slice is empty. + if len(ur) == 0 { + panic("UnicodeRanges is empty.") + } + // if not empty, each range should be checked. + for i := range ur { + ur[i].check() + } + return func(s *string, c Continue) { + *s = ur.randString(c.Rand) + } +} + +// randString of UnicodeRanges makes a random string up to 20 characters long. +// Each character is selected form one of the ranges of ur(UnicodeRanges), +// and each range has an equal probability of being chosen. +func (ur UnicodeRanges) randString(r *rand.Rand) string { + n := r.Intn(20) + sb := strings.Builder{} + sb.Grow(n) + for i := 0; i < n; i++ { + sb.WriteRune(ur[r.Intn(len(ur))].choose(r)) + } + return sb.String() +} + // randString makes a random string up to 20 characters long. The returned string // may include a variety of (valid) UTF-8 encodings. func randString(r *rand.Rand) string { - n := r.Intn(20) - runes := make([]rune, n) - for i := range runes { - runes[i] = unicodeRanges[r.Intn(len(unicodeRanges))].choose(r) - } - return string(runes) + return defaultUnicodeRanges.randString(r) } // randUint64 makes random 64 bit numbers. diff --git a/vendor/github.com/hashicorp/go-retryablehttp/.travis.yml b/vendor/github.com/hashicorp/go-retryablehttp/.travis.yml deleted file mode 100644 index c4fb6d6c8bb..00000000000 --- a/vendor/github.com/hashicorp/go-retryablehttp/.travis.yml +++ /dev/null @@ -1,12 +0,0 @@ -sudo: false - -language: go - -go: - - 1.12.4 - -branches: - only: - - master - -script: make updatedeps test diff --git a/vendor/github.com/hashicorp/go-retryablehttp/README.md b/vendor/github.com/hashicorp/go-retryablehttp/README.md index 30357c75668..8943becf19b 100644 --- a/vendor/github.com/hashicorp/go-retryablehttp/README.md +++ b/vendor/github.com/hashicorp/go-retryablehttp/README.md @@ -26,6 +26,7 @@ fails so that the full request can be attempted again. See the details. Version 0.6.0 and before are compatible with Go prior to 1.12. From 0.6.1 onward, Go 1.12+ is required. +From 0.6.7 onward, Go 1.13+ is required. Example Use =========== diff --git a/vendor/github.com/hashicorp/go-retryablehttp/client.go b/vendor/github.com/hashicorp/go-retryablehttp/client.go index f1ccd3df35c..adbdd92e3ba 100644 --- a/vendor/github.com/hashicorp/go-retryablehttp/client.go +++ b/vendor/github.com/hashicorp/go-retryablehttp/client.go @@ -35,11 +35,12 @@ import ( "net/url" "os" "regexp" + "strconv" "strings" "sync" "time" - "github.com/hashicorp/go-cleanhttp" + cleanhttp "github.com/hashicorp/go-cleanhttp" ) var ( @@ -276,12 +277,16 @@ type Logger interface { Printf(string, ...interface{}) } -// LeveledLogger interface implements the basic methods that a logger library needs +// LeveledLogger is an interface that can be implemented by any logger or a +// logger wrapper to provide leveled logging. The methods accept a message +// string and a variadic number of key-value pairs. For log.Printf style +// formatting where message string contains a format specifier, use Logger +// interface. type LeveledLogger interface { - Error(string, ...interface{}) - Info(string, ...interface{}) - Debug(string, ...interface{}) - Warn(string, ...interface{}) + Error(msg string, keysAndValues ...interface{}) + Info(msg string, keysAndValues ...interface{}) + Debug(msg string, keysAndValues ...interface{}) + Warn(msg string, keysAndValues ...interface{}) } // hookLogger adapts an LeveledLogger to Logger for use by the existing hook functions @@ -357,6 +362,7 @@ type Client struct { ErrorHandler ErrorHandler loggerInit sync.Once + clientInit sync.Once } // NewClient creates a new Client with default settings. @@ -398,21 +404,39 @@ func DefaultRetryPolicy(ctx context.Context, resp *http.Response, err error) (bo return false, ctx.Err() } + // don't propagate other errors + shouldRetry, _ := baseRetryPolicy(resp, err) + return shouldRetry, nil +} + +// ErrorPropagatedRetryPolicy is the same as DefaultRetryPolicy, except it +// propagates errors back instead of returning nil. This allows you to inspect +// why it decided to retry or not. +func ErrorPropagatedRetryPolicy(ctx context.Context, resp *http.Response, err error) (bool, error) { + // do not retry on context.Canceled or context.DeadlineExceeded + if ctx.Err() != nil { + return false, ctx.Err() + } + + return baseRetryPolicy(resp, err) +} + +func baseRetryPolicy(resp *http.Response, err error) (bool, error) { if err != nil { if v, ok := err.(*url.Error); ok { // Don't retry if the error was due to too many redirects. if redirectsErrorRe.MatchString(v.Error()) { - return false, nil + return false, v } // Don't retry if the error was due to an invalid protocol scheme. if schemeErrorRe.MatchString(v.Error()) { - return false, nil + return false, v } // Don't retry if the error was due to TLS cert verification failure. if _, ok := v.Err.(x509.UnknownAuthorityError); ok { - return false, nil + return false, v } } @@ -420,12 +444,19 @@ func DefaultRetryPolicy(ctx context.Context, resp *http.Response, err error) (bo return true, nil } + // 429 Too Many Requests is recoverable. Sometimes the server puts + // a Retry-After response header to indicate when the server is + // available to start processing request from client. + if resp.StatusCode == http.StatusTooManyRequests { + return true, nil + } + // Check the response code. We retry on 500-range responses to allow // the server time to recover, as 500's are typically not permanent // errors and may relate to outages on the server side. This will catch // invalid response codes as well, like 0 and 999. if resp.StatusCode == 0 || (resp.StatusCode >= 500 && resp.StatusCode != 501) { - return true, nil + return true, fmt.Errorf("unexpected HTTP status %s", resp.Status) } return false, nil @@ -434,7 +465,21 @@ func DefaultRetryPolicy(ctx context.Context, resp *http.Response, err error) (bo // DefaultBackoff provides a default callback for Client.Backoff which // will perform exponential backoff based on the attempt number and limited // by the provided minimum and maximum durations. +// +// It also tries to parse Retry-After response header when a http.StatusTooManyRequests +// (HTTP Code 429) is found in the resp parameter. Hence it will return the number of +// seconds the server states it may be ready to process more requests from this client. func DefaultBackoff(min, max time.Duration, attemptNum int, resp *http.Response) time.Duration { + if resp != nil { + if resp.StatusCode == http.StatusTooManyRequests || resp.StatusCode == http.StatusServiceUnavailable { + if s, ok := resp.Header["Retry-After"]; ok { + if sleep, err := strconv.ParseInt(s[0], 10, 64); err == nil { + return time.Second * time.Duration(sleep) + } + } + } + } + mult := math.Pow(2, float64(attemptNum)) * float64(min) sleep := time.Duration(mult) if float64(sleep) != mult || sleep > max { @@ -490,25 +535,31 @@ func PassthroughErrorHandler(resp *http.Response, err error, _ int) (*http.Respo // Do wraps calling an HTTP method with retries. func (c *Client) Do(req *Request) (*http.Response, error) { - if c.HTTPClient == nil { - c.HTTPClient = cleanhttp.DefaultPooledClient() - } + c.clientInit.Do(func() { + if c.HTTPClient == nil { + c.HTTPClient = cleanhttp.DefaultPooledClient() + } + }) logger := c.logger() if logger != nil { switch v := logger.(type) { - case Logger: - v.Printf("[DEBUG] %s %s", req.Method, req.URL) case LeveledLogger: v.Debug("performing request", "method", req.Method, "url", req.URL) + case Logger: + v.Printf("[DEBUG] %s %s", req.Method, req.URL) } } var resp *http.Response - var err error + var attempt int + var shouldRetry bool + var doErr, checkErr error for i := 0; ; i++ { + attempt++ + var code int // HTTP response code // Always rewind the request body when non-nil. @@ -527,30 +578,30 @@ func (c *Client) Do(req *Request) (*http.Response, error) { if c.RequestLogHook != nil { switch v := logger.(type) { - case Logger: - c.RequestLogHook(v, req.Request, i) case LeveledLogger: c.RequestLogHook(hookLogger{v}, req.Request, i) + case Logger: + c.RequestLogHook(v, req.Request, i) default: c.RequestLogHook(nil, req.Request, i) } } // Attempt the request - resp, err = c.HTTPClient.Do(req.Request) + resp, doErr = c.HTTPClient.Do(req.Request) if resp != nil { code = resp.StatusCode } // Check if we should continue with retries. - checkOK, checkErr := c.CheckRetry(req.Context(), resp, err) + shouldRetry, checkErr = c.CheckRetry(req.Context(), resp, doErr) - if err != nil { + if doErr != nil { switch v := logger.(type) { - case Logger: - v.Printf("[ERR] %s %s request failed: %v", req.Method, req.URL, err) case LeveledLogger: - v.Error("request failed", "error", err, "method", req.Method, "url", req.URL) + v.Error("request failed", "error", doErr, "method", req.Method, "url", req.URL) + case Logger: + v.Printf("[ERR] %s %s request failed: %v", req.Method, req.URL, doErr) } } else { // Call this here to maintain the behavior of logging all requests, @@ -558,23 +609,18 @@ func (c *Client) Do(req *Request) (*http.Response, error) { if c.ResponseLogHook != nil { // Call the response logger function if provided. switch v := logger.(type) { - case Logger: - c.ResponseLogHook(v, resp) case LeveledLogger: c.ResponseLogHook(hookLogger{v}, resp) + case Logger: + c.ResponseLogHook(v, resp) default: c.ResponseLogHook(nil, resp) } } } - // Now decide if we should continue. - if !checkOK { - if checkErr != nil { - err = checkErr - } - c.HTTPClient.CloseIdleConnections() - return resp, err + if !shouldRetry { + break } // We do this before drainBody because there's no need for the I/O if @@ -585,7 +631,7 @@ func (c *Client) Do(req *Request) (*http.Response, error) { } // We're going to retry, consume any response to reuse the connection. - if err == nil && resp != nil { + if doErr == nil { c.drainBody(resp.Body) } @@ -596,10 +642,10 @@ func (c *Client) Do(req *Request) (*http.Response, error) { } if logger != nil { switch v := logger.(type) { - case Logger: - v.Printf("[DEBUG] %s: retrying in %s (%d left)", desc, wait, remain) case LeveledLogger: v.Debug("retrying request", "request", desc, "timeout", wait, "remaining", remain) + case Logger: + v.Printf("[DEBUG] %s: retrying in %s (%d left)", desc, wait, remain) } } select { @@ -608,21 +654,44 @@ func (c *Client) Do(req *Request) (*http.Response, error) { return nil, req.Context().Err() case <-time.After(wait): } + + // Make shallow copy of http Request so that we can modify its body + // without racing against the closeBody call in persistConn.writeLoop. + httpreq := *req.Request + req.Request = &httpreq + } + + // this is the closest we have to success criteria + if doErr == nil && checkErr == nil && !shouldRetry { + return resp, nil + } + + defer c.HTTPClient.CloseIdleConnections() + + err := doErr + if checkErr != nil { + err = checkErr } if c.ErrorHandler != nil { - c.HTTPClient.CloseIdleConnections() - return c.ErrorHandler(resp, err, c.RetryMax+1) + return c.ErrorHandler(resp, err, attempt) } // By default, we close the response body and return an error without // returning the response if resp != nil { - resp.Body.Close() + c.drainBody(resp.Body) } - c.HTTPClient.CloseIdleConnections() - return nil, fmt.Errorf("%s %s giving up after %d attempts", - req.Method, req.URL, c.RetryMax+1) + + // this means CheckRetry thought the request was a failure, but didn't + // communicate why + if err == nil { + return nil, fmt.Errorf("%s %s giving up after %d attempt(s)", + req.Method, req.URL, attempt) + } + + return nil, fmt.Errorf("%s %s giving up after %d attempt(s): %w", + req.Method, req.URL, attempt, err) } // Try to read the response body so we can reuse this connection. @@ -632,10 +701,10 @@ func (c *Client) drainBody(body io.ReadCloser) { if err != nil { if c.logger() != nil { switch v := c.logger().(type) { - case Logger: - v.Printf("[ERR] error reading response body: %v", err) case LeveledLogger: v.Error("error reading response body", "error", err) + case Logger: + v.Printf("[ERR] error reading response body: %v", err) } } } diff --git a/vendor/github.com/hashicorp/go-retryablehttp/roundtripper.go b/vendor/github.com/hashicorp/go-retryablehttp/roundtripper.go index b841b4cfe53..8f3ee358427 100644 --- a/vendor/github.com/hashicorp/go-retryablehttp/roundtripper.go +++ b/vendor/github.com/hashicorp/go-retryablehttp/roundtripper.go @@ -1,7 +1,9 @@ package retryablehttp import ( + "errors" "net/http" + "net/url" "sync" ) @@ -39,5 +41,12 @@ func (rt *RoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { } // Execute the request. - return rt.Client.Do(retryableReq) + resp, err := rt.Client.Do(retryableReq) + // If we got an error returned by standard library's `Do` method, unwrap it + // otherwise we will wind up erroneously re-nesting the error. + if _, ok := err.(*url.Error); ok { + return resp, errors.Unwrap(err) + } + + return resp, err } diff --git a/vendor/github.com/josharian/intern/README.md b/vendor/github.com/josharian/intern/README.md new file mode 100644 index 00000000000..ffc44b219b2 --- /dev/null +++ b/vendor/github.com/josharian/intern/README.md @@ -0,0 +1,5 @@ +Docs: https://godoc.org/github.com/josharian/intern + +See also [Go issue 5160](https://golang.org/issue/5160). + +License: MIT diff --git a/vendor/github.com/josharian/intern/intern.go b/vendor/github.com/josharian/intern/intern.go new file mode 100644 index 00000000000..7acb1fe90a1 --- /dev/null +++ b/vendor/github.com/josharian/intern/intern.go @@ -0,0 +1,44 @@ +// Package intern interns strings. +// Interning is best effort only. +// Interned strings may be removed automatically +// at any time without notification. +// All functions may be called concurrently +// with themselves and each other. +package intern + +import "sync" + +var ( + pool sync.Pool = sync.Pool{ + New: func() interface{} { + return make(map[string]string) + }, + } +) + +// String returns s, interned. +func String(s string) string { + m := pool.Get().(map[string]string) + c, ok := m[s] + if ok { + pool.Put(m) + return c + } + m[s] = s + pool.Put(m) + return s +} + +// Bytes returns b converted to a string, interned. +func Bytes(b []byte) string { + m := pool.Get().(map[string]string) + c, ok := m[string(b)] + if ok { + pool.Put(m) + return c + } + s := string(b) + m[s] = s + pool.Put(m) + return s +} diff --git a/vendor/github.com/josharian/intern/license.md b/vendor/github.com/josharian/intern/license.md new file mode 100644 index 00000000000..353d3055f0b --- /dev/null +++ b/vendor/github.com/josharian/intern/license.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Josh Bleecher Snyder + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/github.com/leodido/go-urn/.travis.yml b/vendor/github.com/leodido/go-urn/.travis.yml index e56cf7cc066..21f348d65a3 100644 --- a/vendor/github.com/leodido/go-urn/.travis.yml +++ b/vendor/github.com/leodido/go-urn/.travis.yml @@ -1,11 +1,9 @@ language: go go: - - 1.9.x - - 1.10.x - - 1.11.x - - 1.12.x - 1.13.x + - 1.14.x + - 1.15.x - tip before_install: diff --git a/vendor/github.com/leodido/go-urn/urn.go b/vendor/github.com/leodido/go-urn/urn.go index b903b7b3cd5..d51a6c915be 100644 --- a/vendor/github.com/leodido/go-urn/urn.go +++ b/vendor/github.com/leodido/go-urn/urn.go @@ -1,9 +1,13 @@ package urn import ( + "encoding/json" + "fmt" "strings" ) +const errInvalidURN = "invalid URN: %s" + // URN represents an Uniform Resource Name. // // The general form represented is: @@ -61,3 +65,22 @@ func Parse(u []byte) (*URN, bool) { return urn, true } + +// MarshalJSON marshals the URN to JSON string form (e.g. `"urn:oid:1.2.3.4"`). +func (u URN) MarshalJSON() ([]byte, error) { + return json.Marshal(u.String()) +} + +// MarshalJSON unmarshals a URN from JSON string form (e.g. `"urn:oid:1.2.3.4"`). +func (u *URN) UnmarshalJSON(bytes []byte) error { + var str string + if err := json.Unmarshal(bytes, &str); err != nil { + return err + } + if value, ok := Parse([]byte(str)); !ok { + return fmt.Errorf(errInvalidURN, str) + } else { + *u = *value + } + return nil +} \ No newline at end of file diff --git a/vendor/github.com/mailru/easyjson/LICENSE b/vendor/github.com/mailru/easyjson/LICENSE new file mode 100644 index 00000000000..fbff658f70d --- /dev/null +++ b/vendor/github.com/mailru/easyjson/LICENSE @@ -0,0 +1,7 @@ +Copyright (c) 2016 Mail.Ru Group + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/mailru/easyjson/buffer/pool.go b/vendor/github.com/mailru/easyjson/buffer/pool.go new file mode 100644 index 00000000000..598a54af9db --- /dev/null +++ b/vendor/github.com/mailru/easyjson/buffer/pool.go @@ -0,0 +1,278 @@ +// Package buffer implements a buffer for serialization, consisting of a chain of []byte-s to +// reduce copying and to allow reuse of individual chunks. +package buffer + +import ( + "io" + "net" + "sync" +) + +// PoolConfig contains configuration for the allocation and reuse strategy. +type PoolConfig struct { + StartSize int // Minimum chunk size that is allocated. + PooledSize int // Minimum chunk size that is reused, reusing chunks too small will result in overhead. + MaxSize int // Maximum chunk size that will be allocated. +} + +var config = PoolConfig{ + StartSize: 128, + PooledSize: 512, + MaxSize: 32768, +} + +// Reuse pool: chunk size -> pool. +var buffers = map[int]*sync.Pool{} + +func initBuffers() { + for l := config.PooledSize; l <= config.MaxSize; l *= 2 { + buffers[l] = new(sync.Pool) + } +} + +func init() { + initBuffers() +} + +// Init sets up a non-default pooling and allocation strategy. Should be run before serialization is done. +func Init(cfg PoolConfig) { + config = cfg + initBuffers() +} + +// putBuf puts a chunk to reuse pool if it can be reused. +func putBuf(buf []byte) { + size := cap(buf) + if size < config.PooledSize { + return + } + if c := buffers[size]; c != nil { + c.Put(buf[:0]) + } +} + +// getBuf gets a chunk from reuse pool or creates a new one if reuse failed. +func getBuf(size int) []byte { + if size >= config.PooledSize { + if c := buffers[size]; c != nil { + v := c.Get() + if v != nil { + return v.([]byte) + } + } + } + return make([]byte, 0, size) +} + +// Buffer is a buffer optimized for serialization without extra copying. +type Buffer struct { + + // Buf is the current chunk that can be used for serialization. + Buf []byte + + toPool []byte + bufs [][]byte +} + +// EnsureSpace makes sure that the current chunk contains at least s free bytes, +// possibly creating a new chunk. +func (b *Buffer) EnsureSpace(s int) { + if cap(b.Buf)-len(b.Buf) < s { + b.ensureSpaceSlow(s) + } +} + +func (b *Buffer) ensureSpaceSlow(s int) { + l := len(b.Buf) + if l > 0 { + if cap(b.toPool) != cap(b.Buf) { + // Chunk was reallocated, toPool can be pooled. + putBuf(b.toPool) + } + if cap(b.bufs) == 0 { + b.bufs = make([][]byte, 0, 8) + } + b.bufs = append(b.bufs, b.Buf) + l = cap(b.toPool) * 2 + } else { + l = config.StartSize + } + + if l > config.MaxSize { + l = config.MaxSize + } + b.Buf = getBuf(l) + b.toPool = b.Buf +} + +// AppendByte appends a single byte to buffer. +func (b *Buffer) AppendByte(data byte) { + b.EnsureSpace(1) + b.Buf = append(b.Buf, data) +} + +// AppendBytes appends a byte slice to buffer. +func (b *Buffer) AppendBytes(data []byte) { + if len(data) <= cap(b.Buf)-len(b.Buf) { + b.Buf = append(b.Buf, data...) // fast path + } else { + b.appendBytesSlow(data) + } +} + +func (b *Buffer) appendBytesSlow(data []byte) { + for len(data) > 0 { + b.EnsureSpace(1) + + sz := cap(b.Buf) - len(b.Buf) + if sz > len(data) { + sz = len(data) + } + + b.Buf = append(b.Buf, data[:sz]...) + data = data[sz:] + } +} + +// AppendString appends a string to buffer. +func (b *Buffer) AppendString(data string) { + if len(data) <= cap(b.Buf)-len(b.Buf) { + b.Buf = append(b.Buf, data...) // fast path + } else { + b.appendStringSlow(data) + } +} + +func (b *Buffer) appendStringSlow(data string) { + for len(data) > 0 { + b.EnsureSpace(1) + + sz := cap(b.Buf) - len(b.Buf) + if sz > len(data) { + sz = len(data) + } + + b.Buf = append(b.Buf, data[:sz]...) + data = data[sz:] + } +} + +// Size computes the size of a buffer by adding sizes of every chunk. +func (b *Buffer) Size() int { + size := len(b.Buf) + for _, buf := range b.bufs { + size += len(buf) + } + return size +} + +// DumpTo outputs the contents of a buffer to a writer and resets the buffer. +func (b *Buffer) DumpTo(w io.Writer) (written int, err error) { + bufs := net.Buffers(b.bufs) + if len(b.Buf) > 0 { + bufs = append(bufs, b.Buf) + } + n, err := bufs.WriteTo(w) + + for _, buf := range b.bufs { + putBuf(buf) + } + putBuf(b.toPool) + + b.bufs = nil + b.Buf = nil + b.toPool = nil + + return int(n), err +} + +// BuildBytes creates a single byte slice with all the contents of the buffer. Data is +// copied if it does not fit in a single chunk. You can optionally provide one byte +// slice as argument that it will try to reuse. +func (b *Buffer) BuildBytes(reuse ...[]byte) []byte { + if len(b.bufs) == 0 { + ret := b.Buf + b.toPool = nil + b.Buf = nil + return ret + } + + var ret []byte + size := b.Size() + + // If we got a buffer as argument and it is big enough, reuse it. + if len(reuse) == 1 && cap(reuse[0]) >= size { + ret = reuse[0][:0] + } else { + ret = make([]byte, 0, size) + } + for _, buf := range b.bufs { + ret = append(ret, buf...) + putBuf(buf) + } + + ret = append(ret, b.Buf...) + putBuf(b.toPool) + + b.bufs = nil + b.toPool = nil + b.Buf = nil + + return ret +} + +type readCloser struct { + offset int + bufs [][]byte +} + +func (r *readCloser) Read(p []byte) (n int, err error) { + for _, buf := range r.bufs { + // Copy as much as we can. + x := copy(p[n:], buf[r.offset:]) + n += x // Increment how much we filled. + + // Did we empty the whole buffer? + if r.offset+x == len(buf) { + // On to the next buffer. + r.offset = 0 + r.bufs = r.bufs[1:] + + // We can release this buffer. + putBuf(buf) + } else { + r.offset += x + } + + if n == len(p) { + break + } + } + // No buffers left or nothing read? + if len(r.bufs) == 0 { + err = io.EOF + } + return +} + +func (r *readCloser) Close() error { + // Release all remaining buffers. + for _, buf := range r.bufs { + putBuf(buf) + } + // In case Close gets called multiple times. + r.bufs = nil + + return nil +} + +// ReadCloser creates an io.ReadCloser with all the contents of the buffer. +func (b *Buffer) ReadCloser() io.ReadCloser { + ret := &readCloser{0, append(b.bufs, b.Buf)} + + b.bufs = nil + b.toPool = nil + b.Buf = nil + + return ret +} diff --git a/vendor/github.com/mailru/easyjson/jlexer/bytestostr.go b/vendor/github.com/mailru/easyjson/jlexer/bytestostr.go new file mode 100644 index 00000000000..ff7b27c5b20 --- /dev/null +++ b/vendor/github.com/mailru/easyjson/jlexer/bytestostr.go @@ -0,0 +1,24 @@ +// This file will only be included to the build if neither +// easyjson_nounsafe nor appengine build tag is set. See README notes +// for more details. + +//+build !easyjson_nounsafe +//+build !appengine + +package jlexer + +import ( + "reflect" + "unsafe" +) + +// bytesToStr creates a string pointing at the slice to avoid copying. +// +// Warning: the string returned by the function should be used with care, as the whole input data +// chunk may be either blocked from being freed by GC because of a single string or the buffer.Data +// may be garbage-collected even when the string exists. +func bytesToStr(data []byte) string { + h := (*reflect.SliceHeader)(unsafe.Pointer(&data)) + shdr := reflect.StringHeader{Data: h.Data, Len: h.Len} + return *(*string)(unsafe.Pointer(&shdr)) +} diff --git a/vendor/github.com/mailru/easyjson/jlexer/bytestostr_nounsafe.go b/vendor/github.com/mailru/easyjson/jlexer/bytestostr_nounsafe.go new file mode 100644 index 00000000000..864d1be6763 --- /dev/null +++ b/vendor/github.com/mailru/easyjson/jlexer/bytestostr_nounsafe.go @@ -0,0 +1,13 @@ +// This file is included to the build if any of the buildtags below +// are defined. Refer to README notes for more details. + +//+build easyjson_nounsafe appengine + +package jlexer + +// bytesToStr creates a string normally from []byte +// +// Note that this method is roughly 1.5x slower than using the 'unsafe' method. +func bytesToStr(data []byte) string { + return string(data) +} diff --git a/vendor/github.com/mailru/easyjson/jlexer/error.go b/vendor/github.com/mailru/easyjson/jlexer/error.go new file mode 100644 index 00000000000..e90ec40d05f --- /dev/null +++ b/vendor/github.com/mailru/easyjson/jlexer/error.go @@ -0,0 +1,15 @@ +package jlexer + +import "fmt" + +// LexerError implements the error interface and represents all possible errors that can be +// generated during parsing the JSON data. +type LexerError struct { + Reason string + Offset int + Data string +} + +func (l *LexerError) Error() string { + return fmt.Sprintf("parse error: %s near offset %d of '%s'", l.Reason, l.Offset, l.Data) +} diff --git a/vendor/github.com/mailru/easyjson/jlexer/lexer.go b/vendor/github.com/mailru/easyjson/jlexer/lexer.go new file mode 100644 index 00000000000..b5f5e261329 --- /dev/null +++ b/vendor/github.com/mailru/easyjson/jlexer/lexer.go @@ -0,0 +1,1244 @@ +// Package jlexer contains a JSON lexer implementation. +// +// It is expected that it is mostly used with generated parser code, so the interface is tuned +// for a parser that knows what kind of data is expected. +package jlexer + +import ( + "bytes" + "encoding/base64" + "encoding/json" + "errors" + "fmt" + "io" + "strconv" + "unicode" + "unicode/utf16" + "unicode/utf8" + + "github.com/josharian/intern" +) + +// tokenKind determines type of a token. +type tokenKind byte + +const ( + tokenUndef tokenKind = iota // No token. + tokenDelim // Delimiter: one of '{', '}', '[' or ']'. + tokenString // A string literal, e.g. "abc\u1234" + tokenNumber // Number literal, e.g. 1.5e5 + tokenBool // Boolean literal: true or false. + tokenNull // null keyword. +) + +// token describes a single token: type, position in the input and value. +type token struct { + kind tokenKind // Type of a token. + + boolValue bool // Value if a boolean literal token. + byteValueCloned bool // true if byteValue was allocated and does not refer to original json body + byteValue []byte // Raw value of a token. + delimValue byte +} + +// Lexer is a JSON lexer: it iterates over JSON tokens in a byte slice. +type Lexer struct { + Data []byte // Input data given to the lexer. + + start int // Start of the current token. + pos int // Current unscanned position in the input stream. + token token // Last scanned token, if token.kind != tokenUndef. + + firstElement bool // Whether current element is the first in array or an object. + wantSep byte // A comma or a colon character, which need to occur before a token. + + UseMultipleErrors bool // If we want to use multiple errors. + fatalError error // Fatal error occurred during lexing. It is usually a syntax error. + multipleErrors []*LexerError // Semantic errors occurred during lexing. Marshalling will be continued after finding this errors. +} + +// FetchToken scans the input for the next token. +func (r *Lexer) FetchToken() { + r.token.kind = tokenUndef + r.start = r.pos + + // Check if r.Data has r.pos element + // If it doesn't, it mean corrupted input data + if len(r.Data) < r.pos { + r.errParse("Unexpected end of data") + return + } + // Determine the type of a token by skipping whitespace and reading the + // first character. + for _, c := range r.Data[r.pos:] { + switch c { + case ':', ',': + if r.wantSep == c { + r.pos++ + r.start++ + r.wantSep = 0 + } else { + r.errSyntax() + } + + case ' ', '\t', '\r', '\n': + r.pos++ + r.start++ + + case '"': + if r.wantSep != 0 { + r.errSyntax() + } + + r.token.kind = tokenString + r.fetchString() + return + + case '{', '[': + if r.wantSep != 0 { + r.errSyntax() + } + r.firstElement = true + r.token.kind = tokenDelim + r.token.delimValue = r.Data[r.pos] + r.pos++ + return + + case '}', ']': + if !r.firstElement && (r.wantSep != ',') { + r.errSyntax() + } + r.wantSep = 0 + r.token.kind = tokenDelim + r.token.delimValue = r.Data[r.pos] + r.pos++ + return + + case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-': + if r.wantSep != 0 { + r.errSyntax() + } + r.token.kind = tokenNumber + r.fetchNumber() + return + + case 'n': + if r.wantSep != 0 { + r.errSyntax() + } + + r.token.kind = tokenNull + r.fetchNull() + return + + case 't': + if r.wantSep != 0 { + r.errSyntax() + } + + r.token.kind = tokenBool + r.token.boolValue = true + r.fetchTrue() + return + + case 'f': + if r.wantSep != 0 { + r.errSyntax() + } + + r.token.kind = tokenBool + r.token.boolValue = false + r.fetchFalse() + return + + default: + r.errSyntax() + return + } + } + r.fatalError = io.EOF + return +} + +// isTokenEnd returns true if the char can follow a non-delimiter token +func isTokenEnd(c byte) bool { + return c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '[' || c == ']' || c == '{' || c == '}' || c == ',' || c == ':' +} + +// fetchNull fetches and checks remaining bytes of null keyword. +func (r *Lexer) fetchNull() { + r.pos += 4 + if r.pos > len(r.Data) || + r.Data[r.pos-3] != 'u' || + r.Data[r.pos-2] != 'l' || + r.Data[r.pos-1] != 'l' || + (r.pos != len(r.Data) && !isTokenEnd(r.Data[r.pos])) { + + r.pos -= 4 + r.errSyntax() + } +} + +// fetchTrue fetches and checks remaining bytes of true keyword. +func (r *Lexer) fetchTrue() { + r.pos += 4 + if r.pos > len(r.Data) || + r.Data[r.pos-3] != 'r' || + r.Data[r.pos-2] != 'u' || + r.Data[r.pos-1] != 'e' || + (r.pos != len(r.Data) && !isTokenEnd(r.Data[r.pos])) { + + r.pos -= 4 + r.errSyntax() + } +} + +// fetchFalse fetches and checks remaining bytes of false keyword. +func (r *Lexer) fetchFalse() { + r.pos += 5 + if r.pos > len(r.Data) || + r.Data[r.pos-4] != 'a' || + r.Data[r.pos-3] != 'l' || + r.Data[r.pos-2] != 's' || + r.Data[r.pos-1] != 'e' || + (r.pos != len(r.Data) && !isTokenEnd(r.Data[r.pos])) { + + r.pos -= 5 + r.errSyntax() + } +} + +// fetchNumber scans a number literal token. +func (r *Lexer) fetchNumber() { + hasE := false + afterE := false + hasDot := false + + r.pos++ + for i, c := range r.Data[r.pos:] { + switch { + case c >= '0' && c <= '9': + afterE = false + case c == '.' && !hasDot: + hasDot = true + case (c == 'e' || c == 'E') && !hasE: + hasE = true + hasDot = true + afterE = true + case (c == '+' || c == '-') && afterE: + afterE = false + default: + r.pos += i + if !isTokenEnd(c) { + r.errSyntax() + } else { + r.token.byteValue = r.Data[r.start:r.pos] + } + return + } + } + + r.pos = len(r.Data) + r.token.byteValue = r.Data[r.start:] +} + +// findStringLen tries to scan into the string literal for ending quote char to determine required size. +// The size will be exact if no escapes are present and may be inexact if there are escaped chars. +func findStringLen(data []byte) (isValid bool, length int) { + for { + idx := bytes.IndexByte(data, '"') + if idx == -1 { + return false, len(data) + } + if idx == 0 || (idx > 0 && data[idx-1] != '\\') { + return true, length + idx + } + + // count \\\\\\\ sequences. even number of slashes means quote is not really escaped + cnt := 1 + for idx-cnt-1 >= 0 && data[idx-cnt-1] == '\\' { + cnt++ + } + if cnt%2 == 0 { + return true, length + idx + } + + length += idx + 1 + data = data[idx+1:] + } +} + +// unescapeStringToken performs unescaping of string token. +// if no escaping is needed, original string is returned, otherwise - a new one allocated +func (r *Lexer) unescapeStringToken() (err error) { + data := r.token.byteValue + var unescapedData []byte + + for { + i := bytes.IndexByte(data, '\\') + if i == -1 { + break + } + + escapedRune, escapedBytes, err := decodeEscape(data[i:]) + if err != nil { + r.errParse(err.Error()) + return err + } + + if unescapedData == nil { + unescapedData = make([]byte, 0, len(r.token.byteValue)) + } + + var d [4]byte + s := utf8.EncodeRune(d[:], escapedRune) + unescapedData = append(unescapedData, data[:i]...) + unescapedData = append(unescapedData, d[:s]...) + + data = data[i+escapedBytes:] + } + + if unescapedData != nil { + r.token.byteValue = append(unescapedData, data...) + r.token.byteValueCloned = true + } + return +} + +// getu4 decodes \uXXXX from the beginning of s, returning the hex value, +// or it returns -1. +func getu4(s []byte) rune { + if len(s) < 6 || s[0] != '\\' || s[1] != 'u' { + return -1 + } + var val rune + for i := 2; i < len(s) && i < 6; i++ { + var v byte + c := s[i] + switch c { + case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': + v = c - '0' + case 'a', 'b', 'c', 'd', 'e', 'f': + v = c - 'a' + 10 + case 'A', 'B', 'C', 'D', 'E', 'F': + v = c - 'A' + 10 + default: + return -1 + } + + val <<= 4 + val |= rune(v) + } + return val +} + +// decodeEscape processes a single escape sequence and returns number of bytes processed. +func decodeEscape(data []byte) (decoded rune, bytesProcessed int, err error) { + if len(data) < 2 { + return 0, 0, errors.New("incorrect escape symbol \\ at the end of token") + } + + c := data[1] + switch c { + case '"', '/', '\\': + return rune(c), 2, nil + case 'b': + return '\b', 2, nil + case 'f': + return '\f', 2, nil + case 'n': + return '\n', 2, nil + case 'r': + return '\r', 2, nil + case 't': + return '\t', 2, nil + case 'u': + rr := getu4(data) + if rr < 0 { + return 0, 0, errors.New("incorrectly escaped \\uXXXX sequence") + } + + read := 6 + if utf16.IsSurrogate(rr) { + rr1 := getu4(data[read:]) + if dec := utf16.DecodeRune(rr, rr1); dec != unicode.ReplacementChar { + read += 6 + rr = dec + } else { + rr = unicode.ReplacementChar + } + } + return rr, read, nil + } + + return 0, 0, errors.New("incorrectly escaped bytes") +} + +// fetchString scans a string literal token. +func (r *Lexer) fetchString() { + r.pos++ + data := r.Data[r.pos:] + + isValid, length := findStringLen(data) + if !isValid { + r.pos += length + r.errParse("unterminated string literal") + return + } + r.token.byteValue = data[:length] + r.pos += length + 1 // skip closing '"' as well +} + +// scanToken scans the next token if no token is currently available in the lexer. +func (r *Lexer) scanToken() { + if r.token.kind != tokenUndef || r.fatalError != nil { + return + } + + r.FetchToken() +} + +// consume resets the current token to allow scanning the next one. +func (r *Lexer) consume() { + r.token.kind = tokenUndef + r.token.byteValueCloned = false + r.token.delimValue = 0 +} + +// Ok returns true if no error (including io.EOF) was encountered during scanning. +func (r *Lexer) Ok() bool { + return r.fatalError == nil +} + +const maxErrorContextLen = 13 + +func (r *Lexer) errParse(what string) { + if r.fatalError == nil { + var str string + if len(r.Data)-r.pos <= maxErrorContextLen { + str = string(r.Data) + } else { + str = string(r.Data[r.pos:r.pos+maxErrorContextLen-3]) + "..." + } + r.fatalError = &LexerError{ + Reason: what, + Offset: r.pos, + Data: str, + } + } +} + +func (r *Lexer) errSyntax() { + r.errParse("syntax error") +} + +func (r *Lexer) errInvalidToken(expected string) { + if r.fatalError != nil { + return + } + if r.UseMultipleErrors { + r.pos = r.start + r.consume() + r.SkipRecursive() + switch expected { + case "[": + r.token.delimValue = ']' + r.token.kind = tokenDelim + case "{": + r.token.delimValue = '}' + r.token.kind = tokenDelim + } + r.addNonfatalError(&LexerError{ + Reason: fmt.Sprintf("expected %s", expected), + Offset: r.start, + Data: string(r.Data[r.start:r.pos]), + }) + return + } + + var str string + if len(r.token.byteValue) <= maxErrorContextLen { + str = string(r.token.byteValue) + } else { + str = string(r.token.byteValue[:maxErrorContextLen-3]) + "..." + } + r.fatalError = &LexerError{ + Reason: fmt.Sprintf("expected %s", expected), + Offset: r.pos, + Data: str, + } +} + +func (r *Lexer) GetPos() int { + return r.pos +} + +// Delim consumes a token and verifies that it is the given delimiter. +func (r *Lexer) Delim(c byte) { + if r.token.kind == tokenUndef && r.Ok() { + r.FetchToken() + } + + if !r.Ok() || r.token.delimValue != c { + r.consume() // errInvalidToken can change token if UseMultipleErrors is enabled. + r.errInvalidToken(string([]byte{c})) + } else { + r.consume() + } +} + +// IsDelim returns true if there was no scanning error and next token is the given delimiter. +func (r *Lexer) IsDelim(c byte) bool { + if r.token.kind == tokenUndef && r.Ok() { + r.FetchToken() + } + return !r.Ok() || r.token.delimValue == c +} + +// Null verifies that the next token is null and consumes it. +func (r *Lexer) Null() { + if r.token.kind == tokenUndef && r.Ok() { + r.FetchToken() + } + if !r.Ok() || r.token.kind != tokenNull { + r.errInvalidToken("null") + } + r.consume() +} + +// IsNull returns true if the next token is a null keyword. +func (r *Lexer) IsNull() bool { + if r.token.kind == tokenUndef && r.Ok() { + r.FetchToken() + } + return r.Ok() && r.token.kind == tokenNull +} + +// Skip skips a single token. +func (r *Lexer) Skip() { + if r.token.kind == tokenUndef && r.Ok() { + r.FetchToken() + } + r.consume() +} + +// SkipRecursive skips next array or object completely, or just skips a single token if not +// an array/object. +// +// Note: no syntax validation is performed on the skipped data. +func (r *Lexer) SkipRecursive() { + r.scanToken() + var start, end byte + startPos := r.start + + switch r.token.delimValue { + case '{': + start, end = '{', '}' + case '[': + start, end = '[', ']' + default: + r.consume() + return + } + + r.consume() + + level := 1 + inQuotes := false + wasEscape := false + + for i, c := range r.Data[r.pos:] { + switch { + case c == start && !inQuotes: + level++ + case c == end && !inQuotes: + level-- + if level == 0 { + r.pos += i + 1 + if !json.Valid(r.Data[startPos:r.pos]) { + r.pos = len(r.Data) + r.fatalError = &LexerError{ + Reason: "skipped array/object json value is invalid", + Offset: r.pos, + Data: string(r.Data[r.pos:]), + } + } + return + } + case c == '\\' && inQuotes: + wasEscape = !wasEscape + continue + case c == '"' && inQuotes: + inQuotes = wasEscape + case c == '"': + inQuotes = true + } + wasEscape = false + } + r.pos = len(r.Data) + r.fatalError = &LexerError{ + Reason: "EOF reached while skipping array/object or token", + Offset: r.pos, + Data: string(r.Data[r.pos:]), + } +} + +// Raw fetches the next item recursively as a data slice +func (r *Lexer) Raw() []byte { + r.SkipRecursive() + if !r.Ok() { + return nil + } + return r.Data[r.start:r.pos] +} + +// IsStart returns whether the lexer is positioned at the start +// of an input string. +func (r *Lexer) IsStart() bool { + return r.pos == 0 +} + +// Consumed reads all remaining bytes from the input, publishing an error if +// there is anything but whitespace remaining. +func (r *Lexer) Consumed() { + if r.pos > len(r.Data) || !r.Ok() { + return + } + + for _, c := range r.Data[r.pos:] { + if c != ' ' && c != '\t' && c != '\r' && c != '\n' { + r.AddError(&LexerError{ + Reason: "invalid character '" + string(c) + "' after top-level value", + Offset: r.pos, + Data: string(r.Data[r.pos:]), + }) + return + } + + r.pos++ + r.start++ + } +} + +func (r *Lexer) unsafeString(skipUnescape bool) (string, []byte) { + if r.token.kind == tokenUndef && r.Ok() { + r.FetchToken() + } + if !r.Ok() || r.token.kind != tokenString { + r.errInvalidToken("string") + return "", nil + } + if !skipUnescape { + if err := r.unescapeStringToken(); err != nil { + r.errInvalidToken("string") + return "", nil + } + } + + bytes := r.token.byteValue + ret := bytesToStr(r.token.byteValue) + r.consume() + return ret, bytes +} + +// UnsafeString returns the string value if the token is a string literal. +// +// Warning: returned string may point to the input buffer, so the string should not outlive +// the input buffer. Intended pattern of usage is as an argument to a switch statement. +func (r *Lexer) UnsafeString() string { + ret, _ := r.unsafeString(false) + return ret +} + +// UnsafeBytes returns the byte slice if the token is a string literal. +func (r *Lexer) UnsafeBytes() []byte { + _, ret := r.unsafeString(false) + return ret +} + +// UnsafeFieldName returns current member name string token +func (r *Lexer) UnsafeFieldName(skipUnescape bool) string { + ret, _ := r.unsafeString(skipUnescape) + return ret +} + +// String reads a string literal. +func (r *Lexer) String() string { + if r.token.kind == tokenUndef && r.Ok() { + r.FetchToken() + } + if !r.Ok() || r.token.kind != tokenString { + r.errInvalidToken("string") + return "" + } + if err := r.unescapeStringToken(); err != nil { + r.errInvalidToken("string") + return "" + } + var ret string + if r.token.byteValueCloned { + ret = bytesToStr(r.token.byteValue) + } else { + ret = string(r.token.byteValue) + } + r.consume() + return ret +} + +// StringIntern reads a string literal, and performs string interning on it. +func (r *Lexer) StringIntern() string { + if r.token.kind == tokenUndef && r.Ok() { + r.FetchToken() + } + if !r.Ok() || r.token.kind != tokenString { + r.errInvalidToken("string") + return "" + } + if err := r.unescapeStringToken(); err != nil { + r.errInvalidToken("string") + return "" + } + ret := intern.Bytes(r.token.byteValue) + r.consume() + return ret +} + +// Bytes reads a string literal and base64 decodes it into a byte slice. +func (r *Lexer) Bytes() []byte { + if r.token.kind == tokenUndef && r.Ok() { + r.FetchToken() + } + if !r.Ok() || r.token.kind != tokenString { + r.errInvalidToken("string") + return nil + } + if err := r.unescapeStringToken(); err != nil { + r.errInvalidToken("string") + return nil + } + ret := make([]byte, base64.StdEncoding.DecodedLen(len(r.token.byteValue))) + n, err := base64.StdEncoding.Decode(ret, r.token.byteValue) + if err != nil { + r.fatalError = &LexerError{ + Reason: err.Error(), + } + return nil + } + + r.consume() + return ret[:n] +} + +// Bool reads a true or false boolean keyword. +func (r *Lexer) Bool() bool { + if r.token.kind == tokenUndef && r.Ok() { + r.FetchToken() + } + if !r.Ok() || r.token.kind != tokenBool { + r.errInvalidToken("bool") + return false + } + ret := r.token.boolValue + r.consume() + return ret +} + +func (r *Lexer) number() string { + if r.token.kind == tokenUndef && r.Ok() { + r.FetchToken() + } + if !r.Ok() || r.token.kind != tokenNumber { + r.errInvalidToken("number") + return "" + } + ret := bytesToStr(r.token.byteValue) + r.consume() + return ret +} + +func (r *Lexer) Uint8() uint8 { + s := r.number() + if !r.Ok() { + return 0 + } + + n, err := strconv.ParseUint(s, 10, 8) + if err != nil { + r.addNonfatalError(&LexerError{ + Offset: r.start, + Reason: err.Error(), + Data: s, + }) + } + return uint8(n) +} + +func (r *Lexer) Uint16() uint16 { + s := r.number() + if !r.Ok() { + return 0 + } + + n, err := strconv.ParseUint(s, 10, 16) + if err != nil { + r.addNonfatalError(&LexerError{ + Offset: r.start, + Reason: err.Error(), + Data: s, + }) + } + return uint16(n) +} + +func (r *Lexer) Uint32() uint32 { + s := r.number() + if !r.Ok() { + return 0 + } + + n, err := strconv.ParseUint(s, 10, 32) + if err != nil { + r.addNonfatalError(&LexerError{ + Offset: r.start, + Reason: err.Error(), + Data: s, + }) + } + return uint32(n) +} + +func (r *Lexer) Uint64() uint64 { + s := r.number() + if !r.Ok() { + return 0 + } + + n, err := strconv.ParseUint(s, 10, 64) + if err != nil { + r.addNonfatalError(&LexerError{ + Offset: r.start, + Reason: err.Error(), + Data: s, + }) + } + return n +} + +func (r *Lexer) Uint() uint { + return uint(r.Uint64()) +} + +func (r *Lexer) Int8() int8 { + s := r.number() + if !r.Ok() { + return 0 + } + + n, err := strconv.ParseInt(s, 10, 8) + if err != nil { + r.addNonfatalError(&LexerError{ + Offset: r.start, + Reason: err.Error(), + Data: s, + }) + } + return int8(n) +} + +func (r *Lexer) Int16() int16 { + s := r.number() + if !r.Ok() { + return 0 + } + + n, err := strconv.ParseInt(s, 10, 16) + if err != nil { + r.addNonfatalError(&LexerError{ + Offset: r.start, + Reason: err.Error(), + Data: s, + }) + } + return int16(n) +} + +func (r *Lexer) Int32() int32 { + s := r.number() + if !r.Ok() { + return 0 + } + + n, err := strconv.ParseInt(s, 10, 32) + if err != nil { + r.addNonfatalError(&LexerError{ + Offset: r.start, + Reason: err.Error(), + Data: s, + }) + } + return int32(n) +} + +func (r *Lexer) Int64() int64 { + s := r.number() + if !r.Ok() { + return 0 + } + + n, err := strconv.ParseInt(s, 10, 64) + if err != nil { + r.addNonfatalError(&LexerError{ + Offset: r.start, + Reason: err.Error(), + Data: s, + }) + } + return n +} + +func (r *Lexer) Int() int { + return int(r.Int64()) +} + +func (r *Lexer) Uint8Str() uint8 { + s, b := r.unsafeString(false) + if !r.Ok() { + return 0 + } + + n, err := strconv.ParseUint(s, 10, 8) + if err != nil { + r.addNonfatalError(&LexerError{ + Offset: r.start, + Reason: err.Error(), + Data: string(b), + }) + } + return uint8(n) +} + +func (r *Lexer) Uint16Str() uint16 { + s, b := r.unsafeString(false) + if !r.Ok() { + return 0 + } + + n, err := strconv.ParseUint(s, 10, 16) + if err != nil { + r.addNonfatalError(&LexerError{ + Offset: r.start, + Reason: err.Error(), + Data: string(b), + }) + } + return uint16(n) +} + +func (r *Lexer) Uint32Str() uint32 { + s, b := r.unsafeString(false) + if !r.Ok() { + return 0 + } + + n, err := strconv.ParseUint(s, 10, 32) + if err != nil { + r.addNonfatalError(&LexerError{ + Offset: r.start, + Reason: err.Error(), + Data: string(b), + }) + } + return uint32(n) +} + +func (r *Lexer) Uint64Str() uint64 { + s, b := r.unsafeString(false) + if !r.Ok() { + return 0 + } + + n, err := strconv.ParseUint(s, 10, 64) + if err != nil { + r.addNonfatalError(&LexerError{ + Offset: r.start, + Reason: err.Error(), + Data: string(b), + }) + } + return n +} + +func (r *Lexer) UintStr() uint { + return uint(r.Uint64Str()) +} + +func (r *Lexer) UintptrStr() uintptr { + return uintptr(r.Uint64Str()) +} + +func (r *Lexer) Int8Str() int8 { + s, b := r.unsafeString(false) + if !r.Ok() { + return 0 + } + + n, err := strconv.ParseInt(s, 10, 8) + if err != nil { + r.addNonfatalError(&LexerError{ + Offset: r.start, + Reason: err.Error(), + Data: string(b), + }) + } + return int8(n) +} + +func (r *Lexer) Int16Str() int16 { + s, b := r.unsafeString(false) + if !r.Ok() { + return 0 + } + + n, err := strconv.ParseInt(s, 10, 16) + if err != nil { + r.addNonfatalError(&LexerError{ + Offset: r.start, + Reason: err.Error(), + Data: string(b), + }) + } + return int16(n) +} + +func (r *Lexer) Int32Str() int32 { + s, b := r.unsafeString(false) + if !r.Ok() { + return 0 + } + + n, err := strconv.ParseInt(s, 10, 32) + if err != nil { + r.addNonfatalError(&LexerError{ + Offset: r.start, + Reason: err.Error(), + Data: string(b), + }) + } + return int32(n) +} + +func (r *Lexer) Int64Str() int64 { + s, b := r.unsafeString(false) + if !r.Ok() { + return 0 + } + + n, err := strconv.ParseInt(s, 10, 64) + if err != nil { + r.addNonfatalError(&LexerError{ + Offset: r.start, + Reason: err.Error(), + Data: string(b), + }) + } + return n +} + +func (r *Lexer) IntStr() int { + return int(r.Int64Str()) +} + +func (r *Lexer) Float32() float32 { + s := r.number() + if !r.Ok() { + return 0 + } + + n, err := strconv.ParseFloat(s, 32) + if err != nil { + r.addNonfatalError(&LexerError{ + Offset: r.start, + Reason: err.Error(), + Data: s, + }) + } + return float32(n) +} + +func (r *Lexer) Float32Str() float32 { + s, b := r.unsafeString(false) + if !r.Ok() { + return 0 + } + n, err := strconv.ParseFloat(s, 32) + if err != nil { + r.addNonfatalError(&LexerError{ + Offset: r.start, + Reason: err.Error(), + Data: string(b), + }) + } + return float32(n) +} + +func (r *Lexer) Float64() float64 { + s := r.number() + if !r.Ok() { + return 0 + } + + n, err := strconv.ParseFloat(s, 64) + if err != nil { + r.addNonfatalError(&LexerError{ + Offset: r.start, + Reason: err.Error(), + Data: s, + }) + } + return n +} + +func (r *Lexer) Float64Str() float64 { + s, b := r.unsafeString(false) + if !r.Ok() { + return 0 + } + n, err := strconv.ParseFloat(s, 64) + if err != nil { + r.addNonfatalError(&LexerError{ + Offset: r.start, + Reason: err.Error(), + Data: string(b), + }) + } + return n +} + +func (r *Lexer) Error() error { + return r.fatalError +} + +func (r *Lexer) AddError(e error) { + if r.fatalError == nil { + r.fatalError = e + } +} + +func (r *Lexer) AddNonFatalError(e error) { + r.addNonfatalError(&LexerError{ + Offset: r.start, + Data: string(r.Data[r.start:r.pos]), + Reason: e.Error(), + }) +} + +func (r *Lexer) addNonfatalError(err *LexerError) { + if r.UseMultipleErrors { + // We don't want to add errors with the same offset. + if len(r.multipleErrors) != 0 && r.multipleErrors[len(r.multipleErrors)-1].Offset == err.Offset { + return + } + r.multipleErrors = append(r.multipleErrors, err) + return + } + r.fatalError = err +} + +func (r *Lexer) GetNonFatalErrors() []*LexerError { + return r.multipleErrors +} + +// JsonNumber fetches and json.Number from 'encoding/json' package. +// Both int, float or string, contains them are valid values +func (r *Lexer) JsonNumber() json.Number { + if r.token.kind == tokenUndef && r.Ok() { + r.FetchToken() + } + if !r.Ok() { + r.errInvalidToken("json.Number") + return json.Number("") + } + + switch r.token.kind { + case tokenString: + return json.Number(r.String()) + case tokenNumber: + return json.Number(r.Raw()) + case tokenNull: + r.Null() + return json.Number("") + default: + r.errSyntax() + return json.Number("") + } +} + +// Interface fetches an interface{} analogous to the 'encoding/json' package. +func (r *Lexer) Interface() interface{} { + if r.token.kind == tokenUndef && r.Ok() { + r.FetchToken() + } + + if !r.Ok() { + return nil + } + switch r.token.kind { + case tokenString: + return r.String() + case tokenNumber: + return r.Float64() + case tokenBool: + return r.Bool() + case tokenNull: + r.Null() + return nil + } + + if r.token.delimValue == '{' { + r.consume() + + ret := map[string]interface{}{} + for !r.IsDelim('}') { + key := r.String() + r.WantColon() + ret[key] = r.Interface() + r.WantComma() + } + r.Delim('}') + + if r.Ok() { + return ret + } else { + return nil + } + } else if r.token.delimValue == '[' { + r.consume() + + ret := []interface{}{} + for !r.IsDelim(']') { + ret = append(ret, r.Interface()) + r.WantComma() + } + r.Delim(']') + + if r.Ok() { + return ret + } else { + return nil + } + } + r.errSyntax() + return nil +} + +// WantComma requires a comma to be present before fetching next token. +func (r *Lexer) WantComma() { + r.wantSep = ',' + r.firstElement = false +} + +// WantColon requires a colon to be present before fetching next token. +func (r *Lexer) WantColon() { + r.wantSep = ':' + r.firstElement = false +} diff --git a/vendor/github.com/mailru/easyjson/jwriter/writer.go b/vendor/github.com/mailru/easyjson/jwriter/writer.go new file mode 100644 index 00000000000..2c5b20105bb --- /dev/null +++ b/vendor/github.com/mailru/easyjson/jwriter/writer.go @@ -0,0 +1,405 @@ +// Package jwriter contains a JSON writer. +package jwriter + +import ( + "io" + "strconv" + "unicode/utf8" + + "github.com/mailru/easyjson/buffer" +) + +// Flags describe various encoding options. The behavior may be actually implemented in the encoder, but +// Flags field in Writer is used to set and pass them around. +type Flags int + +const ( + NilMapAsEmpty Flags = 1 << iota // Encode nil map as '{}' rather than 'null'. + NilSliceAsEmpty // Encode nil slice as '[]' rather than 'null'. +) + +// Writer is a JSON writer. +type Writer struct { + Flags Flags + + Error error + Buffer buffer.Buffer + NoEscapeHTML bool +} + +// Size returns the size of the data that was written out. +func (w *Writer) Size() int { + return w.Buffer.Size() +} + +// DumpTo outputs the data to given io.Writer, resetting the buffer. +func (w *Writer) DumpTo(out io.Writer) (written int, err error) { + return w.Buffer.DumpTo(out) +} + +// BuildBytes returns writer data as a single byte slice. You can optionally provide one byte slice +// as argument that it will try to reuse. +func (w *Writer) BuildBytes(reuse ...[]byte) ([]byte, error) { + if w.Error != nil { + return nil, w.Error + } + + return w.Buffer.BuildBytes(reuse...), nil +} + +// ReadCloser returns an io.ReadCloser that can be used to read the data. +// ReadCloser also resets the buffer. +func (w *Writer) ReadCloser() (io.ReadCloser, error) { + if w.Error != nil { + return nil, w.Error + } + + return w.Buffer.ReadCloser(), nil +} + +// RawByte appends raw binary data to the buffer. +func (w *Writer) RawByte(c byte) { + w.Buffer.AppendByte(c) +} + +// RawByte appends raw binary data to the buffer. +func (w *Writer) RawString(s string) { + w.Buffer.AppendString(s) +} + +// Raw appends raw binary data to the buffer or sets the error if it is given. Useful for +// calling with results of MarshalJSON-like functions. +func (w *Writer) Raw(data []byte, err error) { + switch { + case w.Error != nil: + return + case err != nil: + w.Error = err + case len(data) > 0: + w.Buffer.AppendBytes(data) + default: + w.RawString("null") + } +} + +// RawText encloses raw binary data in quotes and appends in to the buffer. +// Useful for calling with results of MarshalText-like functions. +func (w *Writer) RawText(data []byte, err error) { + switch { + case w.Error != nil: + return + case err != nil: + w.Error = err + case len(data) > 0: + w.String(string(data)) + default: + w.RawString("null") + } +} + +// Base64Bytes appends data to the buffer after base64 encoding it +func (w *Writer) Base64Bytes(data []byte) { + if data == nil { + w.Buffer.AppendString("null") + return + } + w.Buffer.AppendByte('"') + w.base64(data) + w.Buffer.AppendByte('"') +} + +func (w *Writer) Uint8(n uint8) { + w.Buffer.EnsureSpace(3) + w.Buffer.Buf = strconv.AppendUint(w.Buffer.Buf, uint64(n), 10) +} + +func (w *Writer) Uint16(n uint16) { + w.Buffer.EnsureSpace(5) + w.Buffer.Buf = strconv.AppendUint(w.Buffer.Buf, uint64(n), 10) +} + +func (w *Writer) Uint32(n uint32) { + w.Buffer.EnsureSpace(10) + w.Buffer.Buf = strconv.AppendUint(w.Buffer.Buf, uint64(n), 10) +} + +func (w *Writer) Uint(n uint) { + w.Buffer.EnsureSpace(20) + w.Buffer.Buf = strconv.AppendUint(w.Buffer.Buf, uint64(n), 10) +} + +func (w *Writer) Uint64(n uint64) { + w.Buffer.EnsureSpace(20) + w.Buffer.Buf = strconv.AppendUint(w.Buffer.Buf, n, 10) +} + +func (w *Writer) Int8(n int8) { + w.Buffer.EnsureSpace(4) + w.Buffer.Buf = strconv.AppendInt(w.Buffer.Buf, int64(n), 10) +} + +func (w *Writer) Int16(n int16) { + w.Buffer.EnsureSpace(6) + w.Buffer.Buf = strconv.AppendInt(w.Buffer.Buf, int64(n), 10) +} + +func (w *Writer) Int32(n int32) { + w.Buffer.EnsureSpace(11) + w.Buffer.Buf = strconv.AppendInt(w.Buffer.Buf, int64(n), 10) +} + +func (w *Writer) Int(n int) { + w.Buffer.EnsureSpace(21) + w.Buffer.Buf = strconv.AppendInt(w.Buffer.Buf, int64(n), 10) +} + +func (w *Writer) Int64(n int64) { + w.Buffer.EnsureSpace(21) + w.Buffer.Buf = strconv.AppendInt(w.Buffer.Buf, n, 10) +} + +func (w *Writer) Uint8Str(n uint8) { + w.Buffer.EnsureSpace(3) + w.Buffer.Buf = append(w.Buffer.Buf, '"') + w.Buffer.Buf = strconv.AppendUint(w.Buffer.Buf, uint64(n), 10) + w.Buffer.Buf = append(w.Buffer.Buf, '"') +} + +func (w *Writer) Uint16Str(n uint16) { + w.Buffer.EnsureSpace(5) + w.Buffer.Buf = append(w.Buffer.Buf, '"') + w.Buffer.Buf = strconv.AppendUint(w.Buffer.Buf, uint64(n), 10) + w.Buffer.Buf = append(w.Buffer.Buf, '"') +} + +func (w *Writer) Uint32Str(n uint32) { + w.Buffer.EnsureSpace(10) + w.Buffer.Buf = append(w.Buffer.Buf, '"') + w.Buffer.Buf = strconv.AppendUint(w.Buffer.Buf, uint64(n), 10) + w.Buffer.Buf = append(w.Buffer.Buf, '"') +} + +func (w *Writer) UintStr(n uint) { + w.Buffer.EnsureSpace(20) + w.Buffer.Buf = append(w.Buffer.Buf, '"') + w.Buffer.Buf = strconv.AppendUint(w.Buffer.Buf, uint64(n), 10) + w.Buffer.Buf = append(w.Buffer.Buf, '"') +} + +func (w *Writer) Uint64Str(n uint64) { + w.Buffer.EnsureSpace(20) + w.Buffer.Buf = append(w.Buffer.Buf, '"') + w.Buffer.Buf = strconv.AppendUint(w.Buffer.Buf, n, 10) + w.Buffer.Buf = append(w.Buffer.Buf, '"') +} + +func (w *Writer) UintptrStr(n uintptr) { + w.Buffer.EnsureSpace(20) + w.Buffer.Buf = append(w.Buffer.Buf, '"') + w.Buffer.Buf = strconv.AppendUint(w.Buffer.Buf, uint64(n), 10) + w.Buffer.Buf = append(w.Buffer.Buf, '"') +} + +func (w *Writer) Int8Str(n int8) { + w.Buffer.EnsureSpace(4) + w.Buffer.Buf = append(w.Buffer.Buf, '"') + w.Buffer.Buf = strconv.AppendInt(w.Buffer.Buf, int64(n), 10) + w.Buffer.Buf = append(w.Buffer.Buf, '"') +} + +func (w *Writer) Int16Str(n int16) { + w.Buffer.EnsureSpace(6) + w.Buffer.Buf = append(w.Buffer.Buf, '"') + w.Buffer.Buf = strconv.AppendInt(w.Buffer.Buf, int64(n), 10) + w.Buffer.Buf = append(w.Buffer.Buf, '"') +} + +func (w *Writer) Int32Str(n int32) { + w.Buffer.EnsureSpace(11) + w.Buffer.Buf = append(w.Buffer.Buf, '"') + w.Buffer.Buf = strconv.AppendInt(w.Buffer.Buf, int64(n), 10) + w.Buffer.Buf = append(w.Buffer.Buf, '"') +} + +func (w *Writer) IntStr(n int) { + w.Buffer.EnsureSpace(21) + w.Buffer.Buf = append(w.Buffer.Buf, '"') + w.Buffer.Buf = strconv.AppendInt(w.Buffer.Buf, int64(n), 10) + w.Buffer.Buf = append(w.Buffer.Buf, '"') +} + +func (w *Writer) Int64Str(n int64) { + w.Buffer.EnsureSpace(21) + w.Buffer.Buf = append(w.Buffer.Buf, '"') + w.Buffer.Buf = strconv.AppendInt(w.Buffer.Buf, n, 10) + w.Buffer.Buf = append(w.Buffer.Buf, '"') +} + +func (w *Writer) Float32(n float32) { + w.Buffer.EnsureSpace(20) + w.Buffer.Buf = strconv.AppendFloat(w.Buffer.Buf, float64(n), 'g', -1, 32) +} + +func (w *Writer) Float32Str(n float32) { + w.Buffer.EnsureSpace(20) + w.Buffer.Buf = append(w.Buffer.Buf, '"') + w.Buffer.Buf = strconv.AppendFloat(w.Buffer.Buf, float64(n), 'g', -1, 32) + w.Buffer.Buf = append(w.Buffer.Buf, '"') +} + +func (w *Writer) Float64(n float64) { + w.Buffer.EnsureSpace(20) + w.Buffer.Buf = strconv.AppendFloat(w.Buffer.Buf, n, 'g', -1, 64) +} + +func (w *Writer) Float64Str(n float64) { + w.Buffer.EnsureSpace(20) + w.Buffer.Buf = append(w.Buffer.Buf, '"') + w.Buffer.Buf = strconv.AppendFloat(w.Buffer.Buf, float64(n), 'g', -1, 64) + w.Buffer.Buf = append(w.Buffer.Buf, '"') +} + +func (w *Writer) Bool(v bool) { + w.Buffer.EnsureSpace(5) + if v { + w.Buffer.Buf = append(w.Buffer.Buf, "true"...) + } else { + w.Buffer.Buf = append(w.Buffer.Buf, "false"...) + } +} + +const chars = "0123456789abcdef" + +func getTable(falseValues ...int) [128]bool { + table := [128]bool{} + + for i := 0; i < 128; i++ { + table[i] = true + } + + for _, v := range falseValues { + table[v] = false + } + + return table +} + +var ( + htmlEscapeTable = getTable(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, '"', '&', '<', '>', '\\') + htmlNoEscapeTable = getTable(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, '"', '\\') +) + +func (w *Writer) String(s string) { + w.Buffer.AppendByte('"') + + // Portions of the string that contain no escapes are appended as + // byte slices. + + p := 0 // last non-escape symbol + + escapeTable := &htmlEscapeTable + if w.NoEscapeHTML { + escapeTable = &htmlNoEscapeTable + } + + for i := 0; i < len(s); { + c := s[i] + + if c < utf8.RuneSelf { + if escapeTable[c] { + // single-width character, no escaping is required + i++ + continue + } + + w.Buffer.AppendString(s[p:i]) + switch c { + case '\t': + w.Buffer.AppendString(`\t`) + case '\r': + w.Buffer.AppendString(`\r`) + case '\n': + w.Buffer.AppendString(`\n`) + case '\\': + w.Buffer.AppendString(`\\`) + case '"': + w.Buffer.AppendString(`\"`) + default: + w.Buffer.AppendString(`\u00`) + w.Buffer.AppendByte(chars[c>>4]) + w.Buffer.AppendByte(chars[c&0xf]) + } + + i++ + p = i + continue + } + + // broken utf + runeValue, runeWidth := utf8.DecodeRuneInString(s[i:]) + if runeValue == utf8.RuneError && runeWidth == 1 { + w.Buffer.AppendString(s[p:i]) + w.Buffer.AppendString(`\ufffd`) + i++ + p = i + continue + } + + // jsonp stuff - tab separator and line separator + if runeValue == '\u2028' || runeValue == '\u2029' { + w.Buffer.AppendString(s[p:i]) + w.Buffer.AppendString(`\u202`) + w.Buffer.AppendByte(chars[runeValue&0xf]) + i += runeWidth + p = i + continue + } + i += runeWidth + } + w.Buffer.AppendString(s[p:]) + w.Buffer.AppendByte('"') +} + +const encode = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" +const padChar = '=' + +func (w *Writer) base64(in []byte) { + + if len(in) == 0 { + return + } + + w.Buffer.EnsureSpace(((len(in)-1)/3 + 1) * 4) + + si := 0 + n := (len(in) / 3) * 3 + + for si < n { + // Convert 3x 8bit source bytes into 4 bytes + val := uint(in[si+0])<<16 | uint(in[si+1])<<8 | uint(in[si+2]) + + w.Buffer.Buf = append(w.Buffer.Buf, encode[val>>18&0x3F], encode[val>>12&0x3F], encode[val>>6&0x3F], encode[val&0x3F]) + + si += 3 + } + + remain := len(in) - si + if remain == 0 { + return + } + + // Add the remaining small block + val := uint(in[si+0]) << 16 + if remain == 2 { + val |= uint(in[si+1]) << 8 + } + + w.Buffer.Buf = append(w.Buffer.Buf, encode[val>>18&0x3F], encode[val>>12&0x3F]) + + switch remain { + case 2: + w.Buffer.Buf = append(w.Buffer.Buf, encode[val>>6&0x3F], byte(padChar)) + case 1: + w.Buffer.Buf = append(w.Buffer.Buf, byte(padChar), byte(padChar)) + } +} diff --git a/vendor/github.com/mattn/go-colorable/.travis.yml b/vendor/github.com/mattn/go-colorable/.travis.yml index 98db8f060bd..7942c565ce6 100644 --- a/vendor/github.com/mattn/go-colorable/.travis.yml +++ b/vendor/github.com/mattn/go-colorable/.travis.yml @@ -1,9 +1,15 @@ language: go +sudo: false go: + - 1.13.x - tip before_install: - - go get github.com/mattn/goveralls - - go get golang.org/x/tools/cmd/cover + - go get -t -v ./... + script: - - $HOME/gopath/bin/goveralls -repotoken xnXqRGwgW3SXIguzxf90ZSK1GPYZPaGrw + - ./go.test.sh + +after_success: + - bash <(curl -s https://codecov.io/bash) + diff --git a/vendor/github.com/mattn/go-colorable/README.md b/vendor/github.com/mattn/go-colorable/README.md index 56729a92ca6..e055952b667 100644 --- a/vendor/github.com/mattn/go-colorable/README.md +++ b/vendor/github.com/mattn/go-colorable/README.md @@ -1,8 +1,8 @@ # go-colorable -[![Godoc Reference](https://godoc.org/github.com/mattn/go-colorable?status.svg)](http://godoc.org/github.com/mattn/go-colorable) [![Build Status](https://travis-ci.org/mattn/go-colorable.svg?branch=master)](https://travis-ci.org/mattn/go-colorable) -[![Coverage Status](https://coveralls.io/repos/github/mattn/go-colorable/badge.svg?branch=master)](https://coveralls.io/github/mattn/go-colorable?branch=master) +[![Codecov](https://codecov.io/gh/mattn/go-colorable/branch/master/graph/badge.svg)](https://codecov.io/gh/mattn/go-colorable) +[![GoDoc](https://godoc.org/github.com/mattn/go-colorable?status.svg)](http://godoc.org/github.com/mattn/go-colorable) [![Go Report Card](https://goreportcard.com/badge/mattn/go-colorable)](https://goreportcard.com/report/mattn/go-colorable) Colorable writer for windows. diff --git a/vendor/github.com/mattn/go-colorable/colorable_appengine.go b/vendor/github.com/mattn/go-colorable/colorable_appengine.go index 1f28d773d74..1f7806fe16b 100644 --- a/vendor/github.com/mattn/go-colorable/colorable_appengine.go +++ b/vendor/github.com/mattn/go-colorable/colorable_appengine.go @@ -9,7 +9,7 @@ import ( _ "github.com/mattn/go-isatty" ) -// NewColorable return new instance of Writer which handle escape sequence. +// NewColorable returns new instance of Writer which handles escape sequence. func NewColorable(file *os.File) io.Writer { if file == nil { panic("nil passed instead of *os.File to NewColorable()") @@ -18,12 +18,20 @@ func NewColorable(file *os.File) io.Writer { return file } -// NewColorableStdout return new instance of Writer which handle escape sequence for stdout. +// NewColorableStdout returns new instance of Writer which handles escape sequence for stdout. func NewColorableStdout() io.Writer { return os.Stdout } -// NewColorableStderr return new instance of Writer which handle escape sequence for stderr. +// NewColorableStderr returns new instance of Writer which handles escape sequence for stderr. func NewColorableStderr() io.Writer { return os.Stderr } + +// EnableColorsStdout enable colors if possible. +func EnableColorsStdout(enabled *bool) func() { + if enabled != nil { + *enabled = true + } + return func() {} +} diff --git a/vendor/github.com/mattn/go-colorable/colorable_others.go b/vendor/github.com/mattn/go-colorable/colorable_others.go index 887f203dc7f..08cbd1e0fa2 100644 --- a/vendor/github.com/mattn/go-colorable/colorable_others.go +++ b/vendor/github.com/mattn/go-colorable/colorable_others.go @@ -10,7 +10,7 @@ import ( _ "github.com/mattn/go-isatty" ) -// NewColorable return new instance of Writer which handle escape sequence. +// NewColorable returns new instance of Writer which handles escape sequence. func NewColorable(file *os.File) io.Writer { if file == nil { panic("nil passed instead of *os.File to NewColorable()") @@ -19,12 +19,20 @@ func NewColorable(file *os.File) io.Writer { return file } -// NewColorableStdout return new instance of Writer which handle escape sequence for stdout. +// NewColorableStdout returns new instance of Writer which handles escape sequence for stdout. func NewColorableStdout() io.Writer { return os.Stdout } -// NewColorableStderr return new instance of Writer which handle escape sequence for stderr. +// NewColorableStderr returns new instance of Writer which handles escape sequence for stderr. func NewColorableStderr() io.Writer { return os.Stderr } + +// EnableColorsStdout enable colors if possible. +func EnableColorsStdout(enabled *bool) func() { + if enabled != nil { + *enabled = true + } + return func() {} +} diff --git a/vendor/github.com/mattn/go-colorable/colorable_windows.go b/vendor/github.com/mattn/go-colorable/colorable_windows.go index 404e10ca02b..41215d7fc4f 100644 --- a/vendor/github.com/mattn/go-colorable/colorable_windows.go +++ b/vendor/github.com/mattn/go-colorable/colorable_windows.go @@ -10,6 +10,7 @@ import ( "os" "strconv" "strings" + "sync" "syscall" "unsafe" @@ -27,6 +28,9 @@ const ( backgroundRed = 0x40 backgroundIntensity = 0x80 backgroundMask = (backgroundRed | backgroundBlue | backgroundGreen | backgroundIntensity) + commonLvbUnderscore = 0x8000 + + cENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x4 ) const ( @@ -78,10 +82,12 @@ var ( procGetConsoleCursorInfo = kernel32.NewProc("GetConsoleCursorInfo") procSetConsoleCursorInfo = kernel32.NewProc("SetConsoleCursorInfo") procSetConsoleTitle = kernel32.NewProc("SetConsoleTitleW") + procGetConsoleMode = kernel32.NewProc("GetConsoleMode") + procSetConsoleMode = kernel32.NewProc("SetConsoleMode") procCreateConsoleScreenBuffer = kernel32.NewProc("CreateConsoleScreenBuffer") ) -// Writer provide colorable Writer to the console +// Writer provides colorable Writer to the console type Writer struct { out io.Writer handle syscall.Handle @@ -89,15 +95,20 @@ type Writer struct { oldattr word oldpos coord rest bytes.Buffer + mutex sync.Mutex } -// NewColorable return new instance of Writer which handle escape sequence from File. +// NewColorable returns new instance of Writer which handles escape sequence from File. func NewColorable(file *os.File) io.Writer { if file == nil { panic("nil passed instead of *os.File to NewColorable()") } if isatty.IsTerminal(file.Fd()) { + var mode uint32 + if r, _, _ := procGetConsoleMode.Call(file.Fd(), uintptr(unsafe.Pointer(&mode))); r != 0 && mode&cENABLE_VIRTUAL_TERMINAL_PROCESSING != 0 { + return file + } var csbi consoleScreenBufferInfo handle := syscall.Handle(file.Fd()) procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi))) @@ -106,12 +117,12 @@ func NewColorable(file *os.File) io.Writer { return file } -// NewColorableStdout return new instance of Writer which handle escape sequence for stdout. +// NewColorableStdout returns new instance of Writer which handles escape sequence for stdout. func NewColorableStdout() io.Writer { return NewColorable(os.Stdout) } -// NewColorableStderr return new instance of Writer which handle escape sequence for stderr. +// NewColorableStderr returns new instance of Writer which handles escape sequence for stderr. func NewColorableStderr() io.Writer { return NewColorable(os.Stderr) } @@ -414,8 +425,18 @@ func doTitleSequence(er *bytes.Reader) error { return nil } -// Write write data on console +// returns Atoi(s) unless s == "" in which case it returns def +func atoiWithDefault(s string, def int) (int, error) { + if s == "" { + return def, nil + } + return strconv.Atoi(s) +} + +// Write writes data on console func (w *Writer) Write(data []byte) (n int, err error) { + w.mutex.Lock() + defer w.mutex.Unlock() var csbi consoleScreenBufferInfo procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi))) @@ -500,7 +521,7 @@ loop: switch m { case 'A': - n, err = strconv.Atoi(buf.String()) + n, err = atoiWithDefault(buf.String(), 1) if err != nil { continue } @@ -508,7 +529,7 @@ loop: csbi.cursorPosition.y -= short(n) procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition))) case 'B': - n, err = strconv.Atoi(buf.String()) + n, err = atoiWithDefault(buf.String(), 1) if err != nil { continue } @@ -516,7 +537,7 @@ loop: csbi.cursorPosition.y += short(n) procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition))) case 'C': - n, err = strconv.Atoi(buf.String()) + n, err = atoiWithDefault(buf.String(), 1) if err != nil { continue } @@ -524,7 +545,7 @@ loop: csbi.cursorPosition.x += short(n) procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition))) case 'D': - n, err = strconv.Atoi(buf.String()) + n, err = atoiWithDefault(buf.String(), 1) if err != nil { continue } @@ -557,6 +578,9 @@ loop: if err != nil { continue } + if n < 1 { + n = 1 + } procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi))) csbi.cursorPosition.x = short(n - 1) procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition))) @@ -635,6 +659,20 @@ loop: } procFillConsoleOutputCharacter.Call(uintptr(handle), uintptr(' '), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written))) procFillConsoleOutputAttribute.Call(uintptr(handle), uintptr(csbi.attributes), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written))) + case 'X': + n := 0 + if buf.Len() > 0 { + n, err = strconv.Atoi(buf.String()) + if err != nil { + continue + } + } + procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi))) + var cursor coord + var written dword + cursor = coord{x: csbi.cursorPosition.x, y: csbi.cursorPosition.y} + procFillConsoleOutputCharacter.Call(uintptr(handle), uintptr(' '), uintptr(n), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written))) + procFillConsoleOutputAttribute.Call(uintptr(handle), uintptr(csbi.attributes), uintptr(n), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written))) case 'm': procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi))) attr := csbi.attributes @@ -650,14 +688,19 @@ loop: switch { case n == 0 || n == 100: attr = w.oldattr - case 1 <= n && n <= 5: - attr |= foregroundIntensity - case n == 7: - attr = ((attr & foregroundMask) << 4) | ((attr & backgroundMask) >> 4) - case n == 22 || n == 25: + case n == 4: + attr |= commonLvbUnderscore + case (1 <= n && n <= 3) || n == 5: attr |= foregroundIntensity - case n == 27: - attr = ((attr & foregroundMask) << 4) | ((attr & backgroundMask) >> 4) + case n == 7 || n == 27: + attr = + (attr &^ (foregroundMask | backgroundMask)) | + ((attr & foregroundMask) << 4) | + ((attr & backgroundMask) >> 4) + case n == 22: + attr &^= foregroundIntensity + case n == 24: + attr &^= commonLvbUnderscore case 30 <= n && n <= 37: attr &= backgroundMask if (n-30)&1 != 0 { @@ -676,7 +719,7 @@ loop: n256setup() } attr &= backgroundMask - attr |= n256foreAttr[n256] + attr |= n256foreAttr[n256%len(n256foreAttr)] i += 2 } } else if len(token) == 5 && token[i+1] == "2" { @@ -718,7 +761,7 @@ loop: n256setup() } attr &= foregroundMask - attr |= n256backAttr[n256] + attr |= n256backAttr[n256%len(n256backAttr)] i += 2 } } else if len(token) == 5 && token[i+1] == "2" { @@ -978,3 +1021,23 @@ func n256setup() { n256backAttr[i] = c.backgroundAttr() } } + +// EnableColorsStdout enable colors if possible. +func EnableColorsStdout(enabled *bool) func() { + var mode uint32 + h := os.Stdout.Fd() + if r, _, _ := procGetConsoleMode.Call(h, uintptr(unsafe.Pointer(&mode))); r != 0 { + if r, _, _ = procSetConsoleMode.Call(h, uintptr(mode|cENABLE_VIRTUAL_TERMINAL_PROCESSING)); r != 0 { + if enabled != nil { + *enabled = true + } + return func() { + procSetConsoleMode.Call(h, uintptr(mode)) + } + } + } + if enabled != nil { + *enabled = true + } + return func() {} +} diff --git a/vendor/github.com/mattn/go-colorable/go.test.sh b/vendor/github.com/mattn/go-colorable/go.test.sh new file mode 100644 index 00000000000..012162b077c --- /dev/null +++ b/vendor/github.com/mattn/go-colorable/go.test.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -e +echo "" > coverage.txt + +for d in $(go list ./... | grep -v vendor); do + go test -race -coverprofile=profile.out -covermode=atomic "$d" + if [ -f profile.out ]; then + cat profile.out >> coverage.txt + rm profile.out + fi +done diff --git a/vendor/github.com/mattn/go-colorable/noncolorable.go b/vendor/github.com/mattn/go-colorable/noncolorable.go index 9721e16f4bf..95f2c6be257 100644 --- a/vendor/github.com/mattn/go-colorable/noncolorable.go +++ b/vendor/github.com/mattn/go-colorable/noncolorable.go @@ -5,17 +5,17 @@ import ( "io" ) -// NonColorable hold writer but remove escape sequence. +// NonColorable holds writer but removes escape sequence. type NonColorable struct { out io.Writer } -// NewNonColorable return new instance of Writer which remove escape sequence from Writer. +// NewNonColorable returns new instance of Writer which removes escape sequence from Writer. func NewNonColorable(w io.Writer) io.Writer { return &NonColorable{out: w} } -// Write write data on console +// Write writes data on console func (w *NonColorable) Write(data []byte) (n int, err error) { er := bytes.NewReader(data) var bw [1]byte diff --git a/vendor/github.com/mitchellh/mapstructure/CHANGELOG.md b/vendor/github.com/mitchellh/mapstructure/CHANGELOG.md index 1955f2878c8..38a099162ca 100644 --- a/vendor/github.com/mitchellh/mapstructure/CHANGELOG.md +++ b/vendor/github.com/mitchellh/mapstructure/CHANGELOG.md @@ -1,6 +1,16 @@ -## unreleased +## 1.4.3 -* Fix regression where `*time.Time` value would be set to empty and not be sent +* Fix cases where `json.Number` didn't decode properly [GH-261] + +## 1.4.2 + +* Custom name matchers to support any sort of casing, formatting, etc. for + field names. [GH-250] +* Fix possible panic in ComposeDecodeHookFunc [GH-251] + +## 1.4.1 + +* Fix regression where `*time.Time` value would be set to empty and not be sent to decode hooks properly [GH-232] ## 1.4.0 diff --git a/vendor/github.com/mitchellh/mapstructure/decode_hooks.go b/vendor/github.com/mitchellh/mapstructure/decode_hooks.go index 92e6f76fff4..4d4bbc733ba 100644 --- a/vendor/github.com/mitchellh/mapstructure/decode_hooks.go +++ b/vendor/github.com/mitchellh/mapstructure/decode_hooks.go @@ -62,7 +62,8 @@ func DecodeHookExec( func ComposeDecodeHookFunc(fs ...DecodeHookFunc) DecodeHookFunc { return func(f reflect.Value, t reflect.Value) (interface{}, error) { var err error - var data interface{} + data := f.Interface() + newFrom := f for _, f1 := range fs { data, err = DecodeHookExec(f1, newFrom, t) diff --git a/vendor/github.com/mitchellh/mapstructure/mapstructure.go b/vendor/github.com/mitchellh/mapstructure/mapstructure.go index 3643901f55f..6b81b00679e 100644 --- a/vendor/github.com/mitchellh/mapstructure/mapstructure.go +++ b/vendor/github.com/mitchellh/mapstructure/mapstructure.go @@ -192,7 +192,7 @@ type DecodeHookFuncType func(reflect.Type, reflect.Type, interface{}) (interface // source and target types. type DecodeHookFuncKind func(reflect.Kind, reflect.Kind, interface{}) (interface{}, error) -// DecodeHookFuncRaw is a DecodeHookFunc which has complete access to both the source and target +// DecodeHookFuncValue is a DecodeHookFunc which has complete access to both the source and target // values. type DecodeHookFuncValue func(from reflect.Value, to reflect.Value) (interface{}, error) @@ -258,6 +258,11 @@ type DecoderConfig struct { // The tag name that mapstructure reads for field names. This // defaults to "mapstructure" TagName string + + // MatchName is the function used to match the map key to the struct + // field name or tag. Defaults to `strings.EqualFold`. This can be used + // to implement case-sensitive tag values, support snake casing, etc. + MatchName func(mapKey, fieldName string) bool } // A Decoder takes a raw interface value and turns it into structured @@ -376,6 +381,10 @@ func NewDecoder(config *DecoderConfig) (*Decoder, error) { config.TagName = "mapstructure" } + if config.MatchName == nil { + config.MatchName = strings.EqualFold + } + result := &Decoder{ config: config, } @@ -675,16 +684,12 @@ func (d *Decoder) decodeUint(name string, data interface{}, val reflect.Value) e } case dataType.PkgPath() == "encoding/json" && dataType.Name() == "Number": jn := data.(json.Number) - i, err := jn.Int64() + i, err := strconv.ParseUint(string(jn), 0, 64) if err != nil { return fmt.Errorf( "error decoding json.Number into %s: %s", name, err) } - if i < 0 && !d.config.WeaklyTypedInput { - return fmt.Errorf("cannot parse '%s', %d overflows uint", - name, i) - } - val.SetUint(uint64(i)) + val.SetUint(i) default: return fmt.Errorf( "'%s' expected type '%s', got unconvertible type '%s', value: '%v'", @@ -1340,7 +1345,7 @@ func (d *Decoder) decodeStructFromMap(name string, dataVal, val reflect.Value) e continue } - if strings.EqualFold(mK, fieldName) { + if d.config.MatchName(mK, fieldName) { rawMapKey = dataValKey rawMapVal = dataVal.MapIndex(dataValKey) break diff --git a/vendor/github.com/openshift/client-go/config/clientset/versioned/clientset.go b/vendor/github.com/openshift/client-go/config/clientset/versioned/clientset.go index 70cd52cc073..992f9b22c97 100644 --- a/vendor/github.com/openshift/client-go/config/clientset/versioned/clientset.go +++ b/vendor/github.com/openshift/client-go/config/clientset/versioned/clientset.go @@ -4,6 +4,7 @@ package versioned import ( "fmt" + "net/http" configv1 "github.com/openshift/client-go/config/clientset/versioned/typed/config/v1" discovery "k8s.io/client-go/discovery" @@ -39,22 +40,41 @@ func (c *Clientset) Discovery() discovery.DiscoveryInterface { // NewForConfig creates a new Clientset for the given config. // If config's RateLimiter is not set and QPS and Burst are acceptable, // NewForConfig will generate a rate-limiter in configShallowCopy. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*Clientset, error) { configShallowCopy := *c + + // share the transport between all clients + httpClient, err := rest.HTTPClientFor(&configShallowCopy) + if err != nil { + return nil, err + } + + return NewForConfigAndClient(&configShallowCopy, httpClient) +} + +// NewForConfigAndClient creates a new Clientset for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +// If config's RateLimiter is not set and QPS and Burst are acceptable, +// NewForConfigAndClient will generate a rate-limiter in configShallowCopy. +func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, error) { + configShallowCopy := *c if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { if configShallowCopy.Burst <= 0 { return nil, fmt.Errorf("burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0") } configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) } + var cs Clientset var err error - cs.configV1, err = configv1.NewForConfig(&configShallowCopy) + cs.configV1, err = configv1.NewForConfigAndClient(&configShallowCopy, httpClient) if err != nil { return nil, err } - cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) + cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient) if err != nil { return nil, err } @@ -64,11 +84,11 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { // NewForConfigOrDie creates a new Clientset for the given config and // panics if there is an error in the config. func NewForConfigOrDie(c *rest.Config) *Clientset { - var cs Clientset - cs.configV1 = configv1.NewForConfigOrDie(c) - - cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) - return &cs + cs, err := NewForConfig(c) + if err != nil { + panic(err) + } + return cs } // New creates a new Clientset for the given RESTClient. diff --git a/vendor/github.com/openshift/client-go/config/clientset/versioned/typed/config/v1/config_client.go b/vendor/github.com/openshift/client-go/config/clientset/versioned/typed/config/v1/config_client.go index 707e5fc06ed..5792b9aa740 100644 --- a/vendor/github.com/openshift/client-go/config/clientset/versioned/typed/config/v1/config_client.go +++ b/vendor/github.com/openshift/client-go/config/clientset/versioned/typed/config/v1/config_client.go @@ -3,6 +3,8 @@ package v1 import ( + "net/http" + v1 "github.com/openshift/api/config/v1" "github.com/openshift/client-go/config/clientset/versioned/scheme" rest "k8s.io/client-go/rest" @@ -108,12 +110,28 @@ func (c *ConfigV1Client) Schedulers() SchedulerInterface { } // NewForConfig creates a new ConfigV1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*ConfigV1Client, error) { config := *c if err := setConfigDefaults(&config); err != nil { return nil, err } - client, err := rest.RESTClientFor(&config) + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new ConfigV1Client for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*ConfigV1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientForConfigAndClient(&config, h) if err != nil { return nil, err } diff --git a/vendor/github.com/openshift/client-go/route/clientset/versioned/clientset.go b/vendor/github.com/openshift/client-go/route/clientset/versioned/clientset.go index 6689bcac66b..2d3ba95de00 100644 --- a/vendor/github.com/openshift/client-go/route/clientset/versioned/clientset.go +++ b/vendor/github.com/openshift/client-go/route/clientset/versioned/clientset.go @@ -4,6 +4,7 @@ package versioned import ( "fmt" + "net/http" routev1 "github.com/openshift/client-go/route/clientset/versioned/typed/route/v1" discovery "k8s.io/client-go/discovery" @@ -39,22 +40,41 @@ func (c *Clientset) Discovery() discovery.DiscoveryInterface { // NewForConfig creates a new Clientset for the given config. // If config's RateLimiter is not set and QPS and Burst are acceptable, // NewForConfig will generate a rate-limiter in configShallowCopy. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*Clientset, error) { configShallowCopy := *c + + // share the transport between all clients + httpClient, err := rest.HTTPClientFor(&configShallowCopy) + if err != nil { + return nil, err + } + + return NewForConfigAndClient(&configShallowCopy, httpClient) +} + +// NewForConfigAndClient creates a new Clientset for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +// If config's RateLimiter is not set and QPS and Burst are acceptable, +// NewForConfigAndClient will generate a rate-limiter in configShallowCopy. +func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, error) { + configShallowCopy := *c if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { if configShallowCopy.Burst <= 0 { return nil, fmt.Errorf("burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0") } configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) } + var cs Clientset var err error - cs.routeV1, err = routev1.NewForConfig(&configShallowCopy) + cs.routeV1, err = routev1.NewForConfigAndClient(&configShallowCopy, httpClient) if err != nil { return nil, err } - cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) + cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient) if err != nil { return nil, err } @@ -64,11 +84,11 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { // NewForConfigOrDie creates a new Clientset for the given config and // panics if there is an error in the config. func NewForConfigOrDie(c *rest.Config) *Clientset { - var cs Clientset - cs.routeV1 = routev1.NewForConfigOrDie(c) - - cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) - return &cs + cs, err := NewForConfig(c) + if err != nil { + panic(err) + } + return cs } // New creates a new Clientset for the given RESTClient. diff --git a/vendor/github.com/openshift/client-go/route/clientset/versioned/typed/route/v1/route_client.go b/vendor/github.com/openshift/client-go/route/clientset/versioned/typed/route/v1/route_client.go index 351945deab7..e71d826c9f2 100644 --- a/vendor/github.com/openshift/client-go/route/clientset/versioned/typed/route/v1/route_client.go +++ b/vendor/github.com/openshift/client-go/route/clientset/versioned/typed/route/v1/route_client.go @@ -3,6 +3,8 @@ package v1 import ( + "net/http" + v1 "github.com/openshift/api/route/v1" "github.com/openshift/client-go/route/clientset/versioned/scheme" rest "k8s.io/client-go/rest" @@ -23,12 +25,28 @@ func (c *RouteV1Client) Routes(namespace string) RouteInterface { } // NewForConfig creates a new RouteV1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*RouteV1Client, error) { config := *c if err := setConfigDefaults(&config); err != nil { return nil, err } - client, err := rest.RESTClientFor(&config) + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new RouteV1Client for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*RouteV1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientForConfigAndClient(&config, h) if err != nil { return nil, err } diff --git a/vendor/github.com/opentracing/opentracing-go/.gitignore b/vendor/github.com/opentracing/opentracing-go/.gitignore new file mode 100644 index 00000000000..c57100a595c --- /dev/null +++ b/vendor/github.com/opentracing/opentracing-go/.gitignore @@ -0,0 +1 @@ +coverage.txt diff --git a/vendor/github.com/opentracing/opentracing-go/.travis.yml b/vendor/github.com/opentracing/opentracing-go/.travis.yml new file mode 100644 index 00000000000..b950e42965f --- /dev/null +++ b/vendor/github.com/opentracing/opentracing-go/.travis.yml @@ -0,0 +1,20 @@ +language: go + +matrix: + include: + - go: "1.13.x" + - go: "1.14.x" + - go: "tip" + env: + - LINT=true + - COVERAGE=true + +install: + - if [ "$LINT" == true ]; then go get -u golang.org/x/lint/golint/... ; else echo 'skipping lint'; fi + - go get -u github.com/stretchr/testify/... + +script: + - make test + - go build ./... + - if [ "$LINT" == true ]; then make lint ; else echo 'skipping lint'; fi + - if [ "$COVERAGE" == true ]; then make cover && bash <(curl -s https://codecov.io/bash) ; else echo 'skipping coverage'; fi diff --git a/vendor/github.com/opentracing/opentracing-go/CHANGELOG.md b/vendor/github.com/opentracing/opentracing-go/CHANGELOG.md new file mode 100644 index 00000000000..d3bfcf62359 --- /dev/null +++ b/vendor/github.com/opentracing/opentracing-go/CHANGELOG.md @@ -0,0 +1,63 @@ +Changes by Version +================== + + +1.2.0 (2020-07-01) +------------------- + +* Restore the ability to reset the current span in context to nil (#231) -- Yuri Shkuro +* Use error.object per OpenTracing Semantic Conventions (#179) -- Rahman Syed +* Convert nil pointer log field value to string "nil" (#230) -- Cyril Tovena +* Add Go module support (#215) -- Zaba505 +* Make SetTag helper types in ext public (#229) -- Blake Edwards +* Add log/fields helpers for keys from specification (#226) -- Dmitry Monakhov +* Improve noop impementation (#223) -- chanxuehong +* Add an extension to Tracer interface for custom go context creation (#220) -- Krzesimir Nowak +* Fix typo in comments (#222) -- meteorlxy +* Improve documentation for log.Object() to emphasize the requirement to pass immutable arguments (#219) -- 疯狂的小企鹅 +* [mock] Return ErrInvalidSpanContext if span context is not MockSpanContext (#216) -- Milad Irannejad + + +1.1.0 (2019-03-23) +------------------- + +Notable changes: +- The library is now released under Apache 2.0 license +- Use Set() instead of Add() in HTTPHeadersCarrier is functionally a breaking change (fixes issue [#159](https://github.com/opentracing/opentracing-go/issues/159)) +- 'golang.org/x/net/context' is replaced with 'context' from the standard library + +List of all changes: + +- Export StartSpanFromContextWithTracer (#214) +- Add IsGlobalTracerRegistered() to indicate if a tracer has been registered (#201) +- Use Set() instead of Add() in HTTPHeadersCarrier (#191) +- Update license to Apache 2.0 (#181) +- Replace 'golang.org/x/net/context' with 'context' (#176) +- Port of Python opentracing/harness/api_check.py to Go (#146) +- Fix race condition in MockSpan.Context() (#170) +- Add PeerHostIPv4.SetString() (#155) +- Add a Noop log field type to log to allow for optional fields (#150) + + +1.0.2 (2017-04-26) +------------------- + +- Add more semantic tags (#139) + + +1.0.1 (2017-02-06) +------------------- + +- Correct spelling in comments +- Address race in nextMockID() (#123) +- log: avoid panic marshaling nil error (#131) +- Deprecate InitGlobalTracer in favor of SetGlobalTracer (#128) +- Drop Go 1.5 that fails in Travis (#129) +- Add convenience methods Key() and Value() to log.Field +- Add convenience methods to log.Field (2 years, 6 months ago) + +1.0.0 (2016-09-26) +------------------- + +- This release implements OpenTracing Specification 1.0 (https://opentracing.io/spec) + diff --git a/vendor/github.com/opentracing/opentracing-go/LICENSE b/vendor/github.com/opentracing/opentracing-go/LICENSE new file mode 100644 index 00000000000..f0027349e83 --- /dev/null +++ b/vendor/github.com/opentracing/opentracing-go/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2016 The OpenTracing Authors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/opentracing/opentracing-go/Makefile b/vendor/github.com/opentracing/opentracing-go/Makefile new file mode 100644 index 00000000000..62abb63f58d --- /dev/null +++ b/vendor/github.com/opentracing/opentracing-go/Makefile @@ -0,0 +1,20 @@ +.DEFAULT_GOAL := test-and-lint + +.PHONY: test-and-lint +test-and-lint: test lint + +.PHONY: test +test: + go test -v -cover -race ./... + +.PHONY: cover +cover: + go test -v -coverprofile=coverage.txt -covermode=atomic -race ./... + +.PHONY: lint +lint: + go fmt ./... + golint ./... + @# Run again with magic to exit non-zero if golint outputs anything. + @! (golint ./... | read dummy) + go vet ./... diff --git a/vendor/github.com/opentracing/opentracing-go/README.md b/vendor/github.com/opentracing/opentracing-go/README.md new file mode 100644 index 00000000000..6ef1d7c9d27 --- /dev/null +++ b/vendor/github.com/opentracing/opentracing-go/README.md @@ -0,0 +1,171 @@ +[![Gitter chat](http://img.shields.io/badge/gitter-join%20chat%20%E2%86%92-brightgreen.svg)](https://gitter.im/opentracing/public) [![Build Status](https://travis-ci.org/opentracing/opentracing-go.svg?branch=master)](https://travis-ci.org/opentracing/opentracing-go) [![GoDoc](https://godoc.org/github.com/opentracing/opentracing-go?status.svg)](http://godoc.org/github.com/opentracing/opentracing-go) +[![Sourcegraph Badge](https://sourcegraph.com/github.com/opentracing/opentracing-go/-/badge.svg)](https://sourcegraph.com/github.com/opentracing/opentracing-go?badge) + +# OpenTracing API for Go + +This package is a Go platform API for OpenTracing. + +## Required Reading + +In order to understand the Go platform API, one must first be familiar with the +[OpenTracing project](https://opentracing.io) and +[terminology](https://opentracing.io/specification/) more specifically. + +## API overview for those adding instrumentation + +Everyday consumers of this `opentracing` package really only need to worry +about a couple of key abstractions: the `StartSpan` function, the `Span` +interface, and binding a `Tracer` at `main()`-time. Here are code snippets +demonstrating some important use cases. + +#### Singleton initialization + +The simplest starting point is `./default_tracer.go`. As early as possible, call + +```go + import "github.com/opentracing/opentracing-go" + import ".../some_tracing_impl" + + func main() { + opentracing.SetGlobalTracer( + // tracing impl specific: + some_tracing_impl.New(...), + ) + ... + } +``` + +#### Non-Singleton initialization + +If you prefer direct control to singletons, manage ownership of the +`opentracing.Tracer` implementation explicitly. + +#### Creating a Span given an existing Go `context.Context` + +If you use `context.Context` in your application, OpenTracing's Go library will +happily rely on it for `Span` propagation. To start a new (blocking child) +`Span`, you can use `StartSpanFromContext`. + +```go + func xyz(ctx context.Context, ...) { + ... + span, ctx := opentracing.StartSpanFromContext(ctx, "operation_name") + defer span.Finish() + span.LogFields( + log.String("event", "soft error"), + log.String("type", "cache timeout"), + log.Int("waited.millis", 1500)) + ... + } +``` + +#### Starting an empty trace by creating a "root span" + +It's always possible to create a "root" `Span` with no parent or other causal +reference. + +```go + func xyz() { + ... + sp := opentracing.StartSpan("operation_name") + defer sp.Finish() + ... + } +``` + +#### Creating a (child) Span given an existing (parent) Span + +```go + func xyz(parentSpan opentracing.Span, ...) { + ... + sp := opentracing.StartSpan( + "operation_name", + opentracing.ChildOf(parentSpan.Context())) + defer sp.Finish() + ... + } +``` + +#### Serializing to the wire + +```go + func makeSomeRequest(ctx context.Context) ... { + if span := opentracing.SpanFromContext(ctx); span != nil { + httpClient := &http.Client{} + httpReq, _ := http.NewRequest("GET", "http://myservice/", nil) + + // Transmit the span's TraceContext as HTTP headers on our + // outbound request. + opentracing.GlobalTracer().Inject( + span.Context(), + opentracing.HTTPHeaders, + opentracing.HTTPHeadersCarrier(httpReq.Header)) + + resp, err := httpClient.Do(httpReq) + ... + } + ... + } +``` + +#### Deserializing from the wire + +```go + http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { + var serverSpan opentracing.Span + appSpecificOperationName := ... + wireContext, err := opentracing.GlobalTracer().Extract( + opentracing.HTTPHeaders, + opentracing.HTTPHeadersCarrier(req.Header)) + if err != nil { + // Optionally record something about err here + } + + // Create the span referring to the RPC client if available. + // If wireContext == nil, a root span will be created. + serverSpan = opentracing.StartSpan( + appSpecificOperationName, + ext.RPCServerOption(wireContext)) + + defer serverSpan.Finish() + + ctx := opentracing.ContextWithSpan(context.Background(), serverSpan) + ... + } +``` + +#### Conditionally capture a field using `log.Noop` + +In some situations, you may want to dynamically decide whether or not +to log a field. For example, you may want to capture additional data, +such as a customer ID, in non-production environments: + +```go + func Customer(order *Order) log.Field { + if os.Getenv("ENVIRONMENT") == "dev" { + return log.String("customer", order.Customer.ID) + } + return log.Noop() + } +``` + +#### Goroutine-safety + +The entire public API is goroutine-safe and does not require external +synchronization. + +## API pointers for those implementing a tracing system + +Tracing system implementors may be able to reuse or copy-paste-modify the `basictracer` package, found [here](https://github.com/opentracing/basictracer-go). In particular, see `basictracer.New(...)`. + +## API compatibility + +For the time being, "mild" backwards-incompatible changes may be made without changing the major version number. As OpenTracing and `opentracing-go` mature, backwards compatibility will become more of a priority. + +## Tracer test suite + +A test suite is available in the [harness](https://godoc.org/github.com/opentracing/opentracing-go/harness) package that can assist Tracer implementors to assert that their Tracer is working correctly. + +## Licensing + +[Apache 2.0 License](./LICENSE). diff --git a/vendor/github.com/opentracing/opentracing-go/ext.go b/vendor/github.com/opentracing/opentracing-go/ext.go new file mode 100644 index 00000000000..e11977ebe85 --- /dev/null +++ b/vendor/github.com/opentracing/opentracing-go/ext.go @@ -0,0 +1,24 @@ +package opentracing + +import ( + "context" +) + +// TracerContextWithSpanExtension is an extension interface that the +// implementation of the Tracer interface may want to implement. It +// allows to have some control over the go context when the +// ContextWithSpan is invoked. +// +// The primary purpose of this extension are adapters from opentracing +// API to some other tracing API. +type TracerContextWithSpanExtension interface { + // ContextWithSpanHook gets called by the ContextWithSpan + // function, when the Tracer implementation also implements + // this interface. It allows to put extra information into the + // context and make it available to the callers of the + // ContextWithSpan. + // + // This hook is invoked before the ContextWithSpan function + // actually puts the span into the context. + ContextWithSpanHook(ctx context.Context, span Span) context.Context +} diff --git a/vendor/github.com/opentracing/opentracing-go/ext/field.go b/vendor/github.com/opentracing/opentracing-go/ext/field.go new file mode 100644 index 00000000000..8282bd75846 --- /dev/null +++ b/vendor/github.com/opentracing/opentracing-go/ext/field.go @@ -0,0 +1,17 @@ +package ext + +import ( + "github.com/opentracing/opentracing-go" + "github.com/opentracing/opentracing-go/log" +) + +// LogError sets the error=true tag on the Span and logs err as an "error" event. +func LogError(span opentracing.Span, err error, fields ...log.Field) { + Error.Set(span, true) + ef := []log.Field{ + log.Event("error"), + log.Error(err), + } + ef = append(ef, fields...) + span.LogFields(ef...) +} diff --git a/vendor/github.com/opentracing/opentracing-go/ext/tags.go b/vendor/github.com/opentracing/opentracing-go/ext/tags.go new file mode 100644 index 00000000000..a414b5951f0 --- /dev/null +++ b/vendor/github.com/opentracing/opentracing-go/ext/tags.go @@ -0,0 +1,215 @@ +package ext + +import "github.com/opentracing/opentracing-go" + +// These constants define common tag names recommended for better portability across +// tracing systems and languages/platforms. +// +// The tag names are defined as typed strings, so that in addition to the usual use +// +// span.setTag(TagName, value) +// +// they also support value type validation via this additional syntax: +// +// TagName.Set(span, value) +// +var ( + ////////////////////////////////////////////////////////////////////// + // SpanKind (client/server or producer/consumer) + ////////////////////////////////////////////////////////////////////// + + // SpanKind hints at relationship between spans, e.g. client/server + SpanKind = spanKindTagName("span.kind") + + // SpanKindRPCClient marks a span representing the client-side of an RPC + // or other remote call + SpanKindRPCClientEnum = SpanKindEnum("client") + SpanKindRPCClient = opentracing.Tag{Key: string(SpanKind), Value: SpanKindRPCClientEnum} + + // SpanKindRPCServer marks a span representing the server-side of an RPC + // or other remote call + SpanKindRPCServerEnum = SpanKindEnum("server") + SpanKindRPCServer = opentracing.Tag{Key: string(SpanKind), Value: SpanKindRPCServerEnum} + + // SpanKindProducer marks a span representing the producer-side of a + // message bus + SpanKindProducerEnum = SpanKindEnum("producer") + SpanKindProducer = opentracing.Tag{Key: string(SpanKind), Value: SpanKindProducerEnum} + + // SpanKindConsumer marks a span representing the consumer-side of a + // message bus + SpanKindConsumerEnum = SpanKindEnum("consumer") + SpanKindConsumer = opentracing.Tag{Key: string(SpanKind), Value: SpanKindConsumerEnum} + + ////////////////////////////////////////////////////////////////////// + // Component name + ////////////////////////////////////////////////////////////////////// + + // Component is a low-cardinality identifier of the module, library, + // or package that is generating a span. + Component = StringTagName("component") + + ////////////////////////////////////////////////////////////////////// + // Sampling hint + ////////////////////////////////////////////////////////////////////// + + // SamplingPriority determines the priority of sampling this Span. + SamplingPriority = Uint16TagName("sampling.priority") + + ////////////////////////////////////////////////////////////////////// + // Peer tags. These tags can be emitted by either client-side or + // server-side to describe the other side/service in a peer-to-peer + // communications, like an RPC call. + ////////////////////////////////////////////////////////////////////// + + // PeerService records the service name of the peer. + PeerService = StringTagName("peer.service") + + // PeerAddress records the address name of the peer. This may be a "ip:port", + // a bare "hostname", a FQDN or even a database DSN substring + // like "mysql://username@127.0.0.1:3306/dbname" + PeerAddress = StringTagName("peer.address") + + // PeerHostname records the host name of the peer + PeerHostname = StringTagName("peer.hostname") + + // PeerHostIPv4 records IP v4 host address of the peer + PeerHostIPv4 = IPv4TagName("peer.ipv4") + + // PeerHostIPv6 records IP v6 host address of the peer + PeerHostIPv6 = StringTagName("peer.ipv6") + + // PeerPort records port number of the peer + PeerPort = Uint16TagName("peer.port") + + ////////////////////////////////////////////////////////////////////// + // HTTP Tags + ////////////////////////////////////////////////////////////////////// + + // HTTPUrl should be the URL of the request being handled in this segment + // of the trace, in standard URI format. The protocol is optional. + HTTPUrl = StringTagName("http.url") + + // HTTPMethod is the HTTP method of the request, and is case-insensitive. + HTTPMethod = StringTagName("http.method") + + // HTTPStatusCode is the numeric HTTP status code (200, 404, etc) of the + // HTTP response. + HTTPStatusCode = Uint16TagName("http.status_code") + + ////////////////////////////////////////////////////////////////////// + // DB Tags + ////////////////////////////////////////////////////////////////////// + + // DBInstance is database instance name. + DBInstance = StringTagName("db.instance") + + // DBStatement is a database statement for the given database type. + // It can be a query or a prepared statement (i.e., before substitution). + DBStatement = StringTagName("db.statement") + + // DBType is a database type. For any SQL database, "sql". + // For others, the lower-case database category, e.g. "redis" + DBType = StringTagName("db.type") + + // DBUser is a username for accessing database. + DBUser = StringTagName("db.user") + + ////////////////////////////////////////////////////////////////////// + // Message Bus Tag + ////////////////////////////////////////////////////////////////////// + + // MessageBusDestination is an address at which messages can be exchanged + MessageBusDestination = StringTagName("message_bus.destination") + + ////////////////////////////////////////////////////////////////////// + // Error Tag + ////////////////////////////////////////////////////////////////////// + + // Error indicates that operation represented by the span resulted in an error. + Error = BoolTagName("error") +) + +// --- + +// SpanKindEnum represents common span types +type SpanKindEnum string + +type spanKindTagName string + +// Set adds a string tag to the `span` +func (tag spanKindTagName) Set(span opentracing.Span, value SpanKindEnum) { + span.SetTag(string(tag), value) +} + +type rpcServerOption struct { + clientContext opentracing.SpanContext +} + +func (r rpcServerOption) Apply(o *opentracing.StartSpanOptions) { + if r.clientContext != nil { + opentracing.ChildOf(r.clientContext).Apply(o) + } + SpanKindRPCServer.Apply(o) +} + +// RPCServerOption returns a StartSpanOption appropriate for an RPC server span +// with `client` representing the metadata for the remote peer Span if available. +// In case client == nil, due to the client not being instrumented, this RPC +// server span will be a root span. +func RPCServerOption(client opentracing.SpanContext) opentracing.StartSpanOption { + return rpcServerOption{client} +} + +// --- + +// StringTagName is a common tag name to be set to a string value +type StringTagName string + +// Set adds a string tag to the `span` +func (tag StringTagName) Set(span opentracing.Span, value string) { + span.SetTag(string(tag), value) +} + +// --- + +// Uint32TagName is a common tag name to be set to a uint32 value +type Uint32TagName string + +// Set adds a uint32 tag to the `span` +func (tag Uint32TagName) Set(span opentracing.Span, value uint32) { + span.SetTag(string(tag), value) +} + +// --- + +// Uint16TagName is a common tag name to be set to a uint16 value +type Uint16TagName string + +// Set adds a uint16 tag to the `span` +func (tag Uint16TagName) Set(span opentracing.Span, value uint16) { + span.SetTag(string(tag), value) +} + +// --- + +// BoolTagName is a common tag name to be set to a bool value +type BoolTagName string + +// Set adds a bool tag to the `span` +func (tag BoolTagName) Set(span opentracing.Span, value bool) { + span.SetTag(string(tag), value) +} + +// IPv4TagName is a common tag name to be set to an ipv4 value +type IPv4TagName string + +// Set adds IP v4 host address of the peer as an uint32 value to the `span`, keep this for backward and zipkin compatibility +func (tag IPv4TagName) Set(span opentracing.Span, value uint32) { + span.SetTag(string(tag), value) +} + +// SetString records IP v4 host address of the peer as a .-separated tuple to the `span`. E.g., "127.0.0.1" +func (tag IPv4TagName) SetString(span opentracing.Span, value string) { + span.SetTag(string(tag), value) +} diff --git a/vendor/github.com/opentracing/opentracing-go/globaltracer.go b/vendor/github.com/opentracing/opentracing-go/globaltracer.go new file mode 100644 index 00000000000..4f7066a925c --- /dev/null +++ b/vendor/github.com/opentracing/opentracing-go/globaltracer.go @@ -0,0 +1,42 @@ +package opentracing + +type registeredTracer struct { + tracer Tracer + isRegistered bool +} + +var ( + globalTracer = registeredTracer{NoopTracer{}, false} +) + +// SetGlobalTracer sets the [singleton] opentracing.Tracer returned by +// GlobalTracer(). Those who use GlobalTracer (rather than directly manage an +// opentracing.Tracer instance) should call SetGlobalTracer as early as +// possible in main(), prior to calling the `StartSpan` global func below. +// Prior to calling `SetGlobalTracer`, any Spans started via the `StartSpan` +// (etc) globals are noops. +func SetGlobalTracer(tracer Tracer) { + globalTracer = registeredTracer{tracer, true} +} + +// GlobalTracer returns the global singleton `Tracer` implementation. +// Before `SetGlobalTracer()` is called, the `GlobalTracer()` is a noop +// implementation that drops all data handed to it. +func GlobalTracer() Tracer { + return globalTracer.tracer +} + +// StartSpan defers to `Tracer.StartSpan`. See `GlobalTracer()`. +func StartSpan(operationName string, opts ...StartSpanOption) Span { + return globalTracer.tracer.StartSpan(operationName, opts...) +} + +// InitGlobalTracer is deprecated. Please use SetGlobalTracer. +func InitGlobalTracer(tracer Tracer) { + SetGlobalTracer(tracer) +} + +// IsGlobalTracerRegistered returns a `bool` to indicate if a tracer has been globally registered +func IsGlobalTracerRegistered() bool { + return globalTracer.isRegistered +} diff --git a/vendor/github.com/opentracing/opentracing-go/gocontext.go b/vendor/github.com/opentracing/opentracing-go/gocontext.go new file mode 100644 index 00000000000..1831bc9b263 --- /dev/null +++ b/vendor/github.com/opentracing/opentracing-go/gocontext.go @@ -0,0 +1,65 @@ +package opentracing + +import "context" + +type contextKey struct{} + +var activeSpanKey = contextKey{} + +// ContextWithSpan returns a new `context.Context` that holds a reference to +// the span. If span is nil, a new context without an active span is returned. +func ContextWithSpan(ctx context.Context, span Span) context.Context { + if span != nil { + if tracerWithHook, ok := span.Tracer().(TracerContextWithSpanExtension); ok { + ctx = tracerWithHook.ContextWithSpanHook(ctx, span) + } + } + return context.WithValue(ctx, activeSpanKey, span) +} + +// SpanFromContext returns the `Span` previously associated with `ctx`, or +// `nil` if no such `Span` could be found. +// +// NOTE: context.Context != SpanContext: the former is Go's intra-process +// context propagation mechanism, and the latter houses OpenTracing's per-Span +// identity and baggage information. +func SpanFromContext(ctx context.Context) Span { + val := ctx.Value(activeSpanKey) + if sp, ok := val.(Span); ok { + return sp + } + return nil +} + +// StartSpanFromContext starts and returns a Span with `operationName`, using +// any Span found within `ctx` as a ChildOfRef. If no such parent could be +// found, StartSpanFromContext creates a root (parentless) Span. +// +// The second return value is a context.Context object built around the +// returned Span. +// +// Example usage: +// +// SomeFunction(ctx context.Context, ...) { +// sp, ctx := opentracing.StartSpanFromContext(ctx, "SomeFunction") +// defer sp.Finish() +// ... +// } +func StartSpanFromContext(ctx context.Context, operationName string, opts ...StartSpanOption) (Span, context.Context) { + return StartSpanFromContextWithTracer(ctx, GlobalTracer(), operationName, opts...) +} + +// StartSpanFromContextWithTracer starts and returns a span with `operationName` +// using a span found within the context as a ChildOfRef. If that doesn't exist +// it creates a root span. It also returns a context.Context object built +// around the returned span. +// +// It's behavior is identical to StartSpanFromContext except that it takes an explicit +// tracer as opposed to using the global tracer. +func StartSpanFromContextWithTracer(ctx context.Context, tracer Tracer, operationName string, opts ...StartSpanOption) (Span, context.Context) { + if parentSpan := SpanFromContext(ctx); parentSpan != nil { + opts = append(opts, ChildOf(parentSpan.Context())) + } + span := tracer.StartSpan(operationName, opts...) + return span, ContextWithSpan(ctx, span) +} diff --git a/vendor/github.com/opentracing/opentracing-go/log/field.go b/vendor/github.com/opentracing/opentracing-go/log/field.go new file mode 100644 index 00000000000..f222ded797c --- /dev/null +++ b/vendor/github.com/opentracing/opentracing-go/log/field.go @@ -0,0 +1,282 @@ +package log + +import ( + "fmt" + "math" +) + +type fieldType int + +const ( + stringType fieldType = iota + boolType + intType + int32Type + uint32Type + int64Type + uint64Type + float32Type + float64Type + errorType + objectType + lazyLoggerType + noopType +) + +// Field instances are constructed via LogBool, LogString, and so on. +// Tracing implementations may then handle them via the Field.Marshal +// method. +// +// "heavily influenced by" (i.e., partially stolen from) +// https://github.com/uber-go/zap +type Field struct { + key string + fieldType fieldType + numericVal int64 + stringVal string + interfaceVal interface{} +} + +// String adds a string-valued key:value pair to a Span.LogFields() record +func String(key, val string) Field { + return Field{ + key: key, + fieldType: stringType, + stringVal: val, + } +} + +// Bool adds a bool-valued key:value pair to a Span.LogFields() record +func Bool(key string, val bool) Field { + var numericVal int64 + if val { + numericVal = 1 + } + return Field{ + key: key, + fieldType: boolType, + numericVal: numericVal, + } +} + +// Int adds an int-valued key:value pair to a Span.LogFields() record +func Int(key string, val int) Field { + return Field{ + key: key, + fieldType: intType, + numericVal: int64(val), + } +} + +// Int32 adds an int32-valued key:value pair to a Span.LogFields() record +func Int32(key string, val int32) Field { + return Field{ + key: key, + fieldType: int32Type, + numericVal: int64(val), + } +} + +// Int64 adds an int64-valued key:value pair to a Span.LogFields() record +func Int64(key string, val int64) Field { + return Field{ + key: key, + fieldType: int64Type, + numericVal: val, + } +} + +// Uint32 adds a uint32-valued key:value pair to a Span.LogFields() record +func Uint32(key string, val uint32) Field { + return Field{ + key: key, + fieldType: uint32Type, + numericVal: int64(val), + } +} + +// Uint64 adds a uint64-valued key:value pair to a Span.LogFields() record +func Uint64(key string, val uint64) Field { + return Field{ + key: key, + fieldType: uint64Type, + numericVal: int64(val), + } +} + +// Float32 adds a float32-valued key:value pair to a Span.LogFields() record +func Float32(key string, val float32) Field { + return Field{ + key: key, + fieldType: float32Type, + numericVal: int64(math.Float32bits(val)), + } +} + +// Float64 adds a float64-valued key:value pair to a Span.LogFields() record +func Float64(key string, val float64) Field { + return Field{ + key: key, + fieldType: float64Type, + numericVal: int64(math.Float64bits(val)), + } +} + +// Error adds an error with the key "error.object" to a Span.LogFields() record +func Error(err error) Field { + return Field{ + key: "error.object", + fieldType: errorType, + interfaceVal: err, + } +} + +// Object adds an object-valued key:value pair to a Span.LogFields() record +// Please pass in an immutable object, otherwise there may be concurrency issues. +// Such as passing in the map, log.Object may result in "fatal error: concurrent map iteration and map write". +// Because span is sent asynchronously, it is possible that this map will also be modified. +func Object(key string, obj interface{}) Field { + return Field{ + key: key, + fieldType: objectType, + interfaceVal: obj, + } +} + +// Event creates a string-valued Field for span logs with key="event" and value=val. +func Event(val string) Field { + return String("event", val) +} + +// Message creates a string-valued Field for span logs with key="message" and value=val. +func Message(val string) Field { + return String("message", val) +} + +// LazyLogger allows for user-defined, late-bound logging of arbitrary data +type LazyLogger func(fv Encoder) + +// Lazy adds a LazyLogger to a Span.LogFields() record; the tracing +// implementation will call the LazyLogger function at an indefinite time in +// the future (after Lazy() returns). +func Lazy(ll LazyLogger) Field { + return Field{ + fieldType: lazyLoggerType, + interfaceVal: ll, + } +} + +// Noop creates a no-op log field that should be ignored by the tracer. +// It can be used to capture optional fields, for example those that should +// only be logged in non-production environment: +// +// func customerField(order *Order) log.Field { +// if os.Getenv("ENVIRONMENT") == "dev" { +// return log.String("customer", order.Customer.ID) +// } +// return log.Noop() +// } +// +// span.LogFields(log.String("event", "purchase"), customerField(order)) +// +func Noop() Field { + return Field{ + fieldType: noopType, + } +} + +// Encoder allows access to the contents of a Field (via a call to +// Field.Marshal). +// +// Tracer implementations typically provide an implementation of Encoder; +// OpenTracing callers typically do not need to concern themselves with it. +type Encoder interface { + EmitString(key, value string) + EmitBool(key string, value bool) + EmitInt(key string, value int) + EmitInt32(key string, value int32) + EmitInt64(key string, value int64) + EmitUint32(key string, value uint32) + EmitUint64(key string, value uint64) + EmitFloat32(key string, value float32) + EmitFloat64(key string, value float64) + EmitObject(key string, value interface{}) + EmitLazyLogger(value LazyLogger) +} + +// Marshal passes a Field instance through to the appropriate +// field-type-specific method of an Encoder. +func (lf Field) Marshal(visitor Encoder) { + switch lf.fieldType { + case stringType: + visitor.EmitString(lf.key, lf.stringVal) + case boolType: + visitor.EmitBool(lf.key, lf.numericVal != 0) + case intType: + visitor.EmitInt(lf.key, int(lf.numericVal)) + case int32Type: + visitor.EmitInt32(lf.key, int32(lf.numericVal)) + case int64Type: + visitor.EmitInt64(lf.key, int64(lf.numericVal)) + case uint32Type: + visitor.EmitUint32(lf.key, uint32(lf.numericVal)) + case uint64Type: + visitor.EmitUint64(lf.key, uint64(lf.numericVal)) + case float32Type: + visitor.EmitFloat32(lf.key, math.Float32frombits(uint32(lf.numericVal))) + case float64Type: + visitor.EmitFloat64(lf.key, math.Float64frombits(uint64(lf.numericVal))) + case errorType: + if err, ok := lf.interfaceVal.(error); ok { + visitor.EmitString(lf.key, err.Error()) + } else { + visitor.EmitString(lf.key, "") + } + case objectType: + visitor.EmitObject(lf.key, lf.interfaceVal) + case lazyLoggerType: + visitor.EmitLazyLogger(lf.interfaceVal.(LazyLogger)) + case noopType: + // intentionally left blank + } +} + +// Key returns the field's key. +func (lf Field) Key() string { + return lf.key +} + +// Value returns the field's value as interface{}. +func (lf Field) Value() interface{} { + switch lf.fieldType { + case stringType: + return lf.stringVal + case boolType: + return lf.numericVal != 0 + case intType: + return int(lf.numericVal) + case int32Type: + return int32(lf.numericVal) + case int64Type: + return int64(lf.numericVal) + case uint32Type: + return uint32(lf.numericVal) + case uint64Type: + return uint64(lf.numericVal) + case float32Type: + return math.Float32frombits(uint32(lf.numericVal)) + case float64Type: + return math.Float64frombits(uint64(lf.numericVal)) + case errorType, objectType, lazyLoggerType: + return lf.interfaceVal + case noopType: + return nil + default: + return nil + } +} + +// String returns a string representation of the key and value. +func (lf Field) String() string { + return fmt.Sprint(lf.key, ":", lf.Value()) +} diff --git a/vendor/github.com/opentracing/opentracing-go/log/util.go b/vendor/github.com/opentracing/opentracing-go/log/util.go new file mode 100644 index 00000000000..d57e28aa57f --- /dev/null +++ b/vendor/github.com/opentracing/opentracing-go/log/util.go @@ -0,0 +1,61 @@ +package log + +import ( + "fmt" + "reflect" +) + +// InterleavedKVToFields converts keyValues a la Span.LogKV() to a Field slice +// a la Span.LogFields(). +func InterleavedKVToFields(keyValues ...interface{}) ([]Field, error) { + if len(keyValues)%2 != 0 { + return nil, fmt.Errorf("non-even keyValues len: %d", len(keyValues)) + } + fields := make([]Field, len(keyValues)/2) + for i := 0; i*2 < len(keyValues); i++ { + key, ok := keyValues[i*2].(string) + if !ok { + return nil, fmt.Errorf( + "non-string key (pair #%d): %T", + i, keyValues[i*2]) + } + switch typedVal := keyValues[i*2+1].(type) { + case bool: + fields[i] = Bool(key, typedVal) + case string: + fields[i] = String(key, typedVal) + case int: + fields[i] = Int(key, typedVal) + case int8: + fields[i] = Int32(key, int32(typedVal)) + case int16: + fields[i] = Int32(key, int32(typedVal)) + case int32: + fields[i] = Int32(key, typedVal) + case int64: + fields[i] = Int64(key, typedVal) + case uint: + fields[i] = Uint64(key, uint64(typedVal)) + case uint64: + fields[i] = Uint64(key, typedVal) + case uint8: + fields[i] = Uint32(key, uint32(typedVal)) + case uint16: + fields[i] = Uint32(key, uint32(typedVal)) + case uint32: + fields[i] = Uint32(key, typedVal) + case float32: + fields[i] = Float32(key, typedVal) + case float64: + fields[i] = Float64(key, typedVal) + default: + if typedVal == nil || (reflect.ValueOf(typedVal).Kind() == reflect.Ptr && reflect.ValueOf(typedVal).IsNil()) { + fields[i] = String(key, "nil") + continue + } + // When in doubt, coerce to a string + fields[i] = String(key, fmt.Sprint(typedVal)) + } + } + return fields, nil +} diff --git a/vendor/github.com/opentracing/opentracing-go/noop.go b/vendor/github.com/opentracing/opentracing-go/noop.go new file mode 100644 index 00000000000..f9b680a213d --- /dev/null +++ b/vendor/github.com/opentracing/opentracing-go/noop.go @@ -0,0 +1,64 @@ +package opentracing + +import "github.com/opentracing/opentracing-go/log" + +// A NoopTracer is a trivial, minimum overhead implementation of Tracer +// for which all operations are no-ops. +// +// The primary use of this implementation is in libraries, such as RPC +// frameworks, that make tracing an optional feature controlled by the +// end user. A no-op implementation allows said libraries to use it +// as the default Tracer and to write instrumentation that does +// not need to keep checking if the tracer instance is nil. +// +// For the same reason, the NoopTracer is the default "global" tracer +// (see GlobalTracer and SetGlobalTracer functions). +// +// WARNING: NoopTracer does not support baggage propagation. +type NoopTracer struct{} + +type noopSpan struct{} +type noopSpanContext struct{} + +var ( + defaultNoopSpanContext SpanContext = noopSpanContext{} + defaultNoopSpan Span = noopSpan{} + defaultNoopTracer Tracer = NoopTracer{} +) + +const ( + emptyString = "" +) + +// noopSpanContext: +func (n noopSpanContext) ForeachBaggageItem(handler func(k, v string) bool) {} + +// noopSpan: +func (n noopSpan) Context() SpanContext { return defaultNoopSpanContext } +func (n noopSpan) SetBaggageItem(key, val string) Span { return n } +func (n noopSpan) BaggageItem(key string) string { return emptyString } +func (n noopSpan) SetTag(key string, value interface{}) Span { return n } +func (n noopSpan) LogFields(fields ...log.Field) {} +func (n noopSpan) LogKV(keyVals ...interface{}) {} +func (n noopSpan) Finish() {} +func (n noopSpan) FinishWithOptions(opts FinishOptions) {} +func (n noopSpan) SetOperationName(operationName string) Span { return n } +func (n noopSpan) Tracer() Tracer { return defaultNoopTracer } +func (n noopSpan) LogEvent(event string) {} +func (n noopSpan) LogEventWithPayload(event string, payload interface{}) {} +func (n noopSpan) Log(data LogData) {} + +// StartSpan belongs to the Tracer interface. +func (n NoopTracer) StartSpan(operationName string, opts ...StartSpanOption) Span { + return defaultNoopSpan +} + +// Inject belongs to the Tracer interface. +func (n NoopTracer) Inject(sp SpanContext, format interface{}, carrier interface{}) error { + return nil +} + +// Extract belongs to the Tracer interface. +func (n NoopTracer) Extract(format interface{}, carrier interface{}) (SpanContext, error) { + return nil, ErrSpanContextNotFound +} diff --git a/vendor/github.com/opentracing/opentracing-go/propagation.go b/vendor/github.com/opentracing/opentracing-go/propagation.go new file mode 100644 index 00000000000..b0c275eb05e --- /dev/null +++ b/vendor/github.com/opentracing/opentracing-go/propagation.go @@ -0,0 +1,176 @@ +package opentracing + +import ( + "errors" + "net/http" +) + +/////////////////////////////////////////////////////////////////////////////// +// CORE PROPAGATION INTERFACES: +/////////////////////////////////////////////////////////////////////////////// + +var ( + // ErrUnsupportedFormat occurs when the `format` passed to Tracer.Inject() or + // Tracer.Extract() is not recognized by the Tracer implementation. + ErrUnsupportedFormat = errors.New("opentracing: Unknown or unsupported Inject/Extract format") + + // ErrSpanContextNotFound occurs when the `carrier` passed to + // Tracer.Extract() is valid and uncorrupted but has insufficient + // information to extract a SpanContext. + ErrSpanContextNotFound = errors.New("opentracing: SpanContext not found in Extract carrier") + + // ErrInvalidSpanContext errors occur when Tracer.Inject() is asked to + // operate on a SpanContext which it is not prepared to handle (for + // example, since it was created by a different tracer implementation). + ErrInvalidSpanContext = errors.New("opentracing: SpanContext type incompatible with tracer") + + // ErrInvalidCarrier errors occur when Tracer.Inject() or Tracer.Extract() + // implementations expect a different type of `carrier` than they are + // given. + ErrInvalidCarrier = errors.New("opentracing: Invalid Inject/Extract carrier") + + // ErrSpanContextCorrupted occurs when the `carrier` passed to + // Tracer.Extract() is of the expected type but is corrupted. + ErrSpanContextCorrupted = errors.New("opentracing: SpanContext data corrupted in Extract carrier") +) + +/////////////////////////////////////////////////////////////////////////////// +// BUILTIN PROPAGATION FORMATS: +/////////////////////////////////////////////////////////////////////////////// + +// BuiltinFormat is used to demarcate the values within package `opentracing` +// that are intended for use with the Tracer.Inject() and Tracer.Extract() +// methods. +type BuiltinFormat byte + +const ( + // Binary represents SpanContexts as opaque binary data. + // + // For Tracer.Inject(): the carrier must be an `io.Writer`. + // + // For Tracer.Extract(): the carrier must be an `io.Reader`. + Binary BuiltinFormat = iota + + // TextMap represents SpanContexts as key:value string pairs. + // + // Unlike HTTPHeaders, the TextMap format does not restrict the key or + // value character sets in any way. + // + // For Tracer.Inject(): the carrier must be a `TextMapWriter`. + // + // For Tracer.Extract(): the carrier must be a `TextMapReader`. + TextMap + + // HTTPHeaders represents SpanContexts as HTTP header string pairs. + // + // Unlike TextMap, the HTTPHeaders format requires that the keys and values + // be valid as HTTP headers as-is (i.e., character casing may be unstable + // and special characters are disallowed in keys, values should be + // URL-escaped, etc). + // + // For Tracer.Inject(): the carrier must be a `TextMapWriter`. + // + // For Tracer.Extract(): the carrier must be a `TextMapReader`. + // + // See HTTPHeadersCarrier for an implementation of both TextMapWriter + // and TextMapReader that defers to an http.Header instance for storage. + // For example, Inject(): + // + // carrier := opentracing.HTTPHeadersCarrier(httpReq.Header) + // err := span.Tracer().Inject( + // span.Context(), opentracing.HTTPHeaders, carrier) + // + // Or Extract(): + // + // carrier := opentracing.HTTPHeadersCarrier(httpReq.Header) + // clientContext, err := tracer.Extract( + // opentracing.HTTPHeaders, carrier) + // + HTTPHeaders +) + +// TextMapWriter is the Inject() carrier for the TextMap builtin format. With +// it, the caller can encode a SpanContext for propagation as entries in a map +// of unicode strings. +type TextMapWriter interface { + // Set a key:value pair to the carrier. Multiple calls to Set() for the + // same key leads to undefined behavior. + // + // NOTE: The backing store for the TextMapWriter may contain data unrelated + // to SpanContext. As such, Inject() and Extract() implementations that + // call the TextMapWriter and TextMapReader interfaces must agree on a + // prefix or other convention to distinguish their own key:value pairs. + Set(key, val string) +} + +// TextMapReader is the Extract() carrier for the TextMap builtin format. With it, +// the caller can decode a propagated SpanContext as entries in a map of +// unicode strings. +type TextMapReader interface { + // ForeachKey returns TextMap contents via repeated calls to the `handler` + // function. If any call to `handler` returns a non-nil error, ForeachKey + // terminates and returns that error. + // + // NOTE: The backing store for the TextMapReader may contain data unrelated + // to SpanContext. As such, Inject() and Extract() implementations that + // call the TextMapWriter and TextMapReader interfaces must agree on a + // prefix or other convention to distinguish their own key:value pairs. + // + // The "foreach" callback pattern reduces unnecessary copying in some cases + // and also allows implementations to hold locks while the map is read. + ForeachKey(handler func(key, val string) error) error +} + +// TextMapCarrier allows the use of regular map[string]string +// as both TextMapWriter and TextMapReader. +type TextMapCarrier map[string]string + +// ForeachKey conforms to the TextMapReader interface. +func (c TextMapCarrier) ForeachKey(handler func(key, val string) error) error { + for k, v := range c { + if err := handler(k, v); err != nil { + return err + } + } + return nil +} + +// Set implements Set() of opentracing.TextMapWriter +func (c TextMapCarrier) Set(key, val string) { + c[key] = val +} + +// HTTPHeadersCarrier satisfies both TextMapWriter and TextMapReader. +// +// Example usage for server side: +// +// carrier := opentracing.HTTPHeadersCarrier(httpReq.Header) +// clientContext, err := tracer.Extract(opentracing.HTTPHeaders, carrier) +// +// Example usage for client side: +// +// carrier := opentracing.HTTPHeadersCarrier(httpReq.Header) +// err := tracer.Inject( +// span.Context(), +// opentracing.HTTPHeaders, +// carrier) +// +type HTTPHeadersCarrier http.Header + +// Set conforms to the TextMapWriter interface. +func (c HTTPHeadersCarrier) Set(key, val string) { + h := http.Header(c) + h.Set(key, val) +} + +// ForeachKey conforms to the TextMapReader interface. +func (c HTTPHeadersCarrier) ForeachKey(handler func(key, val string) error) error { + for k, vals := range c { + for _, v := range vals { + if err := handler(k, v); err != nil { + return err + } + } + } + return nil +} diff --git a/vendor/github.com/opentracing/opentracing-go/span.go b/vendor/github.com/opentracing/opentracing-go/span.go new file mode 100644 index 00000000000..0d3fb534183 --- /dev/null +++ b/vendor/github.com/opentracing/opentracing-go/span.go @@ -0,0 +1,189 @@ +package opentracing + +import ( + "time" + + "github.com/opentracing/opentracing-go/log" +) + +// SpanContext represents Span state that must propagate to descendant Spans and across process +// boundaries (e.g., a tuple). +type SpanContext interface { + // ForeachBaggageItem grants access to all baggage items stored in the + // SpanContext. + // The handler function will be called for each baggage key/value pair. + // The ordering of items is not guaranteed. + // + // The bool return value indicates if the handler wants to continue iterating + // through the rest of the baggage items; for example if the handler is trying to + // find some baggage item by pattern matching the name, it can return false + // as soon as the item is found to stop further iterations. + ForeachBaggageItem(handler func(k, v string) bool) +} + +// Span represents an active, un-finished span in the OpenTracing system. +// +// Spans are created by the Tracer interface. +type Span interface { + // Sets the end timestamp and finalizes Span state. + // + // With the exception of calls to Context() (which are always allowed), + // Finish() must be the last call made to any span instance, and to do + // otherwise leads to undefined behavior. + Finish() + // FinishWithOptions is like Finish() but with explicit control over + // timestamps and log data. + FinishWithOptions(opts FinishOptions) + + // Context() yields the SpanContext for this Span. Note that the return + // value of Context() is still valid after a call to Span.Finish(), as is + // a call to Span.Context() after a call to Span.Finish(). + Context() SpanContext + + // Sets or changes the operation name. + // + // Returns a reference to this Span for chaining. + SetOperationName(operationName string) Span + + // Adds a tag to the span. + // + // If there is a pre-existing tag set for `key`, it is overwritten. + // + // Tag values can be numeric types, strings, or bools. The behavior of + // other tag value types is undefined at the OpenTracing level. If a + // tracing system does not know how to handle a particular value type, it + // may ignore the tag, but shall not panic. + // + // Returns a reference to this Span for chaining. + SetTag(key string, value interface{}) Span + + // LogFields is an efficient and type-checked way to record key:value + // logging data about a Span, though the programming interface is a little + // more verbose than LogKV(). Here's an example: + // + // span.LogFields( + // log.String("event", "soft error"), + // log.String("type", "cache timeout"), + // log.Int("waited.millis", 1500)) + // + // Also see Span.FinishWithOptions() and FinishOptions.BulkLogData. + LogFields(fields ...log.Field) + + // LogKV is a concise, readable way to record key:value logging data about + // a Span, though unfortunately this also makes it less efficient and less + // type-safe than LogFields(). Here's an example: + // + // span.LogKV( + // "event", "soft error", + // "type", "cache timeout", + // "waited.millis", 1500) + // + // For LogKV (as opposed to LogFields()), the parameters must appear as + // key-value pairs, like + // + // span.LogKV(key1, val1, key2, val2, key3, val3, ...) + // + // The keys must all be strings. The values may be strings, numeric types, + // bools, Go error instances, or arbitrary structs. + // + // (Note to implementors: consider the log.InterleavedKVToFields() helper) + LogKV(alternatingKeyValues ...interface{}) + + // SetBaggageItem sets a key:value pair on this Span and its SpanContext + // that also propagates to descendants of this Span. + // + // SetBaggageItem() enables powerful functionality given a full-stack + // opentracing integration (e.g., arbitrary application data from a mobile + // app can make it, transparently, all the way into the depths of a storage + // system), and with it some powerful costs: use this feature with care. + // + // IMPORTANT NOTE #1: SetBaggageItem() will only propagate baggage items to + // *future* causal descendants of the associated Span. + // + // IMPORTANT NOTE #2: Use this thoughtfully and with care. Every key and + // value is copied into every local *and remote* child of the associated + // Span, and that can add up to a lot of network and cpu overhead. + // + // Returns a reference to this Span for chaining. + SetBaggageItem(restrictedKey, value string) Span + + // Gets the value for a baggage item given its key. Returns the empty string + // if the value isn't found in this Span. + BaggageItem(restrictedKey string) string + + // Provides access to the Tracer that created this Span. + Tracer() Tracer + + // Deprecated: use LogFields or LogKV + LogEvent(event string) + // Deprecated: use LogFields or LogKV + LogEventWithPayload(event string, payload interface{}) + // Deprecated: use LogFields or LogKV + Log(data LogData) +} + +// LogRecord is data associated with a single Span log. Every LogRecord +// instance must specify at least one Field. +type LogRecord struct { + Timestamp time.Time + Fields []log.Field +} + +// FinishOptions allows Span.FinishWithOptions callers to override the finish +// timestamp and provide log data via a bulk interface. +type FinishOptions struct { + // FinishTime overrides the Span's finish time, or implicitly becomes + // time.Now() if FinishTime.IsZero(). + // + // FinishTime must resolve to a timestamp that's >= the Span's StartTime + // (per StartSpanOptions). + FinishTime time.Time + + // LogRecords allows the caller to specify the contents of many LogFields() + // calls with a single slice. May be nil. + // + // None of the LogRecord.Timestamp values may be .IsZero() (i.e., they must + // be set explicitly). Also, they must be >= the Span's start timestamp and + // <= the FinishTime (or time.Now() if FinishTime.IsZero()). Otherwise the + // behavior of FinishWithOptions() is undefined. + // + // If specified, the caller hands off ownership of LogRecords at + // FinishWithOptions() invocation time. + // + // If specified, the (deprecated) BulkLogData must be nil or empty. + LogRecords []LogRecord + + // BulkLogData is DEPRECATED. + BulkLogData []LogData +} + +// LogData is DEPRECATED +type LogData struct { + Timestamp time.Time + Event string + Payload interface{} +} + +// ToLogRecord converts a deprecated LogData to a non-deprecated LogRecord +func (ld *LogData) ToLogRecord() LogRecord { + var literalTimestamp time.Time + if ld.Timestamp.IsZero() { + literalTimestamp = time.Now() + } else { + literalTimestamp = ld.Timestamp + } + rval := LogRecord{ + Timestamp: literalTimestamp, + } + if ld.Payload == nil { + rval.Fields = []log.Field{ + log.String("event", ld.Event), + } + } else { + rval.Fields = []log.Field{ + log.String("event", ld.Event), + log.Object("payload", ld.Payload), + } + } + return rval +} diff --git a/vendor/github.com/opentracing/opentracing-go/tracer.go b/vendor/github.com/opentracing/opentracing-go/tracer.go new file mode 100644 index 00000000000..715f0cedfb6 --- /dev/null +++ b/vendor/github.com/opentracing/opentracing-go/tracer.go @@ -0,0 +1,304 @@ +package opentracing + +import "time" + +// Tracer is a simple, thin interface for Span creation and SpanContext +// propagation. +type Tracer interface { + + // Create, start, and return a new Span with the given `operationName` and + // incorporate the given StartSpanOption `opts`. (Note that `opts` borrows + // from the "functional options" pattern, per + // http://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis) + // + // A Span with no SpanReference options (e.g., opentracing.ChildOf() or + // opentracing.FollowsFrom()) becomes the root of its own trace. + // + // Examples: + // + // var tracer opentracing.Tracer = ... + // + // // The root-span case: + // sp := tracer.StartSpan("GetFeed") + // + // // The vanilla child span case: + // sp := tracer.StartSpan( + // "GetFeed", + // opentracing.ChildOf(parentSpan.Context())) + // + // // All the bells and whistles: + // sp := tracer.StartSpan( + // "GetFeed", + // opentracing.ChildOf(parentSpan.Context()), + // opentracing.Tag{"user_agent", loggedReq.UserAgent}, + // opentracing.StartTime(loggedReq.Timestamp), + // ) + // + StartSpan(operationName string, opts ...StartSpanOption) Span + + // Inject() takes the `sm` SpanContext instance and injects it for + // propagation within `carrier`. The actual type of `carrier` depends on + // the value of `format`. + // + // OpenTracing defines a common set of `format` values (see BuiltinFormat), + // and each has an expected carrier type. + // + // Other packages may declare their own `format` values, much like the keys + // used by `context.Context` (see https://godoc.org/context#WithValue). + // + // Example usage (sans error handling): + // + // carrier := opentracing.HTTPHeadersCarrier(httpReq.Header) + // err := tracer.Inject( + // span.Context(), + // opentracing.HTTPHeaders, + // carrier) + // + // NOTE: All opentracing.Tracer implementations MUST support all + // BuiltinFormats. + // + // Implementations may return opentracing.ErrUnsupportedFormat if `format` + // is not supported by (or not known by) the implementation. + // + // Implementations may return opentracing.ErrInvalidCarrier or any other + // implementation-specific error if the format is supported but injection + // fails anyway. + // + // See Tracer.Extract(). + Inject(sm SpanContext, format interface{}, carrier interface{}) error + + // Extract() returns a SpanContext instance given `format` and `carrier`. + // + // OpenTracing defines a common set of `format` values (see BuiltinFormat), + // and each has an expected carrier type. + // + // Other packages may declare their own `format` values, much like the keys + // used by `context.Context` (see + // https://godoc.org/golang.org/x/net/context#WithValue). + // + // Example usage (with StartSpan): + // + // + // carrier := opentracing.HTTPHeadersCarrier(httpReq.Header) + // clientContext, err := tracer.Extract(opentracing.HTTPHeaders, carrier) + // + // // ... assuming the ultimate goal here is to resume the trace with a + // // server-side Span: + // var serverSpan opentracing.Span + // if err == nil { + // span = tracer.StartSpan( + // rpcMethodName, ext.RPCServerOption(clientContext)) + // } else { + // span = tracer.StartSpan(rpcMethodName) + // } + // + // + // NOTE: All opentracing.Tracer implementations MUST support all + // BuiltinFormats. + // + // Return values: + // - A successful Extract returns a SpanContext instance and a nil error + // - If there was simply no SpanContext to extract in `carrier`, Extract() + // returns (nil, opentracing.ErrSpanContextNotFound) + // - If `format` is unsupported or unrecognized, Extract() returns (nil, + // opentracing.ErrUnsupportedFormat) + // - If there are more fundamental problems with the `carrier` object, + // Extract() may return opentracing.ErrInvalidCarrier, + // opentracing.ErrSpanContextCorrupted, or implementation-specific + // errors. + // + // See Tracer.Inject(). + Extract(format interface{}, carrier interface{}) (SpanContext, error) +} + +// StartSpanOptions allows Tracer.StartSpan() callers and implementors a +// mechanism to override the start timestamp, specify Span References, and make +// a single Tag or multiple Tags available at Span start time. +// +// StartSpan() callers should look at the StartSpanOption interface and +// implementations available in this package. +// +// Tracer implementations can convert a slice of `StartSpanOption` instances +// into a `StartSpanOptions` struct like so: +// +// func StartSpan(opName string, opts ...opentracing.StartSpanOption) { +// sso := opentracing.StartSpanOptions{} +// for _, o := range opts { +// o.Apply(&sso) +// } +// ... +// } +// +type StartSpanOptions struct { + // Zero or more causal references to other Spans (via their SpanContext). + // If empty, start a "root" Span (i.e., start a new trace). + References []SpanReference + + // StartTime overrides the Span's start time, or implicitly becomes + // time.Now() if StartTime.IsZero(). + StartTime time.Time + + // Tags may have zero or more entries; the restrictions on map values are + // identical to those for Span.SetTag(). May be nil. + // + // If specified, the caller hands off ownership of Tags at + // StartSpan() invocation time. + Tags map[string]interface{} +} + +// StartSpanOption instances (zero or more) may be passed to Tracer.StartSpan. +// +// StartSpanOption borrows from the "functional options" pattern, per +// http://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis +type StartSpanOption interface { + Apply(*StartSpanOptions) +} + +// SpanReferenceType is an enum type describing different categories of +// relationships between two Spans. If Span-2 refers to Span-1, the +// SpanReferenceType describes Span-1 from Span-2's perspective. For example, +// ChildOfRef means that Span-1 created Span-2. +// +// NOTE: Span-1 and Span-2 do *not* necessarily depend on each other for +// completion; e.g., Span-2 may be part of a background job enqueued by Span-1, +// or Span-2 may be sitting in a distributed queue behind Span-1. +type SpanReferenceType int + +const ( + // ChildOfRef refers to a parent Span that caused *and* somehow depends + // upon the new child Span. Often (but not always), the parent Span cannot + // finish until the child Span does. + // + // An timing diagram for a ChildOfRef that's blocked on the new Span: + // + // [-Parent Span---------] + // [-Child Span----] + // + // See http://opentracing.io/spec/ + // + // See opentracing.ChildOf() + ChildOfRef SpanReferenceType = iota + + // FollowsFromRef refers to a parent Span that does not depend in any way + // on the result of the new child Span. For instance, one might use + // FollowsFromRefs to describe pipeline stages separated by queues, + // or a fire-and-forget cache insert at the tail end of a web request. + // + // A FollowsFromRef Span is part of the same logical trace as the new Span: + // i.e., the new Span is somehow caused by the work of its FollowsFromRef. + // + // All of the following could be valid timing diagrams for children that + // "FollowFrom" a parent. + // + // [-Parent Span-] [-Child Span-] + // + // + // [-Parent Span--] + // [-Child Span-] + // + // + // [-Parent Span-] + // [-Child Span-] + // + // See http://opentracing.io/spec/ + // + // See opentracing.FollowsFrom() + FollowsFromRef +) + +// SpanReference is a StartSpanOption that pairs a SpanReferenceType and a +// referenced SpanContext. See the SpanReferenceType documentation for +// supported relationships. If SpanReference is created with +// ReferencedContext==nil, it has no effect. Thus it allows for a more concise +// syntax for starting spans: +// +// sc, _ := tracer.Extract(someFormat, someCarrier) +// span := tracer.StartSpan("operation", opentracing.ChildOf(sc)) +// +// The `ChildOf(sc)` option above will not panic if sc == nil, it will just +// not add the parent span reference to the options. +type SpanReference struct { + Type SpanReferenceType + ReferencedContext SpanContext +} + +// Apply satisfies the StartSpanOption interface. +func (r SpanReference) Apply(o *StartSpanOptions) { + if r.ReferencedContext != nil { + o.References = append(o.References, r) + } +} + +// ChildOf returns a StartSpanOption pointing to a dependent parent span. +// If sc == nil, the option has no effect. +// +// See ChildOfRef, SpanReference +func ChildOf(sc SpanContext) SpanReference { + return SpanReference{ + Type: ChildOfRef, + ReferencedContext: sc, + } +} + +// FollowsFrom returns a StartSpanOption pointing to a parent Span that caused +// the child Span but does not directly depend on its result in any way. +// If sc == nil, the option has no effect. +// +// See FollowsFromRef, SpanReference +func FollowsFrom(sc SpanContext) SpanReference { + return SpanReference{ + Type: FollowsFromRef, + ReferencedContext: sc, + } +} + +// StartTime is a StartSpanOption that sets an explicit start timestamp for the +// new Span. +type StartTime time.Time + +// Apply satisfies the StartSpanOption interface. +func (t StartTime) Apply(o *StartSpanOptions) { + o.StartTime = time.Time(t) +} + +// Tags are a generic map from an arbitrary string key to an opaque value type. +// The underlying tracing system is responsible for interpreting and +// serializing the values. +type Tags map[string]interface{} + +// Apply satisfies the StartSpanOption interface. +func (t Tags) Apply(o *StartSpanOptions) { + if o.Tags == nil { + o.Tags = make(map[string]interface{}) + } + for k, v := range t { + o.Tags[k] = v + } +} + +// Tag may be passed as a StartSpanOption to add a tag to new spans, +// or its Set method may be used to apply the tag to an existing Span, +// for example: +// +// tracer.StartSpan("opName", Tag{"Key", value}) +// +// or +// +// Tag{"key", value}.Set(span) +type Tag struct { + Key string + Value interface{} +} + +// Apply satisfies the StartSpanOption interface. +func (t Tag) Apply(o *StartSpanOptions) { + if o.Tags == nil { + o.Tags = make(map[string]interface{}) + } + o.Tags[t.Key] = t.Value +} + +// Set applies the tag to an existing Span. +func (t Tag) Set(s Span) { + s.SetTag(t.Key, t.Value) +} diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bson.go b/vendor/go.mongodb.org/mongo-driver/bson/bson.go index ae1a87faa7b..95ffc1078da 100644 --- a/vendor/go.mongodb.org/mongo-driver/bson/bson.go +++ b/vendor/go.mongodb.org/mongo-driver/bson/bson.go @@ -7,8 +7,6 @@ // Based on gopkg.in/mgo.v2/bson by Gustavo Niemeyer // See THIRD-PARTY-NOTICES for original license terms. -// +build go1.9 - package bson // import "go.mongodb.org/mongo-driver/bson" import ( @@ -25,6 +23,8 @@ type Zeroer interface { // D is an ordered representation of a BSON document. This type should be used when the order of the elements matters, // such as MongoDB command documents. If the order of the elements does not matter, an M should be used instead. // +// A D should not be constructed with duplicate key names, as that can cause undefined server behavior. +// // Example usage: // // bson.D{{"foo", "bar"}, {"hello", "world"}, {"pi", 3.14159}} diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bson_1_8.go b/vendor/go.mongodb.org/mongo-driver/bson/bson_1_8.go deleted file mode 100644 index bbe7792848f..00000000000 --- a/vendor/go.mongodb.org/mongo-driver/bson/bson_1_8.go +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (C) MongoDB, Inc. 2017-present. -// -// Licensed under the Apache License, Version 2.0 (the "License"); you may -// not use this file except in compliance with the License. You may obtain -// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - -// +build !go1.9 - -package bson // import "go.mongodb.org/mongo-driver/bson" - -import ( - "math" - "strconv" - "strings" -) - -// Zeroer allows custom struct types to implement a report of zero -// state. All struct types that don't implement Zeroer or where IsZero -// returns false are considered to be not zero. -type Zeroer interface { - IsZero() bool -} - -// D is an ordered representation of a BSON document. This type should be used when the order of the elements matters, -// such as MongoDB command documents. If the order of the elements does not matter, an M should be used instead. -// -// Example usage: -// -// bson.D{{"foo", "bar"}, {"hello", "world"}, {"pi", 3.14159}} -type D []E - -// Map creates a map from the elements of the D. -func (d D) Map() M { - m := make(M, len(d)) - for _, e := range d { - m[e.Key] = e.Value - } - return m -} - -// E represents a BSON element for a D. It is usually used inside a D. -type E struct { - Key string - Value interface{} -} - -// M is an unordered representation of a BSON document. This type should be used when the order of the elements does not -// matter. This type is handled as a regular map[string]interface{} when encoding and decoding. Elements will be -// serialized in an undefined, random order. If the order of the elements matters, a D should be used instead. -// -// Example usage: -// -// bson.M{"foo": "bar", "hello": "world", "pi": 3.14159} -type M map[string]interface{} - -// An A is an ordered representation of a BSON array. -// -// Example usage: -// -// bson.A{"bar", "world", 3.14159, bson.D{{"qux", 12345}}} -type A []interface{} - -func formatDouble(f float64) string { - var s string - if math.IsInf(f, 1) { - s = "Infinity" - } else if math.IsInf(f, -1) { - s = "-Infinity" - } else if math.IsNaN(f) { - s = "NaN" - } else { - // Print exactly one decimalType place for integers; otherwise, print as many are necessary to - // perfectly represent it. - s = strconv.FormatFloat(f, 'G', -1, 64) - if !strings.ContainsRune(s, '.') { - s += ".0" - } - } - - return s -} diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_decoders.go b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_decoders.go index 18919e3c402..32fd1427874 100644 --- a/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_decoders.go +++ b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_decoders.go @@ -55,7 +55,7 @@ type DefaultValueDecoders struct{} // // There is no support for decoding map[string]interface{} becuase there is no decoder for // interface{}, so users must either register this decoder themselves or use the -// EmptyInterfaceDecoder avaialble in the bson package. +// EmptyInterfaceDecoder available in the bson package. func (dvd DefaultValueDecoders) RegisterDefaultDecoders(rb *RegistryBuilder) { if rb == nil { panic(errors.New("argument to RegisterDefaultDecoders must not be nil")) diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_encoders.go b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_encoders.go index 49a0c3f14bf..6bdb43cb436 100644 --- a/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_encoders.go +++ b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_encoders.go @@ -30,7 +30,7 @@ var errInvalidValue = errors.New("cannot encode invalid element") var sliceWriterPool = sync.Pool{ New: func() interface{} { - sw := make(bsonrw.SliceWriter, 0, 0) + sw := make(bsonrw.SliceWriter, 0) return &sw }, } @@ -333,14 +333,7 @@ func (dve DefaultValueEncoders) mapEncodeValue(ec EncodeContext, dw bsonrw.Docum continue } - if enc, ok := currEncoder.(ValueEncoder); ok { - err = enc.EncodeValue(ec, vw, currVal) - if err != nil { - return err - } - continue - } - err = encoder.EncodeValue(ec, vw, currVal) + err = currEncoder.EncodeValue(ec, vw, currVal) if err != nil { return err } diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/map_codec.go b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/map_codec.go index fbb8ef427ce..1f7acbcf16b 100644 --- a/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/map_codec.go +++ b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/map_codec.go @@ -126,14 +126,7 @@ func (mc *MapCodec) mapEncodeValue(ec EncodeContext, dw bsonrw.DocumentWriter, v continue } - if enc, ok := currEncoder.(ValueEncoder); ok { - err = enc.EncodeValue(ec, vw, currVal) - if err != nil { - return err - } - continue - } - err = encoder.EncodeValue(ec, vw, currVal) + err = currEncoder.EncodeValue(ec, vw, currVal) if err != nil { return err } @@ -265,17 +258,15 @@ func (mc *MapCodec) decodeKey(key string, keyType reflect.Type) (reflect.Value, case reflect.String: keyVal = reflect.ValueOf(key).Convert(keyType) case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - s := string(key) - n, parseErr := strconv.ParseInt(s, 10, 64) + n, parseErr := strconv.ParseInt(key, 10, 64) if parseErr != nil || reflect.Zero(keyType).OverflowInt(n) { - err = fmt.Errorf("failed to unmarshal number key %v", s) + err = fmt.Errorf("failed to unmarshal number key %v", key) } keyVal = reflect.ValueOf(n).Convert(keyType) case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - s := string(key) - n, parseErr := strconv.ParseUint(s, 10, 64) + n, parseErr := strconv.ParseUint(key, 10, 64) if parseErr != nil || reflect.Zero(keyType).OverflowUint(n) { - err = fmt.Errorf("failed to unmarshal number key %v", s) + err = fmt.Errorf("failed to unmarshal number key %v", key) break } keyVal = reflect.ValueOf(n).Convert(keyType) diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/registry.go b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/registry.go index 60abffb2483..02b9341ffed 100644 --- a/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/registry.go +++ b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/registry.go @@ -54,12 +54,6 @@ func (entme ErrNoTypeMapEntry) Error() string { // ErrNotInterface is returned when the provided type is not an interface. var ErrNotInterface = errors.New("The provided type is not an interface") -var defaultRegistry *Registry - -func init() { - defaultRegistry = buildDefaultRegistry() -} - // A RegistryBuilder is used to build a Registry. This type is not goroutine // safe. type RegistryBuilder struct { @@ -374,7 +368,7 @@ func (r *Registry) lookupInterfaceEncoder(t reflect.Type, allowAddr bool) (Value // in interfaceEncoders defaultEnc, found := r.lookupInterfaceEncoder(t, false) if !found { - defaultEnc, _ = r.kindEncoders[t.Kind()] + defaultEnc = r.kindEncoders[t.Kind()] } return newCondAddrEncoder(ienc.ve, defaultEnc), true } @@ -445,7 +439,7 @@ func (r *Registry) lookupInterfaceDecoder(t reflect.Type, allowAddr bool) (Value // in interfaceDecoders defaultDec, found := r.lookupInterfaceDecoder(t, false) if !found { - defaultDec, _ = r.kindDecoders[t.Kind()] + defaultDec = r.kindDecoders[t.Kind()] } return newCondAddrDecoder(idec.vd, defaultDec), true } diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/struct_codec.go b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/struct_codec.go index 9ce901782f7..be3f2081e9a 100644 --- a/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/struct_codec.go +++ b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/struct_codec.go @@ -331,14 +331,7 @@ func (sc *StructCodec) DecodeValue(r DecodeContext, vr bsonrw.ValueReader, val r return newDecodeError(fd.name, ErrNoDecoder{Type: field.Elem().Type()}) } - if decoder, ok := fd.decoder.(ValueDecoder); ok { - err = decoder.DecodeValue(dctx, vr, field.Elem()) - if err != nil { - return newDecodeError(fd.name, err) - } - continue - } - err = fd.decoder.DecodeValue(dctx, vr, field) + err = fd.decoder.DecodeValue(dctx, vr, field.Elem()) if err != nil { return newDecodeError(fd.name, err) } @@ -567,7 +560,7 @@ func (sc *StructCodec) describeStruct(r *Registry, t reflect.Type) (*structDescr } dominant, ok := dominantField(fields[i : i+advance]) if !ok || !sc.OverwriteDuplicatedInlinedFields { - return nil, fmt.Errorf("struct %s) duplicated key %s", t.String(), name) + return nil, fmt.Errorf("struct %s has duplicated key %s", t.String(), name) } sd.fl = append(sd.fl, dominant) sd.fm[name] = dominant diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/types.go b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/types.go index fb5b51084da..07f4b70e6d5 100644 --- a/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/types.go +++ b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/types.go @@ -16,36 +16,12 @@ import ( "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" ) -var ptBool = reflect.TypeOf((*bool)(nil)) -var ptInt8 = reflect.TypeOf((*int8)(nil)) -var ptInt16 = reflect.TypeOf((*int16)(nil)) -var ptInt32 = reflect.TypeOf((*int32)(nil)) -var ptInt64 = reflect.TypeOf((*int64)(nil)) -var ptInt = reflect.TypeOf((*int)(nil)) -var ptUint8 = reflect.TypeOf((*uint8)(nil)) -var ptUint16 = reflect.TypeOf((*uint16)(nil)) -var ptUint32 = reflect.TypeOf((*uint32)(nil)) -var ptUint64 = reflect.TypeOf((*uint64)(nil)) -var ptUint = reflect.TypeOf((*uint)(nil)) -var ptFloat32 = reflect.TypeOf((*float32)(nil)) -var ptFloat64 = reflect.TypeOf((*float64)(nil)) -var ptString = reflect.TypeOf((*string)(nil)) - var tBool = reflect.TypeOf(false) -var tFloat32 = reflect.TypeOf(float32(0)) var tFloat64 = reflect.TypeOf(float64(0)) -var tInt = reflect.TypeOf(int(0)) -var tInt8 = reflect.TypeOf(int8(0)) -var tInt16 = reflect.TypeOf(int16(0)) var tInt32 = reflect.TypeOf(int32(0)) var tInt64 = reflect.TypeOf(int64(0)) var tString = reflect.TypeOf("") var tTime = reflect.TypeOf(time.Time{}) -var tUint = reflect.TypeOf(uint(0)) -var tUint8 = reflect.TypeOf(uint8(0)) -var tUint16 = reflect.TypeOf(uint16(0)) -var tUint32 = reflect.TypeOf(uint32(0)) -var tUint64 = reflect.TypeOf(uint64(0)) var tEmpty = reflect.TypeOf((*interface{})(nil)).Elem() var tByteSlice = reflect.TypeOf([]byte(nil)) @@ -74,7 +50,6 @@ var tDecimal = reflect.TypeOf(primitive.Decimal128{}) var tMinKey = reflect.TypeOf(primitive.MinKey{}) var tMaxKey = reflect.TypeOf(primitive.MaxKey{}) var tD = reflect.TypeOf(primitive.D{}) -var tM = reflect.TypeOf(primitive.M{}) var tA = reflect.TypeOf(primitive.A{}) var tE = reflect.TypeOf(primitive.E{}) diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_reader.go b/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_reader.go index b83012b21c8..35832d73aab 100644 --- a/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_reader.go +++ b/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_reader.go @@ -164,6 +164,23 @@ func (ejvr *extJSONValueReader) skipObject() { depth := 1 for depth > 0 { ejvr.p.advanceState() + + // If object is empty, raise depth and continue. When emptyObject is true, the + // parser has already read both the opening and closing brackets of an empty + // object ("{}"), so the next valid token will be part of the parent document, + // not part of the nested document. + // + // If there is a comma, there are remaining fields, emptyObject must be set back + // to false, and comma must be skipped with advanceState(). + if ejvr.p.emptyObject { + if ejvr.p.s == jpsSawComma { + ejvr.p.emptyObject = false + ejvr.p.advanceState() + } + depth-- + continue + } + switch ejvr.p.s { case jpsSawBeginObject, jpsSawBeginArray: depth++ diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_wrappers.go b/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_wrappers.go index 7bcf662135a..9695704246d 100644 --- a/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_wrappers.go +++ b/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_wrappers.go @@ -19,7 +19,7 @@ import ( ) func wrapperKeyBSONType(key string) bsontype.Type { - switch string(key) { + switch key { case "$numberInt": return bsontype.Int32 case "$numberLong": @@ -46,12 +46,6 @@ func wrapperKeyBSONType(key string) bsontype.Type { return bsontype.DBPointer case "$date": return bsontype.DateTime - case "$ref": - fallthrough - case "$id": - fallthrough - case "$db": - return bsontype.EmbeddedDocument // dbrefs aren't bson types case "$minKey": return bsontype.MinKey case "$maxKey": @@ -275,7 +269,7 @@ func (ejv *extJSONValue) parseDouble() (float64, error) { return 0, fmt.Errorf("$numberDouble value should be string, but instead is %s", ejv.t) } - switch string(ejv.v.(string)) { + switch ejv.v.(string) { case "Infinity": return math.Inf(1), nil case "-Infinity": @@ -370,7 +364,7 @@ func (ejv *extJSONValue) parseRegex() (pattern, options string, err error) { for i, key := range regexObj.keys { val := regexObj.values[i] - switch string(key) { + switch key { case "pattern": if patFound { return "", "", errors.New("duplicate pattern key in $regularExpression") diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_writer.go b/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_writer.go index 605e41a138c..99ed524b77e 100644 --- a/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_writer.go +++ b/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_writer.go @@ -10,7 +10,6 @@ import ( "bytes" "encoding/base64" "fmt" - "go.mongodb.org/mongo-driver/bson/primitive" "io" "math" "sort" @@ -19,13 +18,9 @@ import ( "sync" "time" "unicode/utf8" -) -var ejvwPool = sync.Pool{ - New: func() interface{} { - return new(extJSONValueWriter) - }, -} + "go.mongodb.org/mongo-driver/bson/primitive" +) // ExtJSONValueWriterPool is a pool for ExtJSON ValueWriters. type ExtJSONValueWriterPool struct { diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/json_scanner.go b/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/json_scanner.go index 212f3483489..cd4843a3a40 100644 --- a/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/json_scanner.go +++ b/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/json_scanner.go @@ -13,8 +13,8 @@ import ( "io" "math" "strconv" - "strings" "unicode" + "unicode/utf16" ) type jsonTokenType byte @@ -162,6 +162,31 @@ func isValueTerminator(c byte) bool { return c == ',' || c == '}' || c == ']' || isWhiteSpace(c) } +// getu4 decodes the 4-byte hex sequence from the beginning of s, returning the hex value as a rune, +// or it returns -1. Note that the "\u" from the unicode escape sequence should not be present. +// It is copied and lightly modified from the Go JSON decode function at +// https://github.com/golang/go/blob/1b0a0316802b8048d69da49dc23c5a5ab08e8ae8/src/encoding/json/decode.go#L1169-L1188 +func getu4(s []byte) rune { + if len(s) < 4 { + return -1 + } + var r rune + for _, c := range s[:4] { + switch { + case '0' <= c && c <= '9': + c = c - '0' + case 'a' <= c && c <= 'f': + c = c - 'a' + 10 + case 'A' <= c && c <= 'F': + c = c - 'A' + 10 + default: + return -1 + } + r = r*16 + rune(c) + } + return r +} + // scanString reads from an opening '"' to a closing '"' and handles escaped characters func (js *jsonScanner) scanString() (*jsonToken, error) { var b bytes.Buffer @@ -179,9 +204,18 @@ func (js *jsonScanner) scanString() (*jsonToken, error) { return nil, err } + evalNextChar: switch c { case '\\': c, err = js.readNextByte() + if err != nil { + if err == io.EOF { + return nil, errors.New("end of input in JSON string") + } + return nil, err + } + + evalNextEscapeChar: switch c { case '"', '\\', '/': b.WriteByte(c) @@ -202,13 +236,68 @@ func (js *jsonScanner) scanString() (*jsonToken, error) { return nil, fmt.Errorf("invalid unicode sequence in JSON string: %s", us) } - s := fmt.Sprintf(`\u%s`, us) - s, err = strconv.Unquote(strings.Replace(strconv.Quote(s), `\\u`, `\u`, 1)) - if err != nil { - return nil, err + rn := getu4(us) + + // If the rune we just decoded is the high or low value of a possible surrogate pair, + // try to decode the next sequence as the low value of a surrogate pair. We're + // expecting the next sequence to be another Unicode escape sequence (e.g. "\uDD1E"), + // but need to handle cases where the input is not a valid surrogate pair. + // For more context on unicode surrogate pairs, see: + // https://www.christianfscott.com/rust-chars-vs-go-runes/ + // https://www.unicode.org/glossary/#high_surrogate_code_point + if utf16.IsSurrogate(rn) { + c, err = js.readNextByte() + if err != nil { + if err == io.EOF { + return nil, errors.New("end of input in JSON string") + } + return nil, err + } + + // If the next value isn't the beginning of a backslash escape sequence, write + // the Unicode replacement character for the surrogate value and goto the + // beginning of the next char eval block. + if c != '\\' { + b.WriteRune(unicode.ReplacementChar) + goto evalNextChar + } + + c, err = js.readNextByte() + if err != nil { + if err == io.EOF { + return nil, errors.New("end of input in JSON string") + } + return nil, err + } + + // If the next value isn't the beginning of a unicode escape sequence, write the + // Unicode replacement character for the surrogate value and goto the beginning + // of the next escape char eval block. + if c != 'u' { + b.WriteRune(unicode.ReplacementChar) + goto evalNextEscapeChar + } + + err = js.readNNextBytes(us, 4, 0) + if err != nil { + return nil, fmt.Errorf("invalid unicode sequence in JSON string: %s", us) + } + + rn2 := getu4(us) + + // Try to decode the pair of runes as a utf16 surrogate pair. If that fails, write + // the Unicode replacement character for the surrogate value and the 2nd decoded rune. + if rnPair := utf16.DecodeRune(rn, rn2); rnPair != unicode.ReplacementChar { + b.WriteRune(rnPair) + } else { + b.WriteRune(unicode.ReplacementChar) + b.WriteRune(rn2) + } + + break } - b.WriteString(s) + b.WriteRune(rn) default: return nil, fmt.Errorf("invalid escape sequence in JSON string '\\%c'", c) } diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/value_reader.go b/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/value_reader.go index 55378093a23..5e147373bc2 100644 --- a/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/value_reader.go +++ b/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/value_reader.go @@ -790,16 +790,6 @@ func (vr *valueReader) readCString() (string, error) { return string(vr.d[start : start+int64(idx)]), nil } -func (vr *valueReader) skipCString() error { - idx := bytes.IndexByte(vr.d[vr.offset:], 0x00) - if idx < 0 { - return io.EOF - } - // idx does not include the null byte - vr.offset += int64(idx) + 1 - return nil -} - func (vr *valueReader) readString() (string, error) { length, err := vr.readLength() if err != nil { diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/value_writer.go b/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/value_writer.go index 7b7d7ad3f2b..a39c4ea4cb8 100644 --- a/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/value_writer.go +++ b/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/value_writer.go @@ -47,11 +47,9 @@ func NewBSONValueWriterPool() *BSONValueWriterPool { // Get retrieves a BSON ValueWriter from the pool and resets it to use w as the destination. func (bvwp *BSONValueWriterPool) Get(w io.Writer) ValueWriter { vw := bvwp.pool.Get().(*valueWriter) - if writer, ok := w.(*SliceWriter); ok { - vw.reset(*writer) - vw.w = writer - return vw - } + + // TODO: Having to call reset here with the same buffer doesn't really make sense. + vw.reset(vw.buf) vw.buf = vw.buf[:0] vw.w = w return vw @@ -72,11 +70,6 @@ func (bvwp *BSONValueWriterPool) Put(vw ValueWriter) (ok bool) { return false } - if _, ok := bvw.w.(*SliceWriter); ok { - bvw.buf = nil - } - bvw.w = nil - bvwp.pool.Put(bvw) return true } @@ -549,10 +542,6 @@ func (vw *valueWriter) Flush() error { return nil } - if sw, ok := vw.w.(*SliceWriter); ok { - *sw = vw.buf - return nil - } if _, err := vw.w.Write(vw.buf); err != nil { return err } diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/writer.go b/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/writer.go index 7644df12909..dff65f87f71 100644 --- a/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/writer.go +++ b/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/writer.go @@ -76,27 +76,3 @@ func (sw *SliceWriter) Write(p []byte) (int, error) { *sw = append(*sw, p...) return written, nil } - -type writer []byte - -func (w *writer) Write(p []byte) (int, error) { - index := len(*w) - return w.WriteAt(p, int64(index)) -} - -func (w *writer) WriteAt(p []byte, off int64) (int, error) { - newend := off + int64(len(p)) - if newend < int64(len(*w)) { - newend = int64(len(*w)) - } - - if newend > int64(cap(*w)) { - buf := make([]byte, int64(2*cap(*w))+newend) - copy(buf, *w) - *w = buf - } - - *w = []byte(*w)[:newend] - copy([]byte(*w)[off:], p) - return len(p), nil -} diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsontype/bsontype.go b/vendor/go.mongodb.org/mongo-driver/bson/bsontype/bsontype.go index 63a59ca08f3..7c91ae5186f 100644 --- a/vendor/go.mongodb.org/mongo-driver/bson/bsontype/bsontype.go +++ b/vendor/go.mongodb.org/mongo-driver/bson/bsontype/bsontype.go @@ -38,6 +38,8 @@ const ( BinaryUUIDOld byte = 0x03 BinaryUUID byte = 0x04 BinaryMD5 byte = 0x05 + BinaryEncrypted byte = 0x06 + BinaryColumn byte = 0x07 BinaryUserDefined byte = 0x80 ) diff --git a/vendor/go.mongodb.org/mongo-driver/bson/doc.go b/vendor/go.mongodb.org/mongo-driver/bson/doc.go index 16341568dc5..094be934f09 100644 --- a/vendor/go.mongodb.org/mongo-driver/bson/doc.go +++ b/vendor/go.mongodb.org/mongo-driver/bson/doc.go @@ -29,6 +29,8 @@ // slice and M is a map. For more information about the use cases for these types, see the documentation on the type // definitions. // +// Note that a D should not be constructed with duplicate key names, as that can cause undefined server behavior. +// // Example: // bson.D{{"foo", "bar"}, {"hello", "world"}, {"pi", 3.14159}} // bson.M{"foo": "bar", "hello": "world", "pi": 3.14159} @@ -78,7 +80,7 @@ // 1. Only exported fields in structs will be marshalled or unmarshalled. // // 2. When marshalling a struct, each field will be lowercased to generate the key for the corresponding BSON element. -// For example, a struct field named "Foo" will generate key "foo". This can be overriden via a struct tag (e.g. +// For example, a struct field named "Foo" will generate key "foo". This can be overridden via a struct tag (e.g. // `bson:"fooField"` to generate key "fooField" instead). // // 3. An embedded struct field is marshalled as a subdocument. The key will be the lowercased name of the field's type. diff --git a/vendor/go.mongodb.org/mongo-driver/bson/marshal.go b/vendor/go.mongodb.org/mongo-driver/bson/marshal.go index 381822af53e..79f038581e0 100644 --- a/vendor/go.mongodb.org/mongo-driver/bson/marshal.go +++ b/vendor/go.mongodb.org/mongo-driver/bson/marshal.go @@ -7,6 +7,9 @@ package bson import ( + "bytes" + "encoding/json" + "go.mongodb.org/mongo-driver/bson/bsoncodec" "go.mongodb.org/mongo-driver/bson/bsonrw" "go.mongodb.org/mongo-driver/bson/bsontype" @@ -52,14 +55,14 @@ func MarshalAppend(dst []byte, val interface{}) ([]byte, error) { // MarshalWithRegistry returns the BSON encoding of val as a BSON document. If val is not a type that can be transformed // into a document, MarshalValueWithRegistry should be used instead. func MarshalWithRegistry(r *bsoncodec.Registry, val interface{}) ([]byte, error) { - dst := make([]byte, 0, 256) // TODO: make the default cap a constant + dst := make([]byte, 0) return MarshalAppendWithRegistry(r, dst, val) } // MarshalWithContext returns the BSON encoding of val as a BSON document using EncodeContext ec. If val is not a type // that can be transformed into a document, MarshalValueWithContext should be used instead. func MarshalWithContext(ec bsoncodec.EncodeContext, val interface{}) ([]byte, error) { - dst := make([]byte, 0, 256) // TODO: make the default cap a constant + dst := make([]byte, 0) return MarshalAppendWithContext(ec, dst, val) } @@ -115,13 +118,13 @@ func MarshalValueAppend(dst []byte, val interface{}) (bsontype.Type, []byte, err // MarshalValueWithRegistry returns the BSON encoding of val using Registry r. func MarshalValueWithRegistry(r *bsoncodec.Registry, val interface{}) (bsontype.Type, []byte, error) { - dst := make([]byte, 0, defaultDstCap) + dst := make([]byte, 0) return MarshalValueAppendWithRegistry(r, dst, val) } // MarshalValueWithContext returns the BSON encoding of val using EncodeContext ec. func MarshalValueWithContext(ec bsoncodec.EncodeContext, val interface{}) (bsontype.Type, []byte, error) { - dst := make([]byte, 0, defaultDstCap) + dst := make([]byte, 0) return MarshalValueAppendWithContext(ec, dst, val) } @@ -221,3 +224,22 @@ func MarshalExtJSONAppendWithContext(ec bsoncodec.EncodeContext, dst []byte, val return *sw, nil } + +func IndentExtJSON(dst *bytes.Buffer, src []byte, prefix, indent string) error { + return json.Indent(dst, src, prefix, indent) +} + +func MarshalExtJSONIndent(val interface{}, canonical, escapeHTML bool, prefix, indent string) ([]byte, error) { + marshaled, err := MarshalExtJSON(val, canonical, escapeHTML) + if err != nil { + return nil, err + } + + var buf bytes.Buffer + err = IndentExtJSON(&buf, marshaled, prefix, indent) + if err != nil { + return nil, err + } + + return buf.Bytes(), nil +} diff --git a/vendor/go.mongodb.org/mongo-driver/bson/primitive/decimal.go b/vendor/go.mongodb.org/mongo-driver/bson/primitive/decimal.go index a57e1d69877..ffe4eed07ae 100644 --- a/vendor/go.mongodb.org/mongo-driver/bson/primitive/decimal.go +++ b/vendor/go.mongodb.org/mongo-driver/bson/primitive/decimal.go @@ -133,11 +133,9 @@ Loop: } // BigInt returns significand as big.Int and exponent, bi * 10 ^ exp. -func (d Decimal128) BigInt() (bi *big.Int, exp int, err error) { +func (d Decimal128) BigInt() (*big.Int, int, error) { high, low := d.GetBytes() - var posSign bool // positive sign - - posSign = high>>63&1 == 0 + posSign := high>>63&1 == 0 // positive sign switch high >> 58 & (1<<5 - 1) { case 0x1F: @@ -149,6 +147,7 @@ func (d Decimal128) BigInt() (bi *big.Int, exp int, err error) { return nil, 0, ErrParseNegInf } + var exp int if high>>61&3 == 3 { // Bits: 1*sign 2*ignored 14*exponent 111*significand. // Implicit 0b100 prefix in significand. @@ -171,7 +170,7 @@ func (d Decimal128) BigInt() (bi *big.Int, exp int, err error) { return new(big.Int), 0, nil } - bi = big.NewInt(0) + bi := big.NewInt(0) const host32bit = ^uint(0)>>32 == 0 if host32bit { bi.SetBits([]big.Word{big.Word(low), big.Word(low >> 32), big.Word(high), big.Word(high >> 32)}) @@ -182,7 +181,7 @@ func (d Decimal128) BigInt() (bi *big.Int, exp int, err error) { if !posSign { return bi.Neg(bi), exp, nil } - return + return bi, exp, nil } // IsNaN returns whether d is NaN. diff --git a/vendor/go.mongodb.org/mongo-driver/bson/primitive/objectid.go b/vendor/go.mongodb.org/mongo-driver/bson/primitive/objectid.go index 30aaafe6d95..652898fea75 100644 --- a/vendor/go.mongodb.org/mongo-driver/bson/primitive/objectid.go +++ b/vendor/go.mongodb.org/mongo-driver/bson/primitive/objectid.go @@ -10,8 +10,8 @@ package primitive import ( - "bytes" "crypto/rand" + "encoding" "encoding/binary" "encoding/hex" "encoding/json" @@ -34,6 +34,9 @@ var NilObjectID ObjectID var objectIDCounter = readRandomUint32() var processUnique = processUniqueBytes() +var _ encoding.TextMarshaler = ObjectID{} +var _ encoding.TextUnmarshaler = &ObjectID{} + // NewObjectID generates a new ObjectID. func NewObjectID() ObjectID { return NewObjectIDFromTimestamp(time.Now()) @@ -67,23 +70,23 @@ func (id ObjectID) String() string { // IsZero returns true if id is the empty ObjectID. func (id ObjectID) IsZero() bool { - return bytes.Equal(id[:], NilObjectID[:]) + return id == NilObjectID } // ObjectIDFromHex creates a new ObjectID from a hex string. It returns an error if the hex string is not a // valid ObjectID. func ObjectIDFromHex(s string) (ObjectID, error) { + if len(s) != 24 { + return NilObjectID, ErrInvalidHex + } + b, err := hex.DecodeString(s) if err != nil { return NilObjectID, err } - if len(b) != 12 { - return NilObjectID, ErrInvalidHex - } - var oid [12]byte - copy(oid[:], b[:]) + copy(oid[:], b) return oid, nil } @@ -94,6 +97,23 @@ func IsValidObjectID(s string) bool { return err == nil } +// MarshalText returns the ObjectID as UTF-8-encoded text. Implementing this allows us to use ObjectID +// as a map key when marshalling JSON. See https://pkg.go.dev/encoding#TextMarshaler +func (id ObjectID) MarshalText() ([]byte, error) { + return []byte(id.Hex()), nil +} + +// UnmarshalText populates the byte slice with the ObjectID. Implementing this allows us to use ObjectID +// as a map key when unmarshalling JSON. See https://pkg.go.dev/encoding#TextUnmarshaler +func (id *ObjectID) UnmarshalText(b []byte) error { + oid, err := ObjectIDFromHex(string(b)) + if err != nil { + return err + } + *id = oid + return nil +} + // MarshalJSON returns the ObjectID as a string func (id ObjectID) MarshalJSON() ([]byte, error) { return json.Marshal(id.Hex()) diff --git a/vendor/go.mongodb.org/mongo-driver/bson/primitive/primitive.go b/vendor/go.mongodb.org/mongo-driver/bson/primitive/primitive.go index 5420496b570..b3cba1bf9df 100644 --- a/vendor/go.mongodb.org/mongo-driver/bson/primitive/primitive.go +++ b/vendor/go.mongodb.org/mongo-driver/bson/primitive/primitive.go @@ -4,7 +4,7 @@ // not use this file except in compliance with the License. You may obtain // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 -// Package primitive contains types similar to Go primitives for BSON types can do not have direct +// Package primitive contains types similar to Go primitives for BSON types that do not have direct // Go primitive representations. package primitive // import "go.mongodb.org/mongo-driver/bson/primitive" @@ -21,7 +21,7 @@ type Binary struct { Data []byte } -// Equal compares bp to bp2 and returns true is the are equal. +// Equal compares bp to bp2 and returns true if they are equal. func (bp Binary) Equal(bp2 Binary) bool { if bp.Subtype != bp2.Subtype { return false @@ -29,7 +29,7 @@ func (bp Binary) Equal(bp2 Binary) bool { return bytes.Equal(bp.Data, bp2.Data) } -// IsZero returns if bp is the empty Binary +// IsZero returns if bp is the empty Binary. func (bp Binary) IsZero() bool { return bp.Subtype == 0 && len(bp.Data) == 0 } @@ -43,7 +43,7 @@ type DateTime int64 var _ json.Marshaler = DateTime(0) var _ json.Unmarshaler = (*DateTime)(nil) -// MarshalJSON marshal to time type +// MarshalJSON marshal to time type. func (d DateTime) MarshalJSON() ([]byte, error) { return json.Marshal(d.Time()) } @@ -89,12 +89,12 @@ func (rp Regex) String() string { return fmt.Sprintf(`{"pattern": "%s", "options": "%s"}`, rp.Pattern, rp.Options) } -// Equal compares rp to rp2 and returns true is the are equal. +// Equal compares rp to rp2 and returns true if they are equal. func (rp Regex) Equal(rp2 Regex) bool { return rp.Pattern == rp2.Pattern && rp.Options == rp2.Options } -// IsZero returns if rp is the empty Regex +// IsZero returns if rp is the empty Regex. func (rp Regex) IsZero() bool { return rp.Pattern == "" && rp.Options == "" } @@ -109,12 +109,12 @@ func (d DBPointer) String() string { return fmt.Sprintf(`{"db": "%s", "pointer": "%s"}`, d.DB, d.Pointer) } -// Equal compares d to d2 and returns true is the are equal. +// Equal compares d to d2 and returns true if they are equal. func (d DBPointer) Equal(d2 DBPointer) bool { - return d.DB == d2.DB && bytes.Equal(d.Pointer[:], d2.Pointer[:]) + return d == d2 } -// IsZero returns if d is the empty DBPointer +// IsZero returns if d is the empty DBPointer. func (d DBPointer) IsZero() bool { return d.DB == "" && d.Pointer.IsZero() } @@ -141,12 +141,12 @@ type Timestamp struct { I uint32 } -// Equal compares tp to tp2 and returns true is the are equal. +// Equal compares tp to tp2 and returns true if they are equal. func (tp Timestamp) Equal(tp2 Timestamp) bool { return tp.T == tp2.T && tp.I == tp2.I } -// IsZero returns if tp is the zero Timestamp +// IsZero returns if tp is the zero Timestamp. func (tp Timestamp) IsZero() bool { return tp.T == 0 && tp.I == 0 } @@ -206,7 +206,7 @@ type E struct { // // Example usage: // -// bson.M{"foo": "bar", "hello": "world", "pi": 3.14159}. +// bson.M{"foo": "bar", "hello": "world", "pi": 3.14159} type M map[string]interface{} // An A is an ordered representation of a BSON array. diff --git a/vendor/go.mongodb.org/mongo-driver/bson/primitive_codecs.go b/vendor/go.mongodb.org/mongo-driver/bson/primitive_codecs.go index f397fa2d58a..1cbe3884d19 100644 --- a/vendor/go.mongodb.org/mongo-driver/bson/primitive_codecs.go +++ b/vendor/go.mongodb.org/mongo-driver/bson/primitive_codecs.go @@ -14,6 +14,9 @@ import ( "go.mongodb.org/mongo-driver/bson/bsonrw" ) +var tRawValue = reflect.TypeOf(RawValue{}) +var tRaw = reflect.TypeOf(Raw(nil)) + var primitiveCodecs PrimitiveCodecs // PrimitiveCodecs is a namespace for all of the default bsoncodec.Codecs for the primitive types @@ -87,25 +90,3 @@ func (PrimitiveCodecs) RawDecodeValue(dc bsoncodec.DecodeContext, vr bsonrw.Valu val.Set(reflect.ValueOf(rdr)) return err } - -func (pc PrimitiveCodecs) encodeRaw(ec bsoncodec.EncodeContext, dw bsonrw.DocumentWriter, raw Raw) error { - var copier bsonrw.Copier - elems, err := raw.Elements() - if err != nil { - return err - } - for _, elem := range elems { - dvw, err := dw.WriteDocumentElement(elem.Key()) - if err != nil { - return err - } - - val := elem.Value() - err = copier.CopyValueFromBytes(dvw, val.Type, val.Value) - if err != nil { - return err - } - } - - return dw.WriteDocumentEnd() -} diff --git a/vendor/go.mongodb.org/mongo-driver/bson/raw.go b/vendor/go.mongodb.org/mongo-driver/bson/raw.go index 2aae9f56ab5..efd705daaa5 100644 --- a/vendor/go.mongodb.org/mongo-driver/bson/raw.go +++ b/vendor/go.mongodb.org/mongo-driver/bson/raw.go @@ -15,7 +15,6 @@ import ( // ErrNilReader indicates that an operation was attempted on a nil bson.Reader. var ErrNilReader = errors.New("nil reader") -var errValidateDone = errors.New("validation loop complete") // Raw is a wrapper around a byte slice. It will interpret the slice as a // BSON document. This type is a wrapper around a bsoncore.Document. Errors returned from the @@ -84,9 +83,3 @@ func (r Raw) IndexErr(index uint) (RawElement, error) { // String implements the fmt.Stringer interface. func (r Raw) String() string { return bsoncore.Document(r).String() } - -// readi32 is a helper function for reading an int32 from slice of bytes. -func readi32(b []byte) int32 { - _ = b[3] // bounds check hint to compiler; see golang.org/issue/14808 - return int32(b[0]) | int32(b[1])<<8 | int32(b[2])<<16 | int32(b[3])<<24 -} diff --git a/vendor/go.mongodb.org/mongo-driver/bson/types.go b/vendor/go.mongodb.org/mongo-driver/bson/types.go index bf91f691ade..13a1c35cf6f 100644 --- a/vendor/go.mongodb.org/mongo-driver/bson/types.go +++ b/vendor/go.mongodb.org/mongo-driver/bson/types.go @@ -7,11 +7,7 @@ package bson import ( - "reflect" - "time" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" ) // These constants uniquely refer to each BSON type. @@ -38,48 +34,3 @@ const ( TypeMinKey = bsontype.MinKey TypeMaxKey = bsontype.MaxKey ) - -var tBinary = reflect.TypeOf(primitive.Binary{}) -var tBool = reflect.TypeOf(false) -var tCodeWithScope = reflect.TypeOf(primitive.CodeWithScope{}) -var tDBPointer = reflect.TypeOf(primitive.DBPointer{}) -var tDecimal = reflect.TypeOf(primitive.Decimal128{}) -var tD = reflect.TypeOf(D{}) -var tA = reflect.TypeOf(A{}) -var tDateTime = reflect.TypeOf(primitive.DateTime(0)) -var tUndefined = reflect.TypeOf(primitive.Undefined{}) -var tNull = reflect.TypeOf(primitive.Null{}) -var tRawValue = reflect.TypeOf(RawValue{}) -var tFloat32 = reflect.TypeOf(float32(0)) -var tFloat64 = reflect.TypeOf(float64(0)) -var tInt = reflect.TypeOf(int(0)) -var tInt8 = reflect.TypeOf(int8(0)) -var tInt16 = reflect.TypeOf(int16(0)) -var tInt32 = reflect.TypeOf(int32(0)) -var tInt64 = reflect.TypeOf(int64(0)) -var tJavaScript = reflect.TypeOf(primitive.JavaScript("")) -var tOID = reflect.TypeOf(primitive.ObjectID{}) -var tRaw = reflect.TypeOf(Raw(nil)) -var tRegex = reflect.TypeOf(primitive.Regex{}) -var tString = reflect.TypeOf("") -var tSymbol = reflect.TypeOf(primitive.Symbol("")) -var tTime = reflect.TypeOf(time.Time{}) -var tTimestamp = reflect.TypeOf(primitive.Timestamp{}) -var tUint = reflect.TypeOf(uint(0)) -var tUint8 = reflect.TypeOf(uint8(0)) -var tUint16 = reflect.TypeOf(uint16(0)) -var tUint32 = reflect.TypeOf(uint32(0)) -var tUint64 = reflect.TypeOf(uint64(0)) -var tMinKey = reflect.TypeOf(primitive.MinKey{}) -var tMaxKey = reflect.TypeOf(primitive.MaxKey{}) - -var tEmpty = reflect.TypeOf((*interface{})(nil)).Elem() -var tEmptySlice = reflect.TypeOf([]interface{}(nil)) - -var zeroVal reflect.Value - -// this references the quantity of milliseconds between zero time and -// the unix epoch. useful for making sure that we convert time.Time -// objects correctly to match the legacy bson library's handling of -// time.Time values. -const zeroEpochMs = int64(62135596800000) diff --git a/vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/bsoncore.go b/vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/bsoncore.go index 97ef1b85d59..b8db838a5fb 100644 --- a/vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/bsoncore.go +++ b/vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/bsoncore.go @@ -308,7 +308,7 @@ func BuildArrayElement(dst []byte, key string, values ...Value) []byte { // ReadArray will read an array from src. If there are not enough bytes it // will return false. -func ReadArray(src []byte) (arr Document, rem []byte, ok bool) { return readLengthBytes(src) } +func ReadArray(src []byte) (arr Array, rem []byte, ok bool) { return readLengthBytes(src) } // AppendBinary will append subtype and b to dst and return the extended buffer. func AppendBinary(dst []byte, subtype byte, b []byte) []byte { diff --git a/vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/document.go b/vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/document.go index b77c593ede3..b687b5a8066 100644 --- a/vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/document.go +++ b/vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/document.go @@ -200,7 +200,8 @@ func (d Document) LookupErr(key ...string) (Value, error) { } return val, nil case bsontype.Array: - val, err := elem.Value().Array().LookupErr(key[1:]...) + // Convert to Document to continue Lookup recursion. + val, err := Document(elem.Value().Array()).LookupErr(key[1:]...) if err != nil { return Value{}, err } diff --git a/vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/value.go b/vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/value.go index ca29815495c..54aa617cfd5 100644 --- a/vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/value.go +++ b/vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/value.go @@ -250,7 +250,7 @@ func (v Value) String() string { if !ok { return "" } - return docAsArray(arr, false) + return arr.String() case bsontype.Binary: subtype, data, ok := v.BinaryOK() if !ok { @@ -366,7 +366,7 @@ func (v Value) DebugString() string { if !ok { return "" } - return docAsArray(arr, true) + return arr.DebugString() case bsontype.CodeWithScope: code, scope, ok := v.CodeWithScopeOK() if !ok { @@ -464,7 +464,7 @@ func (v Value) DocumentOK() (Document, bool) { // Array returns the BSON array the Value represents as an Array. It panics if the // value is a BSON type other than array. -func (v Value) Array() Document { +func (v Value) Array() Array { if v.Type != bsontype.Array { panic(ElementTypeError{"bsoncore.Value.Array", v.Type}) } @@ -477,7 +477,7 @@ func (v Value) Array() Document { // ArrayOK is the same as Array, except it returns a boolean instead // of panicking. -func (v Value) ArrayOK() (Document, bool) { +func (v Value) ArrayOK() (Array, bool) { if v.Type != bsontype.Array { return nil, false } @@ -602,7 +602,7 @@ func (v Value) Time() time.Time { if !ok { panic(NewInsufficientBytesError(v.Data, v.Data)) } - return time.Unix(int64(dt)/1000, int64(dt)%1000*1000000) + return time.Unix(dt/1000, dt%1000*1000000) } // TimeOK is the same as Time, except it returns a boolean instead of @@ -615,7 +615,7 @@ func (v Value) TimeOK() (time.Time, bool) { if !ok { return time.Time{}, false } - return time.Unix(int64(dt)/1000, int64(dt)%1000*1000000), true + return time.Unix(dt/1000, dt%1000*1000000), true } // Regex returns the BSON regex value the Value represents. It panics if the value is a BSON @@ -978,38 +978,3 @@ func sortStringAlphebeticAscending(s string) string { sort.Sort(ss) return string([]rune(ss)) } - -func docAsArray(d Document, debug bool) string { - if len(d) < 5 { - return "" - } - var buf bytes.Buffer - buf.WriteByte('[') - - length, rem, _ := ReadLength(d) // We know we have enough bytes to read the length - - length -= 4 - - var elem Element - var ok bool - first := true - for length > 1 { - if !first { - buf.WriteByte(',') - } - elem, rem, ok = ReadElement(rem) - length -= int32(len(elem)) - if !ok { - return "" - } - if debug { - fmt.Fprintf(&buf, "%s ", elem.Value().DebugString()) - } else { - fmt.Fprintf(&buf, "%s", elem.Value()) - } - first = false - } - buf.WriteByte(']') - - return buf.String() -} diff --git a/vendor/golang.org/x/net/http2/client_conn_pool.go b/vendor/golang.org/x/net/http2/client_conn_pool.go index 652bc11a029..c936843eafa 100644 --- a/vendor/golang.org/x/net/http2/client_conn_pool.go +++ b/vendor/golang.org/x/net/http2/client_conn_pool.go @@ -16,6 +16,12 @@ import ( // ClientConnPool manages a pool of HTTP/2 client connections. type ClientConnPool interface { + // GetClientConn returns a specific HTTP/2 connection (usually + // a TLS-TCP connection) to an HTTP/2 server. On success, the + // returned ClientConn accounts for the upcoming RoundTrip + // call, so the caller should not omit it. If the caller needs + // to, ClientConn.RoundTrip can be called with a bogus + // new(http.Request) to release the stream reservation. GetClientConn(req *http.Request, addr string) (*ClientConn, error) MarkDead(*ClientConn) } @@ -42,7 +48,7 @@ type clientConnPool struct { conns map[string][]*ClientConn // key is host:port dialing map[string]*dialCall // currently in-flight dials keys map[*ClientConn][]string - addConnCalls map[string]*addConnCall // in-flight addConnIfNeede calls + addConnCalls map[string]*addConnCall // in-flight addConnIfNeeded calls } func (p *clientConnPool) GetClientConn(req *http.Request, addr string) (*ClientConn, error) { @@ -54,28 +60,8 @@ const ( noDialOnMiss = false ) -// shouldTraceGetConn reports whether getClientConn should call any -// ClientTrace.GetConn hook associated with the http.Request. -// -// This complexity is needed to avoid double calls of the GetConn hook -// during the back-and-forth between net/http and x/net/http2 (when the -// net/http.Transport is upgraded to also speak http2), as well as support -// the case where x/net/http2 is being used directly. -func (p *clientConnPool) shouldTraceGetConn(st clientConnIdleState) bool { - // If our Transport wasn't made via ConfigureTransport, always - // trace the GetConn hook if provided, because that means the - // http2 package is being used directly and it's the one - // dialing, as opposed to net/http. - if _, ok := p.t.ConnPool.(noDialClientConnPool); !ok { - return true - } - // Otherwise, only use the GetConn hook if this connection has - // been used previously for other requests. For fresh - // connections, the net/http package does the dialing. - return !st.freshConn -} - func (p *clientConnPool) getClientConn(req *http.Request, addr string, dialOnMiss bool) (*ClientConn, error) { + // TODO(dneil): Dial a new connection when t.DisableKeepAlives is set? if isConnectionCloseRequest(req) && dialOnMiss { // It gets its own connection. traceGetConn(req, addr) @@ -89,10 +75,14 @@ func (p *clientConnPool) getClientConn(req *http.Request, addr string, dialOnMis for { p.mu.Lock() for _, cc := range p.conns[addr] { - if st := cc.idleState(); st.canTakeNewRequest { - if p.shouldTraceGetConn(st) { + if cc.ReserveNewRequest() { + // When a connection is presented to us by the net/http package, + // the GetConn hook has already been called. + // Don't call it a second time here. + if !cc.getConnCalled { traceGetConn(req, addr) } + cc.getConnCalled = false p.mu.Unlock() return cc, nil } @@ -108,7 +98,13 @@ func (p *clientConnPool) getClientConn(req *http.Request, addr string, dialOnMis if shouldRetryDial(call, req) { continue } - return call.res, call.err + cc, err := call.res, call.err + if err != nil { + return nil, err + } + if cc.ReserveNewRequest() { + return cc, nil + } } } @@ -205,6 +201,7 @@ func (c *addConnCall) run(t *Transport, key string, tc *tls.Conn) { if err != nil { c.err = err } else { + cc.getConnCalled = true // already called by the net/http package p.addConnLocked(key, cc) } delete(p.addConnCalls, key) diff --git a/vendor/golang.org/x/net/http2/errors.go b/vendor/golang.org/x/net/http2/errors.go index 71f2c463178..2663e5d287e 100644 --- a/vendor/golang.org/x/net/http2/errors.go +++ b/vendor/golang.org/x/net/http2/errors.go @@ -53,6 +53,13 @@ func (e ErrCode) String() string { return fmt.Sprintf("unknown error code 0x%x", uint32(e)) } +func (e ErrCode) stringToken() string { + if s, ok := errCodeName[e]; ok { + return s + } + return fmt.Sprintf("ERR_UNKNOWN_%d", uint32(e)) +} + // ConnectionError is an error that results in the termination of the // entire connection. type ConnectionError ErrCode @@ -67,6 +74,11 @@ type StreamError struct { Cause error // optional additional detail } +// errFromPeer is a sentinel error value for StreamError.Cause to +// indicate that the StreamError was sent from the peer over the wire +// and wasn't locally generated in the Transport. +var errFromPeer = errors.New("received from peer") + func streamError(id uint32, code ErrCode) StreamError { return StreamError{StreamID: id, Code: code} } diff --git a/vendor/golang.org/x/net/http2/frame.go b/vendor/golang.org/x/net/http2/frame.go index 514c126c5f8..96a74790524 100644 --- a/vendor/golang.org/x/net/http2/frame.go +++ b/vendor/golang.org/x/net/http2/frame.go @@ -122,7 +122,7 @@ var flagName = map[FrameType]map[Flags]string{ // a frameParser parses a frame given its FrameHeader and payload // bytes. The length of payload will always equal fh.Length (which // might be 0). -type frameParser func(fc *frameCache, fh FrameHeader, payload []byte) (Frame, error) +type frameParser func(fc *frameCache, fh FrameHeader, countError func(string), payload []byte) (Frame, error) var frameParsers = map[FrameType]frameParser{ FrameData: parseDataFrame, @@ -267,6 +267,11 @@ type Framer struct { lastFrame Frame errDetail error + // countError is a non-nil func that's called on a frame parse + // error with some unique error path token. It's initialized + // from Transport.CountError or Server.CountError. + countError func(errToken string) + // lastHeaderStream is non-zero if the last frame was an // unfinished HEADERS/CONTINUATION. lastHeaderStream uint32 @@ -426,6 +431,7 @@ func NewFramer(w io.Writer, r io.Reader) *Framer { fr := &Framer{ w: w, r: r, + countError: func(string) {}, logReads: logFrameReads, logWrites: logFrameWrites, debugReadLoggerf: log.Printf, @@ -500,7 +506,7 @@ func (fr *Framer) ReadFrame() (Frame, error) { if _, err := io.ReadFull(fr.r, payload); err != nil { return nil, err } - f, err := typeFrameParser(fh.Type)(fr.frameCache, fh, payload) + f, err := typeFrameParser(fh.Type)(fr.frameCache, fh, fr.countError, payload) if err != nil { if ce, ok := err.(connError); ok { return nil, fr.connError(ce.Code, ce.Reason) @@ -588,13 +594,14 @@ func (f *DataFrame) Data() []byte { return f.data } -func parseDataFrame(fc *frameCache, fh FrameHeader, payload []byte) (Frame, error) { +func parseDataFrame(fc *frameCache, fh FrameHeader, countError func(string), payload []byte) (Frame, error) { if fh.StreamID == 0 { // DATA frames MUST be associated with a stream. If a // DATA frame is received whose stream identifier // field is 0x0, the recipient MUST respond with a // connection error (Section 5.4.1) of type // PROTOCOL_ERROR. + countError("frame_data_stream_0") return nil, connError{ErrCodeProtocol, "DATA frame with stream ID 0"} } f := fc.getDataFrame() @@ -605,6 +612,7 @@ func parseDataFrame(fc *frameCache, fh FrameHeader, payload []byte) (Frame, erro var err error payload, padSize, err = readByte(payload) if err != nil { + countError("frame_data_pad_byte_short") return nil, err } } @@ -613,6 +621,7 @@ func parseDataFrame(fc *frameCache, fh FrameHeader, payload []byte) (Frame, erro // length of the frame payload, the recipient MUST // treat this as a connection error. // Filed: https://github.com/http2/http2-spec/issues/610 + countError("frame_data_pad_too_big") return nil, connError{ErrCodeProtocol, "pad size larger than data payload"} } f.data = payload[:len(payload)-int(padSize)] @@ -695,7 +704,7 @@ type SettingsFrame struct { p []byte } -func parseSettingsFrame(_ *frameCache, fh FrameHeader, p []byte) (Frame, error) { +func parseSettingsFrame(_ *frameCache, fh FrameHeader, countError func(string), p []byte) (Frame, error) { if fh.Flags.Has(FlagSettingsAck) && fh.Length > 0 { // When this (ACK 0x1) bit is set, the payload of the // SETTINGS frame MUST be empty. Receipt of a @@ -703,6 +712,7 @@ func parseSettingsFrame(_ *frameCache, fh FrameHeader, p []byte) (Frame, error) // field value other than 0 MUST be treated as a // connection error (Section 5.4.1) of type // FRAME_SIZE_ERROR. + countError("frame_settings_ack_with_length") return nil, ConnectionError(ErrCodeFrameSize) } if fh.StreamID != 0 { @@ -713,14 +723,17 @@ func parseSettingsFrame(_ *frameCache, fh FrameHeader, p []byte) (Frame, error) // field is anything other than 0x0, the endpoint MUST // respond with a connection error (Section 5.4.1) of // type PROTOCOL_ERROR. + countError("frame_settings_has_stream") return nil, ConnectionError(ErrCodeProtocol) } if len(p)%6 != 0 { + countError("frame_settings_mod_6") // Expecting even number of 6 byte settings. return nil, ConnectionError(ErrCodeFrameSize) } f := &SettingsFrame{FrameHeader: fh, p: p} if v, ok := f.Value(SettingInitialWindowSize); ok && v > (1<<31)-1 { + countError("frame_settings_window_size_too_big") // Values above the maximum flow control window size of 2^31 - 1 MUST // be treated as a connection error (Section 5.4.1) of type // FLOW_CONTROL_ERROR. @@ -832,11 +845,13 @@ type PingFrame struct { func (f *PingFrame) IsAck() bool { return f.Flags.Has(FlagPingAck) } -func parsePingFrame(_ *frameCache, fh FrameHeader, payload []byte) (Frame, error) { +func parsePingFrame(_ *frameCache, fh FrameHeader, countError func(string), payload []byte) (Frame, error) { if len(payload) != 8 { + countError("frame_ping_length") return nil, ConnectionError(ErrCodeFrameSize) } if fh.StreamID != 0 { + countError("frame_ping_has_stream") return nil, ConnectionError(ErrCodeProtocol) } f := &PingFrame{FrameHeader: fh} @@ -872,11 +887,13 @@ func (f *GoAwayFrame) DebugData() []byte { return f.debugData } -func parseGoAwayFrame(_ *frameCache, fh FrameHeader, p []byte) (Frame, error) { +func parseGoAwayFrame(_ *frameCache, fh FrameHeader, countError func(string), p []byte) (Frame, error) { if fh.StreamID != 0 { + countError("frame_goaway_has_stream") return nil, ConnectionError(ErrCodeProtocol) } if len(p) < 8 { + countError("frame_goaway_short") return nil, ConnectionError(ErrCodeFrameSize) } return &GoAwayFrame{ @@ -912,7 +929,7 @@ func (f *UnknownFrame) Payload() []byte { return f.p } -func parseUnknownFrame(_ *frameCache, fh FrameHeader, p []byte) (Frame, error) { +func parseUnknownFrame(_ *frameCache, fh FrameHeader, countError func(string), p []byte) (Frame, error) { return &UnknownFrame{fh, p}, nil } @@ -923,8 +940,9 @@ type WindowUpdateFrame struct { Increment uint32 // never read with high bit set } -func parseWindowUpdateFrame(_ *frameCache, fh FrameHeader, p []byte) (Frame, error) { +func parseWindowUpdateFrame(_ *frameCache, fh FrameHeader, countError func(string), p []byte) (Frame, error) { if len(p) != 4 { + countError("frame_windowupdate_bad_len") return nil, ConnectionError(ErrCodeFrameSize) } inc := binary.BigEndian.Uint32(p[:4]) & 0x7fffffff // mask off high reserved bit @@ -936,8 +954,10 @@ func parseWindowUpdateFrame(_ *frameCache, fh FrameHeader, p []byte) (Frame, err // control window MUST be treated as a connection // error (Section 5.4.1). if fh.StreamID == 0 { + countError("frame_windowupdate_zero_inc_conn") return nil, ConnectionError(ErrCodeProtocol) } + countError("frame_windowupdate_zero_inc_stream") return nil, streamError(fh.StreamID, ErrCodeProtocol) } return &WindowUpdateFrame{ @@ -988,7 +1008,7 @@ func (f *HeadersFrame) HasPriority() bool { return f.FrameHeader.Flags.Has(FlagHeadersPriority) } -func parseHeadersFrame(_ *frameCache, fh FrameHeader, p []byte) (_ Frame, err error) { +func parseHeadersFrame(_ *frameCache, fh FrameHeader, countError func(string), p []byte) (_ Frame, err error) { hf := &HeadersFrame{ FrameHeader: fh, } @@ -997,11 +1017,13 @@ func parseHeadersFrame(_ *frameCache, fh FrameHeader, p []byte) (_ Frame, err er // is received whose stream identifier field is 0x0, the recipient MUST // respond with a connection error (Section 5.4.1) of type // PROTOCOL_ERROR. + countError("frame_headers_zero_stream") return nil, connError{ErrCodeProtocol, "HEADERS frame with stream ID 0"} } var padLength uint8 if fh.Flags.Has(FlagHeadersPadded) { if p, padLength, err = readByte(p); err != nil { + countError("frame_headers_pad_short") return } } @@ -1009,16 +1031,19 @@ func parseHeadersFrame(_ *frameCache, fh FrameHeader, p []byte) (_ Frame, err er var v uint32 p, v, err = readUint32(p) if err != nil { + countError("frame_headers_prio_short") return nil, err } hf.Priority.StreamDep = v & 0x7fffffff hf.Priority.Exclusive = (v != hf.Priority.StreamDep) // high bit was set p, hf.Priority.Weight, err = readByte(p) if err != nil { + countError("frame_headers_prio_weight_short") return nil, err } } - if len(p)-int(padLength) <= 0 { + if len(p)-int(padLength) < 0 { + countError("frame_headers_pad_too_big") return nil, streamError(fh.StreamID, ErrCodeProtocol) } hf.headerFragBuf = p[:len(p)-int(padLength)] @@ -1125,11 +1150,13 @@ func (p PriorityParam) IsZero() bool { return p == PriorityParam{} } -func parsePriorityFrame(_ *frameCache, fh FrameHeader, payload []byte) (Frame, error) { +func parsePriorityFrame(_ *frameCache, fh FrameHeader, countError func(string), payload []byte) (Frame, error) { if fh.StreamID == 0 { + countError("frame_priority_zero_stream") return nil, connError{ErrCodeProtocol, "PRIORITY frame with stream ID 0"} } if len(payload) != 5 { + countError("frame_priority_bad_length") return nil, connError{ErrCodeFrameSize, fmt.Sprintf("PRIORITY frame payload size was %d; want 5", len(payload))} } v := binary.BigEndian.Uint32(payload[:4]) @@ -1172,11 +1199,13 @@ type RSTStreamFrame struct { ErrCode ErrCode } -func parseRSTStreamFrame(_ *frameCache, fh FrameHeader, p []byte) (Frame, error) { +func parseRSTStreamFrame(_ *frameCache, fh FrameHeader, countError func(string), p []byte) (Frame, error) { if len(p) != 4 { + countError("frame_rststream_bad_len") return nil, ConnectionError(ErrCodeFrameSize) } if fh.StreamID == 0 { + countError("frame_rststream_zero_stream") return nil, ConnectionError(ErrCodeProtocol) } return &RSTStreamFrame{fh, ErrCode(binary.BigEndian.Uint32(p[:4]))}, nil @@ -1202,8 +1231,9 @@ type ContinuationFrame struct { headerFragBuf []byte } -func parseContinuationFrame(_ *frameCache, fh FrameHeader, p []byte) (Frame, error) { +func parseContinuationFrame(_ *frameCache, fh FrameHeader, countError func(string), p []byte) (Frame, error) { if fh.StreamID == 0 { + countError("frame_continuation_zero_stream") return nil, connError{ErrCodeProtocol, "CONTINUATION frame with stream ID 0"} } return &ContinuationFrame{fh, p}, nil @@ -1252,7 +1282,7 @@ func (f *PushPromiseFrame) HeadersEnded() bool { return f.FrameHeader.Flags.Has(FlagPushPromiseEndHeaders) } -func parsePushPromise(_ *frameCache, fh FrameHeader, p []byte) (_ Frame, err error) { +func parsePushPromise(_ *frameCache, fh FrameHeader, countError func(string), p []byte) (_ Frame, err error) { pp := &PushPromiseFrame{ FrameHeader: fh, } @@ -1263,6 +1293,7 @@ func parsePushPromise(_ *frameCache, fh FrameHeader, p []byte) (_ Frame, err err // with. If the stream identifier field specifies the value // 0x0, a recipient MUST respond with a connection error // (Section 5.4.1) of type PROTOCOL_ERROR. + countError("frame_pushpromise_zero_stream") return nil, ConnectionError(ErrCodeProtocol) } // The PUSH_PROMISE frame includes optional padding. @@ -1270,18 +1301,21 @@ func parsePushPromise(_ *frameCache, fh FrameHeader, p []byte) (_ Frame, err err var padLength uint8 if fh.Flags.Has(FlagPushPromisePadded) { if p, padLength, err = readByte(p); err != nil { + countError("frame_pushpromise_pad_short") return } } p, pp.PromiseID, err = readUint32(p) if err != nil { + countError("frame_pushpromise_promiseid_short") return } pp.PromiseID = pp.PromiseID & (1<<31 - 1) if int(padLength) > len(p) { // like the DATA frame, error out if padding is longer than the body. + countError("frame_pushpromise_pad_too_big") return nil, ConnectionError(ErrCodeProtocol) } pp.headerFragBuf = p[:len(p)-int(padLength)] diff --git a/vendor/golang.org/x/net/http2/hpack/huffman.go b/vendor/golang.org/x/net/http2/hpack/huffman.go index a1ab2f05679..fe0b84ccd46 100644 --- a/vendor/golang.org/x/net/http2/hpack/huffman.go +++ b/vendor/golang.org/x/net/http2/hpack/huffman.go @@ -140,25 +140,29 @@ func buildRootHuffmanNode() { panic("unexpected size") } lazyRootHuffmanNode = newInternalNode() - for i, code := range huffmanCodes { - addDecoderNode(byte(i), code, huffmanCodeLen[i]) - } -} + // allocate a leaf node for each of the 256 symbols + leaves := new([256]node) + + for sym, code := range huffmanCodes { + codeLen := huffmanCodeLen[sym] + + cur := lazyRootHuffmanNode + for codeLen > 8 { + codeLen -= 8 + i := uint8(code >> codeLen) + if cur.children[i] == nil { + cur.children[i] = newInternalNode() + } + cur = cur.children[i] + } + shift := 8 - codeLen + start, end := int(uint8(code< 8 { - codeLen -= 8 - i := uint8(code >> codeLen) - if cur.children[i] == nil { - cur.children[i] = newInternalNode() + leaves[sym].sym = byte(sym) + leaves[sym].codeLen = codeLen + for i := start; i < start+end; i++ { + cur.children[i] = &leaves[sym] } - cur = cur.children[i] - } - shift := 8 - codeLen - start, end := int(uint8(code< 0 { // Check whether the client has flow control quota. if st.inflow.available() < int32(f.Length) { - return streamError(id, ErrCodeFlowControl) + return sc.countError("flow_on_data_length", streamError(id, ErrCodeFlowControl)) } st.inflow.take(int32(f.Length)) @@ -1710,7 +1727,7 @@ func (sc *serverConn) processData(f *DataFrame) error { wrote, err := st.body.Write(data) if err != nil { sc.sendWindowUpdate(nil, int(f.Length)-wrote) - return streamError(id, ErrCodeStreamClosed) + return sc.countError("body_write_err", streamError(id, ErrCodeStreamClosed)) } if wrote != len(data) { panic("internal error: bad Writer") @@ -1796,7 +1813,7 @@ func (sc *serverConn) processHeaders(f *MetaHeadersFrame) error { // stream identifier MUST respond with a connection error // (Section 5.4.1) of type PROTOCOL_ERROR. if id%2 != 1 { - return ConnectionError(ErrCodeProtocol) + return sc.countError("headers_even", ConnectionError(ErrCodeProtocol)) } // A HEADERS frame can be used to create a new stream or // send a trailer for an open one. If we already have a stream @@ -1813,7 +1830,7 @@ func (sc *serverConn) processHeaders(f *MetaHeadersFrame) error { // this state, it MUST respond with a stream error (Section 5.4.2) of // type STREAM_CLOSED. if st.state == stateHalfClosedRemote { - return streamError(id, ErrCodeStreamClosed) + return sc.countError("headers_half_closed", streamError(id, ErrCodeStreamClosed)) } return st.processTrailerHeaders(f) } @@ -1824,7 +1841,7 @@ func (sc *serverConn) processHeaders(f *MetaHeadersFrame) error { // receives an unexpected stream identifier MUST respond with // a connection error (Section 5.4.1) of type PROTOCOL_ERROR. if id <= sc.maxClientStreamID { - return ConnectionError(ErrCodeProtocol) + return sc.countError("stream_went_down", ConnectionError(ErrCodeProtocol)) } sc.maxClientStreamID = id @@ -1841,14 +1858,14 @@ func (sc *serverConn) processHeaders(f *MetaHeadersFrame) error { if sc.curClientStreams+1 > sc.advMaxStreams { if sc.unackedSettings == 0 { // They should know better. - return streamError(id, ErrCodeProtocol) + return sc.countError("over_max_streams", streamError(id, ErrCodeProtocol)) } // Assume it's a network race, where they just haven't // received our last SETTINGS update. But actually // this can't happen yet, because we don't yet provide // a way for users to adjust server parameters at // runtime. - return streamError(id, ErrCodeRefusedStream) + return sc.countError("over_max_streams_race", streamError(id, ErrCodeRefusedStream)) } initialState := stateOpen @@ -1858,7 +1875,7 @@ func (sc *serverConn) processHeaders(f *MetaHeadersFrame) error { st := sc.newStream(id, 0, initialState) if f.HasPriority() { - if err := checkPriority(f.StreamID, f.Priority); err != nil { + if err := sc.checkPriority(f.StreamID, f.Priority); err != nil { return err } sc.writeSched.AdjustStream(st.id, f.Priority) @@ -1902,15 +1919,15 @@ func (st *stream) processTrailerHeaders(f *MetaHeadersFrame) error { sc := st.sc sc.serveG.check() if st.gotTrailerHeader { - return ConnectionError(ErrCodeProtocol) + return sc.countError("dup_trailers", ConnectionError(ErrCodeProtocol)) } st.gotTrailerHeader = true if !f.StreamEnded() { - return streamError(st.id, ErrCodeProtocol) + return sc.countError("trailers_not_ended", streamError(st.id, ErrCodeProtocol)) } if len(f.PseudoFields()) > 0 { - return streamError(st.id, ErrCodeProtocol) + return sc.countError("trailers_pseudo", streamError(st.id, ErrCodeProtocol)) } if st.trailer != nil { for _, hf := range f.RegularFields() { @@ -1919,7 +1936,7 @@ func (st *stream) processTrailerHeaders(f *MetaHeadersFrame) error { // TODO: send more details to the peer somehow. But http2 has // no way to send debug data at a stream level. Discuss with // HTTP folk. - return streamError(st.id, ErrCodeProtocol) + return sc.countError("trailers_bogus", streamError(st.id, ErrCodeProtocol)) } st.trailer[key] = append(st.trailer[key], hf.Value) } @@ -1928,13 +1945,13 @@ func (st *stream) processTrailerHeaders(f *MetaHeadersFrame) error { return nil } -func checkPriority(streamID uint32, p PriorityParam) error { +func (sc *serverConn) checkPriority(streamID uint32, p PriorityParam) error { if streamID == p.StreamDep { // Section 5.3.1: "A stream cannot depend on itself. An endpoint MUST treat // this as a stream error (Section 5.4.2) of type PROTOCOL_ERROR." // Section 5.3.3 says that a stream can depend on one of its dependencies, // so it's only self-dependencies that are forbidden. - return streamError(streamID, ErrCodeProtocol) + return sc.countError("priority", streamError(streamID, ErrCodeProtocol)) } return nil } @@ -1943,7 +1960,7 @@ func (sc *serverConn) processPriority(f *PriorityFrame) error { if sc.inGoAway { return nil } - if err := checkPriority(f.StreamID, f.PriorityParam); err != nil { + if err := sc.checkPriority(f.StreamID, f.PriorityParam); err != nil { return err } sc.writeSched.AdjustStream(f.StreamID, f.PriorityParam) @@ -2000,7 +2017,7 @@ func (sc *serverConn) newWriterAndRequest(st *stream, f *MetaHeadersFrame) (*res isConnect := rp.method == "CONNECT" if isConnect { if rp.path != "" || rp.scheme != "" || rp.authority == "" { - return nil, nil, streamError(f.StreamID, ErrCodeProtocol) + return nil, nil, sc.countError("bad_connect", streamError(f.StreamID, ErrCodeProtocol)) } } else if rp.method == "" || rp.path == "" || (rp.scheme != "https" && rp.scheme != "http") { // See 8.1.2.6 Malformed Requests and Responses: @@ -2013,13 +2030,13 @@ func (sc *serverConn) newWriterAndRequest(st *stream, f *MetaHeadersFrame) (*res // "All HTTP/2 requests MUST include exactly one valid // value for the :method, :scheme, and :path // pseudo-header fields" - return nil, nil, streamError(f.StreamID, ErrCodeProtocol) + return nil, nil, sc.countError("bad_path_method", streamError(f.StreamID, ErrCodeProtocol)) } bodyOpen := !f.StreamEnded() if rp.method == "HEAD" && bodyOpen { // HEAD requests can't have bodies - return nil, nil, streamError(f.StreamID, ErrCodeProtocol) + return nil, nil, sc.countError("head_body", streamError(f.StreamID, ErrCodeProtocol)) } rp.header = make(http.Header) @@ -2102,7 +2119,7 @@ func (sc *serverConn) newWriterAndRequestNoBody(st *stream, rp requestParam) (*r var err error url_, err = url.ParseRequestURI(rp.path) if err != nil { - return nil, nil, streamError(st.id, ErrCodeProtocol) + return nil, nil, sc.countError("bad_path", streamError(st.id, ErrCodeProtocol)) } requestURI = rp.path } @@ -2985,3 +3002,31 @@ func h1ServerKeepAlivesDisabled(hs *http.Server) bool { } return false } + +func (sc *serverConn) countError(name string, err error) error { + if sc == nil || sc.srv == nil { + return err + } + f := sc.srv.CountError + if f == nil { + return err + } + var typ string + var code ErrCode + switch e := err.(type) { + case ConnectionError: + typ = "conn" + code = ErrCode(e) + case StreamError: + typ = "stream" + code = ErrCode(e.Code) + default: + return err + } + codeStr := errCodeName[code] + if codeStr == "" { + codeStr = strconv.Itoa(int(code)) + } + f(fmt.Sprintf("%s_%s_%s", typ, codeStr, name)) + return err +} diff --git a/vendor/golang.org/x/net/http2/transport.go b/vendor/golang.org/x/net/http2/transport.go index b261beb1d0b..f135b0f7518 100644 --- a/vendor/golang.org/x/net/http2/transport.go +++ b/vendor/golang.org/x/net/http2/transport.go @@ -24,6 +24,7 @@ import ( "net/http" "net/http/httptrace" "net/textproto" + "os" "sort" "strconv" "strings" @@ -51,6 +52,15 @@ const ( transportDefaultStreamMinRefresh = 4 << 10 defaultUserAgent = "Go-http-client/2.0" + + // initialMaxConcurrentStreams is a connections maxConcurrentStreams until + // it's received servers initial SETTINGS frame, which corresponds with the + // spec's minimum recommended value. + initialMaxConcurrentStreams = 100 + + // defaultMaxConcurrentStreams is a connections default maxConcurrentStreams + // if the server doesn't include one in its initial SETTINGS frame. + defaultMaxConcurrentStreams = 1000 ) // Transport is an HTTP/2 Transport. @@ -121,6 +131,17 @@ type Transport struct { // Defaults to 15s. PingTimeout time.Duration + // WriteByteTimeout is the timeout after which the connection will be + // closed no data can be written to it. The timeout begins when data is + // available to write, and is extended whenever any bytes are written. + WriteByteTimeout time.Duration + + // CountError, if non-nil, is called on HTTP/2 transport errors. + // It's intended to increment a metric for monitoring, such + // as an expvar or Prometheus metric. + // The errType consists of only ASCII word characters. + CountError func(errType string) + // t1, if non-nil, is the standard library Transport using // this transport. Its settings are used (but not its // RoundTrip method, etc). @@ -227,11 +248,12 @@ func (t *Transport) initConnPool() { // ClientConn is the state of a single HTTP/2 client connection to an // HTTP/2 server. type ClientConn struct { - t *Transport - tconn net.Conn // usually *tls.Conn, except specialized impls - tlsState *tls.ConnectionState // nil only for specialized impls - reused uint32 // whether conn is being reused; atomic - singleUse bool // whether being used for a single http.Request + t *Transport + tconn net.Conn // usually *tls.Conn, except specialized impls + tlsState *tls.ConnectionState // nil only for specialized impls + reused uint32 // whether conn is being reused; atomic + singleUse bool // whether being used for a single http.Request + getConnCalled bool // used by clientConnPool // readLoop goroutine fields: readerDone chan struct{} // closed on error @@ -244,86 +266,94 @@ type ClientConn struct { cond *sync.Cond // hold mu; broadcast on flow/closed changes flow flow // our conn-level flow control quota (cs.flow is per stream) inflow flow // peer's conn-level flow control + doNotReuse bool // whether conn is marked to not be reused for any future requests closing bool closed bool + seenSettings bool // true if we've seen a settings frame, false otherwise wantSettingsAck bool // we sent a SETTINGS frame and haven't heard back goAway *GoAwayFrame // if non-nil, the GoAwayFrame we received goAwayDebug string // goAway frame's debug data, retained as a string streams map[uint32]*clientStream // client-initiated + streamsReserved int // incr by ReserveNewRequest; decr on RoundTrip nextStreamID uint32 pendingRequests int // requests blocked and waiting to be sent because len(streams) == maxConcurrentStreams pings map[[8]byte]chan struct{} // in flight ping data to notification channel - bw *bufio.Writer br *bufio.Reader - fr *Framer lastActive time.Time lastIdle time.Time // time last idle - // Settings from peer: (also guarded by mu) + // Settings from peer: (also guarded by wmu) maxFrameSize uint32 maxConcurrentStreams uint32 peerMaxHeaderListSize uint64 initialWindowSize uint32 + // reqHeaderMu is a 1-element semaphore channel controlling access to sending new requests. + // Write to reqHeaderMu to lock it, read from it to unlock. + // Lock reqmu BEFORE mu or wmu. + reqHeaderMu chan struct{} + + // wmu is held while writing. + // Acquire BEFORE mu when holding both, to avoid blocking mu on network writes. + // Only acquire both at the same time when changing peer settings. + wmu sync.Mutex + bw *bufio.Writer + fr *Framer + werr error // first write error that has occurred hbuf bytes.Buffer // HPACK encoder writes into this henc *hpack.Encoder - - wmu sync.Mutex // held while writing; acquire AFTER mu if holding both - werr error // first write error that has occurred } // clientStream is the state for a single HTTP/2 stream. One of these // is created for each Transport.RoundTrip call. type clientStream struct { - cc *ClientConn - req *http.Request + cc *ClientConn + + // Fields of Request that we may access even after the response body is closed. + ctx context.Context + reqCancel <-chan struct{} + trace *httptrace.ClientTrace // or nil ID uint32 - resc chan resAndError bufPipe pipe // buffered pipe with the flow-controlled response payload - startedWrite bool // started request body write; guarded by cc.mu requestedGzip bool - on100 func() // optional code to run if get a 100 continue response + isHead bool + + abortOnce sync.Once + abort chan struct{} // closed to signal stream should end immediately + abortErr error // set if abort is closed + + peerClosed chan struct{} // closed when the peer sends an END_STREAM flag + donec chan struct{} // closed after the stream is in the closed state + on100 chan struct{} // buffered; written to if a 100 is received + + respHeaderRecv chan struct{} // closed when headers are received + res *http.Response // set if respHeaderRecv is closed flow flow // guarded by cc.mu inflow flow // guarded by cc.mu bytesRemain int64 // -1 means unknown; owned by transportResponseBody.Read readErr error // sticky read error; owned by transportResponseBody.Read - stopReqBody error // if non-nil, stop writing req body; guarded by cc.mu - didReset bool // whether we sent a RST_STREAM to the server; guarded by cc.mu - peerReset chan struct{} // closed on peer reset - resetErr error // populated before peerReset is closed + reqBody io.ReadCloser + reqBodyContentLength int64 // -1 means unknown + reqBodyClosed bool // body has been closed; guarded by cc.mu - done chan struct{} // closed when stream remove from cc.streams map; close calls guarded by cc.mu + // owned by writeRequest: + sentEndStream bool // sent an END_STREAM flag to the peer + sentHeaders bool // owned by clientConnReadLoop: firstByte bool // got the first response byte pastHeaders bool // got first MetaHeadersFrame (actual headers) pastTrailers bool // got optional second MetaHeadersFrame (trailers) num1xx uint8 // number of 1xx responses seen + readClosed bool // peer sent an END_STREAM flag + readAborted bool // read loop reset the stream trailer http.Header // accumulated trailers resTrailer *http.Header // client's Response.Trailer } -// awaitRequestCancel waits for the user to cancel a request or for the done -// channel to be signaled. A non-nil error is returned only if the request was -// canceled. -func awaitRequestCancel(req *http.Request, done <-chan struct{}) error { - ctx := req.Context() - if req.Cancel == nil && ctx.Done() == nil { - return nil - } - select { - case <-req.Cancel: - return errRequestCanceled - case <-ctx.Done(): - return ctx.Err() - case <-done: - return nil - } -} - var got1xxFuncForTests func(int, textproto.MIMEHeader) error // get1xxTraceFunc returns the value of request's httptrace.ClientTrace.Got1xxResponse func, @@ -335,78 +365,65 @@ func (cs *clientStream) get1xxTraceFunc() func(int, textproto.MIMEHeader) error return traceGot1xxResponseFunc(cs.trace) } -// awaitRequestCancel waits for the user to cancel a request, its context to -// expire, or for the request to be done (any way it might be removed from the -// cc.streams map: peer reset, successful completion, TCP connection breakage, -// etc). If the request is canceled, then cs will be canceled and closed. -func (cs *clientStream) awaitRequestCancel(req *http.Request) { - if err := awaitRequestCancel(req, cs.done); err != nil { - cs.cancelStream() - cs.bufPipe.CloseWithError(err) - } +func (cs *clientStream) abortStream(err error) { + cs.cc.mu.Lock() + defer cs.cc.mu.Unlock() + cs.abortStreamLocked(err) } -func (cs *clientStream) cancelStream() { - cc := cs.cc - cc.mu.Lock() - didReset := cs.didReset - cs.didReset = true - cc.mu.Unlock() - - if !didReset { - cc.writeStreamReset(cs.ID, ErrCodeCancel, nil) - cc.forgetStreamID(cs.ID) +func (cs *clientStream) abortStreamLocked(err error) { + cs.abortOnce.Do(func() { + cs.abortErr = err + close(cs.abort) + }) + if cs.reqBody != nil && !cs.reqBodyClosed { + cs.reqBody.Close() + cs.reqBodyClosed = true } -} - -// checkResetOrDone reports any error sent in a RST_STREAM frame by the -// server, or errStreamClosed if the stream is complete. -func (cs *clientStream) checkResetOrDone() error { - select { - case <-cs.peerReset: - return cs.resetErr - case <-cs.done: - return errStreamClosed - default: - return nil + // TODO(dneil): Clean up tests where cs.cc.cond is nil. + if cs.cc.cond != nil { + // Wake up writeRequestBody if it is waiting on flow control. + cs.cc.cond.Broadcast() } } -func (cs *clientStream) getStartedWrite() bool { +func (cs *clientStream) abortRequestBodyWrite() { cc := cs.cc cc.mu.Lock() defer cc.mu.Unlock() - return cs.startedWrite -} - -func (cs *clientStream) abortRequestBodyWrite(err error) { - if err == nil { - panic("nil error") - } - cc := cs.cc - cc.mu.Lock() - if cs.stopReqBody == nil { - cs.stopReqBody = err - if cs.req.Body != nil { - cs.req.Body.Close() - } + if cs.reqBody != nil && !cs.reqBodyClosed { + cs.reqBody.Close() + cs.reqBodyClosed = true cc.cond.Broadcast() } - cc.mu.Unlock() } type stickyErrWriter struct { - w io.Writer - err *error + conn net.Conn + timeout time.Duration + err *error } func (sew stickyErrWriter) Write(p []byte) (n int, err error) { if *sew.err != nil { return 0, *sew.err } - n, err = sew.w.Write(p) - *sew.err = err - return + for { + if sew.timeout != 0 { + sew.conn.SetWriteDeadline(time.Now().Add(sew.timeout)) + } + nn, err := sew.conn.Write(p[n:]) + n += nn + if n < len(p) && nn > 0 && errors.Is(err, os.ErrDeadlineExceeded) { + // Keep extending the deadline so long as we're making progress. + continue + } + if sew.timeout != 0 { + sew.conn.SetWriteDeadline(time.Time{}) + } + *sew.err = err + return n, err + } } // noCachedConnError is the concrete type of ErrNoCachedConn, which @@ -479,9 +496,9 @@ func (t *Transport) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Res } reused := !atomic.CompareAndSwapUint32(&cc.reused, 0, 1) traceGotConn(req, cc, reused) - res, gotErrAfterReqBodyWrite, err := cc.roundTrip(req) + res, err := cc.RoundTrip(req) if err != nil && retry <= 6 { - if req, err = shouldRetryRequest(req, err, gotErrAfterReqBodyWrite); err == nil { + if req, err = shouldRetryRequest(req, err); err == nil { // After the first retry, do exponential backoff with 10% jitter. if retry == 0 { continue @@ -492,7 +509,7 @@ func (t *Transport) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Res case <-time.After(time.Second * time.Duration(backoff)): continue case <-req.Context().Done(): - return nil, req.Context().Err() + err = req.Context().Err() } } } @@ -523,7 +540,7 @@ var ( // response headers. It is always called with a non-nil error. // It returns either a request to retry (either the same request, or a // modified clone), or an error if the request can't be replayed. -func shouldRetryRequest(req *http.Request, err error, afterBodyWrite bool) (*http.Request, error) { +func shouldRetryRequest(req *http.Request, err error) (*http.Request, error) { if !canRetryError(err) { return nil, err } @@ -536,7 +553,6 @@ func shouldRetryRequest(req *http.Request, err error, afterBodyWrite bool) (*htt // If the request body can be reset back to its original // state via the optional req.GetBody, do that. if req.GetBody != nil { - // TODO: consider a req.Body.Close here? or audit that all caller paths do? body, err := req.GetBody() if err != nil { return nil, err @@ -548,10 +564,8 @@ func shouldRetryRequest(req *http.Request, err error, afterBodyWrite bool) (*htt // The Request.Body can't reset back to the beginning, but we // don't seem to have started to read from it yet, so reuse - // the request directly. The "afterBodyWrite" means the - // bodyWrite process has started, which becomes true before - // the first Read. - if !afterBodyWrite { + // the request directly. + if err == errClientConnUnusable { return req, nil } @@ -563,6 +577,10 @@ func canRetryError(err error) bool { return true } if se, ok := err.(StreamError); ok { + if se.Code == ErrCodeProtocol && se.Cause == errFromPeer { + // See golang/go#47635, golang/go#42777 + return true + } return se.Code == ErrCodeRefusedStream } return false @@ -637,14 +655,15 @@ func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, erro tconn: c, readerDone: make(chan struct{}), nextStreamID: 1, - maxFrameSize: 16 << 10, // spec default - initialWindowSize: 65535, // spec default - maxConcurrentStreams: 1000, // "infinite", per spec. 1000 seems good enough. - peerMaxHeaderListSize: 0xffffffffffffffff, // "infinite", per spec. Use 2^64-1 instead. + maxFrameSize: 16 << 10, // spec default + initialWindowSize: 65535, // spec default + maxConcurrentStreams: initialMaxConcurrentStreams, // "infinite", per spec. Use a smaller value until we have received server settings. + peerMaxHeaderListSize: 0xffffffffffffffff, // "infinite", per spec. Use 2^64-1 instead. streams: make(map[uint32]*clientStream), singleUse: singleUse, wantSettingsAck: true, pings: make(map[[8]byte]chan struct{}), + reqHeaderMu: make(chan struct{}, 1), } if d := t.idleConnTimeout(); d != 0 { cc.idleTimeout = d @@ -659,9 +678,16 @@ func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, erro // TODO: adjust this writer size to account for frame size + // MTU + crypto/tls record padding. - cc.bw = bufio.NewWriter(stickyErrWriter{c, &cc.werr}) + cc.bw = bufio.NewWriter(stickyErrWriter{ + conn: c, + timeout: t.WriteByteTimeout, + err: &cc.werr, + }) cc.br = bufio.NewReader(c) cc.fr = NewFramer(cc.bw, cc.br) + if t.CountError != nil { + cc.fr.countError = t.CountError + } cc.fr.ReadMetaHeaders = hpack.NewDecoder(initialHeaderTableSize, nil) cc.fr.MaxHeaderListSize = t.maxHeaderListSize() @@ -714,6 +740,13 @@ func (cc *ClientConn) healthCheck() { } } +// SetDoNotReuse marks cc as not reusable for future HTTP requests. +func (cc *ClientConn) SetDoNotReuse() { + cc.mu.Lock() + defer cc.mu.Unlock() + cc.doNotReuse = true +} + func (cc *ClientConn) setGoAway(f *GoAwayFrame) { cc.mu.Lock() defer cc.mu.Unlock() @@ -731,27 +764,94 @@ func (cc *ClientConn) setGoAway(f *GoAwayFrame) { last := f.LastStreamID for streamID, cs := range cc.streams { if streamID > last { - select { - case cs.resc <- resAndError{err: errClientConnGotGoAway}: - default: - } + cs.abortStreamLocked(errClientConnGotGoAway) } } } // CanTakeNewRequest reports whether the connection can take a new request, // meaning it has not been closed or received or sent a GOAWAY. +// +// If the caller is going to immediately make a new request on this +// connection, use ReserveNewRequest instead. func (cc *ClientConn) CanTakeNewRequest() bool { cc.mu.Lock() defer cc.mu.Unlock() return cc.canTakeNewRequestLocked() } +// ReserveNewRequest is like CanTakeNewRequest but also reserves a +// concurrent stream in cc. The reservation is decremented on the +// next call to RoundTrip. +func (cc *ClientConn) ReserveNewRequest() bool { + cc.mu.Lock() + defer cc.mu.Unlock() + if st := cc.idleStateLocked(); !st.canTakeNewRequest { + return false + } + cc.streamsReserved++ + return true +} + +// ClientConnState describes the state of a ClientConn. +type ClientConnState struct { + // Closed is whether the connection is closed. + Closed bool + + // Closing is whether the connection is in the process of + // closing. It may be closing due to shutdown, being a + // single-use connection, being marked as DoNotReuse, or + // having received a GOAWAY frame. + Closing bool + + // StreamsActive is how many streams are active. + StreamsActive int + + // StreamsReserved is how many streams have been reserved via + // ClientConn.ReserveNewRequest. + StreamsReserved int + + // StreamsPending is how many requests have been sent in excess + // of the peer's advertised MaxConcurrentStreams setting and + // are waiting for other streams to complete. + StreamsPending int + + // MaxConcurrentStreams is how many concurrent streams the + // peer advertised as acceptable. Zero means no SETTINGS + // frame has been received yet. + MaxConcurrentStreams uint32 + + // LastIdle, if non-zero, is when the connection last + // transitioned to idle state. + LastIdle time.Time +} + +// State returns a snapshot of cc's state. +func (cc *ClientConn) State() ClientConnState { + cc.wmu.Lock() + maxConcurrent := cc.maxConcurrentStreams + if !cc.seenSettings { + maxConcurrent = 0 + } + cc.wmu.Unlock() + + cc.mu.Lock() + defer cc.mu.Unlock() + return ClientConnState{ + Closed: cc.closed, + Closing: cc.closing || cc.singleUse || cc.doNotReuse || cc.goAway != nil, + StreamsActive: len(cc.streams), + StreamsReserved: cc.streamsReserved, + StreamsPending: cc.pendingRequests, + LastIdle: cc.lastIdle, + MaxConcurrentStreams: maxConcurrent, + } +} + // clientConnIdleState describes the suitability of a client // connection to initiate a new RoundTrip request. type clientConnIdleState struct { canTakeNewRequest bool - freshConn bool // whether it's unused by any previous request } func (cc *ClientConn) idleState() clientConnIdleState { @@ -772,13 +872,13 @@ func (cc *ClientConn) idleStateLocked() (st clientConnIdleState) { // writing it. maxConcurrentOkay = true } else { - maxConcurrentOkay = int64(len(cc.streams)+1) < int64(cc.maxConcurrentStreams) + maxConcurrentOkay = int64(len(cc.streams)+cc.streamsReserved+1) <= int64(cc.maxConcurrentStreams) } st.canTakeNewRequest = cc.goAway == nil && !cc.closed && !cc.closing && maxConcurrentOkay && + !cc.doNotReuse && int64(cc.nextStreamID)+2*int64(cc.pendingRequests) < math.MaxInt32 && !cc.tooIdleLocked() - st.freshConn = cc.nextStreamID == 1 && st.canTakeNewRequest return } @@ -809,7 +909,7 @@ func (cc *ClientConn) onIdleTimeout() { func (cc *ClientConn) closeIfIdle() { cc.mu.Lock() - if len(cc.streams) > 0 { + if len(cc.streams) > 0 || cc.streamsReserved > 0 { cc.mu.Unlock() return } @@ -824,9 +924,15 @@ func (cc *ClientConn) closeIfIdle() { cc.tconn.Close() } +func (cc *ClientConn) isDoNotReuseAndIdle() bool { + cc.mu.Lock() + defer cc.mu.Unlock() + return cc.doNotReuse && len(cc.streams) == 0 +} + var shutdownEnterWaitStateHook = func() {} -// Shutdown gracefully close the client connection, waiting for running streams to complete. +// Shutdown gracefully closes the client connection, waiting for running streams to complete. func (cc *ClientConn) Shutdown(ctx context.Context) error { if err := cc.sendGoAway(); err != nil { return err @@ -865,15 +971,18 @@ func (cc *ClientConn) Shutdown(ctx context.Context) error { func (cc *ClientConn) sendGoAway() error { cc.mu.Lock() - defer cc.mu.Unlock() - cc.wmu.Lock() - defer cc.wmu.Unlock() - if cc.closing { + closing := cc.closing + cc.closing = true + maxStreamID := cc.nextStreamID + cc.mu.Unlock() + if closing { // GOAWAY sent already return nil } + + cc.wmu.Lock() + defer cc.wmu.Unlock() // Send a graceful shutdown frame to server - maxStreamID := cc.nextStreamID if err := cc.fr.WriteGoAway(maxStreamID, ErrCodeNo, nil); err != nil { return err } @@ -881,7 +990,6 @@ func (cc *ClientConn) sendGoAway() error { return err } // Prevent new requests - cc.closing = true return nil } @@ -889,17 +997,12 @@ func (cc *ClientConn) sendGoAway() error { // err is sent to streams. func (cc *ClientConn) closeForError(err error) error { cc.mu.Lock() + cc.closed = true + for _, cs := range cc.streams { + cs.abortStreamLocked(err) + } defer cc.cond.Broadcast() defer cc.mu.Unlock() - for id, cs := range cc.streams { - select { - case cs.resc <- resAndError{err: err}: - default: - } - cs.bufPipe.CloseWithError(err) - delete(cc.streams, id) - } - cc.closed = true return cc.tconn.Close() } @@ -914,6 +1017,9 @@ func (cc *ClientConn) Close() error { // closes the client connection immediately. In-flight requests are interrupted. func (cc *ClientConn) closeForLostPing() error { err := errors.New("http2: client connection lost") + if f := cc.t.CountError; f != nil { + f("conn_close_lost_ping") + } return cc.closeForError(err) } @@ -978,41 +1084,158 @@ func actualContentLength(req *http.Request) int64 { return -1 } +func (cc *ClientConn) decrStreamReservations() { + cc.mu.Lock() + defer cc.mu.Unlock() + cc.decrStreamReservationsLocked() +} + +func (cc *ClientConn) decrStreamReservationsLocked() { + if cc.streamsReserved > 0 { + cc.streamsReserved-- + } +} + func (cc *ClientConn) RoundTrip(req *http.Request) (*http.Response, error) { - resp, _, err := cc.roundTrip(req) - return resp, err + ctx := req.Context() + cs := &clientStream{ + cc: cc, + ctx: ctx, + reqCancel: req.Cancel, + isHead: req.Method == "HEAD", + reqBody: req.Body, + reqBodyContentLength: actualContentLength(req), + trace: httptrace.ContextClientTrace(ctx), + peerClosed: make(chan struct{}), + abort: make(chan struct{}), + respHeaderRecv: make(chan struct{}), + donec: make(chan struct{}), + } + go cs.doRequest(req) + + waitDone := func() error { + select { + case <-cs.donec: + return nil + case <-ctx.Done(): + return ctx.Err() + case <-cs.reqCancel: + return errRequestCanceled + } + } + + handleResponseHeaders := func() (*http.Response, error) { + res := cs.res + if res.StatusCode > 299 { + // On error or status code 3xx, 4xx, 5xx, etc abort any + // ongoing write, assuming that the server doesn't care + // about our request body. If the server replied with 1xx or + // 2xx, however, then assume the server DOES potentially + // want our body (e.g. full-duplex streaming: + // golang.org/issue/13444). If it turns out the server + // doesn't, they'll RST_STREAM us soon enough. This is a + // heuristic to avoid adding knobs to Transport. Hopefully + // we can keep it. + cs.abortRequestBodyWrite() + } + res.Request = req + res.TLS = cc.tlsState + if res.Body == noBody && actualContentLength(req) == 0 { + // If there isn't a request or response body still being + // written, then wait for the stream to be closed before + // RoundTrip returns. + if err := waitDone(); err != nil { + return nil, err + } + } + return res, nil + } + + for { + select { + case <-cs.respHeaderRecv: + return handleResponseHeaders() + case <-cs.abort: + select { + case <-cs.respHeaderRecv: + // If both cs.respHeaderRecv and cs.abort are signaling, + // pick respHeaderRecv. The server probably wrote the + // response and immediately reset the stream. + // golang.org/issue/49645 + return handleResponseHeaders() + default: + waitDone() + return nil, cs.abortErr + } + case <-ctx.Done(): + err := ctx.Err() + cs.abortStream(err) + return nil, err + case <-cs.reqCancel: + cs.abortStream(errRequestCanceled) + return nil, errRequestCanceled + } + } } -func (cc *ClientConn) roundTrip(req *http.Request) (res *http.Response, gotErrAfterReqBodyWrite bool, err error) { +// doRequest runs for the duration of the request lifetime. +// +// It sends the request and performs post-request cleanup (closing Request.Body, etc.). +func (cs *clientStream) doRequest(req *http.Request) { + err := cs.writeRequest(req) + cs.cleanupWriteRequest(err) +} + +// writeRequest sends a request. +// +// It returns nil after the request is written, the response read, +// and the request stream is half-closed by the peer. +// +// It returns non-nil if the request ends otherwise. +// If the returned error is StreamError, the error Code may be used in resetting the stream. +func (cs *clientStream) writeRequest(req *http.Request) (err error) { + cc := cs.cc + ctx := cs.ctx + if err := checkConnHeaders(req); err != nil { - return nil, false, err - } - if cc.idleTimer != nil { - cc.idleTimer.Stop() + return err } - trailers, err := commaSeparatedTrailers(req) - if err != nil { - return nil, false, err + // Acquire the new-request lock by writing to reqHeaderMu. + // This lock guards the critical section covering allocating a new stream ID + // (requires mu) and creating the stream (requires wmu). + if cc.reqHeaderMu == nil { + panic("RoundTrip on uninitialized ClientConn") // for tests + } + select { + case cc.reqHeaderMu <- struct{}{}: + case <-cs.reqCancel: + return errRequestCanceled + case <-ctx.Done(): + return ctx.Err() } - hasTrailers := trailers != "" cc.mu.Lock() - if err := cc.awaitOpenSlotForRequest(req); err != nil { + if cc.idleTimer != nil { + cc.idleTimer.Stop() + } + cc.decrStreamReservationsLocked() + if err := cc.awaitOpenSlotForStreamLocked(cs); err != nil { cc.mu.Unlock() - return nil, false, err + <-cc.reqHeaderMu + return err } - - body := req.Body - contentLen := actualContentLength(req) - hasBody := contentLen != 0 + cc.addStreamLocked(cs) // assigns stream ID + if isConnectionCloseRequest(req) { + cc.doNotReuse = true + } + cc.mu.Unlock() // TODO(bradfitz): this is a copy of the logic in net/http. Unify somewhere? - var requestedGzip bool if !cc.t.disableCompression() && req.Header.Get("Accept-Encoding") == "" && req.Header.Get("Range") == "" && - req.Method != "HEAD" { + !cs.isHead { // Request gzip only, not deflate. Deflate is ambiguous and // not as universally supported anyway. // See: https://zlib.net/zlib_faq.html#faq39 @@ -1025,183 +1248,224 @@ func (cc *ClientConn) roundTrip(req *http.Request) (res *http.Response, gotErrAf // We don't request gzip if the request is for a range, since // auto-decoding a portion of a gzipped document will just fail // anyway. See https://golang.org/issue/8923 - requestedGzip = true + cs.requestedGzip = true } - // we send: HEADERS{1}, CONTINUATION{0,} + DATA{0,} (DATA is - // sent by writeRequestBody below, along with any Trailers, - // again in form HEADERS{1}, CONTINUATION{0,}) - hdrs, err := cc.encodeHeaders(req, requestedGzip, trailers, contentLen) + continueTimeout := cc.t.expectContinueTimeout() + if continueTimeout != 0 { + if !httpguts.HeaderValuesContainsToken(req.Header["Expect"], "100-continue") { + continueTimeout = 0 + } else { + cs.on100 = make(chan struct{}, 1) + } + } + + // Past this point (where we send request headers), it is possible for + // RoundTrip to return successfully. Since the RoundTrip contract permits + // the caller to "mutate or reuse" the Request after closing the Response's Body, + // we must take care when referencing the Request from here on. + err = cs.encodeAndWriteHeaders(req) + <-cc.reqHeaderMu if err != nil { - cc.mu.Unlock() - return nil, false, err + return err } - cs := cc.newStream() - cs.req = req - cs.trace = httptrace.ContextClientTrace(req.Context()) - cs.requestedGzip = requestedGzip - bodyWriter := cc.t.getBodyWriterState(cs, body) - cs.on100 = bodyWriter.on100 + hasBody := cs.reqBodyContentLength != 0 + if !hasBody { + cs.sentEndStream = true + } else { + if continueTimeout != 0 { + traceWait100Continue(cs.trace) + timer := time.NewTimer(continueTimeout) + select { + case <-timer.C: + err = nil + case <-cs.on100: + err = nil + case <-cs.abort: + err = cs.abortErr + case <-ctx.Done(): + err = ctx.Err() + case <-cs.reqCancel: + err = errRequestCanceled + } + timer.Stop() + if err != nil { + traceWroteRequest(cs.trace, err) + return err + } + } - defer func() { - cc.wmu.Lock() - werr := cc.werr - cc.wmu.Unlock() - if werr != nil { - cc.Close() + if err = cs.writeRequestBody(req); err != nil { + if err != errStopReqBodyWrite { + traceWroteRequest(cs.trace, err) + return err + } + } else { + cs.sentEndStream = true } - }() + } + + traceWroteRequest(cs.trace, err) + + var respHeaderTimer <-chan time.Time + var respHeaderRecv chan struct{} + if d := cc.responseHeaderTimeout(); d != 0 { + timer := time.NewTimer(d) + defer timer.Stop() + respHeaderTimer = timer.C + respHeaderRecv = cs.respHeaderRecv + } + // Wait until the peer half-closes its end of the stream, + // or until the request is aborted (via context, error, or otherwise), + // whichever comes first. + for { + select { + case <-cs.peerClosed: + return nil + case <-respHeaderTimer: + return errTimeout + case <-respHeaderRecv: + respHeaderRecv = nil + respHeaderTimer = nil // keep waiting for END_STREAM + case <-cs.abort: + return cs.abortErr + case <-ctx.Done(): + return ctx.Err() + case <-cs.reqCancel: + return errRequestCanceled + } + } +} + +func (cs *clientStream) encodeAndWriteHeaders(req *http.Request) error { + cc := cs.cc + ctx := cs.ctx cc.wmu.Lock() + defer cc.wmu.Unlock() + + // If the request was canceled while waiting for cc.mu, just quit. + select { + case <-cs.abort: + return cs.abortErr + case <-ctx.Done(): + return ctx.Err() + case <-cs.reqCancel: + return errRequestCanceled + default: + } + + // Encode headers. + // + // we send: HEADERS{1}, CONTINUATION{0,} + DATA{0,} (DATA is + // sent by writeRequestBody below, along with any Trailers, + // again in form HEADERS{1}, CONTINUATION{0,}) + trailers, err := commaSeparatedTrailers(req) + if err != nil { + return err + } + hasTrailers := trailers != "" + contentLen := actualContentLength(req) + hasBody := contentLen != 0 + hdrs, err := cc.encodeHeaders(req, cs.requestedGzip, trailers, contentLen) + if err != nil { + return err + } + + // Write the request. endStream := !hasBody && !hasTrailers - werr := cc.writeHeaders(cs.ID, endStream, int(cc.maxFrameSize), hdrs) - cc.wmu.Unlock() + cs.sentHeaders = true + err = cc.writeHeaders(cs.ID, endStream, int(cc.maxFrameSize), hdrs) traceWroteHeaders(cs.trace) - cc.mu.Unlock() + return err +} - if werr != nil { - if hasBody { - req.Body.Close() // per RoundTripper contract - bodyWriter.cancel() - } - cc.forgetStreamID(cs.ID) - // Don't bother sending a RST_STREAM (our write already failed; - // no need to keep writing) - traceWroteRequest(cs.trace, werr) - return nil, false, werr - } +// cleanupWriteRequest performs post-request tasks. +// +// If err (the result of writeRequest) is non-nil and the stream is not closed, +// cleanupWriteRequest will send a reset to the peer. +func (cs *clientStream) cleanupWriteRequest(err error) { + cc := cs.cc - var respHeaderTimer <-chan time.Time - if hasBody { - bodyWriter.scheduleBodyWrite() - } else { - traceWroteRequest(cs.trace, nil) - if d := cc.responseHeaderTimeout(); d != 0 { - timer := time.NewTimer(d) - defer timer.Stop() - respHeaderTimer = timer.C - } + if cs.ID == 0 { + // We were canceled before creating the stream, so return our reservation. + cc.decrStreamReservations() } - readLoopResCh := cs.resc - bodyWritten := false - ctx := req.Context() + // TODO: write h12Compare test showing whether + // Request.Body is closed by the Transport, + // and in multiple cases: server replies <=299 and >299 + // while still writing request body + cc.mu.Lock() + bodyClosed := cs.reqBodyClosed + cs.reqBodyClosed = true + cc.mu.Unlock() + if !bodyClosed && cs.reqBody != nil { + cs.reqBody.Close() + } - handleReadLoopResponse := func(re resAndError) (*http.Response, bool, error) { - res := re.res - if re.err != nil || res.StatusCode > 299 { - // On error or status code 3xx, 4xx, 5xx, etc abort any - // ongoing write, assuming that the server doesn't care - // about our request body. If the server replied with 1xx or - // 2xx, however, then assume the server DOES potentially - // want our body (e.g. full-duplex streaming: - // golang.org/issue/13444). If it turns out the server - // doesn't, they'll RST_STREAM us soon enough. This is a - // heuristic to avoid adding knobs to Transport. Hopefully - // we can keep it. - bodyWriter.cancel() - cs.abortRequestBodyWrite(errStopReqBodyWrite) - if hasBody && !bodyWritten { - <-bodyWriter.resc + if err != nil && cs.sentEndStream { + // If the connection is closed immediately after the response is read, + // we may be aborted before finishing up here. If the stream was closed + // cleanly on both sides, there is no error. + select { + case <-cs.peerClosed: + err = nil + default: + } + } + if err != nil { + cs.abortStream(err) // possibly redundant, but harmless + if cs.sentHeaders { + if se, ok := err.(StreamError); ok { + if se.Cause != errFromPeer { + cc.writeStreamReset(cs.ID, se.Code, err) + } + } else { + cc.writeStreamReset(cs.ID, ErrCodeCancel, err) } } - if re.err != nil { - cc.forgetStreamID(cs.ID) - return nil, cs.getStartedWrite(), re.err + cs.bufPipe.CloseWithError(err) // no-op if already closed + } else { + if cs.sentHeaders && !cs.sentEndStream { + cc.writeStreamReset(cs.ID, ErrCodeNo, nil) } - res.Request = req - res.TLS = cc.tlsState - return res, false, nil + cs.bufPipe.CloseWithError(errRequestCanceled) } - - handleError := func(err error) (*http.Response, bool, error) { - if !hasBody || bodyWritten { - cc.writeStreamReset(cs.ID, ErrCodeCancel, nil) - } else { - bodyWriter.cancel() - cs.abortRequestBodyWrite(errStopReqBodyWriteAndCancel) - <-bodyWriter.resc - } + if cs.ID != 0 { cc.forgetStreamID(cs.ID) - return nil, cs.getStartedWrite(), err } - for { - select { - case re := <-readLoopResCh: - return handleReadLoopResponse(re) - case <-respHeaderTimer: - return handleError(errTimeout) - case <-ctx.Done(): - return handleError(ctx.Err()) - case <-req.Cancel: - return handleError(errRequestCanceled) - case <-cs.peerReset: - // processResetStream already removed the - // stream from the streams map; no need for - // forgetStreamID. - return nil, cs.getStartedWrite(), cs.resetErr - case err := <-bodyWriter.resc: - bodyWritten = true - // Prefer the read loop's response, if available. Issue 16102. - select { - case re := <-readLoopResCh: - return handleReadLoopResponse(re) - default: - } - if err != nil { - cc.forgetStreamID(cs.ID) - return nil, cs.getStartedWrite(), err - } - if d := cc.responseHeaderTimeout(); d != 0 { - timer := time.NewTimer(d) - defer timer.Stop() - respHeaderTimer = timer.C - } - } + cc.wmu.Lock() + werr := cc.werr + cc.wmu.Unlock() + if werr != nil { + cc.Close() } + + close(cs.donec) } -// awaitOpenSlotForRequest waits until len(streams) < maxConcurrentStreams. +// awaitOpenSlotForStream waits until len(streams) < maxConcurrentStreams. // Must hold cc.mu. -func (cc *ClientConn) awaitOpenSlotForRequest(req *http.Request) error { - var waitingForConn chan struct{} - var waitingForConnErr error // guarded by cc.mu +func (cc *ClientConn) awaitOpenSlotForStreamLocked(cs *clientStream) error { for { cc.lastActive = time.Now() if cc.closed || !cc.canTakeNewRequestLocked() { - if waitingForConn != nil { - close(waitingForConn) - } return errClientConnUnusable } cc.lastIdle = time.Time{} - if int64(len(cc.streams))+1 <= int64(cc.maxConcurrentStreams) { - if waitingForConn != nil { - close(waitingForConn) - } + if int64(len(cc.streams)) < int64(cc.maxConcurrentStreams) { return nil } - // Unfortunately, we cannot wait on a condition variable and channel at - // the same time, so instead, we spin up a goroutine to check if the - // request is canceled while we wait for a slot to open in the connection. - if waitingForConn == nil { - waitingForConn = make(chan struct{}) - go func() { - if err := awaitRequestCancel(req, waitingForConn); err != nil { - cc.mu.Lock() - waitingForConnErr = err - cc.cond.Broadcast() - cc.mu.Unlock() - } - }() - } cc.pendingRequests++ cc.cond.Wait() cc.pendingRequests-- - if waitingForConnErr != nil { - return waitingForConnErr + select { + case <-cs.abort: + return cs.abortErr + default: } } } @@ -1228,10 +1492,6 @@ func (cc *ClientConn) writeHeaders(streamID uint32, endStream bool, maxFrameSize cc.fr.WriteContinuation(streamID, endHeaders, chunk) } } - // TODO(bradfitz): this Flush could potentially block (as - // could the WriteHeaders call(s) above), which means they - // wouldn't respond to Request.Cancel being readable. That's - // rare, but this should probably be in a goroutine. cc.bw.Flush() return cc.werr } @@ -1258,7 +1518,7 @@ func (cs *clientStream) frameScratchBufferLen(maxFrameSize int) int { if n > max { n = max } - if cl := actualContentLength(cs.req); cl != -1 && cl+1 < n { + if cl := cs.reqBodyContentLength; cl != -1 && cl+1 < n { // Add an extra byte past the declared content-length to // give the caller's Request.Body io.Reader a chance to // give us more bytes than they declared, so we can catch it @@ -1273,31 +1533,13 @@ func (cs *clientStream) frameScratchBufferLen(maxFrameSize int) int { var bufPool sync.Pool // of *[]byte -func (cs *clientStream) writeRequestBody(body io.Reader, bodyCloser io.Closer) (err error) { +func (cs *clientStream) writeRequestBody(req *http.Request) (err error) { cc := cs.cc + body := cs.reqBody sentEnd := false // whether we sent the final DATA frame w/ END_STREAM - defer func() { - traceWroteRequest(cs.trace, err) - // TODO: write h12Compare test showing whether - // Request.Body is closed by the Transport, - // and in multiple cases: server replies <=299 and >299 - // while still writing request body - var cerr error - cc.mu.Lock() - if cs.stopReqBody == nil { - cs.stopReqBody = errStopReqBodyWrite - cerr = bodyCloser.Close() - } - cc.mu.Unlock() - if err == nil { - err = cerr - } - }() - - req := cs.req hasTrailers := req.Trailer != nil - remainLen := actualContentLength(req) + remainLen := cs.reqBodyContentLength hasContentLen := remainLen != -1 cc.mu.Lock() @@ -1335,29 +1577,29 @@ func (cs *clientStream) writeRequestBody(body io.Reader, bodyCloser io.Closer) ( } if remainLen < 0 { err = errReqBodyTooLong - cc.writeStreamReset(cs.ID, ErrCodeCancel, err) return err } } - if err == io.EOF { - sawEOF = true - err = nil - } else if err != nil { - cc.writeStreamReset(cs.ID, ErrCodeCancel, err) - return err + if err != nil { + cc.mu.Lock() + bodyClosed := cs.reqBodyClosed + cc.mu.Unlock() + switch { + case bodyClosed: + return errStopReqBodyWrite + case err == io.EOF: + sawEOF = true + err = nil + default: + return err + } } remain := buf[:n] for len(remain) > 0 && err == nil { var allowed int32 allowed, err = cs.awaitFlowControl(len(remain)) - switch { - case err == errStopReqBodyWrite: - return err - case err == errStopReqBodyWriteAndCancel: - cc.writeStreamReset(cs.ID, ErrCodeCancel, nil) - return err - case err != nil: + if err != nil { return err } cc.wmu.Lock() @@ -1388,21 +1630,27 @@ func (cs *clientStream) writeRequestBody(body io.Reader, bodyCloser io.Closer) ( return nil } + // Since the RoundTrip contract permits the caller to "mutate or reuse" + // a request after the Response's Body is closed, verify that this hasn't + // happened before accessing the trailers. + cc.mu.Lock() + trailer := req.Trailer + err = cs.abortErr + cc.mu.Unlock() + if err != nil { + return err + } + + cc.wmu.Lock() + defer cc.wmu.Unlock() var trls []byte - if hasTrailers { - cc.mu.Lock() - trls, err = cc.encodeTrailers(req) - cc.mu.Unlock() + if len(trailer) > 0 { + trls, err = cc.encodeTrailers(trailer) if err != nil { - cc.writeStreamReset(cs.ID, ErrCodeInternal, err) - cc.forgetStreamID(cs.ID) return err } } - cc.wmu.Lock() - defer cc.wmu.Unlock() - // Two ways to send END_STREAM: either with trailers, or // with an empty DATA frame. if len(trls) > 0 { @@ -1422,17 +1670,24 @@ func (cs *clientStream) writeRequestBody(body io.Reader, bodyCloser io.Closer) ( // if the stream is dead. func (cs *clientStream) awaitFlowControl(maxBytes int) (taken int32, err error) { cc := cs.cc + ctx := cs.ctx cc.mu.Lock() defer cc.mu.Unlock() for { if cc.closed { return 0, errClientConnClosed } - if cs.stopReqBody != nil { - return 0, cs.stopReqBody + if cs.reqBodyClosed { + return 0, errStopReqBodyWrite } - if err := cs.checkResetOrDone(); err != nil { - return 0, err + select { + case <-cs.abort: + return 0, cs.abortErr + case <-ctx.Done(): + return 0, ctx.Err() + case <-cs.reqCancel: + return 0, errRequestCanceled + default: } if a := cs.flow.available(); a > 0 { take := a @@ -1450,9 +1705,14 @@ func (cs *clientStream) awaitFlowControl(maxBytes int) (taken int32, err error) } } -// requires cc.mu be held. +var errNilRequestURL = errors.New("http2: Request.URI is nil") + +// requires cc.wmu be held. func (cc *ClientConn) encodeHeaders(req *http.Request, addGzipHeader bool, trailers string, contentLength int64) ([]byte, error) { cc.hbuf.Reset() + if req.URL == nil { + return nil, errNilRequestURL + } host := req.Host if host == "" { @@ -1638,12 +1898,12 @@ func shouldSendReqContentLength(method string, contentLength int64) bool { } } -// requires cc.mu be held. -func (cc *ClientConn) encodeTrailers(req *http.Request) ([]byte, error) { +// requires cc.wmu be held. +func (cc *ClientConn) encodeTrailers(trailer http.Header) ([]byte, error) { cc.hbuf.Reset() hlSize := uint64(0) - for k, vv := range req.Trailer { + for k, vv := range trailer { for _, v := range vv { hf := hpack.HeaderField{Name: k, Value: v} hlSize += uint64(hf.Size()) @@ -1653,7 +1913,7 @@ func (cc *ClientConn) encodeTrailers(req *http.Request) ([]byte, error) { return nil, errRequestHeaderListSize } - for k, vv := range req.Trailer { + for k, vv := range trailer { lowKey, ascii := asciiToLower(k) if !ascii { // Skip writing invalid headers. Per RFC 7540, Section 8.1.2, header @@ -1683,51 +1943,51 @@ type resAndError struct { } // requires cc.mu be held. -func (cc *ClientConn) newStream() *clientStream { - cs := &clientStream{ - cc: cc, - ID: cc.nextStreamID, - resc: make(chan resAndError, 1), - peerReset: make(chan struct{}), - done: make(chan struct{}), - } +func (cc *ClientConn) addStreamLocked(cs *clientStream) { cs.flow.add(int32(cc.initialWindowSize)) cs.flow.setConnFlow(&cc.flow) cs.inflow.add(transportDefaultStreamFlow) cs.inflow.setConnFlow(&cc.inflow) + cs.ID = cc.nextStreamID cc.nextStreamID += 2 cc.streams[cs.ID] = cs - return cs + if cs.ID == 0 { + panic("assigned stream ID 0") + } } func (cc *ClientConn) forgetStreamID(id uint32) { - cc.streamByID(id, true) -} - -func (cc *ClientConn) streamByID(id uint32, andRemove bool) *clientStream { cc.mu.Lock() - defer cc.mu.Unlock() - cs := cc.streams[id] - if andRemove && cs != nil && !cc.closed { - cc.lastActive = time.Now() - delete(cc.streams, id) - if len(cc.streams) == 0 && cc.idleTimer != nil { - cc.idleTimer.Reset(cc.idleTimeout) - cc.lastIdle = time.Now() - } - close(cs.done) - // Wake up checkResetOrDone via clientStream.awaitFlowControl and - // wake up RoundTrip if there is a pending request. - cc.cond.Broadcast() + slen := len(cc.streams) + delete(cc.streams, id) + if len(cc.streams) != slen-1 { + panic("forgetting unknown stream id") + } + cc.lastActive = time.Now() + if len(cc.streams) == 0 && cc.idleTimer != nil { + cc.idleTimer.Reset(cc.idleTimeout) + cc.lastIdle = time.Now() + } + // Wake up writeRequestBody via clientStream.awaitFlowControl and + // wake up RoundTrip if there is a pending request. + cc.cond.Broadcast() + + closeOnIdle := cc.singleUse || cc.doNotReuse || cc.t.disableKeepAlives() + if closeOnIdle && cc.streamsReserved == 0 && len(cc.streams) == 0 { + if VerboseLogs { + cc.vlogf("http2: Transport closing idle conn %p (forSingleUse=%v, maxStream=%v)", cc, cc.singleUse, cc.nextStreamID-2) + } + cc.closed = true + defer cc.tconn.Close() } - return cs + + cc.mu.Unlock() } // clientConnReadLoop is the state owned by the clientConn's frame-reading readLoop. type clientConnReadLoop struct { - _ incomparable - cc *ClientConn - closeWhenIdle bool + _ incomparable + cc *ClientConn } // readLoop runs in its own goroutine and reads and dispatches frames. @@ -1787,23 +2047,49 @@ func (rl *clientConnReadLoop) cleanup() { } else if err == io.EOF { err = io.ErrUnexpectedEOF } + cc.closed = true for _, cs := range cc.streams { - cs.bufPipe.CloseWithError(err) // no-op if already closed select { - case cs.resc <- resAndError{err: err}: + case <-cs.peerClosed: + // The server closed the stream before closing the conn, + // so no need to interrupt it. default: + cs.abortStreamLocked(err) } - close(cs.done) } - cc.closed = true cc.cond.Broadcast() cc.mu.Unlock() } +// countReadFrameError calls Transport.CountError with a string +// representing err. +func (cc *ClientConn) countReadFrameError(err error) { + f := cc.t.CountError + if f == nil || err == nil { + return + } + if ce, ok := err.(ConnectionError); ok { + errCode := ErrCode(ce) + f(fmt.Sprintf("read_frame_conn_error_%s", errCode.stringToken())) + return + } + if errors.Is(err, io.EOF) { + f("read_frame_eof") + return + } + if errors.Is(err, io.ErrUnexpectedEOF) { + f("read_frame_unexpected_eof") + return + } + if errors.Is(err, ErrFrameTooLarge) { + f("read_frame_too_large") + return + } + f("read_frame_other") +} + func (rl *clientConnReadLoop) run() error { cc := rl.cc - rl.closeWhenIdle = cc.t.disableKeepAlives() || cc.singleUse - gotReply := false // ever saw a HEADERS reply gotSettings := false readIdleTimeout := cc.t.ReadIdleTimeout var t *time.Timer @@ -1820,9 +2106,7 @@ func (rl *clientConnReadLoop) run() error { cc.vlogf("http2: Transport readFrame error on conn %p: (%T) %v", cc, err, err) } if se, ok := err.(StreamError); ok { - if cs := cc.streamByID(se.StreamID, false); cs != nil { - cs.cc.writeStreamReset(cs.ID, se.Code, err) - cs.cc.forgetStreamID(cs.ID) + if cs := rl.streamByID(se.StreamID); cs != nil { if se.Cause == nil { se.Cause = cc.fr.errDetail } @@ -1830,6 +2114,7 @@ func (rl *clientConnReadLoop) run() error { } continue } else if err != nil { + cc.countReadFrameError(err) return err } if VerboseLogs { @@ -1842,22 +2127,16 @@ func (rl *clientConnReadLoop) run() error { } gotSettings = true } - maybeIdle := false // whether frame might transition us to idle switch f := f.(type) { case *MetaHeadersFrame: err = rl.processHeaders(f) - maybeIdle = true - gotReply = true case *DataFrame: err = rl.processData(f) - maybeIdle = true case *GoAwayFrame: err = rl.processGoAway(f) - maybeIdle = true case *RSTStreamFrame: err = rl.processResetStream(f) - maybeIdle = true case *SettingsFrame: err = rl.processSettings(f) case *PushPromiseFrame: @@ -1875,38 +2154,24 @@ func (rl *clientConnReadLoop) run() error { } return err } - if rl.closeWhenIdle && gotReply && maybeIdle { - cc.closeIfIdle() - } } } func (rl *clientConnReadLoop) processHeaders(f *MetaHeadersFrame) error { - cc := rl.cc - cs := cc.streamByID(f.StreamID, false) + cs := rl.streamByID(f.StreamID) if cs == nil { // We'd get here if we canceled a request while the // server had its response still in flight. So if this // was just something we canceled, ignore it. return nil } - if f.StreamEnded() { - // Issue 20521: If the stream has ended, streamByID() causes - // clientStream.done to be closed, which causes the request's bodyWriter - // to be closed with an errStreamClosed, which may be received by - // clientConn.RoundTrip before the result of processing these headers. - // Deferring stream closure allows the header processing to occur first. - // clientConn.RoundTrip may still receive the bodyWriter error first, but - // the fix for issue 16102 prioritises any response. - // - // Issue 22413: If there is no request body, we should close the - // stream before writing to cs.resc so that the stream is closed - // immediately once RoundTrip returns. - if cs.req.Body != nil { - defer cc.forgetStreamID(f.StreamID) - } else { - cc.forgetStreamID(f.StreamID) - } + if cs.readClosed { + rl.endStreamError(cs, StreamError{ + StreamID: f.StreamID, + Code: ErrCodeProtocol, + Cause: errors.New("protocol error: headers after END_STREAM"), + }) + return nil } if !cs.firstByte { if cs.trace != nil { @@ -1930,9 +2195,11 @@ func (rl *clientConnReadLoop) processHeaders(f *MetaHeadersFrame) error { return err } // Any other error type is a stream error. - cs.cc.writeStreamReset(f.StreamID, ErrCodeProtocol, err) - cc.forgetStreamID(cs.ID) - cs.resc <- resAndError{err: err} + rl.endStreamError(cs, StreamError{ + StreamID: f.StreamID, + Code: ErrCodeProtocol, + Cause: err, + }) return nil // return nil from process* funcs to keep conn alive } if res == nil { @@ -1940,7 +2207,11 @@ func (rl *clientConnReadLoop) processHeaders(f *MetaHeadersFrame) error { return nil } cs.resTrailer = &res.Trailer - cs.resc <- resAndError{res: res} + cs.res = res + close(cs.respHeaderRecv) + if f.StreamEnded() { + rl.endStream(cs) + } return nil } @@ -2002,6 +2273,9 @@ func (rl *clientConnReadLoop) handleResponse(cs *clientStream, f *MetaHeadersFra } if statusCode >= 100 && statusCode <= 199 { + if f.StreamEnded() { + return nil, errors.New("1xx informational response with END_STREAM flag") + } cs.num1xx++ const max1xxResponses = 5 // arbitrary bound on number of informational responses, same as net/http if cs.num1xx > max1xxResponses { @@ -2014,42 +2288,49 @@ func (rl *clientConnReadLoop) handleResponse(cs *clientStream, f *MetaHeadersFra } if statusCode == 100 { traceGot100Continue(cs.trace) - if cs.on100 != nil { - cs.on100() // forces any write delay timer to fire + select { + case cs.on100 <- struct{}{}: + default: } } cs.pastHeaders = false // do it all again return nil, nil } - streamEnded := f.StreamEnded() - isHead := cs.req.Method == "HEAD" - if !streamEnded || isHead { - res.ContentLength = -1 - if clens := res.Header["Content-Length"]; len(clens) == 1 { - if cl, err := strconv.ParseUint(clens[0], 10, 63); err == nil { - res.ContentLength = int64(cl) - } else { - // TODO: care? unlike http/1, it won't mess up our framing, so it's - // more safe smuggling-wise to ignore. - } - } else if len(clens) > 1 { + res.ContentLength = -1 + if clens := res.Header["Content-Length"]; len(clens) == 1 { + if cl, err := strconv.ParseUint(clens[0], 10, 63); err == nil { + res.ContentLength = int64(cl) + } else { // TODO: care? unlike http/1, it won't mess up our framing, so it's // more safe smuggling-wise to ignore. } + } else if len(clens) > 1 { + // TODO: care? unlike http/1, it won't mess up our framing, so it's + // more safe smuggling-wise to ignore. + } else if f.StreamEnded() && !cs.isHead { + res.ContentLength = 0 } - if streamEnded || isHead { + if cs.isHead { res.Body = noBody return res, nil } - cs.bufPipe = pipe{b: &dataBuffer{expected: res.ContentLength}} + if f.StreamEnded() { + if res.ContentLength > 0 { + res.Body = missingBody{} + } else { + res.Body = noBody + } + return res, nil + } + + cs.bufPipe.setBuffer(&dataBuffer{expected: res.ContentLength}) cs.bytesRemain = res.ContentLength res.Body = transportResponseBody{cs} - go cs.awaitRequestCancel(cs.req) - if cs.requestedGzip && res.Header.Get("Content-Encoding") == "gzip" { + if cs.requestedGzip && asciiEqualFold(res.Header.Get("Content-Encoding"), "gzip") { res.Header.Del("Content-Encoding") res.Header.Del("Content-Length") res.ContentLength = -1 @@ -2088,8 +2369,7 @@ func (rl *clientConnReadLoop) processTrailers(cs *clientStream, f *MetaHeadersFr } // transportResponseBody is the concrete type of Transport.RoundTrip's -// Response.Body. It is an io.ReadCloser. On Read, it reads from cs.body. -// On Close it sends RST_STREAM if EOF wasn't already seen. +// Response.Body. It is an io.ReadCloser. type transportResponseBody struct { cs *clientStream } @@ -2107,7 +2387,7 @@ func (b transportResponseBody) Read(p []byte) (n int, err error) { n = int(cs.bytesRemain) if err == nil { err = errors.New("net/http: server replied with more than declared Content-Length; truncated") - cc.writeStreamReset(cs.ID, ErrCodeProtocol, err) + cs.abortStream(err) } cs.readErr = err return int(cs.bytesRemain), err @@ -2125,8 +2405,6 @@ func (b transportResponseBody) Read(p []byte) (n int, err error) { } cc.mu.Lock() - defer cc.mu.Unlock() - var connAdd, streamAdd int32 // Check the conn-level first, before the stream-level. if v := cc.inflow.available(); v < transportDefaultConnFlow/2 { @@ -2143,6 +2421,8 @@ func (b transportResponseBody) Read(p []byte) (n int, err error) { cs.inflow.add(streamAdd) } } + cc.mu.Unlock() + if connAdd != 0 || streamAdd != 0 { cc.wmu.Lock() defer cc.wmu.Unlock() @@ -2163,34 +2443,45 @@ func (b transportResponseBody) Close() error { cs := b.cs cc := cs.cc - serverSentStreamEnd := cs.bufPipe.Err() == io.EOF unread := cs.bufPipe.Len() - - if unread > 0 || !serverSentStreamEnd { + if unread > 0 { cc.mu.Lock() - cc.wmu.Lock() - if !serverSentStreamEnd { - cc.fr.WriteRSTStream(cs.ID, ErrCodeCancel) - cs.didReset = true - } // Return connection-level flow control. if unread > 0 { cc.inflow.add(int32(unread)) + } + cc.mu.Unlock() + + // TODO(dneil): Acquiring this mutex can block indefinitely. + // Move flow control return to a goroutine? + cc.wmu.Lock() + // Return connection-level flow control. + if unread > 0 { cc.fr.WriteWindowUpdate(0, uint32(unread)) } cc.bw.Flush() cc.wmu.Unlock() - cc.mu.Unlock() } cs.bufPipe.BreakWithError(errClosedResponseBody) - cc.forgetStreamID(cs.ID) + cs.abortStream(errClosedResponseBody) + + select { + case <-cs.donec: + case <-cs.ctx.Done(): + // See golang/go#49366: The net/http package can cancel the + // request context after the response body is fully read. + // Don't treat this as an error. + return nil + case <-cs.reqCancel: + return errRequestCanceled + } return nil } func (rl *clientConnReadLoop) processData(f *DataFrame) error { cc := rl.cc - cs := cc.streamByID(f.StreamID, f.StreamEnded()) + cs := rl.streamByID(f.StreamID) data := f.Data() if cs == nil { cc.mu.Lock() @@ -2219,6 +2510,14 @@ func (rl *clientConnReadLoop) processData(f *DataFrame) error { } return nil } + if cs.readClosed { + cc.logf("protocol error: received DATA after END_STREAM") + rl.endStreamError(cs, StreamError{ + StreamID: f.StreamID, + Code: ErrCodeProtocol, + }) + return nil + } if !cs.firstByte { cc.logf("protocol error: received DATA before a HEADERS frame") rl.endStreamError(cs, StreamError{ @@ -2228,7 +2527,7 @@ func (rl *clientConnReadLoop) processData(f *DataFrame) error { return nil } if f.Length > 0 { - if cs.req.Method == "HEAD" && len(data) > 0 { + if cs.isHead && len(data) > 0 { cc.logf("protocol error: received DATA on a HEAD request") rl.endStreamError(cs, StreamError{ StreamID: f.StreamID, @@ -2250,30 +2549,39 @@ func (rl *clientConnReadLoop) processData(f *DataFrame) error { if pad := int(f.Length) - len(data); pad > 0 { refund += pad } - // Return len(data) now if the stream is already closed, - // since data will never be read. - didReset := cs.didReset - if didReset { - refund += len(data) + + didReset := false + var err error + if len(data) > 0 { + if _, err = cs.bufPipe.Write(data); err != nil { + // Return len(data) now if the stream is already closed, + // since data will never be read. + didReset = true + refund += len(data) + } } + if refund > 0 { cc.inflow.add(int32(refund)) + if !didReset { + cs.inflow.add(int32(refund)) + } + } + cc.mu.Unlock() + + if refund > 0 { cc.wmu.Lock() cc.fr.WriteWindowUpdate(0, uint32(refund)) if !didReset { - cs.inflow.add(int32(refund)) cc.fr.WriteWindowUpdate(cs.ID, uint32(refund)) } cc.bw.Flush() cc.wmu.Unlock() } - cc.mu.Unlock() - if len(data) > 0 && !didReset { - if _, err := cs.bufPipe.Write(data); err != nil { - rl.endStreamError(cs, err) - return err - } + if err != nil { + rl.endStreamError(cs, err) + return nil } } @@ -2286,24 +2594,32 @@ func (rl *clientConnReadLoop) processData(f *DataFrame) error { func (rl *clientConnReadLoop) endStream(cs *clientStream) { // TODO: check that any declared content-length matches, like // server.go's (*stream).endStream method. - rl.endStreamError(cs, nil) + if !cs.readClosed { + cs.readClosed = true + // Close cs.bufPipe and cs.peerClosed with cc.mu held to avoid a + // race condition: The caller can read io.EOF from Response.Body + // and close the body before we close cs.peerClosed, causing + // cleanupWriteRequest to send a RST_STREAM. + rl.cc.mu.Lock() + defer rl.cc.mu.Unlock() + cs.bufPipe.closeWithErrorAndCode(io.EOF, cs.copyTrailers) + close(cs.peerClosed) + } } func (rl *clientConnReadLoop) endStreamError(cs *clientStream, err error) { - var code func() - if err == nil { - err = io.EOF - code = cs.copyTrailers - } - if isConnectionCloseRequest(cs.req) { - rl.closeWhenIdle = true - } - cs.bufPipe.closeWithErrorAndCode(err, code) + cs.readAborted = true + cs.abortStream(err) +} - select { - case cs.resc <- resAndError{err: err}: - default: +func (rl *clientConnReadLoop) streamByID(id uint32) *clientStream { + rl.cc.mu.Lock() + defer rl.cc.mu.Unlock() + cs := rl.cc.streams[id] + if cs != nil && !cs.readAborted { + return cs } + return nil } func (cs *clientStream) copyTrailers() { @@ -2322,12 +2638,33 @@ func (rl *clientConnReadLoop) processGoAway(f *GoAwayFrame) error { if f.ErrCode != 0 { // TODO: deal with GOAWAY more. particularly the error code cc.vlogf("transport got GOAWAY with error code = %v", f.ErrCode) + if fn := cc.t.CountError; fn != nil { + fn("recv_goaway_" + f.ErrCode.stringToken()) + } + } cc.setGoAway(f) return nil } func (rl *clientConnReadLoop) processSettings(f *SettingsFrame) error { + cc := rl.cc + // Locking both mu and wmu here allows frame encoding to read settings with only wmu held. + // Acquiring wmu when f.IsAck() is unnecessary, but convenient and mostly harmless. + cc.wmu.Lock() + defer cc.wmu.Unlock() + + if err := rl.processSettingsNoWrite(f); err != nil { + return err + } + if !f.IsAck() { + cc.fr.WriteSettingsAck() + cc.bw.Flush() + } + return nil +} + +func (rl *clientConnReadLoop) processSettingsNoWrite(f *SettingsFrame) error { cc := rl.cc cc.mu.Lock() defer cc.mu.Unlock() @@ -2340,12 +2677,14 @@ func (rl *clientConnReadLoop) processSettings(f *SettingsFrame) error { return ConnectionError(ErrCodeProtocol) } + var seenMaxConcurrentStreams bool err := f.ForeachSetting(func(s Setting) error { switch s.ID { case SettingMaxFrameSize: cc.maxFrameSize = s.Val case SettingMaxConcurrentStreams: cc.maxConcurrentStreams = s.Val + seenMaxConcurrentStreams = true case SettingMaxHeaderListSize: cc.peerMaxHeaderListSize = uint64(s.Val) case SettingInitialWindowSize: @@ -2377,17 +2716,23 @@ func (rl *clientConnReadLoop) processSettings(f *SettingsFrame) error { return err } - cc.wmu.Lock() - defer cc.wmu.Unlock() + if !cc.seenSettings { + if !seenMaxConcurrentStreams { + // This was the servers initial SETTINGS frame and it + // didn't contain a MAX_CONCURRENT_STREAMS field so + // increase the number of concurrent streams this + // connection can establish to our default. + cc.maxConcurrentStreams = defaultMaxConcurrentStreams + } + cc.seenSettings = true + } - cc.fr.WriteSettingsAck() - cc.bw.Flush() - return cc.werr + return nil } func (rl *clientConnReadLoop) processWindowUpdate(f *WindowUpdateFrame) error { cc := rl.cc - cs := cc.streamByID(f.StreamID, false) + cs := rl.streamByID(f.StreamID) if f.StreamID != 0 && cs == nil { return nil } @@ -2407,24 +2752,22 @@ func (rl *clientConnReadLoop) processWindowUpdate(f *WindowUpdateFrame) error { } func (rl *clientConnReadLoop) processResetStream(f *RSTStreamFrame) error { - cs := rl.cc.streamByID(f.StreamID, true) + cs := rl.streamByID(f.StreamID) if cs == nil { - // TODO: return error if server tries to RST_STEAM an idle stream + // TODO: return error if server tries to RST_STREAM an idle stream return nil } - select { - case <-cs.peerReset: - // Already reset. - // This is the only goroutine - // which closes this, so there - // isn't a race. - default: - err := streamError(cs.ID, f.ErrCode) - cs.resetErr = err - close(cs.peerReset) - cs.bufPipe.CloseWithError(err) - cs.cc.cond.Broadcast() // wake up checkResetOrDone via clientStream.awaitFlowControl + serr := streamError(cs.ID, f.ErrCode) + serr.Cause = errFromPeer + if f.ErrCode == ErrCodeProtocol { + rl.cc.SetDoNotReuse() } + if fn := cs.cc.t.CountError; fn != nil { + fn("recv_rststream_" + f.ErrCode.stringToken()) + } + cs.abortStream(serr) + + cs.bufPipe.CloseWithError(serr) return nil } @@ -2446,19 +2789,24 @@ func (cc *ClientConn) Ping(ctx context.Context) error { } cc.mu.Unlock() } - cc.wmu.Lock() - if err := cc.fr.WritePing(false, p); err != nil { - cc.wmu.Unlock() - return err - } - if err := cc.bw.Flush(); err != nil { - cc.wmu.Unlock() - return err - } - cc.wmu.Unlock() + errc := make(chan error, 1) + go func() { + cc.wmu.Lock() + defer cc.wmu.Unlock() + if err := cc.fr.WritePing(false, p); err != nil { + errc <- err + return + } + if err := cc.bw.Flush(); err != nil { + errc <- err + return + } + }() select { case <-c: return nil + case err := <-errc: + return err case <-ctx.Done(): return ctx.Err() case <-cc.readerDone: @@ -2535,6 +2883,11 @@ func (t *Transport) logf(format string, args ...interface{}) { var noBody io.ReadCloser = ioutil.NopCloser(bytes.NewReader(nil)) +type missingBody struct{} + +func (missingBody) Close() error { return nil } +func (missingBody) Read([]byte) (int, error) { return 0, io.ErrUnexpectedEOF } + func strSliceContains(ss []string, s string) bool { for _, v := range ss { if v == s { @@ -2580,87 +2933,6 @@ type errorReader struct{ err error } func (r errorReader) Read(p []byte) (int, error) { return 0, r.err } -// bodyWriterState encapsulates various state around the Transport's writing -// of the request body, particularly regarding doing delayed writes of the body -// when the request contains "Expect: 100-continue". -type bodyWriterState struct { - cs *clientStream - timer *time.Timer // if non-nil, we're doing a delayed write - fnonce *sync.Once // to call fn with - fn func() // the code to run in the goroutine, writing the body - resc chan error // result of fn's execution - delay time.Duration // how long we should delay a delayed write for -} - -func (t *Transport) getBodyWriterState(cs *clientStream, body io.Reader) (s bodyWriterState) { - s.cs = cs - if body == nil { - return - } - resc := make(chan error, 1) - s.resc = resc - s.fn = func() { - cs.cc.mu.Lock() - cs.startedWrite = true - cs.cc.mu.Unlock() - resc <- cs.writeRequestBody(body, cs.req.Body) - } - s.delay = t.expectContinueTimeout() - if s.delay == 0 || - !httpguts.HeaderValuesContainsToken( - cs.req.Header["Expect"], - "100-continue") { - return - } - s.fnonce = new(sync.Once) - - // Arm the timer with a very large duration, which we'll - // intentionally lower later. It has to be large now because - // we need a handle to it before writing the headers, but the - // s.delay value is defined to not start until after the - // request headers were written. - const hugeDuration = 365 * 24 * time.Hour - s.timer = time.AfterFunc(hugeDuration, func() { - s.fnonce.Do(s.fn) - }) - return -} - -func (s bodyWriterState) cancel() { - if s.timer != nil { - if s.timer.Stop() { - s.resc <- nil - } - } -} - -func (s bodyWriterState) on100() { - if s.timer == nil { - // If we didn't do a delayed write, ignore the server's - // bogus 100 continue response. - return - } - s.timer.Stop() - go func() { s.fnonce.Do(s.fn) }() -} - -// scheduleBodyWrite starts writing the body, either immediately (in -// the common case) or after the delay timeout. It should not be -// called until after the headers have been written. -func (s bodyWriterState) scheduleBodyWrite() { - if s.timer == nil { - // We're not doing a delayed write (see - // getBodyWriterState), so just start the writing - // goroutine immediately. - go s.fn() - return - } - traceWait100Continue(s.cs.trace) - if s.timer.Stop() { - s.timer.Reset(s.delay) - } -} - // isConnectionCloseRequest reports whether req should use its own // connection for a single request and then close the connection. func isConnectionCloseRequest(req *http.Request) bool { diff --git a/vendor/golang.org/x/net/http2/writesched.go b/vendor/golang.org/x/net/http2/writesched.go index f24d2b1e7d4..c7cd0017392 100644 --- a/vendor/golang.org/x/net/http2/writesched.go +++ b/vendor/golang.org/x/net/http2/writesched.go @@ -32,7 +32,8 @@ type WriteScheduler interface { // Pop dequeues the next frame to write. Returns false if no frames can // be written. Frames with a given wr.StreamID() are Pop'd in the same - // order they are Push'd. No frames should be discarded except by CloseStream. + // order they are Push'd, except RST_STREAM frames. No frames should be + // discarded except by CloseStream. Pop() (wr FrameWriteRequest, ok bool) } @@ -52,6 +53,7 @@ type FrameWriteRequest struct { // stream is the stream on which this frame will be written. // nil for non-stream frames like PING and SETTINGS. + // nil for RST_STREAM streams, which use the StreamError.StreamID field instead. stream *stream // done, if non-nil, must be a buffered channel with space for diff --git a/vendor/golang.org/x/net/http2/writesched_random.go b/vendor/golang.org/x/net/http2/writesched_random.go index 9a7b9e581c1..f2e55e05ce9 100644 --- a/vendor/golang.org/x/net/http2/writesched_random.go +++ b/vendor/golang.org/x/net/http2/writesched_random.go @@ -45,11 +45,11 @@ func (ws *randomWriteScheduler) AdjustStream(streamID uint32, priority PriorityP } func (ws *randomWriteScheduler) Push(wr FrameWriteRequest) { - id := wr.StreamID() - if id == 0 { + if wr.isControl() { ws.zero.push(wr) return } + id := wr.StreamID() q, ok := ws.sq[id] if !ok { q = ws.queuePool.get() @@ -59,7 +59,7 @@ func (ws *randomWriteScheduler) Push(wr FrameWriteRequest) { } func (ws *randomWriteScheduler) Pop() (FrameWriteRequest, bool) { - // Control frames first. + // Control and RST_STREAM frames first. if !ws.zero.empty() { return ws.zero.shift(), true } diff --git a/vendor/golang.org/x/net/idna/go118.go b/vendor/golang.org/x/net/idna/go118.go new file mode 100644 index 00000000000..c5c4338dbed --- /dev/null +++ b/vendor/golang.org/x/net/idna/go118.go @@ -0,0 +1,14 @@ +// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. + +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build go1.18 +// +build go1.18 + +package idna + +// Transitional processing is disabled by default in Go 1.18. +// https://golang.org/issue/47510 +const transitionalLookup = false diff --git a/vendor/golang.org/x/net/idna/idna10.0.0.go b/vendor/golang.org/x/net/idna/idna10.0.0.go index 5208ba6cb88..64ccf85febb 100644 --- a/vendor/golang.org/x/net/idna/idna10.0.0.go +++ b/vendor/golang.org/x/net/idna/idna10.0.0.go @@ -59,10 +59,10 @@ type Option func(*options) // Transitional sets a Profile to use the Transitional mapping as defined in UTS // #46. This will cause, for example, "ß" to be mapped to "ss". Using the // transitional mapping provides a compromise between IDNA2003 and IDNA2008 -// compatibility. It is used by most browsers when resolving domain names. This +// compatibility. It is used by some browsers when resolving domain names. This // option is only meaningful if combined with MapForLookup. func Transitional(transitional bool) Option { - return func(o *options) { o.transitional = true } + return func(o *options) { o.transitional = transitional } } // VerifyDNSLength sets whether a Profile should fail if any of the IDN parts @@ -284,7 +284,7 @@ var ( punycode = &Profile{} lookup = &Profile{options{ - transitional: true, + transitional: transitionalLookup, useSTD3Rules: true, checkHyphens: true, checkJoiners: true, diff --git a/vendor/golang.org/x/net/idna/idna9.0.0.go b/vendor/golang.org/x/net/idna/idna9.0.0.go index 55f718f1274..aae6aac872b 100644 --- a/vendor/golang.org/x/net/idna/idna9.0.0.go +++ b/vendor/golang.org/x/net/idna/idna9.0.0.go @@ -58,10 +58,10 @@ type Option func(*options) // Transitional sets a Profile to use the Transitional mapping as defined in UTS // #46. This will cause, for example, "ß" to be mapped to "ss". Using the // transitional mapping provides a compromise between IDNA2003 and IDNA2008 -// compatibility. It is used by most browsers when resolving domain names. This +// compatibility. It is used by some browsers when resolving domain names. This // option is only meaningful if combined with MapForLookup. func Transitional(transitional bool) Option { - return func(o *options) { o.transitional = true } + return func(o *options) { o.transitional = transitional } } // VerifyDNSLength sets whether a Profile should fail if any of the IDN parts diff --git a/vendor/golang.org/x/net/idna/pre_go118.go b/vendor/golang.org/x/net/idna/pre_go118.go new file mode 100644 index 00000000000..3aaccab1c5a --- /dev/null +++ b/vendor/golang.org/x/net/idna/pre_go118.go @@ -0,0 +1,12 @@ +// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. + +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !go1.18 +// +build !go1.18 + +package idna + +const transitionalLookup = true diff --git a/vendor/golang.org/x/net/idna/punycode.go b/vendor/golang.org/x/net/idna/punycode.go index 02c7d59af3b..e8e3ac11a94 100644 --- a/vendor/golang.org/x/net/idna/punycode.go +++ b/vendor/golang.org/x/net/idna/punycode.go @@ -49,6 +49,7 @@ func decode(encoded string) (string, error) { } } i, n, bias := int32(0), initialN, initialBias + overflow := false for pos < len(encoded) { oldI, w := i, int32(1) for k := base; ; k += base { @@ -60,29 +61,32 @@ func decode(encoded string) (string, error) { return "", punyError(encoded) } pos++ - i += digit * w - if i < 0 { + i, overflow = madd(i, digit, w) + if overflow { return "", punyError(encoded) } t := k - bias - if t < tmin { + if k <= bias { t = tmin - } else if t > tmax { + } else if k >= bias+tmax { t = tmax } if digit < t { break } - w *= base - t - if w >= math.MaxInt32/base { + w, overflow = madd(0, w, base-t) + if overflow { return "", punyError(encoded) } } + if len(output) >= 1024 { + return "", punyError(encoded) + } x := int32(len(output) + 1) bias = adapt(i-oldI, x, oldI == 0) n += i / x i %= x - if n > utf8.MaxRune || len(output) >= 1024 { + if n < 0 || n > utf8.MaxRune { return "", punyError(encoded) } output = append(output, 0) @@ -115,6 +119,7 @@ func encode(prefix, s string) (string, error) { if b > 0 { output = append(output, '-') } + overflow := false for remaining != 0 { m := int32(0x7fffffff) for _, r := range s { @@ -122,8 +127,8 @@ func encode(prefix, s string) (string, error) { m = r } } - delta += (m - n) * (h + 1) - if delta < 0 { + delta, overflow = madd(delta, m-n, h+1) + if overflow { return "", punyError(s) } n = m @@ -141,9 +146,9 @@ func encode(prefix, s string) (string, error) { q := delta for k := base; ; k += base { t := k - bias - if t < tmin { + if k <= bias { t = tmin - } else if t > tmax { + } else if k >= bias+tmax { t = tmax } if q < t { @@ -164,6 +169,15 @@ func encode(prefix, s string) (string, error) { return string(output), nil } +// madd computes a + (b * c), detecting overflow. +func madd(a, b, c int32) (next int32, overflow bool) { + p := int64(b) * int64(c) + if p > math.MaxInt32-int64(a) { + return 0, true + } + return a + int32(p), false +} + func decodeDigit(x byte) (digit int32, ok bool) { switch { case '0' <= x && x <= '9': diff --git a/vendor/golang.org/x/sys/cpu/cpu_gc_x86.go b/vendor/golang.org/x/sys/cpu/cpu_gc_x86.go index 3298a87e981..fa7cdb9bcd5 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_gc_x86.go +++ b/vendor/golang.org/x/sys/cpu/cpu_gc_x86.go @@ -15,7 +15,3 @@ func cpuid(eaxArg, ecxArg uint32) (eax, ebx, ecx, edx uint32) // xgetbv with ecx = 0 is implemented in cpu_x86.s for gc compiler // and in cpu_gccgo.c for gccgo. func xgetbv() (eax, edx uint32) - -// darwinSupportsAVX512 is implemented in cpu_x86.s for gc compiler -// and in cpu_gccgo_x86.go for gccgo. -func darwinSupportsAVX512() bool diff --git a/vendor/golang.org/x/sys/cpu/cpu_x86.go b/vendor/golang.org/x/sys/cpu/cpu_x86.go index 5ea287b7eca..f5aacfc825d 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_x86.go +++ b/vendor/golang.org/x/sys/cpu/cpu_x86.go @@ -90,9 +90,10 @@ func archInit() { osSupportsAVX = isSet(1, eax) && isSet(2, eax) if runtime.GOOS == "darwin" { - // Check darwin commpage for AVX512 support. Necessary because: - // https://github.com/apple/darwin-xnu/blob/0a798f6738bc1db01281fc08ae024145e84df927/osfmk/i386/fpu.c#L175-L201 - osSupportsAVX512 = osSupportsAVX && darwinSupportsAVX512() + // Darwin doesn't save/restore AVX-512 mask registers correctly across signal handlers. + // Since users can't rely on mask register contents, let's not advertise AVX-512 support. + // See issue 49233. + osSupportsAVX512 = false } else { // Check if OPMASK and ZMM registers have OS support. osSupportsAVX512 = osSupportsAVX && isSet(5, eax) && isSet(6, eax) && isSet(7, eax) diff --git a/vendor/golang.org/x/sys/cpu/cpu_x86.s b/vendor/golang.org/x/sys/cpu/cpu_x86.s index b748ba52f7c..39acab2ff5c 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_x86.s +++ b/vendor/golang.org/x/sys/cpu/cpu_x86.s @@ -26,27 +26,3 @@ TEXT ·xgetbv(SB),NOSPLIT,$0-8 MOVL AX, eax+0(FP) MOVL DX, edx+4(FP) RET - -// func darwinSupportsAVX512() bool -TEXT ·darwinSupportsAVX512(SB), NOSPLIT, $0-1 - MOVB $0, ret+0(FP) // default to false -#ifdef GOOS_darwin // return if not darwin -#ifdef GOARCH_amd64 // return if not amd64 -// These values from: -// https://github.com/apple/darwin-xnu/blob/xnu-4570.1.46/osfmk/i386/cpu_capabilities.h -#define commpage64_base_address 0x00007fffffe00000 -#define commpage64_cpu_capabilities64 (commpage64_base_address+0x010) -#define commpage64_version (commpage64_base_address+0x01E) -#define hasAVX512F 0x0000004000000000 - MOVQ $commpage64_version, BX - CMPW (BX), $13 // cpu_capabilities64 undefined in versions < 13 - JL no_avx512 - MOVQ $commpage64_cpu_capabilities64, BX - MOVQ $hasAVX512F, CX - TESTQ (BX), CX - JZ no_avx512 - MOVB $1, ret+0(FP) -no_avx512: -#endif -#endif - RET diff --git a/vendor/golang.org/x/sys/plan9/pwd_go15_plan9.go b/vendor/golang.org/x/sys/plan9/pwd_go15_plan9.go index 87ae9d2a33e..c9b69937a0d 100644 --- a/vendor/golang.org/x/sys/plan9/pwd_go15_plan9.go +++ b/vendor/golang.org/x/sys/plan9/pwd_go15_plan9.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build go1.5 // +build go1.5 package plan9 diff --git a/vendor/golang.org/x/sys/plan9/pwd_plan9.go b/vendor/golang.org/x/sys/plan9/pwd_plan9.go index c07c798bc57..98bf56b7322 100644 --- a/vendor/golang.org/x/sys/plan9/pwd_plan9.go +++ b/vendor/golang.org/x/sys/plan9/pwd_plan9.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !go1.5 // +build !go1.5 package plan9 diff --git a/vendor/golang.org/x/sys/plan9/race.go b/vendor/golang.org/x/sys/plan9/race.go index 42edd93ef96..62377d2ff96 100644 --- a/vendor/golang.org/x/sys/plan9/race.go +++ b/vendor/golang.org/x/sys/plan9/race.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build plan9 && race // +build plan9,race package plan9 diff --git a/vendor/golang.org/x/sys/plan9/race0.go b/vendor/golang.org/x/sys/plan9/race0.go index c89cf8fc0d7..f8da30876db 100644 --- a/vendor/golang.org/x/sys/plan9/race0.go +++ b/vendor/golang.org/x/sys/plan9/race0.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build plan9 && !race // +build plan9,!race package plan9 diff --git a/vendor/golang.org/x/sys/plan9/str.go b/vendor/golang.org/x/sys/plan9/str.go index 4f7f9ad7c86..55fa8d025ec 100644 --- a/vendor/golang.org/x/sys/plan9/str.go +++ b/vendor/golang.org/x/sys/plan9/str.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build plan9 // +build plan9 package plan9 diff --git a/vendor/golang.org/x/sys/plan9/syscall.go b/vendor/golang.org/x/sys/plan9/syscall.go index e7363a2f54d..602473cba37 100644 --- a/vendor/golang.org/x/sys/plan9/syscall.go +++ b/vendor/golang.org/x/sys/plan9/syscall.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build plan9 // +build plan9 // Package plan9 contains an interface to the low-level operating system diff --git a/vendor/golang.org/x/sys/plan9/syscall_plan9.go b/vendor/golang.org/x/sys/plan9/syscall_plan9.go index 84e14714811..723b1f4002a 100644 --- a/vendor/golang.org/x/sys/plan9/syscall_plan9.go +++ b/vendor/golang.org/x/sys/plan9/syscall_plan9.go @@ -132,8 +132,10 @@ func Pipe(p []int) (err error) { } var pp [2]int32 err = pipe(&pp) - p[0] = int(pp[0]) - p[1] = int(pp[1]) + if err == nil { + p[0] = int(pp[0]) + p[1] = int(pp[1]) + } return } diff --git a/vendor/golang.org/x/sys/plan9/zsyscall_plan9_386.go b/vendor/golang.org/x/sys/plan9/zsyscall_plan9_386.go index 6819bc2094d..3f40b9bd743 100644 --- a/vendor/golang.org/x/sys/plan9/zsyscall_plan9_386.go +++ b/vendor/golang.org/x/sys/plan9/zsyscall_plan9_386.go @@ -1,6 +1,7 @@ // go run mksyscall.go -l32 -plan9 -tags plan9,386 syscall_plan9.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build plan9 && 386 // +build plan9,386 package plan9 diff --git a/vendor/golang.org/x/sys/plan9/zsyscall_plan9_amd64.go b/vendor/golang.org/x/sys/plan9/zsyscall_plan9_amd64.go index 418abbbfc75..0e6a96aa4fa 100644 --- a/vendor/golang.org/x/sys/plan9/zsyscall_plan9_amd64.go +++ b/vendor/golang.org/x/sys/plan9/zsyscall_plan9_amd64.go @@ -1,6 +1,7 @@ // go run mksyscall.go -l32 -plan9 -tags plan9,amd64 syscall_plan9.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build plan9 && amd64 // +build plan9,amd64 package plan9 diff --git a/vendor/golang.org/x/sys/plan9/zsyscall_plan9_arm.go b/vendor/golang.org/x/sys/plan9/zsyscall_plan9_arm.go index 3e8a1a58cac..244c501b77b 100644 --- a/vendor/golang.org/x/sys/plan9/zsyscall_plan9_arm.go +++ b/vendor/golang.org/x/sys/plan9/zsyscall_plan9_arm.go @@ -1,6 +1,7 @@ // go run mksyscall.go -l32 -plan9 -tags plan9,arm syscall_plan9.go // Code generated by the command above; see README.md. DO NOT EDIT. +//go:build plan9 && arm // +build plan9,arm package plan9 diff --git a/vendor/golang.org/x/sys/unix/README.md b/vendor/golang.org/x/sys/unix/README.md index 474efad0e03..7d3c060e122 100644 --- a/vendor/golang.org/x/sys/unix/README.md +++ b/vendor/golang.org/x/sys/unix/README.md @@ -149,7 +149,7 @@ To add a constant, add the header that includes it to the appropriate variable. Then, edit the regex (if necessary) to match the desired constant. Avoid making the regex too broad to avoid matching unintended constants. -### mkmerge.go +### internal/mkmerge This program is used to extract duplicate const, func, and type declarations from the generated architecture-specific files listed below, and merge these diff --git a/vendor/golang.org/x/sys/unix/mkall.sh b/vendor/golang.org/x/sys/unix/mkall.sh index 396aadf86de..ee73623489b 100644 --- a/vendor/golang.org/x/sys/unix/mkall.sh +++ b/vendor/golang.org/x/sys/unix/mkall.sh @@ -50,7 +50,7 @@ if [[ "$GOOS" = "linux" ]]; then # Use the Docker-based build system # Files generated through docker (use $cmd so you can Ctl-C the build or run) $cmd docker build --tag generate:$GOOS $GOOS - $cmd docker run --interactive --tty --volume $(cd -- "$(dirname -- "$0")" && /bin/pwd):/build generate:$GOOS + $cmd docker run --interactive --tty --volume $(cd -- "$(dirname -- "$0")/.." && /bin/pwd):/build generate:$GOOS exit fi diff --git a/vendor/golang.org/x/sys/unix/mkerrors.sh b/vendor/golang.org/x/sys/unix/mkerrors.sh index a74ef58f8c6..a47b035f9af 100644 --- a/vendor/golang.org/x/sys/unix/mkerrors.sh +++ b/vendor/golang.org/x/sys/unix/mkerrors.sh @@ -239,6 +239,7 @@ struct ltchars { #include #include #include +#include #include #include #include @@ -260,6 +261,7 @@ struct ltchars { #include #include #include +#include #include #include @@ -520,7 +522,7 @@ ccflags="$@" $2 ~ /^HW_MACHINE$/ || $2 ~ /^SYSCTL_VERS/ || $2 !~ "MNT_BITS" && - $2 ~ /^(MS|MNT|UMOUNT)_/ || + $2 ~ /^(MS|MNT|MOUNT|UMOUNT)_/ || $2 ~ /^NS_GET_/ || $2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ || $2 ~ /^(O|F|[ES]?FD|NAME|S|PTRACE|PT|TFD)_/ || @@ -605,6 +607,7 @@ ccflags="$@" $2 ~ /^MTD/ || $2 ~ /^OTP/ || $2 ~ /^MEM/ || + $2 ~ /^WG/ || $2 ~ /^BLK[A-Z]*(GET$|SET$|BUF$|PART$|SIZE)/ {printf("\t%s = C.%s\n", $2, $2)} $2 ~ /^__WCOREFLAG$/ {next} $2 ~ /^__W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", substr($2,3), $2)} diff --git a/vendor/golang.org/x/sys/unix/sockcmsg_linux.go b/vendor/golang.org/x/sys/unix/sockcmsg_linux.go index 326fb04a521..5f63147e06c 100644 --- a/vendor/golang.org/x/sys/unix/sockcmsg_linux.go +++ b/vendor/golang.org/x/sys/unix/sockcmsg_linux.go @@ -67,9 +67,7 @@ func ParseOrigDstAddr(m *SocketControlMessage) (Sockaddr, error) { sa := new(SockaddrInet4) p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil case m.Header.Level == SOL_IPV6 && m.Header.Type == IPV6_ORIGDSTADDR: @@ -78,9 +76,7 @@ func ParseOrigDstAddr(m *SocketControlMessage) (Sockaddr, error) { p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) sa.ZoneId = pp.Scope_id - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil default: diff --git a/vendor/golang.org/x/sys/unix/syscall_aix.go b/vendor/golang.org/x/sys/unix/syscall_aix.go index d8efb715ff1..4f55c8d9996 100644 --- a/vendor/golang.org/x/sys/unix/syscall_aix.go +++ b/vendor/golang.org/x/sys/unix/syscall_aix.go @@ -70,9 +70,7 @@ func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) { p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), SizeofSockaddrInet4, nil } @@ -85,9 +83,7 @@ func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) { p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) sa.raw.Scope_id = sa.ZoneId - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), SizeofSockaddrInet6, nil } @@ -261,9 +257,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { sa := new(SockaddrInet4) p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil case AF_INET6: @@ -272,9 +266,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) sa.ZoneId = pp.Scope_id - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil } return nil, EAFNOSUPPORT @@ -385,6 +377,11 @@ func (w WaitStatus) TrapCause() int { return -1 } //sys fcntl(fd int, cmd int, arg int) (val int, err error) +//sys fsyncRange(fd int, how int, start int64, length int64) (err error) = fsync_range +func Fsync(fd int) error { + return fsyncRange(fd, O_SYNC, 0, 0) +} + /* * Direct access */ @@ -401,7 +398,6 @@ func (w WaitStatus) TrapCause() int { return -1 } //sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) //sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) //sys Fdatasync(fd int) (err error) -//sys Fsync(fd int) (err error) // readdir_r //sysnb Getpgid(pid int) (pgid int, err error) @@ -523,8 +519,10 @@ func Pipe(p []int) (err error) { } var pp [2]_C_int err = pipe(&pp) - p[0] = int(pp[0]) - p[1] = int(pp[1]) + if err == nil { + p[0] = int(pp[0]) + p[1] = int(pp[1]) + } return } diff --git a/vendor/golang.org/x/sys/unix/syscall_bsd.go b/vendor/golang.org/x/sys/unix/syscall_bsd.go index 95ac3946b5c..0ce45232611 100644 --- a/vendor/golang.org/x/sys/unix/syscall_bsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_bsd.go @@ -163,9 +163,7 @@ func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) { p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil } @@ -179,9 +177,7 @@ func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) { p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) sa.raw.Scope_id = sa.ZoneId - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil } @@ -210,9 +206,7 @@ func (sa *SockaddrDatalink) sockaddr() (unsafe.Pointer, _Socklen, error) { sa.raw.Nlen = sa.Nlen sa.raw.Alen = sa.Alen sa.raw.Slen = sa.Slen - for i := 0; i < len(sa.raw.Data); i++ { - sa.raw.Data[i] = sa.Data[i] - } + sa.raw.Data = sa.Data return unsafe.Pointer(&sa.raw), SizeofSockaddrDatalink, nil } @@ -228,9 +222,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { sa.Nlen = pp.Nlen sa.Alen = pp.Alen sa.Slen = pp.Slen - for i := 0; i < len(sa.Data); i++ { - sa.Data[i] = pp.Data[i] - } + sa.Data = pp.Data return sa, nil case AF_UNIX: @@ -262,9 +254,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { sa := new(SockaddrInet4) p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil case AF_INET6: @@ -273,9 +263,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) sa.ZoneId = pp.Scope_id - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil } return anyToSockaddrGOOS(fd, rsa) diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin.go b/vendor/golang.org/x/sys/unix/syscall_darwin.go index a8c13317d75..0eaab91314c 100644 --- a/vendor/golang.org/x/sys/unix/syscall_darwin.go +++ b/vendor/golang.org/x/sys/unix/syscall_darwin.go @@ -159,8 +159,10 @@ func Pipe(p []int) (err error) { } var x [2]int32 err = pipe(&x) - p[0] = int(x[0]) - p[1] = int(x[1]) + if err == nil { + p[0] = int(x[0]) + p[1] = int(x[1]) + } return } @@ -430,8 +432,25 @@ func GetsockoptXucred(fd, level, opt int) (*Xucred, error) { return x, err } -func SysctlKinfoProcSlice(name string) ([]KinfoProc, error) { - mib, err := sysctlmib(name) +func SysctlKinfoProc(name string, args ...int) (*KinfoProc, error) { + mib, err := sysctlmib(name, args...) + if err != nil { + return nil, err + } + + var kinfo KinfoProc + n := uintptr(SizeofKinfoProc) + if err := sysctl(mib, (*byte)(unsafe.Pointer(&kinfo)), &n, nil, 0); err != nil { + return nil, err + } + if n != SizeofKinfoProc { + return nil, EIO + } + return &kinfo, nil +} + +func SysctlKinfoProcSlice(name string, args ...int) ([]KinfoProc, error) { + mib, err := sysctlmib(name, args...) if err != nil { return nil, err } diff --git a/vendor/golang.org/x/sys/unix/syscall_dragonfly.go b/vendor/golang.org/x/sys/unix/syscall_dragonfly.go index 5af108a5038..2e37c3167f3 100644 --- a/vendor/golang.org/x/sys/unix/syscall_dragonfly.go +++ b/vendor/golang.org/x/sys/unix/syscall_dragonfly.go @@ -101,7 +101,10 @@ func Pipe(p []int) (err error) { if len(p) != 2 { return EINVAL } - p[0], p[1], err = pipe() + r, w, err := pipe() + if err == nil { + p[0], p[1] = r, w + } return } @@ -114,7 +117,10 @@ func Pipe2(p []int, flags int) (err error) { var pp [2]_C_int // pipe2 on dragonfly takes an fds array as an argument, but still // returns the file descriptors. - p[0], p[1], err = pipe2(&pp, flags) + r, w, err := pipe2(&pp, flags) + if err == nil { + p[0], p[1] = r, w + } return err } diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd.go b/vendor/golang.org/x/sys/unix/syscall_freebsd.go index 18c392cf369..2f650ae665c 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd.go @@ -110,8 +110,10 @@ func Pipe2(p []int, flags int) error { } var pp [2]_C_int err := pipe2(&pp, flags) - p[0] = int(pp[0]) - p[1] = int(pp[1]) + if err == nil { + p[0] = int(pp[0]) + p[1] = int(pp[1]) + } return err } diff --git a/vendor/golang.org/x/sys/unix/syscall_linux.go b/vendor/golang.org/x/sys/unix/syscall_linux.go index fff38a84c9c..f432b0684b8 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -131,8 +131,10 @@ func Pipe2(p []int, flags int) error { } var pp [2]_C_int err := pipe2(&pp, flags) - p[0] = int(pp[0]) - p[1] = int(pp[1]) + if err == nil { + p[0] = int(pp[0]) + p[1] = int(pp[1]) + } return err } @@ -372,9 +374,7 @@ func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) { p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), SizeofSockaddrInet4, nil } @@ -387,9 +387,7 @@ func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) { p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) sa.raw.Scope_id = sa.ZoneId - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), SizeofSockaddrInet6, nil } @@ -438,9 +436,7 @@ func (sa *SockaddrLinklayer) sockaddr() (unsafe.Pointer, _Socklen, error) { sa.raw.Hatype = sa.Hatype sa.raw.Pkttype = sa.Pkttype sa.raw.Halen = sa.Halen - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), SizeofSockaddrLinklayer, nil } @@ -855,12 +851,10 @@ func (sa *SockaddrTIPC) sockaddr() (unsafe.Pointer, _Socklen, error) { if sa.Addr == nil { return nil, 0, EINVAL } - sa.raw.Family = AF_TIPC sa.raw.Scope = int8(sa.Scope) sa.raw.Addrtype = sa.Addr.tipcAddrtype() sa.raw.Addr = sa.Addr.tipcAddr() - return unsafe.Pointer(&sa.raw), SizeofSockaddrTIPC, nil } @@ -874,9 +868,7 @@ type SockaddrL2TPIP struct { func (sa *SockaddrL2TPIP) sockaddr() (unsafe.Pointer, _Socklen, error) { sa.raw.Family = AF_INET sa.raw.Conn_id = sa.ConnId - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), SizeofSockaddrL2TPIP, nil } @@ -892,9 +884,7 @@ func (sa *SockaddrL2TPIP6) sockaddr() (unsafe.Pointer, _Socklen, error) { sa.raw.Family = AF_INET6 sa.raw.Conn_id = sa.ConnId sa.raw.Scope_id = sa.ZoneId - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), SizeofSockaddrL2TPIP6, nil } @@ -990,9 +980,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { sa.Hatype = pp.Hatype sa.Pkttype = pp.Pkttype sa.Halen = pp.Halen - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil case AF_UNIX: @@ -1031,18 +1019,14 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { pp := (*RawSockaddrL2TPIP)(unsafe.Pointer(rsa)) sa := new(SockaddrL2TPIP) sa.ConnId = pp.Conn_id - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil default: pp := (*RawSockaddrInet4)(unsafe.Pointer(rsa)) sa := new(SockaddrInet4) p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil } @@ -1058,9 +1042,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { sa := new(SockaddrL2TPIP6) sa.ConnId = pp.Conn_id sa.ZoneId = pp.Scope_id - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil default: pp := (*RawSockaddrInet6)(unsafe.Pointer(rsa)) @@ -1068,9 +1050,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) sa.ZoneId = pp.Scope_id - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil } @@ -1797,6 +1777,16 @@ func Mount(source string, target string, fstype string, flags uintptr, data stri return mount(source, target, fstype, flags, datap) } +//sys mountSetattr(dirfd int, pathname string, flags uint, attr *MountAttr, size uintptr) (err error) = SYS_MOUNT_SETATTR + +// MountSetattr is a wrapper for mount_setattr(2). +// https://man7.org/linux/man-pages/man2/mount_setattr.2.html +// +// Requires kernel >= 5.12. +func MountSetattr(dirfd int, pathname string, flags uint, attr *MountAttr) error { + return mountSetattr(dirfd, pathname, flags, attr, unsafe.Sizeof(*attr)) +} + func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { if raceenabled { raceReleaseMerge(unsafe.Pointer(&ioSync)) diff --git a/vendor/golang.org/x/sys/unix/syscall_netbsd.go b/vendor/golang.org/x/sys/unix/syscall_netbsd.go index 853d5f0f436..696fed496f6 100644 --- a/vendor/golang.org/x/sys/unix/syscall_netbsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_netbsd.go @@ -110,14 +110,8 @@ func direntNamlen(buf []byte) (uint64, bool) { return readInt(buf, unsafe.Offsetof(Dirent{}.Namlen), unsafe.Sizeof(Dirent{}.Namlen)) } -//sysnb pipe() (fd1 int, fd2 int, err error) - func Pipe(p []int) (err error) { - if len(p) != 2 { - return EINVAL - } - p[0], p[1], err = pipe() - return + return Pipe2(p, 0) } //sysnb pipe2(p *[2]_C_int, flags int) (err error) @@ -128,8 +122,10 @@ func Pipe2(p []int, flags int) error { } var pp [2]_C_int err := pipe2(&pp, flags) - p[0] = int(pp[0]) - p[1] = int(pp[1]) + if err == nil { + p[0] = int(pp[0]) + p[1] = int(pp[1]) + } return err } diff --git a/vendor/golang.org/x/sys/unix/syscall_openbsd.go b/vendor/golang.org/x/sys/unix/syscall_openbsd.go index 22b55038501..11b1d419da9 100644 --- a/vendor/golang.org/x/sys/unix/syscall_openbsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd.go @@ -87,8 +87,10 @@ func Pipe2(p []int, flags int) error { } var pp [2]_C_int err := pipe2(&pp, flags) - p[0] = int(pp[0]) - p[1] = int(pp[1]) + if err == nil { + p[0] = int(pp[0]) + p[1] = int(pp[1]) + } return err } diff --git a/vendor/golang.org/x/sys/unix/syscall_solaris.go b/vendor/golang.org/x/sys/unix/syscall_solaris.go index d2a6495c7e3..5c813921e85 100644 --- a/vendor/golang.org/x/sys/unix/syscall_solaris.go +++ b/vendor/golang.org/x/sys/unix/syscall_solaris.go @@ -66,8 +66,10 @@ func Pipe(p []int) (err error) { if n != 0 { return err } - p[0] = int(pp[0]) - p[1] = int(pp[1]) + if err == nil { + p[0] = int(pp[0]) + p[1] = int(pp[1]) + } return nil } @@ -79,8 +81,10 @@ func Pipe2(p []int, flags int) error { } var pp [2]_C_int err := pipe2(&pp, flags) - p[0] = int(pp[0]) - p[1] = int(pp[1]) + if err == nil { + p[0] = int(pp[0]) + p[1] = int(pp[1]) + } return err } @@ -92,9 +96,7 @@ func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) { p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), SizeofSockaddrInet4, nil } @@ -107,9 +109,7 @@ func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) { p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) sa.raw.Scope_id = sa.ZoneId - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), SizeofSockaddrInet6, nil } @@ -417,9 +417,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { sa := new(SockaddrInet4) p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil case AF_INET6: @@ -428,9 +426,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) sa.ZoneId = pp.Scope_id - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil } return nil, EAFNOSUPPORT diff --git a/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go b/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go index 1ffd8bfcfb9..f8616f454ec 100644 --- a/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go +++ b/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go @@ -67,9 +67,7 @@ func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) { p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil } @@ -83,9 +81,7 @@ func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) { p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) sa.raw.Scope_id = sa.ZoneId - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil } @@ -144,9 +140,7 @@ func anyToSockaddr(_ int, rsa *RawSockaddrAny) (Sockaddr, error) { sa := new(SockaddrInet4) p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil case AF_INET6: @@ -155,9 +149,7 @@ func anyToSockaddr(_ int, rsa *RawSockaddrAny) (Sockaddr, error) { p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) sa.ZoneId = pp.Scope_id - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil } return nil, EAFNOSUPPORT @@ -587,8 +579,10 @@ func Pipe(p []int) (err error) { } var pp [2]_C_int err = pipe(&pp) - p[0] = int(pp[0]) - p[1] = int(pp[1]) + if err == nil { + p[0] = int(pp[0]) + p[1] = int(pp[1]) + } return } diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux.go b/vendor/golang.org/x/sys/unix/zerrors_linux.go index 78d4b85ece5..bcc45d10850 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux.go @@ -1,4 +1,4 @@ -// Code generated by mkmerge.go; DO NOT EDIT. +// Code generated by mkmerge; DO NOT EDIT. //go:build linux // +build linux @@ -116,6 +116,7 @@ const ( ARPHRD_LAPB = 0x204 ARPHRD_LOCALTLK = 0x305 ARPHRD_LOOPBACK = 0x304 + ARPHRD_MCTP = 0x122 ARPHRD_METRICOM = 0x17 ARPHRD_NETLINK = 0x338 ARPHRD_NETROM = 0x0 @@ -472,6 +473,7 @@ const ( DM_DEV_WAIT = 0xc138fd08 DM_DIR = "mapper" DM_GET_TARGET_VERSION = 0xc138fd11 + DM_IMA_MEASUREMENT_FLAG = 0x80000 DM_INACTIVE_PRESENT_FLAG = 0x40 DM_INTERNAL_SUSPEND_FLAG = 0x40000 DM_IOCTL = 0xfd @@ -716,6 +718,7 @@ const ( ETH_P_LOOPBACK = 0x9000 ETH_P_MACSEC = 0x88e5 ETH_P_MAP = 0xf9 + ETH_P_MCTP = 0xfa ETH_P_MOBITEX = 0x15 ETH_P_MPLS_MC = 0x8848 ETH_P_MPLS_UC = 0x8847 @@ -751,6 +754,21 @@ const ( ETH_P_WCCP = 0x883e ETH_P_X25 = 0x805 ETH_P_XDSA = 0xf8 + EV_ABS = 0x3 + EV_CNT = 0x20 + EV_FF = 0x15 + EV_FF_STATUS = 0x17 + EV_KEY = 0x1 + EV_LED = 0x11 + EV_MAX = 0x1f + EV_MSC = 0x4 + EV_PWR = 0x16 + EV_REL = 0x2 + EV_REP = 0x14 + EV_SND = 0x12 + EV_SW = 0x5 + EV_SYN = 0x0 + EV_VERSION = 0x10001 EXABYTE_ENABLE_NEST = 0xf0 EXT2_SUPER_MAGIC = 0xef53 EXT3_SUPER_MAGIC = 0xef53 @@ -789,9 +807,11 @@ const ( FAN_DELETE_SELF = 0x400 FAN_DENY = 0x2 FAN_ENABLE_AUDIT = 0x40 + FAN_EPIDFD = -0x2 FAN_EVENT_INFO_TYPE_DFID = 0x3 FAN_EVENT_INFO_TYPE_DFID_NAME = 0x2 FAN_EVENT_INFO_TYPE_FID = 0x1 + FAN_EVENT_INFO_TYPE_PIDFD = 0x4 FAN_EVENT_METADATA_LEN = 0x18 FAN_EVENT_ON_CHILD = 0x8000000 FAN_MARK_ADD = 0x1 @@ -811,6 +831,7 @@ const ( FAN_MOVE_SELF = 0x800 FAN_NOFD = -0x1 FAN_NONBLOCK = 0x2 + FAN_NOPIDFD = -0x1 FAN_ONDIR = 0x40000000 FAN_OPEN = 0x20 FAN_OPEN_EXEC = 0x1000 @@ -821,6 +842,7 @@ const ( FAN_REPORT_DIR_FID = 0x400 FAN_REPORT_FID = 0x200 FAN_REPORT_NAME = 0x800 + FAN_REPORT_PIDFD = 0x80 FAN_REPORT_TID = 0x100 FAN_UNLIMITED_MARKS = 0x20 FAN_UNLIMITED_QUEUE = 0x10 @@ -1454,6 +1476,18 @@ const ( MNT_FORCE = 0x1 MODULE_INIT_IGNORE_MODVERSIONS = 0x1 MODULE_INIT_IGNORE_VERMAGIC = 0x2 + MOUNT_ATTR_IDMAP = 0x100000 + MOUNT_ATTR_NOATIME = 0x10 + MOUNT_ATTR_NODEV = 0x4 + MOUNT_ATTR_NODIRATIME = 0x80 + MOUNT_ATTR_NOEXEC = 0x8 + MOUNT_ATTR_NOSUID = 0x2 + MOUNT_ATTR_NOSYMFOLLOW = 0x200000 + MOUNT_ATTR_RDONLY = 0x1 + MOUNT_ATTR_RELATIME = 0x0 + MOUNT_ATTR_SIZE_VER0 = 0x20 + MOUNT_ATTR_STRICTATIME = 0x20 + MOUNT_ATTR__ATIME = 0x70 MSDOS_SUPER_MAGIC = 0x4d44 MSG_BATCH = 0x40000 MSG_CMSG_CLOEXEC = 0x40000000 @@ -1997,6 +2031,7 @@ const ( PR_SPEC_ENABLE = 0x2 PR_SPEC_FORCE_DISABLE = 0x8 PR_SPEC_INDIRECT_BRANCH = 0x1 + PR_SPEC_L1D_FLUSH = 0x2 PR_SPEC_NOT_AFFECTED = 0x0 PR_SPEC_PRCTL = 0x1 PR_SPEC_STORE_BYPASS = 0x0 @@ -2432,12 +2467,15 @@ const ( SMART_WRITE_THRESHOLDS = 0xd7 SMB_SUPER_MAGIC = 0x517b SOCKFS_MAGIC = 0x534f434b + SOCK_BUF_LOCK_MASK = 0x3 SOCK_DCCP = 0x6 SOCK_IOC_TYPE = 0x89 SOCK_PACKET = 0xa SOCK_RAW = 0x3 + SOCK_RCVBUF_LOCK = 0x2 SOCK_RDM = 0x4 SOCK_SEQPACKET = 0x5 + SOCK_SNDBUF_LOCK = 0x1 SOL_AAL = 0x109 SOL_ALG = 0x117 SOL_ATM = 0x108 @@ -2788,6 +2826,13 @@ const ( WDIOS_TEMPPANIC = 0x4 WDIOS_UNKNOWN = -0x1 WEXITED = 0x4 + WGALLOWEDIP_A_MAX = 0x3 + WGDEVICE_A_MAX = 0x8 + WGPEER_A_MAX = 0xa + WG_CMD_MAX = 0x1 + WG_GENL_NAME = "wireguard" + WG_GENL_VERSION = 0x1 + WG_KEY_LEN = 0x20 WIN_ACKMEDIACHANGE = 0xdb WIN_CHECKPOWERMODE1 = 0xe5 WIN_CHECKPOWERMODE2 = 0x98 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go index 697811a4600..3ca40ca7f02 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go @@ -5,7 +5,7 @@ // +build 386,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs -- -Wall -Werror -static -I/tmp/include -m32 /build/_const.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include -m32 /build/unix/_const.go package unix @@ -293,6 +293,7 @@ const ( SO_BPF_EXTENSIONS = 0x30 SO_BROADCAST = 0x6 SO_BSDCOMPAT = 0xe + SO_BUF_LOCK = 0x48 SO_BUSY_POLL = 0x2e SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go index 7d8d93bfc4b..ead332091af 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go @@ -5,7 +5,7 @@ // +build amd64,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs -- -Wall -Werror -static -I/tmp/include -m64 /build/_const.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include -m64 /build/unix/_const.go package unix @@ -294,6 +294,7 @@ const ( SO_BPF_EXTENSIONS = 0x30 SO_BROADCAST = 0x6 SO_BSDCOMPAT = 0xe + SO_BUF_LOCK = 0x48 SO_BUSY_POLL = 0x2e SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go index f707d508941..39bdc945589 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go @@ -5,7 +5,7 @@ // +build arm,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/_const.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/_const.go package unix @@ -300,6 +300,7 @@ const ( SO_BPF_EXTENSIONS = 0x30 SO_BROADCAST = 0x6 SO_BSDCOMPAT = 0xe + SO_BUF_LOCK = 0x48 SO_BUSY_POLL = 0x2e SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go index 3a67a9c8521..9aec987db1c 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go @@ -5,7 +5,7 @@ // +build arm64,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs -- -Wall -Werror -static -I/tmp/include -fsigned-char /build/_const.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include -fsigned-char /build/unix/_const.go package unix @@ -290,6 +290,7 @@ const ( SO_BPF_EXTENSIONS = 0x30 SO_BROADCAST = 0x6 SO_BSDCOMPAT = 0xe + SO_BUF_LOCK = 0x48 SO_BUSY_POLL = 0x2e SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go index a7ccef56c52..a8bba9491e8 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go @@ -5,7 +5,7 @@ // +build mips,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/_const.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/_const.go package unix @@ -293,6 +293,7 @@ const ( SO_BPF_EXTENSIONS = 0x30 SO_BROADCAST = 0x20 SO_BSDCOMPAT = 0xe + SO_BUF_LOCK = 0x48 SO_BUSY_POLL = 0x2e SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go index f7b7cec910f..ee9e7e2020e 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go @@ -5,7 +5,7 @@ // +build mips64,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/_const.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/_const.go package unix @@ -293,6 +293,7 @@ const ( SO_BPF_EXTENSIONS = 0x30 SO_BROADCAST = 0x20 SO_BSDCOMPAT = 0xe + SO_BUF_LOCK = 0x48 SO_BUSY_POLL = 0x2e SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go index 4fcacf95849..ba4b288a3c0 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go @@ -5,7 +5,7 @@ // +build mips64le,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/_const.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/_const.go package unix @@ -293,6 +293,7 @@ const ( SO_BPF_EXTENSIONS = 0x30 SO_BROADCAST = 0x20 SO_BSDCOMPAT = 0xe + SO_BUF_LOCK = 0x48 SO_BUSY_POLL = 0x2e SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go index 6f6c223a2cb..bc93afc3675 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go @@ -5,7 +5,7 @@ // +build mipsle,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/_const.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/_const.go package unix @@ -293,6 +293,7 @@ const ( SO_BPF_EXTENSIONS = 0x30 SO_BROADCAST = 0x20 SO_BSDCOMPAT = 0xe + SO_BUF_LOCK = 0x48 SO_BUSY_POLL = 0x2e SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go index 59e522bcf4e..9295e694785 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go @@ -5,7 +5,7 @@ // +build ppc,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/_const.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/_const.go package unix @@ -348,6 +348,7 @@ const ( SO_BPF_EXTENSIONS = 0x30 SO_BROADCAST = 0x6 SO_BSDCOMPAT = 0xe + SO_BUF_LOCK = 0x48 SO_BUSY_POLL = 0x2e SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go index d4264a0f73e..1fa081c9a67 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go @@ -5,7 +5,7 @@ // +build ppc64,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/_const.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/_const.go package unix @@ -352,6 +352,7 @@ const ( SO_BPF_EXTENSIONS = 0x30 SO_BROADCAST = 0x6 SO_BSDCOMPAT = 0xe + SO_BUF_LOCK = 0x48 SO_BUSY_POLL = 0x2e SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go index 21cbec1dd35..74b32114946 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go @@ -5,7 +5,7 @@ // +build ppc64le,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/_const.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/_const.go package unix @@ -352,6 +352,7 @@ const ( SO_BPF_EXTENSIONS = 0x30 SO_BROADCAST = 0x6 SO_BSDCOMPAT = 0xe + SO_BUF_LOCK = 0x48 SO_BUSY_POLL = 0x2e SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go index 9b05bf12fc3..c91c8ac5b01 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go @@ -5,7 +5,7 @@ // +build riscv64,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/_const.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/_const.go package unix @@ -281,6 +281,7 @@ const ( SO_BPF_EXTENSIONS = 0x30 SO_BROADCAST = 0x6 SO_BSDCOMPAT = 0xe + SO_BUF_LOCK = 0x48 SO_BUSY_POLL = 0x2e SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go index bd82ace09a5..b66bf222894 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go @@ -5,7 +5,7 @@ // +build s390x,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs -- -Wall -Werror -static -I/tmp/include -fsigned-char /build/_const.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include -fsigned-char /build/unix/_const.go package unix @@ -356,6 +356,7 @@ const ( SO_BPF_EXTENSIONS = 0x30 SO_BROADCAST = 0x6 SO_BSDCOMPAT = 0xe + SO_BUF_LOCK = 0x48 SO_BUSY_POLL = 0x2e SO_BUSY_POLL_BUDGET = 0x46 SO_CNX_ADVICE = 0x35 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go index 1f8bded56bb..f7fb149b0c9 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go @@ -5,7 +5,7 @@ // +build sparc64,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/_const.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/_const.go package unix @@ -347,6 +347,7 @@ const ( SO_BPF_EXTENSIONS = 0x32 SO_BROADCAST = 0x20 SO_BSDCOMPAT = 0x400 + SO_BUF_LOCK = 0x51 SO_BUSY_POLL = 0x30 SO_BUSY_POLL_BUDGET = 0x49 SO_CNX_ADVICE = 0x37 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go index 91a23cc7287..85e0cc38667 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go @@ -17,6 +17,7 @@ int getdirent(int, uintptr_t, size_t); int wait4(int, uintptr_t, int, uintptr_t); int ioctl(int, int, uintptr_t); int fcntl(uintptr_t, int, uintptr_t); +int fsync_range(int, int, long long, long long); int acct(uintptr_t); int chdir(uintptr_t); int chroot(uintptr_t); @@ -29,7 +30,6 @@ int fchmod(int, unsigned int); int fchmodat(int, uintptr_t, unsigned int, int); int fchownat(int, uintptr_t, int, int, int); int fdatasync(int); -int fsync(int); int getpgid(int); int getpgrp(); int getpid(); @@ -255,6 +255,16 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func fsyncRange(fd int, how int, start int64, length int64) (err error) { + r0, er := C.fsync_range(C.int(fd), C.int(how), C.longlong(start), C.longlong(length)) + if r0 == -1 && er != nil { + err = er + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Acct(path string) (err error) { _p0 := uintptr(unsafe.Pointer(C.CString(path))) r0, er := C.acct(C.uintptr_t(_p0)) @@ -379,16 +389,6 @@ func Fdatasync(fd int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Fsync(fd int) (err error) { - r0, er := C.fsync(C.int(fd)) - if r0 == -1 && er != nil { - err = er - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Getpgid(pid int) (pgid int, err error) { r0, er := C.getpgid(C.int(pid)) pgid = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go index 33c2609b8b4..f1d4a73b089 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go @@ -135,6 +135,16 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func fsyncRange(fd int, how int, start int64, length int64) (err error) { + _, e1 := callfsync_range(fd, how, start, length) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Acct(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -283,16 +293,6 @@ func Fdatasync(fd int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Fsync(fd int) (err error) { - _, e1 := callfsync(fd) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Getpgid(pid int) (pgid int, err error) { r0, e1 := callgetpgid(pid) pgid = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go index 8b737fa971e..2caa5adf950 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go @@ -18,6 +18,7 @@ import ( //go:cgo_import_dynamic libc_wait4 wait4 "libc.a/shr_64.o" //go:cgo_import_dynamic libc_ioctl ioctl "libc.a/shr_64.o" //go:cgo_import_dynamic libc_fcntl fcntl "libc.a/shr_64.o" +//go:cgo_import_dynamic libc_fsync_range fsync_range "libc.a/shr_64.o" //go:cgo_import_dynamic libc_acct acct "libc.a/shr_64.o" //go:cgo_import_dynamic libc_chdir chdir "libc.a/shr_64.o" //go:cgo_import_dynamic libc_chroot chroot "libc.a/shr_64.o" @@ -30,7 +31,6 @@ import ( //go:cgo_import_dynamic libc_fchmodat fchmodat "libc.a/shr_64.o" //go:cgo_import_dynamic libc_fchownat fchownat "libc.a/shr_64.o" //go:cgo_import_dynamic libc_fdatasync fdatasync "libc.a/shr_64.o" -//go:cgo_import_dynamic libc_fsync fsync "libc.a/shr_64.o" //go:cgo_import_dynamic libc_getpgid getpgid "libc.a/shr_64.o" //go:cgo_import_dynamic libc_getpgrp getpgrp "libc.a/shr_64.o" //go:cgo_import_dynamic libc_getpid getpid "libc.a/shr_64.o" @@ -136,6 +136,7 @@ import ( //go:linkname libc_wait4 libc_wait4 //go:linkname libc_ioctl libc_ioctl //go:linkname libc_fcntl libc_fcntl +//go:linkname libc_fsync_range libc_fsync_range //go:linkname libc_acct libc_acct //go:linkname libc_chdir libc_chdir //go:linkname libc_chroot libc_chroot @@ -148,7 +149,6 @@ import ( //go:linkname libc_fchmodat libc_fchmodat //go:linkname libc_fchownat libc_fchownat //go:linkname libc_fdatasync libc_fdatasync -//go:linkname libc_fsync libc_fsync //go:linkname libc_getpgid libc_getpgid //go:linkname libc_getpgrp libc_getpgrp //go:linkname libc_getpid libc_getpid @@ -257,6 +257,7 @@ var ( libc_wait4, libc_ioctl, libc_fcntl, + libc_fsync_range, libc_acct, libc_chdir, libc_chroot, @@ -269,7 +270,6 @@ var ( libc_fchmodat, libc_fchownat, libc_fdatasync, - libc_fsync, libc_getpgid, libc_getpgrp, libc_getpid, @@ -430,6 +430,13 @@ func callfcntl(fd uintptr, cmd int, arg uintptr) (r1 uintptr, e1 Errno) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func callfsync_range(fd int, how int, start int64, length int64) (r1 uintptr, e1 Errno) { + r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_fsync_range)), 4, uintptr(fd), uintptr(how), uintptr(start), uintptr(length), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func callacct(_p0 uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_acct)), 1, _p0, 0, 0, 0, 0, 0) return @@ -514,13 +521,6 @@ func callfdatasync(fd int) (r1 uintptr, e1 Errno) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func callfsync(fd int) (r1 uintptr, e1 Errno) { - r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_fsync)), 1, uintptr(fd), 0, 0, 0, 0, 0) - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func callgetpgid(pid int) (r1 uintptr, e1 Errno) { r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_getpgid)), 1, uintptr(pid), 0, 0, 0, 0, 0) return diff --git a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go index 3c260917ed5..944a714b1ad 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go @@ -16,6 +16,7 @@ int getdirent(int, uintptr_t, size_t); int wait4(int, uintptr_t, int, uintptr_t); int ioctl(int, int, uintptr_t); int fcntl(uintptr_t, int, uintptr_t); +int fsync_range(int, int, long long, long long); int acct(uintptr_t); int chdir(uintptr_t); int chroot(uintptr_t); @@ -28,7 +29,6 @@ int fchmod(int, unsigned int); int fchmodat(int, uintptr_t, unsigned int, int); int fchownat(int, uintptr_t, int, int, int); int fdatasync(int); -int fsync(int); int getpgid(int); int getpgrp(); int getpid(); @@ -199,6 +199,14 @@ func callfcntl(fd uintptr, cmd int, arg uintptr) (r1 uintptr, e1 Errno) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func callfsync_range(fd int, how int, start int64, length int64) (r1 uintptr, e1 Errno) { + r1 = uintptr(C.fsync_range(C.int(fd), C.int(how), C.longlong(start), C.longlong(length))) + e1 = syscall.GetErrno() + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func callacct(_p0 uintptr) (r1 uintptr, e1 Errno) { r1 = uintptr(C.acct(C.uintptr_t(_p0))) e1 = syscall.GetErrno() @@ -295,14 +303,6 @@ func callfdatasync(fd int) (r1 uintptr, e1 Errno) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func callfsync(fd int) (r1 uintptr, e1 Errno) { - r1 = uintptr(C.fsync(C.int(fd))) - e1 = syscall.GetErrno() - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func callgetpgid(pid int) (r1 uintptr, e1 Errno) { r1 = uintptr(C.getpgid(C.int(pid))) e1 = syscall.GetErrno() diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux.go b/vendor/golang.org/x/sys/unix/zsyscall_linux.go index 4f5da1f54f8..93edda4c493 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux.go @@ -1,4 +1,4 @@ -// Code generated by mkmerge.go; DO NOT EDIT. +// Code generated by mkmerge; DO NOT EDIT. //go:build linux // +build linux @@ -409,6 +409,21 @@ func mount(source string, target string, fstype string, flags uintptr, data *byt // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func mountSetattr(dirfd int, pathname string, flags uint, attr *MountAttr, size uintptr) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(pathname) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MOUNT_SETATTR, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(unsafe.Pointer(attr)), uintptr(size), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Acct(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go index 4726ab30a8f..51d0c0742bf 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go @@ -351,18 +351,6 @@ func Munlockall() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe() (fd1 int, fd2 int, err error) { - r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) - fd1 = int(r0) - fd2 = int(r1) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func pipe2(p *[2]_C_int, flags int) (err error) { _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go index fe71456dbc0..df2efb6db3f 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go @@ -351,18 +351,6 @@ func Munlockall() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe() (fd1 int, fd2 int, err error) { - r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) - fd1 = int(r0) - fd2 = int(r1) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func pipe2(p *[2]_C_int, flags int) (err error) { _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go index 0b5b2f0143b..c8536c2c9f0 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go @@ -351,18 +351,6 @@ func Munlockall() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe() (fd1 int, fd2 int, err error) { - r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) - fd1 = int(r0) - fd2 = int(r1) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func pipe2(p *[2]_C_int, flags int) (err error) { _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go index bfca28648fb..8b981bfc2eb 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go @@ -351,18 +351,6 @@ func Munlockall() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe() (fd1 int, fd2 int, err error) { - r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) - fd1 = int(r0) - fd2 = int(r1) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func pipe2(p *[2]_C_int, flags int) (err error) { _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go index aa7ce85d155..31847d2305f 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go @@ -444,4 +444,5 @@ const ( SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_MEMFD_SECRET = 447 + SYS_PROCESS_MRELEASE = 448 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go index b830326386c..3503cbbde38 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go @@ -366,4 +366,5 @@ const ( SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_MEMFD_SECRET = 447 + SYS_PROCESS_MRELEASE = 448 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go index d75f65a0aa7..5ecd24bf683 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go @@ -7,6 +7,7 @@ package unix const ( + SYS_SYSCALL_MASK = 0 SYS_RESTART_SYSCALL = 0 SYS_EXIT = 1 SYS_FORK = 2 @@ -407,4 +408,5 @@ const ( SYS_LANDLOCK_CREATE_RULESET = 444 SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_RESTRICT_SELF = 446 + SYS_PROCESS_MRELEASE = 448 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go index 8b02f09e9b5..7e5c94cc7fe 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go @@ -311,4 +311,5 @@ const ( SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_MEMFD_SECRET = 447 + SYS_PROCESS_MRELEASE = 448 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go index 026695abb1a..e1e2a2bf59e 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go @@ -428,4 +428,5 @@ const ( SYS_LANDLOCK_CREATE_RULESET = 4444 SYS_LANDLOCK_ADD_RULE = 4445 SYS_LANDLOCK_RESTRICT_SELF = 4446 + SYS_PROCESS_MRELEASE = 4448 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go index 7320ba95833..7651915a3ad 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go @@ -358,4 +358,5 @@ const ( SYS_LANDLOCK_CREATE_RULESET = 5444 SYS_LANDLOCK_ADD_RULE = 5445 SYS_LANDLOCK_RESTRICT_SELF = 5446 + SYS_PROCESS_MRELEASE = 5448 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go index 45082dd67ff..a26a2c050bc 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go @@ -358,4 +358,5 @@ const ( SYS_LANDLOCK_CREATE_RULESET = 5444 SYS_LANDLOCK_ADD_RULE = 5445 SYS_LANDLOCK_RESTRICT_SELF = 5446 + SYS_PROCESS_MRELEASE = 5448 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go index 570a857a56e..fda9a6a9913 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go @@ -428,4 +428,5 @@ const ( SYS_LANDLOCK_CREATE_RULESET = 4444 SYS_LANDLOCK_ADD_RULE = 4445 SYS_LANDLOCK_RESTRICT_SELF = 4446 + SYS_PROCESS_MRELEASE = 4448 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go index 638498d62e2..e8496150d41 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go @@ -435,4 +435,5 @@ const ( SYS_LANDLOCK_CREATE_RULESET = 444 SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_RESTRICT_SELF = 446 + SYS_PROCESS_MRELEASE = 448 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go index 702beebfefe..5ee0678a360 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go @@ -407,4 +407,5 @@ const ( SYS_LANDLOCK_CREATE_RULESET = 444 SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_RESTRICT_SELF = 446 + SYS_PROCESS_MRELEASE = 448 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go index bfc87ea4443..29c0f9a39ea 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go @@ -407,4 +407,5 @@ const ( SYS_LANDLOCK_CREATE_RULESET = 444 SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_RESTRICT_SELF = 446 + SYS_PROCESS_MRELEASE = 448 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go index a390e147d3c..5c9a9a3b61c 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go @@ -309,4 +309,5 @@ const ( SYS_LANDLOCK_CREATE_RULESET = 444 SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_RESTRICT_SELF = 446 + SYS_PROCESS_MRELEASE = 448 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go index 3e791e6cd22..913f50f98b9 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go @@ -372,4 +372,5 @@ const ( SYS_LANDLOCK_CREATE_RULESET = 444 SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_RESTRICT_SELF = 446 + SYS_PROCESS_MRELEASE = 448 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go index 78802a5cf7c..0de03a7227c 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go @@ -386,4 +386,5 @@ const ( SYS_LANDLOCK_CREATE_RULESET = 444 SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_RESTRICT_SELF = 446 + SYS_PROCESS_MRELEASE = 448 ) diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go index 7efe5ccba33..885842c0eb4 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go @@ -641,13 +641,13 @@ type Eproc struct { Tdev int32 Tpgid int32 Tsess uintptr - Wmesg [8]int8 + Wmesg [8]byte Xsize int32 Xrssize int16 Xccount int16 Xswrss int16 Flag int32 - Login [12]int8 + Login [12]byte Spare [4]int32 _ [4]byte } @@ -688,7 +688,7 @@ type ExternProc struct { P_priority uint8 P_usrpri uint8 P_nice int8 - P_comm [17]int8 + P_comm [17]byte P_pgrp uintptr P_addr uintptr P_xstat uint16 diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go index b23a2efe81b..b23c02337db 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go @@ -641,13 +641,13 @@ type Eproc struct { Tdev int32 Tpgid int32 Tsess uintptr - Wmesg [8]int8 + Wmesg [8]byte Xsize int32 Xrssize int16 Xccount int16 Xswrss int16 Flag int32 - Login [12]int8 + Login [12]byte Spare [4]int32 _ [4]byte } @@ -688,7 +688,7 @@ type ExternProc struct { P_priority uint8 P_usrpri uint8 P_nice int8 - P_comm [17]int8 + P_comm [17]byte P_pgrp uintptr P_addr uintptr P_xstat uint16 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux.go b/vendor/golang.org/x/sys/unix/ztypes_linux.go index 249ecfcd4cc..f6f0d79c42e 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux.go @@ -1,4 +1,4 @@ -// Code generated by mkmerge.go; DO NOT EDIT. +// Code generated by mkmerge; DO NOT EDIT. //go:build linux // +build linux @@ -743,6 +743,8 @@ const ( AT_STATX_FORCE_SYNC = 0x2000 AT_STATX_DONT_SYNC = 0x4000 + AT_RECURSIVE = 0x8000 + AT_SYMLINK_FOLLOW = 0x400 AT_SYMLINK_NOFOLLOW = 0x100 @@ -865,6 +867,7 @@ const ( CTRL_CMD_NEWMCAST_GRP = 0x7 CTRL_CMD_DELMCAST_GRP = 0x8 CTRL_CMD_GETMCAST_GRP = 0x9 + CTRL_CMD_GETPOLICY = 0xa CTRL_ATTR_UNSPEC = 0x0 CTRL_ATTR_FAMILY_ID = 0x1 CTRL_ATTR_FAMILY_NAME = 0x2 @@ -873,12 +876,19 @@ const ( CTRL_ATTR_MAXATTR = 0x5 CTRL_ATTR_OPS = 0x6 CTRL_ATTR_MCAST_GROUPS = 0x7 + CTRL_ATTR_POLICY = 0x8 + CTRL_ATTR_OP_POLICY = 0x9 + CTRL_ATTR_OP = 0xa CTRL_ATTR_OP_UNSPEC = 0x0 CTRL_ATTR_OP_ID = 0x1 CTRL_ATTR_OP_FLAGS = 0x2 CTRL_ATTR_MCAST_GRP_UNSPEC = 0x0 CTRL_ATTR_MCAST_GRP_NAME = 0x1 CTRL_ATTR_MCAST_GRP_ID = 0x2 + CTRL_ATTR_POLICY_UNSPEC = 0x0 + CTRL_ATTR_POLICY_DO = 0x1 + CTRL_ATTR_POLICY_DUMP = 0x2 + CTRL_ATTR_POLICY_DUMP_MAX = 0x2 ) const ( @@ -3264,7 +3274,8 @@ const ( LWTUNNEL_ENCAP_BPF = 0x6 LWTUNNEL_ENCAP_SEG6_LOCAL = 0x7 LWTUNNEL_ENCAP_RPL = 0x8 - LWTUNNEL_ENCAP_MAX = 0x8 + LWTUNNEL_ENCAP_IOAM6 = 0x9 + LWTUNNEL_ENCAP_MAX = 0x9 MPLS_IPTUNNEL_UNSPEC = 0x0 MPLS_IPTUNNEL_DST = 0x1 @@ -3617,7 +3628,9 @@ const ( ETHTOOL_A_COALESCE_TX_USECS_HIGH = 0x15 ETHTOOL_A_COALESCE_TX_MAX_FRAMES_HIGH = 0x16 ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL = 0x17 - ETHTOOL_A_COALESCE_MAX = 0x17 + ETHTOOL_A_COALESCE_USE_CQE_MODE_TX = 0x18 + ETHTOOL_A_COALESCE_USE_CQE_MODE_RX = 0x19 + ETHTOOL_A_COALESCE_MAX = 0x19 ETHTOOL_A_PAUSE_UNSPEC = 0x0 ETHTOOL_A_PAUSE_HEADER = 0x1 ETHTOOL_A_PAUSE_AUTONEG = 0x2 @@ -3956,3 +3969,77 @@ const ( SHM_RDONLY = 0x1000 SHM_RND = 0x2000 ) + +type MountAttr struct { + Attr_set uint64 + Attr_clr uint64 + Propagation uint64 + Userns_fd uint64 +} + +const ( + WG_CMD_GET_DEVICE = 0x0 + WG_CMD_SET_DEVICE = 0x1 + WGDEVICE_F_REPLACE_PEERS = 0x1 + WGDEVICE_A_UNSPEC = 0x0 + WGDEVICE_A_IFINDEX = 0x1 + WGDEVICE_A_IFNAME = 0x2 + WGDEVICE_A_PRIVATE_KEY = 0x3 + WGDEVICE_A_PUBLIC_KEY = 0x4 + WGDEVICE_A_FLAGS = 0x5 + WGDEVICE_A_LISTEN_PORT = 0x6 + WGDEVICE_A_FWMARK = 0x7 + WGDEVICE_A_PEERS = 0x8 + WGPEER_F_REMOVE_ME = 0x1 + WGPEER_F_REPLACE_ALLOWEDIPS = 0x2 + WGPEER_F_UPDATE_ONLY = 0x4 + WGPEER_A_UNSPEC = 0x0 + WGPEER_A_PUBLIC_KEY = 0x1 + WGPEER_A_PRESHARED_KEY = 0x2 + WGPEER_A_FLAGS = 0x3 + WGPEER_A_ENDPOINT = 0x4 + WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL = 0x5 + WGPEER_A_LAST_HANDSHAKE_TIME = 0x6 + WGPEER_A_RX_BYTES = 0x7 + WGPEER_A_TX_BYTES = 0x8 + WGPEER_A_ALLOWEDIPS = 0x9 + WGPEER_A_PROTOCOL_VERSION = 0xa + WGALLOWEDIP_A_UNSPEC = 0x0 + WGALLOWEDIP_A_FAMILY = 0x1 + WGALLOWEDIP_A_IPADDR = 0x2 + WGALLOWEDIP_A_CIDR_MASK = 0x3 +) + +const ( + NL_ATTR_TYPE_INVALID = 0x0 + NL_ATTR_TYPE_FLAG = 0x1 + NL_ATTR_TYPE_U8 = 0x2 + NL_ATTR_TYPE_U16 = 0x3 + NL_ATTR_TYPE_U32 = 0x4 + NL_ATTR_TYPE_U64 = 0x5 + NL_ATTR_TYPE_S8 = 0x6 + NL_ATTR_TYPE_S16 = 0x7 + NL_ATTR_TYPE_S32 = 0x8 + NL_ATTR_TYPE_S64 = 0x9 + NL_ATTR_TYPE_BINARY = 0xa + NL_ATTR_TYPE_STRING = 0xb + NL_ATTR_TYPE_NUL_STRING = 0xc + NL_ATTR_TYPE_NESTED = 0xd + NL_ATTR_TYPE_NESTED_ARRAY = 0xe + NL_ATTR_TYPE_BITFIELD32 = 0xf + + NL_POLICY_TYPE_ATTR_UNSPEC = 0x0 + NL_POLICY_TYPE_ATTR_TYPE = 0x1 + NL_POLICY_TYPE_ATTR_MIN_VALUE_S = 0x2 + NL_POLICY_TYPE_ATTR_MAX_VALUE_S = 0x3 + NL_POLICY_TYPE_ATTR_MIN_VALUE_U = 0x4 + NL_POLICY_TYPE_ATTR_MAX_VALUE_U = 0x5 + NL_POLICY_TYPE_ATTR_MIN_LENGTH = 0x6 + NL_POLICY_TYPE_ATTR_MAX_LENGTH = 0x7 + NL_POLICY_TYPE_ATTR_POLICY_IDX = 0x8 + NL_POLICY_TYPE_ATTR_POLICY_MAXTYPE = 0x9 + NL_POLICY_TYPE_ATTR_BITFIELD32_MASK = 0xa + NL_POLICY_TYPE_ATTR_PAD = 0xb + NL_POLICY_TYPE_ATTR_MASK = 0xc + NL_POLICY_TYPE_ATTR_MAX = 0xc +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_386.go b/vendor/golang.org/x/sys/unix/ztypes_linux_386.go index eeeb9aa39ac..bea2549455e 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_386.go @@ -1,4 +1,4 @@ -// cgo -godefs -- -Wall -Werror -static -I/tmp/include -m32 /build/linux/types.go | go run mkpost.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include -m32 /build/unix/linux/types.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. //go:build 386 && linux diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go index d30e1155cc0..b8c8f289433 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go @@ -1,4 +1,4 @@ -// cgo -godefs -- -Wall -Werror -static -I/tmp/include -m64 /build/linux/types.go | go run mkpost.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include -m64 /build/unix/linux/types.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. //go:build amd64 && linux diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go b/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go index 69d0297520c..4db44301632 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go @@ -1,4 +1,4 @@ -// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/linux/types.go | go run mkpost.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/linux/types.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. //go:build arm && linux diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go index 28a0455bc9d..3ebcad8a887 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go @@ -1,4 +1,4 @@ -// cgo -godefs -- -Wall -Werror -static -I/tmp/include -fsigned-char /build/linux/types.go | go run mkpost.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include -fsigned-char /build/unix/linux/types.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. //go:build arm64 && linux diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go index 64a845483db..3eb33e48ab5 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go @@ -1,4 +1,4 @@ -// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/linux/types.go | go run mkpost.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/linux/types.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. //go:build mips && linux diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go index a1b7dee4123..79a94467252 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go @@ -1,4 +1,4 @@ -// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/linux/types.go | go run mkpost.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/linux/types.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. //go:build mips64 && linux diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go index 936fa6a266f..8f4b107cad3 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go @@ -1,4 +1,4 @@ -// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/linux/types.go | go run mkpost.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/linux/types.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. //go:build mips64le && linux diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go index 5dd546fbf07..e4eb2179811 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go @@ -1,4 +1,4 @@ -// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/linux/types.go | go run mkpost.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/linux/types.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. //go:build mipsle && linux diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc.go index 947b32e434b..d5b21f0f7da 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc.go @@ -1,4 +1,4 @@ -// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/linux/types.go | go run mkpost.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/linux/types.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. //go:build ppc && linux diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go index 2a606151b0c..5188d142b9f 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go @@ -1,4 +1,4 @@ -// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/linux/types.go | go run mkpost.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/linux/types.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. //go:build ppc64 && linux diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go index d0d735d02cd..de4dd4c736e 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go @@ -1,4 +1,4 @@ -// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/linux/types.go | go run mkpost.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/linux/types.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. //go:build ppc64le && linux diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go index 95e3d6d06fc..dccbf9b0604 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go @@ -1,4 +1,4 @@ -// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/linux/types.go | go run mkpost.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/linux/types.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. //go:build riscv64 && linux diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go b/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go index cccf1ef26a6..6358806106f 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go @@ -1,4 +1,4 @@ -// cgo -godefs -- -Wall -Werror -static -I/tmp/include -fsigned-char /build/linux/types.go | go run mkpost.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include -fsigned-char /build/unix/linux/types.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. //go:build s390x && linux diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go index 44fcbe4e9a1..765edc13ff2 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go @@ -1,4 +1,4 @@ -// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/linux/types.go | go run mkpost.go +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/linux/types.go | go run mkpost.go // Code generated by the command above; see README.md. DO NOT EDIT. //go:build sparc64 && linux diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go index 2a8b1e6f73f..baf5fe65044 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go @@ -564,12 +564,11 @@ type Uvmexp struct { Kmapent int32 } -const SizeofClockinfo = 0x14 +const SizeofClockinfo = 0x10 type Clockinfo struct { - Hz int32 - Tick int32 - Tickadj int32 - Stathz int32 - Profhz int32 + Hz int32 + Tick int32 + Stathz int32 + Profhz int32 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go index b1759cf705c..e21ae8ecfa6 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go @@ -564,12 +564,11 @@ type Uvmexp struct { Kmapent int32 } -const SizeofClockinfo = 0x14 +const SizeofClockinfo = 0x10 type Clockinfo struct { - Hz int32 - Tick int32 - Tickadj int32 - Stathz int32 - Profhz int32 + Hz int32 + Tick int32 + Stathz int32 + Profhz int32 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go index e807de2065c..f190651cd96 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go @@ -565,12 +565,11 @@ type Uvmexp struct { Kmapent int32 } -const SizeofClockinfo = 0x14 +const SizeofClockinfo = 0x10 type Clockinfo struct { - Hz int32 - Tick int32 - Tickadj int32 - Stathz int32 - Profhz int32 + Hz int32 + Tick int32 + Stathz int32 + Profhz int32 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm64.go index ff3aecaee40..84747c582cf 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm64.go @@ -558,12 +558,11 @@ type Uvmexp struct { Kmapent int32 } -const SizeofClockinfo = 0x14 +const SizeofClockinfo = 0x10 type Clockinfo struct { - Hz int32 - Tick int32 - Tickadj int32 - Stathz int32 - Profhz int32 + Hz int32 + Tick int32 + Stathz int32 + Profhz int32 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_mips64.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_mips64.go index 9ecda69174c..ac5c8b6370b 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_mips64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_mips64.go @@ -558,12 +558,11 @@ type Uvmexp struct { Kmapent int32 } -const SizeofClockinfo = 0x14 +const SizeofClockinfo = 0x10 type Clockinfo struct { - Hz int32 - Tick int32 - Tickadj int32 - Stathz int32 - Profhz int32 + Hz int32 + Tick int32 + Stathz int32 + Profhz int32 } diff --git a/vendor/golang.org/x/sys/windows/exec_windows.go b/vendor/golang.org/x/sys/windows/exec_windows.go index 7a11e83b7ec..855698bb282 100644 --- a/vendor/golang.org/x/sys/windows/exec_windows.go +++ b/vendor/golang.org/x/sys/windows/exec_windows.go @@ -9,8 +9,6 @@ package windows import ( errorspkg "errors" "unsafe" - - "golang.org/x/sys/internal/unsafeheader" ) // EscapeArg rewrites command line argument s as prescribed @@ -147,8 +145,12 @@ func NewProcThreadAttributeList(maxAttrCount uint32) (*ProcThreadAttributeListCo } return nil, err } + alloc, err := LocalAlloc(LMEM_FIXED, uint32(size)) + if err != nil { + return nil, err + } // size is guaranteed to be ≥1 by InitializeProcThreadAttributeList. - al := &ProcThreadAttributeListContainer{data: (*ProcThreadAttributeList)(unsafe.Pointer(&make([]byte, size)[0]))} + al := &ProcThreadAttributeListContainer{data: (*ProcThreadAttributeList)(unsafe.Pointer(alloc))} err = initializeProcThreadAttributeList(al.data, maxAttrCount, 0, &size) if err != nil { return nil, err @@ -157,36 +159,17 @@ func NewProcThreadAttributeList(maxAttrCount uint32) (*ProcThreadAttributeListCo } // Update modifies the ProcThreadAttributeList using UpdateProcThreadAttribute. -// Note that the value passed to this function will be copied into memory -// allocated by LocalAlloc, the contents of which should not contain any -// Go-managed pointers, even if the passed value itself is a Go-managed -// pointer. func (al *ProcThreadAttributeListContainer) Update(attribute uintptr, value unsafe.Pointer, size uintptr) error { - alloc, err := LocalAlloc(LMEM_FIXED, uint32(size)) - if err != nil { - return err - } - var src, dst []byte - hdr := (*unsafeheader.Slice)(unsafe.Pointer(&src)) - hdr.Data = value - hdr.Cap = int(size) - hdr.Len = int(size) - hdr = (*unsafeheader.Slice)(unsafe.Pointer(&dst)) - hdr.Data = unsafe.Pointer(alloc) - hdr.Cap = int(size) - hdr.Len = int(size) - copy(dst, src) - al.heapAllocations = append(al.heapAllocations, alloc) - return updateProcThreadAttribute(al.data, 0, attribute, unsafe.Pointer(alloc), size, nil, nil) + al.pointers = append(al.pointers, value) + return updateProcThreadAttribute(al.data, 0, attribute, value, size, nil, nil) } // Delete frees ProcThreadAttributeList's resources. func (al *ProcThreadAttributeListContainer) Delete() { deleteProcThreadAttributeList(al.data) - for i := range al.heapAllocations { - LocalFree(Handle(al.heapAllocations[i])) - } - al.heapAllocations = nil + LocalFree(Handle(unsafe.Pointer(al.data))) + al.data = nil + al.pointers = nil } // List returns the actual ProcThreadAttributeList to be passed to StartupInfoEx. diff --git a/vendor/golang.org/x/sys/windows/mksyscall.go b/vendor/golang.org/x/sys/windows/mksyscall.go index 6102910989b..8563f79c57f 100644 --- a/vendor/golang.org/x/sys/windows/mksyscall.go +++ b/vendor/golang.org/x/sys/windows/mksyscall.go @@ -7,4 +7,4 @@ package windows -//go:generate go run golang.org/x/sys/windows/mkwinsyscall -output zsyscall_windows.go eventlog.go service.go syscall_windows.go security_windows.go +//go:generate go run golang.org/x/sys/windows/mkwinsyscall -output zsyscall_windows.go eventlog.go service.go syscall_windows.go security_windows.go setupapi_windows.go diff --git a/vendor/golang.org/x/sys/windows/setupapi_windows.go b/vendor/golang.org/x/sys/windows/setupapi_windows.go new file mode 100644 index 00000000000..14027da3f3f --- /dev/null +++ b/vendor/golang.org/x/sys/windows/setupapi_windows.go @@ -0,0 +1,1425 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package windows + +import ( + "encoding/binary" + "errors" + "fmt" + "runtime" + "strings" + "syscall" + "unsafe" +) + +// This file contains functions that wrap SetupAPI.dll and CfgMgr32.dll, +// core system functions for managing hardware devices, drivers, and the PnP tree. +// Information about these APIs can be found at: +// https://docs.microsoft.com/en-us/windows-hardware/drivers/install/setupapi +// https://docs.microsoft.com/en-us/windows/win32/devinst/cfgmgr32- + +const ( + ERROR_EXPECTED_SECTION_NAME Errno = 0x20000000 | 0xC0000000 | 0 + ERROR_BAD_SECTION_NAME_LINE Errno = 0x20000000 | 0xC0000000 | 1 + ERROR_SECTION_NAME_TOO_LONG Errno = 0x20000000 | 0xC0000000 | 2 + ERROR_GENERAL_SYNTAX Errno = 0x20000000 | 0xC0000000 | 3 + ERROR_WRONG_INF_STYLE Errno = 0x20000000 | 0xC0000000 | 0x100 + ERROR_SECTION_NOT_FOUND Errno = 0x20000000 | 0xC0000000 | 0x101 + ERROR_LINE_NOT_FOUND Errno = 0x20000000 | 0xC0000000 | 0x102 + ERROR_NO_BACKUP Errno = 0x20000000 | 0xC0000000 | 0x103 + ERROR_NO_ASSOCIATED_CLASS Errno = 0x20000000 | 0xC0000000 | 0x200 + ERROR_CLASS_MISMATCH Errno = 0x20000000 | 0xC0000000 | 0x201 + ERROR_DUPLICATE_FOUND Errno = 0x20000000 | 0xC0000000 | 0x202 + ERROR_NO_DRIVER_SELECTED Errno = 0x20000000 | 0xC0000000 | 0x203 + ERROR_KEY_DOES_NOT_EXIST Errno = 0x20000000 | 0xC0000000 | 0x204 + ERROR_INVALID_DEVINST_NAME Errno = 0x20000000 | 0xC0000000 | 0x205 + ERROR_INVALID_CLASS Errno = 0x20000000 | 0xC0000000 | 0x206 + ERROR_DEVINST_ALREADY_EXISTS Errno = 0x20000000 | 0xC0000000 | 0x207 + ERROR_DEVINFO_NOT_REGISTERED Errno = 0x20000000 | 0xC0000000 | 0x208 + ERROR_INVALID_REG_PROPERTY Errno = 0x20000000 | 0xC0000000 | 0x209 + ERROR_NO_INF Errno = 0x20000000 | 0xC0000000 | 0x20A + ERROR_NO_SUCH_DEVINST Errno = 0x20000000 | 0xC0000000 | 0x20B + ERROR_CANT_LOAD_CLASS_ICON Errno = 0x20000000 | 0xC0000000 | 0x20C + ERROR_INVALID_CLASS_INSTALLER Errno = 0x20000000 | 0xC0000000 | 0x20D + ERROR_DI_DO_DEFAULT Errno = 0x20000000 | 0xC0000000 | 0x20E + ERROR_DI_NOFILECOPY Errno = 0x20000000 | 0xC0000000 | 0x20F + ERROR_INVALID_HWPROFILE Errno = 0x20000000 | 0xC0000000 | 0x210 + ERROR_NO_DEVICE_SELECTED Errno = 0x20000000 | 0xC0000000 | 0x211 + ERROR_DEVINFO_LIST_LOCKED Errno = 0x20000000 | 0xC0000000 | 0x212 + ERROR_DEVINFO_DATA_LOCKED Errno = 0x20000000 | 0xC0000000 | 0x213 + ERROR_DI_BAD_PATH Errno = 0x20000000 | 0xC0000000 | 0x214 + ERROR_NO_CLASSINSTALL_PARAMS Errno = 0x20000000 | 0xC0000000 | 0x215 + ERROR_FILEQUEUE_LOCKED Errno = 0x20000000 | 0xC0000000 | 0x216 + ERROR_BAD_SERVICE_INSTALLSECT Errno = 0x20000000 | 0xC0000000 | 0x217 + ERROR_NO_CLASS_DRIVER_LIST Errno = 0x20000000 | 0xC0000000 | 0x218 + ERROR_NO_ASSOCIATED_SERVICE Errno = 0x20000000 | 0xC0000000 | 0x219 + ERROR_NO_DEFAULT_DEVICE_INTERFACE Errno = 0x20000000 | 0xC0000000 | 0x21A + ERROR_DEVICE_INTERFACE_ACTIVE Errno = 0x20000000 | 0xC0000000 | 0x21B + ERROR_DEVICE_INTERFACE_REMOVED Errno = 0x20000000 | 0xC0000000 | 0x21C + ERROR_BAD_INTERFACE_INSTALLSECT Errno = 0x20000000 | 0xC0000000 | 0x21D + ERROR_NO_SUCH_INTERFACE_CLASS Errno = 0x20000000 | 0xC0000000 | 0x21E + ERROR_INVALID_REFERENCE_STRING Errno = 0x20000000 | 0xC0000000 | 0x21F + ERROR_INVALID_MACHINENAME Errno = 0x20000000 | 0xC0000000 | 0x220 + ERROR_REMOTE_COMM_FAILURE Errno = 0x20000000 | 0xC0000000 | 0x221 + ERROR_MACHINE_UNAVAILABLE Errno = 0x20000000 | 0xC0000000 | 0x222 + ERROR_NO_CONFIGMGR_SERVICES Errno = 0x20000000 | 0xC0000000 | 0x223 + ERROR_INVALID_PROPPAGE_PROVIDER Errno = 0x20000000 | 0xC0000000 | 0x224 + ERROR_NO_SUCH_DEVICE_INTERFACE Errno = 0x20000000 | 0xC0000000 | 0x225 + ERROR_DI_POSTPROCESSING_REQUIRED Errno = 0x20000000 | 0xC0000000 | 0x226 + ERROR_INVALID_COINSTALLER Errno = 0x20000000 | 0xC0000000 | 0x227 + ERROR_NO_COMPAT_DRIVERS Errno = 0x20000000 | 0xC0000000 | 0x228 + ERROR_NO_DEVICE_ICON Errno = 0x20000000 | 0xC0000000 | 0x229 + ERROR_INVALID_INF_LOGCONFIG Errno = 0x20000000 | 0xC0000000 | 0x22A + ERROR_DI_DONT_INSTALL Errno = 0x20000000 | 0xC0000000 | 0x22B + ERROR_INVALID_FILTER_DRIVER Errno = 0x20000000 | 0xC0000000 | 0x22C + ERROR_NON_WINDOWS_NT_DRIVER Errno = 0x20000000 | 0xC0000000 | 0x22D + ERROR_NON_WINDOWS_DRIVER Errno = 0x20000000 | 0xC0000000 | 0x22E + ERROR_NO_CATALOG_FOR_OEM_INF Errno = 0x20000000 | 0xC0000000 | 0x22F + ERROR_DEVINSTALL_QUEUE_NONNATIVE Errno = 0x20000000 | 0xC0000000 | 0x230 + ERROR_NOT_DISABLEABLE Errno = 0x20000000 | 0xC0000000 | 0x231 + ERROR_CANT_REMOVE_DEVINST Errno = 0x20000000 | 0xC0000000 | 0x232 + ERROR_INVALID_TARGET Errno = 0x20000000 | 0xC0000000 | 0x233 + ERROR_DRIVER_NONNATIVE Errno = 0x20000000 | 0xC0000000 | 0x234 + ERROR_IN_WOW64 Errno = 0x20000000 | 0xC0000000 | 0x235 + ERROR_SET_SYSTEM_RESTORE_POINT Errno = 0x20000000 | 0xC0000000 | 0x236 + ERROR_SCE_DISABLED Errno = 0x20000000 | 0xC0000000 | 0x238 + ERROR_UNKNOWN_EXCEPTION Errno = 0x20000000 | 0xC0000000 | 0x239 + ERROR_PNP_REGISTRY_ERROR Errno = 0x20000000 | 0xC0000000 | 0x23A + ERROR_REMOTE_REQUEST_UNSUPPORTED Errno = 0x20000000 | 0xC0000000 | 0x23B + ERROR_NOT_AN_INSTALLED_OEM_INF Errno = 0x20000000 | 0xC0000000 | 0x23C + ERROR_INF_IN_USE_BY_DEVICES Errno = 0x20000000 | 0xC0000000 | 0x23D + ERROR_DI_FUNCTION_OBSOLETE Errno = 0x20000000 | 0xC0000000 | 0x23E + ERROR_NO_AUTHENTICODE_CATALOG Errno = 0x20000000 | 0xC0000000 | 0x23F + ERROR_AUTHENTICODE_DISALLOWED Errno = 0x20000000 | 0xC0000000 | 0x240 + ERROR_AUTHENTICODE_TRUSTED_PUBLISHER Errno = 0x20000000 | 0xC0000000 | 0x241 + ERROR_AUTHENTICODE_TRUST_NOT_ESTABLISHED Errno = 0x20000000 | 0xC0000000 | 0x242 + ERROR_AUTHENTICODE_PUBLISHER_NOT_TRUSTED Errno = 0x20000000 | 0xC0000000 | 0x243 + ERROR_SIGNATURE_OSATTRIBUTE_MISMATCH Errno = 0x20000000 | 0xC0000000 | 0x244 + ERROR_ONLY_VALIDATE_VIA_AUTHENTICODE Errno = 0x20000000 | 0xC0000000 | 0x245 + ERROR_DEVICE_INSTALLER_NOT_READY Errno = 0x20000000 | 0xC0000000 | 0x246 + ERROR_DRIVER_STORE_ADD_FAILED Errno = 0x20000000 | 0xC0000000 | 0x247 + ERROR_DEVICE_INSTALL_BLOCKED Errno = 0x20000000 | 0xC0000000 | 0x248 + ERROR_DRIVER_INSTALL_BLOCKED Errno = 0x20000000 | 0xC0000000 | 0x249 + ERROR_WRONG_INF_TYPE Errno = 0x20000000 | 0xC0000000 | 0x24A + ERROR_FILE_HASH_NOT_IN_CATALOG Errno = 0x20000000 | 0xC0000000 | 0x24B + ERROR_DRIVER_STORE_DELETE_FAILED Errno = 0x20000000 | 0xC0000000 | 0x24C + ERROR_UNRECOVERABLE_STACK_OVERFLOW Errno = 0x20000000 | 0xC0000000 | 0x300 + EXCEPTION_SPAPI_UNRECOVERABLE_STACK_OVERFLOW Errno = ERROR_UNRECOVERABLE_STACK_OVERFLOW + ERROR_NO_DEFAULT_INTERFACE_DEVICE Errno = ERROR_NO_DEFAULT_DEVICE_INTERFACE + ERROR_INTERFACE_DEVICE_ACTIVE Errno = ERROR_DEVICE_INTERFACE_ACTIVE + ERROR_INTERFACE_DEVICE_REMOVED Errno = ERROR_DEVICE_INTERFACE_REMOVED + ERROR_NO_SUCH_INTERFACE_DEVICE Errno = ERROR_NO_SUCH_DEVICE_INTERFACE +) + +const ( + MAX_DEVICE_ID_LEN = 200 + MAX_DEVNODE_ID_LEN = MAX_DEVICE_ID_LEN + MAX_GUID_STRING_LEN = 39 // 38 chars + terminator null + MAX_CLASS_NAME_LEN = 32 + MAX_PROFILE_LEN = 80 + MAX_CONFIG_VALUE = 9999 + MAX_INSTANCE_VALUE = 9999 + CONFIGMG_VERSION = 0x0400 +) + +// Maximum string length constants +const ( + LINE_LEN = 256 // Windows 9x-compatible maximum for displayable strings coming from a device INF. + MAX_INF_STRING_LENGTH = 4096 // Actual maximum size of an INF string (including string substitutions). + MAX_INF_SECTION_NAME_LENGTH = 255 // For Windows 9x compatibility, INF section names should be constrained to 32 characters. + MAX_TITLE_LEN = 60 + MAX_INSTRUCTION_LEN = 256 + MAX_LABEL_LEN = 30 + MAX_SERVICE_NAME_LEN = 256 + MAX_SUBTITLE_LEN = 256 +) + +const ( + // SP_MAX_MACHINENAME_LENGTH defines maximum length of a machine name in the format expected by ConfigMgr32 CM_Connect_Machine (i.e., "\\\\MachineName\0"). + SP_MAX_MACHINENAME_LENGTH = MAX_PATH + 3 +) + +// HSPFILEQ is type for setup file queue +type HSPFILEQ uintptr + +// DevInfo holds reference to device information set +type DevInfo Handle + +// DEVINST is a handle usually recognized by cfgmgr32 APIs +type DEVINST uint32 + +// DevInfoData is a device information structure (references a device instance that is a member of a device information set) +type DevInfoData struct { + size uint32 + ClassGUID GUID + DevInst DEVINST + _ uintptr +} + +// DevInfoListDetailData is a structure for detailed information on a device information set (used for SetupDiGetDeviceInfoListDetail which supersedes the functionality of SetupDiGetDeviceInfoListClass). +type DevInfoListDetailData struct { + size uint32 // Use unsafeSizeOf method + ClassGUID GUID + RemoteMachineHandle Handle + remoteMachineName [SP_MAX_MACHINENAME_LENGTH]uint16 +} + +func (*DevInfoListDetailData) unsafeSizeOf() uint32 { + if unsafe.Sizeof(uintptr(0)) == 4 { + // Windows declares this with pshpack1.h + return uint32(unsafe.Offsetof(DevInfoListDetailData{}.remoteMachineName) + unsafe.Sizeof(DevInfoListDetailData{}.remoteMachineName)) + } + return uint32(unsafe.Sizeof(DevInfoListDetailData{})) +} + +func (data *DevInfoListDetailData) RemoteMachineName() string { + return UTF16ToString(data.remoteMachineName[:]) +} + +func (data *DevInfoListDetailData) SetRemoteMachineName(remoteMachineName string) error { + str, err := UTF16FromString(remoteMachineName) + if err != nil { + return err + } + copy(data.remoteMachineName[:], str) + return nil +} + +// DI_FUNCTION is function type for device installer +type DI_FUNCTION uint32 + +const ( + DIF_SELECTDEVICE DI_FUNCTION = 0x00000001 + DIF_INSTALLDEVICE DI_FUNCTION = 0x00000002 + DIF_ASSIGNRESOURCES DI_FUNCTION = 0x00000003 + DIF_PROPERTIES DI_FUNCTION = 0x00000004 + DIF_REMOVE DI_FUNCTION = 0x00000005 + DIF_FIRSTTIMESETUP DI_FUNCTION = 0x00000006 + DIF_FOUNDDEVICE DI_FUNCTION = 0x00000007 + DIF_SELECTCLASSDRIVERS DI_FUNCTION = 0x00000008 + DIF_VALIDATECLASSDRIVERS DI_FUNCTION = 0x00000009 + DIF_INSTALLCLASSDRIVERS DI_FUNCTION = 0x0000000A + DIF_CALCDISKSPACE DI_FUNCTION = 0x0000000B + DIF_DESTROYPRIVATEDATA DI_FUNCTION = 0x0000000C + DIF_VALIDATEDRIVER DI_FUNCTION = 0x0000000D + DIF_DETECT DI_FUNCTION = 0x0000000F + DIF_INSTALLWIZARD DI_FUNCTION = 0x00000010 + DIF_DESTROYWIZARDDATA DI_FUNCTION = 0x00000011 + DIF_PROPERTYCHANGE DI_FUNCTION = 0x00000012 + DIF_ENABLECLASS DI_FUNCTION = 0x00000013 + DIF_DETECTVERIFY DI_FUNCTION = 0x00000014 + DIF_INSTALLDEVICEFILES DI_FUNCTION = 0x00000015 + DIF_UNREMOVE DI_FUNCTION = 0x00000016 + DIF_SELECTBESTCOMPATDRV DI_FUNCTION = 0x00000017 + DIF_ALLOW_INSTALL DI_FUNCTION = 0x00000018 + DIF_REGISTERDEVICE DI_FUNCTION = 0x00000019 + DIF_NEWDEVICEWIZARD_PRESELECT DI_FUNCTION = 0x0000001A + DIF_NEWDEVICEWIZARD_SELECT DI_FUNCTION = 0x0000001B + DIF_NEWDEVICEWIZARD_PREANALYZE DI_FUNCTION = 0x0000001C + DIF_NEWDEVICEWIZARD_POSTANALYZE DI_FUNCTION = 0x0000001D + DIF_NEWDEVICEWIZARD_FINISHINSTALL DI_FUNCTION = 0x0000001E + DIF_INSTALLINTERFACES DI_FUNCTION = 0x00000020 + DIF_DETECTCANCEL DI_FUNCTION = 0x00000021 + DIF_REGISTER_COINSTALLERS DI_FUNCTION = 0x00000022 + DIF_ADDPROPERTYPAGE_ADVANCED DI_FUNCTION = 0x00000023 + DIF_ADDPROPERTYPAGE_BASIC DI_FUNCTION = 0x00000024 + DIF_TROUBLESHOOTER DI_FUNCTION = 0x00000026 + DIF_POWERMESSAGEWAKE DI_FUNCTION = 0x00000027 + DIF_ADDREMOTEPROPERTYPAGE_ADVANCED DI_FUNCTION = 0x00000028 + DIF_UPDATEDRIVER_UI DI_FUNCTION = 0x00000029 + DIF_FINISHINSTALL_ACTION DI_FUNCTION = 0x0000002A +) + +// DevInstallParams is device installation parameters structure (associated with a particular device information element, or globally with a device information set) +type DevInstallParams struct { + size uint32 + Flags DI_FLAGS + FlagsEx DI_FLAGSEX + hwndParent uintptr + InstallMsgHandler uintptr + InstallMsgHandlerContext uintptr + FileQueue HSPFILEQ + _ uintptr + _ uint32 + driverPath [MAX_PATH]uint16 +} + +func (params *DevInstallParams) DriverPath() string { + return UTF16ToString(params.driverPath[:]) +} + +func (params *DevInstallParams) SetDriverPath(driverPath string) error { + str, err := UTF16FromString(driverPath) + if err != nil { + return err + } + copy(params.driverPath[:], str) + return nil +} + +// DI_FLAGS is SP_DEVINSTALL_PARAMS.Flags values +type DI_FLAGS uint32 + +const ( + // Flags for choosing a device + DI_SHOWOEM DI_FLAGS = 0x00000001 // support Other... button + DI_SHOWCOMPAT DI_FLAGS = 0x00000002 // show compatibility list + DI_SHOWCLASS DI_FLAGS = 0x00000004 // show class list + DI_SHOWALL DI_FLAGS = 0x00000007 // both class & compat list shown + DI_NOVCP DI_FLAGS = 0x00000008 // don't create a new copy queue--use caller-supplied FileQueue + DI_DIDCOMPAT DI_FLAGS = 0x00000010 // Searched for compatible devices + DI_DIDCLASS DI_FLAGS = 0x00000020 // Searched for class devices + DI_AUTOASSIGNRES DI_FLAGS = 0x00000040 // No UI for resources if possible + + // Flags returned by DiInstallDevice to indicate need to reboot/restart + DI_NEEDRESTART DI_FLAGS = 0x00000080 // Reboot required to take effect + DI_NEEDREBOOT DI_FLAGS = 0x00000100 // "" + + // Flags for device installation + DI_NOBROWSE DI_FLAGS = 0x00000200 // no Browse... in InsertDisk + + // Flags set by DiBuildDriverInfoList + DI_MULTMFGS DI_FLAGS = 0x00000400 // Set if multiple manufacturers in class driver list + + // Flag indicates that device is disabled + DI_DISABLED DI_FLAGS = 0x00000800 // Set if device disabled + + // Flags for Device/Class Properties + DI_GENERALPAGE_ADDED DI_FLAGS = 0x00001000 + DI_RESOURCEPAGE_ADDED DI_FLAGS = 0x00002000 + + // Flag to indicate the setting properties for this Device (or class) caused a change so the Dev Mgr UI probably needs to be updated. + DI_PROPERTIES_CHANGE DI_FLAGS = 0x00004000 + + // Flag to indicate that the sorting from the INF file should be used. + DI_INF_IS_SORTED DI_FLAGS = 0x00008000 + + // Flag to indicate that only the the INF specified by SP_DEVINSTALL_PARAMS.DriverPath should be searched. + DI_ENUMSINGLEINF DI_FLAGS = 0x00010000 + + // Flag that prevents ConfigMgr from removing/re-enumerating devices during device + // registration, installation, and deletion. + DI_DONOTCALLCONFIGMG DI_FLAGS = 0x00020000 + + // The following flag can be used to install a device disabled + DI_INSTALLDISABLED DI_FLAGS = 0x00040000 + + // Flag that causes SetupDiBuildDriverInfoList to build a device's compatible driver + // list from its existing class driver list, instead of the normal INF search. + DI_COMPAT_FROM_CLASS DI_FLAGS = 0x00080000 + + // This flag is set if the Class Install params should be used. + DI_CLASSINSTALLPARAMS DI_FLAGS = 0x00100000 + + // This flag is set if the caller of DiCallClassInstaller does NOT want the internal default action performed if the Class installer returns ERROR_DI_DO_DEFAULT. + DI_NODI_DEFAULTACTION DI_FLAGS = 0x00200000 + + // Flags for device installation + DI_QUIETINSTALL DI_FLAGS = 0x00800000 // don't confuse the user with questions or excess info + DI_NOFILECOPY DI_FLAGS = 0x01000000 // No file Copy necessary + DI_FORCECOPY DI_FLAGS = 0x02000000 // Force files to be copied from install path + DI_DRIVERPAGE_ADDED DI_FLAGS = 0x04000000 // Prop provider added Driver page. + DI_USECI_SELECTSTRINGS DI_FLAGS = 0x08000000 // Use Class Installer Provided strings in the Select Device Dlg + DI_OVERRIDE_INFFLAGS DI_FLAGS = 0x10000000 // Override INF flags + DI_PROPS_NOCHANGEUSAGE DI_FLAGS = 0x20000000 // No Enable/Disable in General Props + + DI_NOSELECTICONS DI_FLAGS = 0x40000000 // No small icons in select device dialogs + + DI_NOWRITE_IDS DI_FLAGS = 0x80000000 // Don't write HW & Compat IDs on install +) + +// DI_FLAGSEX is SP_DEVINSTALL_PARAMS.FlagsEx values +type DI_FLAGSEX uint32 + +const ( + DI_FLAGSEX_CI_FAILED DI_FLAGSEX = 0x00000004 // Failed to Load/Call class installer + DI_FLAGSEX_FINISHINSTALL_ACTION DI_FLAGSEX = 0x00000008 // Class/co-installer wants to get a DIF_FINISH_INSTALL action in client context. + DI_FLAGSEX_DIDINFOLIST DI_FLAGSEX = 0x00000010 // Did the Class Info List + DI_FLAGSEX_DIDCOMPATINFO DI_FLAGSEX = 0x00000020 // Did the Compat Info List + DI_FLAGSEX_FILTERCLASSES DI_FLAGSEX = 0x00000040 + DI_FLAGSEX_SETFAILEDINSTALL DI_FLAGSEX = 0x00000080 + DI_FLAGSEX_DEVICECHANGE DI_FLAGSEX = 0x00000100 + DI_FLAGSEX_ALWAYSWRITEIDS DI_FLAGSEX = 0x00000200 + DI_FLAGSEX_PROPCHANGE_PENDING DI_FLAGSEX = 0x00000400 // One or more device property sheets have had changes made to them, and need to have a DIF_PROPERTYCHANGE occur. + DI_FLAGSEX_ALLOWEXCLUDEDDRVS DI_FLAGSEX = 0x00000800 + DI_FLAGSEX_NOUIONQUERYREMOVE DI_FLAGSEX = 0x00001000 + DI_FLAGSEX_USECLASSFORCOMPAT DI_FLAGSEX = 0x00002000 // Use the device's class when building compat drv list. (Ignored if DI_COMPAT_FROM_CLASS flag is specified.) + DI_FLAGSEX_NO_DRVREG_MODIFY DI_FLAGSEX = 0x00008000 // Don't run AddReg and DelReg for device's software (driver) key. + DI_FLAGSEX_IN_SYSTEM_SETUP DI_FLAGSEX = 0x00010000 // Installation is occurring during initial system setup. + DI_FLAGSEX_INET_DRIVER DI_FLAGSEX = 0x00020000 // Driver came from Windows Update + DI_FLAGSEX_APPENDDRIVERLIST DI_FLAGSEX = 0x00040000 // Cause SetupDiBuildDriverInfoList to append a new driver list to an existing list. + DI_FLAGSEX_PREINSTALLBACKUP DI_FLAGSEX = 0x00080000 // not used + DI_FLAGSEX_BACKUPONREPLACE DI_FLAGSEX = 0x00100000 // not used + DI_FLAGSEX_DRIVERLIST_FROM_URL DI_FLAGSEX = 0x00200000 // build driver list from INF(s) retrieved from URL specified in SP_DEVINSTALL_PARAMS.DriverPath (empty string means Windows Update website) + DI_FLAGSEX_EXCLUDE_OLD_INET_DRIVERS DI_FLAGSEX = 0x00800000 // Don't include old Internet drivers when building a driver list. Ignored on Windows Vista and later. + DI_FLAGSEX_POWERPAGE_ADDED DI_FLAGSEX = 0x01000000 // class installer added their own power page + DI_FLAGSEX_FILTERSIMILARDRIVERS DI_FLAGSEX = 0x02000000 // only include similar drivers in class list + DI_FLAGSEX_INSTALLEDDRIVER DI_FLAGSEX = 0x04000000 // only add the installed driver to the class or compat driver list. Used in calls to SetupDiBuildDriverInfoList + DI_FLAGSEX_NO_CLASSLIST_NODE_MERGE DI_FLAGSEX = 0x08000000 // Don't remove identical driver nodes from the class list + DI_FLAGSEX_ALTPLATFORM_DRVSEARCH DI_FLAGSEX = 0x10000000 // Build driver list based on alternate platform information specified in associated file queue + DI_FLAGSEX_RESTART_DEVICE_ONLY DI_FLAGSEX = 0x20000000 // only restart the device drivers are being installed on as opposed to restarting all devices using those drivers. + DI_FLAGSEX_RECURSIVESEARCH DI_FLAGSEX = 0x40000000 // Tell SetupDiBuildDriverInfoList to do a recursive search + DI_FLAGSEX_SEARCH_PUBLISHED_INFS DI_FLAGSEX = 0x80000000 // Tell SetupDiBuildDriverInfoList to do a "published INF" search +) + +// ClassInstallHeader is the first member of any class install parameters structure. It contains the device installation request code that defines the format of the rest of the install parameters structure. +type ClassInstallHeader struct { + size uint32 + InstallFunction DI_FUNCTION +} + +func MakeClassInstallHeader(installFunction DI_FUNCTION) *ClassInstallHeader { + hdr := &ClassInstallHeader{InstallFunction: installFunction} + hdr.size = uint32(unsafe.Sizeof(*hdr)) + return hdr +} + +// DICS_STATE specifies values indicating a change in a device's state +type DICS_STATE uint32 + +const ( + DICS_ENABLE DICS_STATE = 0x00000001 // The device is being enabled. + DICS_DISABLE DICS_STATE = 0x00000002 // The device is being disabled. + DICS_PROPCHANGE DICS_STATE = 0x00000003 // The properties of the device have changed. + DICS_START DICS_STATE = 0x00000004 // The device is being started (if the request is for the currently active hardware profile). + DICS_STOP DICS_STATE = 0x00000005 // The device is being stopped. The driver stack will be unloaded and the CSCONFIGFLAG_DO_NOT_START flag will be set for the device. +) + +// DICS_FLAG specifies the scope of a device property change +type DICS_FLAG uint32 + +const ( + DICS_FLAG_GLOBAL DICS_FLAG = 0x00000001 // make change in all hardware profiles + DICS_FLAG_CONFIGSPECIFIC DICS_FLAG = 0x00000002 // make change in specified profile only + DICS_FLAG_CONFIGGENERAL DICS_FLAG = 0x00000004 // 1 or more hardware profile-specific changes to follow (obsolete) +) + +// PropChangeParams is a structure corresponding to a DIF_PROPERTYCHANGE install function. +type PropChangeParams struct { + ClassInstallHeader ClassInstallHeader + StateChange DICS_STATE + Scope DICS_FLAG + HwProfile uint32 +} + +// DI_REMOVEDEVICE specifies the scope of the device removal +type DI_REMOVEDEVICE uint32 + +const ( + DI_REMOVEDEVICE_GLOBAL DI_REMOVEDEVICE = 0x00000001 // Make this change in all hardware profiles. Remove information about the device from the registry. + DI_REMOVEDEVICE_CONFIGSPECIFIC DI_REMOVEDEVICE = 0x00000002 // Make this change to only the hardware profile specified by HwProfile. this flag only applies to root-enumerated devices. When Windows removes the device from the last hardware profile in which it was configured, Windows performs a global removal. +) + +// RemoveDeviceParams is a structure corresponding to a DIF_REMOVE install function. +type RemoveDeviceParams struct { + ClassInstallHeader ClassInstallHeader + Scope DI_REMOVEDEVICE + HwProfile uint32 +} + +// DrvInfoData is driver information structure (member of a driver info list that may be associated with a particular device instance, or (globally) with a device information set) +type DrvInfoData struct { + size uint32 + DriverType uint32 + _ uintptr + description [LINE_LEN]uint16 + mfgName [LINE_LEN]uint16 + providerName [LINE_LEN]uint16 + DriverDate Filetime + DriverVersion uint64 +} + +func (data *DrvInfoData) Description() string { + return UTF16ToString(data.description[:]) +} + +func (data *DrvInfoData) SetDescription(description string) error { + str, err := UTF16FromString(description) + if err != nil { + return err + } + copy(data.description[:], str) + return nil +} + +func (data *DrvInfoData) MfgName() string { + return UTF16ToString(data.mfgName[:]) +} + +func (data *DrvInfoData) SetMfgName(mfgName string) error { + str, err := UTF16FromString(mfgName) + if err != nil { + return err + } + copy(data.mfgName[:], str) + return nil +} + +func (data *DrvInfoData) ProviderName() string { + return UTF16ToString(data.providerName[:]) +} + +func (data *DrvInfoData) SetProviderName(providerName string) error { + str, err := UTF16FromString(providerName) + if err != nil { + return err + } + copy(data.providerName[:], str) + return nil +} + +// IsNewer method returns true if DrvInfoData date and version is newer than supplied parameters. +func (data *DrvInfoData) IsNewer(driverDate Filetime, driverVersion uint64) bool { + if data.DriverDate.HighDateTime > driverDate.HighDateTime { + return true + } + if data.DriverDate.HighDateTime < driverDate.HighDateTime { + return false + } + + if data.DriverDate.LowDateTime > driverDate.LowDateTime { + return true + } + if data.DriverDate.LowDateTime < driverDate.LowDateTime { + return false + } + + if data.DriverVersion > driverVersion { + return true + } + if data.DriverVersion < driverVersion { + return false + } + + return false +} + +// DrvInfoDetailData is driver information details structure (provides detailed information about a particular driver information structure) +type DrvInfoDetailData struct { + size uint32 // Use unsafeSizeOf method + InfDate Filetime + compatIDsOffset uint32 + compatIDsLength uint32 + _ uintptr + sectionName [LINE_LEN]uint16 + infFileName [MAX_PATH]uint16 + drvDescription [LINE_LEN]uint16 + hardwareID [1]uint16 +} + +func (*DrvInfoDetailData) unsafeSizeOf() uint32 { + if unsafe.Sizeof(uintptr(0)) == 4 { + // Windows declares this with pshpack1.h + return uint32(unsafe.Offsetof(DrvInfoDetailData{}.hardwareID) + unsafe.Sizeof(DrvInfoDetailData{}.hardwareID)) + } + return uint32(unsafe.Sizeof(DrvInfoDetailData{})) +} + +func (data *DrvInfoDetailData) SectionName() string { + return UTF16ToString(data.sectionName[:]) +} + +func (data *DrvInfoDetailData) InfFileName() string { + return UTF16ToString(data.infFileName[:]) +} + +func (data *DrvInfoDetailData) DrvDescription() string { + return UTF16ToString(data.drvDescription[:]) +} + +func (data *DrvInfoDetailData) HardwareID() string { + if data.compatIDsOffset > 1 { + bufW := data.getBuf() + return UTF16ToString(bufW[:wcslen(bufW)]) + } + + return "" +} + +func (data *DrvInfoDetailData) CompatIDs() []string { + a := make([]string, 0) + + if data.compatIDsLength > 0 { + bufW := data.getBuf() + bufW = bufW[data.compatIDsOffset : data.compatIDsOffset+data.compatIDsLength] + for i := 0; i < len(bufW); { + j := i + wcslen(bufW[i:]) + if i < j { + a = append(a, UTF16ToString(bufW[i:j])) + } + i = j + 1 + } + } + + return a +} + +func (data *DrvInfoDetailData) getBuf() []uint16 { + len := (data.size - uint32(unsafe.Offsetof(data.hardwareID))) / 2 + sl := struct { + addr *uint16 + len int + cap int + }{&data.hardwareID[0], int(len), int(len)} + return *(*[]uint16)(unsafe.Pointer(&sl)) +} + +// IsCompatible method tests if given hardware ID matches the driver or is listed on the compatible ID list. +func (data *DrvInfoDetailData) IsCompatible(hwid string) bool { + hwidLC := strings.ToLower(hwid) + if strings.ToLower(data.HardwareID()) == hwidLC { + return true + } + a := data.CompatIDs() + for i := range a { + if strings.ToLower(a[i]) == hwidLC { + return true + } + } + + return false +} + +// DICD flags control SetupDiCreateDeviceInfo +type DICD uint32 + +const ( + DICD_GENERATE_ID DICD = 0x00000001 + DICD_INHERIT_CLASSDRVS DICD = 0x00000002 +) + +// SUOI flags control SetupUninstallOEMInf +type SUOI uint32 + +const ( + SUOI_FORCEDELETE SUOI = 0x0001 +) + +// SPDIT flags to distinguish between class drivers and +// device drivers. (Passed in 'DriverType' parameter of +// driver information list APIs) +type SPDIT uint32 + +const ( + SPDIT_NODRIVER SPDIT = 0x00000000 + SPDIT_CLASSDRIVER SPDIT = 0x00000001 + SPDIT_COMPATDRIVER SPDIT = 0x00000002 +) + +// DIGCF flags control what is included in the device information set built by SetupDiGetClassDevs +type DIGCF uint32 + +const ( + DIGCF_DEFAULT DIGCF = 0x00000001 // only valid with DIGCF_DEVICEINTERFACE + DIGCF_PRESENT DIGCF = 0x00000002 + DIGCF_ALLCLASSES DIGCF = 0x00000004 + DIGCF_PROFILE DIGCF = 0x00000008 + DIGCF_DEVICEINTERFACE DIGCF = 0x00000010 +) + +// DIREG specifies values for SetupDiCreateDevRegKey, SetupDiOpenDevRegKey, and SetupDiDeleteDevRegKey. +type DIREG uint32 + +const ( + DIREG_DEV DIREG = 0x00000001 // Open/Create/Delete device key + DIREG_DRV DIREG = 0x00000002 // Open/Create/Delete driver key + DIREG_BOTH DIREG = 0x00000004 // Delete both driver and Device key +) + +// SPDRP specifies device registry property codes +// (Codes marked as read-only (R) may only be used for +// SetupDiGetDeviceRegistryProperty) +// +// These values should cover the same set of registry properties +// as defined by the CM_DRP codes in cfgmgr32.h. +// +// Note that SPDRP codes are zero based while CM_DRP codes are one based! +type SPDRP uint32 + +const ( + SPDRP_DEVICEDESC SPDRP = 0x00000000 // DeviceDesc (R/W) + SPDRP_HARDWAREID SPDRP = 0x00000001 // HardwareID (R/W) + SPDRP_COMPATIBLEIDS SPDRP = 0x00000002 // CompatibleIDs (R/W) + SPDRP_SERVICE SPDRP = 0x00000004 // Service (R/W) + SPDRP_CLASS SPDRP = 0x00000007 // Class (R--tied to ClassGUID) + SPDRP_CLASSGUID SPDRP = 0x00000008 // ClassGUID (R/W) + SPDRP_DRIVER SPDRP = 0x00000009 // Driver (R/W) + SPDRP_CONFIGFLAGS SPDRP = 0x0000000A // ConfigFlags (R/W) + SPDRP_MFG SPDRP = 0x0000000B // Mfg (R/W) + SPDRP_FRIENDLYNAME SPDRP = 0x0000000C // FriendlyName (R/W) + SPDRP_LOCATION_INFORMATION SPDRP = 0x0000000D // LocationInformation (R/W) + SPDRP_PHYSICAL_DEVICE_OBJECT_NAME SPDRP = 0x0000000E // PhysicalDeviceObjectName (R) + SPDRP_CAPABILITIES SPDRP = 0x0000000F // Capabilities (R) + SPDRP_UI_NUMBER SPDRP = 0x00000010 // UiNumber (R) + SPDRP_UPPERFILTERS SPDRP = 0x00000011 // UpperFilters (R/W) + SPDRP_LOWERFILTERS SPDRP = 0x00000012 // LowerFilters (R/W) + SPDRP_BUSTYPEGUID SPDRP = 0x00000013 // BusTypeGUID (R) + SPDRP_LEGACYBUSTYPE SPDRP = 0x00000014 // LegacyBusType (R) + SPDRP_BUSNUMBER SPDRP = 0x00000015 // BusNumber (R) + SPDRP_ENUMERATOR_NAME SPDRP = 0x00000016 // Enumerator Name (R) + SPDRP_SECURITY SPDRP = 0x00000017 // Security (R/W, binary form) + SPDRP_SECURITY_SDS SPDRP = 0x00000018 // Security (W, SDS form) + SPDRP_DEVTYPE SPDRP = 0x00000019 // Device Type (R/W) + SPDRP_EXCLUSIVE SPDRP = 0x0000001A // Device is exclusive-access (R/W) + SPDRP_CHARACTERISTICS SPDRP = 0x0000001B // Device Characteristics (R/W) + SPDRP_ADDRESS SPDRP = 0x0000001C // Device Address (R) + SPDRP_UI_NUMBER_DESC_FORMAT SPDRP = 0x0000001D // UiNumberDescFormat (R/W) + SPDRP_DEVICE_POWER_DATA SPDRP = 0x0000001E // Device Power Data (R) + SPDRP_REMOVAL_POLICY SPDRP = 0x0000001F // Removal Policy (R) + SPDRP_REMOVAL_POLICY_HW_DEFAULT SPDRP = 0x00000020 // Hardware Removal Policy (R) + SPDRP_REMOVAL_POLICY_OVERRIDE SPDRP = 0x00000021 // Removal Policy Override (RW) + SPDRP_INSTALL_STATE SPDRP = 0x00000022 // Device Install State (R) + SPDRP_LOCATION_PATHS SPDRP = 0x00000023 // Device Location Paths (R) + SPDRP_BASE_CONTAINERID SPDRP = 0x00000024 // Base ContainerID (R) + + SPDRP_MAXIMUM_PROPERTY SPDRP = 0x00000025 // Upper bound on ordinals +) + +// DEVPROPTYPE represents the property-data-type identifier that specifies the +// data type of a device property value in the unified device property model. +type DEVPROPTYPE uint32 + +const ( + DEVPROP_TYPEMOD_ARRAY DEVPROPTYPE = 0x00001000 + DEVPROP_TYPEMOD_LIST DEVPROPTYPE = 0x00002000 + + DEVPROP_TYPE_EMPTY DEVPROPTYPE = 0x00000000 + DEVPROP_TYPE_NULL DEVPROPTYPE = 0x00000001 + DEVPROP_TYPE_SBYTE DEVPROPTYPE = 0x00000002 + DEVPROP_TYPE_BYTE DEVPROPTYPE = 0x00000003 + DEVPROP_TYPE_INT16 DEVPROPTYPE = 0x00000004 + DEVPROP_TYPE_UINT16 DEVPROPTYPE = 0x00000005 + DEVPROP_TYPE_INT32 DEVPROPTYPE = 0x00000006 + DEVPROP_TYPE_UINT32 DEVPROPTYPE = 0x00000007 + DEVPROP_TYPE_INT64 DEVPROPTYPE = 0x00000008 + DEVPROP_TYPE_UINT64 DEVPROPTYPE = 0x00000009 + DEVPROP_TYPE_FLOAT DEVPROPTYPE = 0x0000000A + DEVPROP_TYPE_DOUBLE DEVPROPTYPE = 0x0000000B + DEVPROP_TYPE_DECIMAL DEVPROPTYPE = 0x0000000C + DEVPROP_TYPE_GUID DEVPROPTYPE = 0x0000000D + DEVPROP_TYPE_CURRENCY DEVPROPTYPE = 0x0000000E + DEVPROP_TYPE_DATE DEVPROPTYPE = 0x0000000F + DEVPROP_TYPE_FILETIME DEVPROPTYPE = 0x00000010 + DEVPROP_TYPE_BOOLEAN DEVPROPTYPE = 0x00000011 + DEVPROP_TYPE_STRING DEVPROPTYPE = 0x00000012 + DEVPROP_TYPE_STRING_LIST DEVPROPTYPE = DEVPROP_TYPE_STRING | DEVPROP_TYPEMOD_LIST + DEVPROP_TYPE_SECURITY_DESCRIPTOR DEVPROPTYPE = 0x00000013 + DEVPROP_TYPE_SECURITY_DESCRIPTOR_STRING DEVPROPTYPE = 0x00000014 + DEVPROP_TYPE_DEVPROPKEY DEVPROPTYPE = 0x00000015 + DEVPROP_TYPE_DEVPROPTYPE DEVPROPTYPE = 0x00000016 + DEVPROP_TYPE_BINARY DEVPROPTYPE = DEVPROP_TYPE_BYTE | DEVPROP_TYPEMOD_ARRAY + DEVPROP_TYPE_ERROR DEVPROPTYPE = 0x00000017 + DEVPROP_TYPE_NTSTATUS DEVPROPTYPE = 0x00000018 + DEVPROP_TYPE_STRING_INDIRECT DEVPROPTYPE = 0x00000019 + + MAX_DEVPROP_TYPE DEVPROPTYPE = 0x00000019 + MAX_DEVPROP_TYPEMOD DEVPROPTYPE = 0x00002000 + + DEVPROP_MASK_TYPE DEVPROPTYPE = 0x00000FFF + DEVPROP_MASK_TYPEMOD DEVPROPTYPE = 0x0000F000 +) + +// DEVPROPGUID specifies a property category. +type DEVPROPGUID GUID + +// DEVPROPID uniquely identifies the property within the property category. +type DEVPROPID uint32 + +const DEVPROPID_FIRST_USABLE DEVPROPID = 2 + +// DEVPROPKEY represents a device property key for a device property in the +// unified device property model. +type DEVPROPKEY struct { + FmtID DEVPROPGUID + PID DEVPROPID +} + +// CONFIGRET is a return value or error code from cfgmgr32 APIs +type CONFIGRET uint32 + +func (ret CONFIGRET) Error() string { + if win32Error, ok := ret.Unwrap().(Errno); ok { + return fmt.Sprintf("%s (CfgMgr error: 0x%08x)", win32Error.Error(), uint32(ret)) + } + return fmt.Sprintf("CfgMgr error: 0x%08x", uint32(ret)) +} + +func (ret CONFIGRET) Win32Error(defaultError Errno) Errno { + return cm_MapCrToWin32Err(ret, defaultError) +} + +func (ret CONFIGRET) Unwrap() error { + const noMatch = Errno(^uintptr(0)) + win32Error := ret.Win32Error(noMatch) + if win32Error == noMatch { + return nil + } + return win32Error +} + +const ( + CR_SUCCESS CONFIGRET = 0x00000000 + CR_DEFAULT CONFIGRET = 0x00000001 + CR_OUT_OF_MEMORY CONFIGRET = 0x00000002 + CR_INVALID_POINTER CONFIGRET = 0x00000003 + CR_INVALID_FLAG CONFIGRET = 0x00000004 + CR_INVALID_DEVNODE CONFIGRET = 0x00000005 + CR_INVALID_DEVINST = CR_INVALID_DEVNODE + CR_INVALID_RES_DES CONFIGRET = 0x00000006 + CR_INVALID_LOG_CONF CONFIGRET = 0x00000007 + CR_INVALID_ARBITRATOR CONFIGRET = 0x00000008 + CR_INVALID_NODELIST CONFIGRET = 0x00000009 + CR_DEVNODE_HAS_REQS CONFIGRET = 0x0000000A + CR_DEVINST_HAS_REQS = CR_DEVNODE_HAS_REQS + CR_INVALID_RESOURCEID CONFIGRET = 0x0000000B + CR_DLVXD_NOT_FOUND CONFIGRET = 0x0000000C + CR_NO_SUCH_DEVNODE CONFIGRET = 0x0000000D + CR_NO_SUCH_DEVINST = CR_NO_SUCH_DEVNODE + CR_NO_MORE_LOG_CONF CONFIGRET = 0x0000000E + CR_NO_MORE_RES_DES CONFIGRET = 0x0000000F + CR_ALREADY_SUCH_DEVNODE CONFIGRET = 0x00000010 + CR_ALREADY_SUCH_DEVINST = CR_ALREADY_SUCH_DEVNODE + CR_INVALID_RANGE_LIST CONFIGRET = 0x00000011 + CR_INVALID_RANGE CONFIGRET = 0x00000012 + CR_FAILURE CONFIGRET = 0x00000013 + CR_NO_SUCH_LOGICAL_DEV CONFIGRET = 0x00000014 + CR_CREATE_BLOCKED CONFIGRET = 0x00000015 + CR_NOT_SYSTEM_VM CONFIGRET = 0x00000016 + CR_REMOVE_VETOED CONFIGRET = 0x00000017 + CR_APM_VETOED CONFIGRET = 0x00000018 + CR_INVALID_LOAD_TYPE CONFIGRET = 0x00000019 + CR_BUFFER_SMALL CONFIGRET = 0x0000001A + CR_NO_ARBITRATOR CONFIGRET = 0x0000001B + CR_NO_REGISTRY_HANDLE CONFIGRET = 0x0000001C + CR_REGISTRY_ERROR CONFIGRET = 0x0000001D + CR_INVALID_DEVICE_ID CONFIGRET = 0x0000001E + CR_INVALID_DATA CONFIGRET = 0x0000001F + CR_INVALID_API CONFIGRET = 0x00000020 + CR_DEVLOADER_NOT_READY CONFIGRET = 0x00000021 + CR_NEED_RESTART CONFIGRET = 0x00000022 + CR_NO_MORE_HW_PROFILES CONFIGRET = 0x00000023 + CR_DEVICE_NOT_THERE CONFIGRET = 0x00000024 + CR_NO_SUCH_VALUE CONFIGRET = 0x00000025 + CR_WRONG_TYPE CONFIGRET = 0x00000026 + CR_INVALID_PRIORITY CONFIGRET = 0x00000027 + CR_NOT_DISABLEABLE CONFIGRET = 0x00000028 + CR_FREE_RESOURCES CONFIGRET = 0x00000029 + CR_QUERY_VETOED CONFIGRET = 0x0000002A + CR_CANT_SHARE_IRQ CONFIGRET = 0x0000002B + CR_NO_DEPENDENT CONFIGRET = 0x0000002C + CR_SAME_RESOURCES CONFIGRET = 0x0000002D + CR_NO_SUCH_REGISTRY_KEY CONFIGRET = 0x0000002E + CR_INVALID_MACHINENAME CONFIGRET = 0x0000002F + CR_REMOTE_COMM_FAILURE CONFIGRET = 0x00000030 + CR_MACHINE_UNAVAILABLE CONFIGRET = 0x00000031 + CR_NO_CM_SERVICES CONFIGRET = 0x00000032 + CR_ACCESS_DENIED CONFIGRET = 0x00000033 + CR_CALL_NOT_IMPLEMENTED CONFIGRET = 0x00000034 + CR_INVALID_PROPERTY CONFIGRET = 0x00000035 + CR_DEVICE_INTERFACE_ACTIVE CONFIGRET = 0x00000036 + CR_NO_SUCH_DEVICE_INTERFACE CONFIGRET = 0x00000037 + CR_INVALID_REFERENCE_STRING CONFIGRET = 0x00000038 + CR_INVALID_CONFLICT_LIST CONFIGRET = 0x00000039 + CR_INVALID_INDEX CONFIGRET = 0x0000003A + CR_INVALID_STRUCTURE_SIZE CONFIGRET = 0x0000003B + NUM_CR_RESULTS CONFIGRET = 0x0000003C +) + +const ( + CM_GET_DEVICE_INTERFACE_LIST_PRESENT = 0 // only currently 'live' device interfaces + CM_GET_DEVICE_INTERFACE_LIST_ALL_DEVICES = 1 // all registered device interfaces, live or not +) + +const ( + DN_ROOT_ENUMERATED = 0x00000001 // Was enumerated by ROOT + DN_DRIVER_LOADED = 0x00000002 // Has Register_Device_Driver + DN_ENUM_LOADED = 0x00000004 // Has Register_Enumerator + DN_STARTED = 0x00000008 // Is currently configured + DN_MANUAL = 0x00000010 // Manually installed + DN_NEED_TO_ENUM = 0x00000020 // May need reenumeration + DN_NOT_FIRST_TIME = 0x00000040 // Has received a config + DN_HARDWARE_ENUM = 0x00000080 // Enum generates hardware ID + DN_LIAR = 0x00000100 // Lied about can reconfig once + DN_HAS_MARK = 0x00000200 // Not CM_Create_DevInst lately + DN_HAS_PROBLEM = 0x00000400 // Need device installer + DN_FILTERED = 0x00000800 // Is filtered + DN_MOVED = 0x00001000 // Has been moved + DN_DISABLEABLE = 0x00002000 // Can be disabled + DN_REMOVABLE = 0x00004000 // Can be removed + DN_PRIVATE_PROBLEM = 0x00008000 // Has a private problem + DN_MF_PARENT = 0x00010000 // Multi function parent + DN_MF_CHILD = 0x00020000 // Multi function child + DN_WILL_BE_REMOVED = 0x00040000 // DevInst is being removed + DN_NOT_FIRST_TIMEE = 0x00080000 // Has received a config enumerate + DN_STOP_FREE_RES = 0x00100000 // When child is stopped, free resources + DN_REBAL_CANDIDATE = 0x00200000 // Don't skip during rebalance + DN_BAD_PARTIAL = 0x00400000 // This devnode's log_confs do not have same resources + DN_NT_ENUMERATOR = 0x00800000 // This devnode's is an NT enumerator + DN_NT_DRIVER = 0x01000000 // This devnode's is an NT driver + DN_NEEDS_LOCKING = 0x02000000 // Devnode need lock resume processing + DN_ARM_WAKEUP = 0x04000000 // Devnode can be the wakeup device + DN_APM_ENUMERATOR = 0x08000000 // APM aware enumerator + DN_APM_DRIVER = 0x10000000 // APM aware driver + DN_SILENT_INSTALL = 0x20000000 // Silent install + DN_NO_SHOW_IN_DM = 0x40000000 // No show in device manager + DN_BOOT_LOG_PROB = 0x80000000 // Had a problem during preassignment of boot log conf + DN_NEED_RESTART = DN_LIAR // System needs to be restarted for this Devnode to work properly + DN_DRIVER_BLOCKED = DN_NOT_FIRST_TIME // One or more drivers are blocked from loading for this Devnode + DN_LEGACY_DRIVER = DN_MOVED // This device is using a legacy driver + DN_CHILD_WITH_INVALID_ID = DN_HAS_MARK // One or more children have invalid IDs + DN_DEVICE_DISCONNECTED = DN_NEEDS_LOCKING // The function driver for a device reported that the device is not connected. Typically this means a wireless device is out of range. + DN_QUERY_REMOVE_PENDING = DN_MF_PARENT // Device is part of a set of related devices collectively pending query-removal + DN_QUERY_REMOVE_ACTIVE = DN_MF_CHILD // Device is actively engaged in a query-remove IRP + DN_CHANGEABLE_FLAGS = DN_NOT_FIRST_TIME | DN_HARDWARE_ENUM | DN_HAS_MARK | DN_DISABLEABLE | DN_REMOVABLE | DN_MF_CHILD | DN_MF_PARENT | DN_NOT_FIRST_TIMEE | DN_STOP_FREE_RES | DN_REBAL_CANDIDATE | DN_NT_ENUMERATOR | DN_NT_DRIVER | DN_SILENT_INSTALL | DN_NO_SHOW_IN_DM +) + +//sys setupDiCreateDeviceInfoListEx(classGUID *GUID, hwndParent uintptr, machineName *uint16, reserved uintptr) (handle DevInfo, err error) [failretval==DevInfo(InvalidHandle)] = setupapi.SetupDiCreateDeviceInfoListExW + +// SetupDiCreateDeviceInfoListEx function creates an empty device information set on a remote or a local computer and optionally associates the set with a device setup class. +func SetupDiCreateDeviceInfoListEx(classGUID *GUID, hwndParent uintptr, machineName string) (deviceInfoSet DevInfo, err error) { + var machineNameUTF16 *uint16 + if machineName != "" { + machineNameUTF16, err = UTF16PtrFromString(machineName) + if err != nil { + return + } + } + return setupDiCreateDeviceInfoListEx(classGUID, hwndParent, machineNameUTF16, 0) +} + +//sys setupDiGetDeviceInfoListDetail(deviceInfoSet DevInfo, deviceInfoSetDetailData *DevInfoListDetailData) (err error) = setupapi.SetupDiGetDeviceInfoListDetailW + +// SetupDiGetDeviceInfoListDetail function retrieves information associated with a device information set including the class GUID, remote computer handle, and remote computer name. +func SetupDiGetDeviceInfoListDetail(deviceInfoSet DevInfo) (deviceInfoSetDetailData *DevInfoListDetailData, err error) { + data := &DevInfoListDetailData{} + data.size = data.unsafeSizeOf() + + return data, setupDiGetDeviceInfoListDetail(deviceInfoSet, data) +} + +// DeviceInfoListDetail method retrieves information associated with a device information set including the class GUID, remote computer handle, and remote computer name. +func (deviceInfoSet DevInfo) DeviceInfoListDetail() (*DevInfoListDetailData, error) { + return SetupDiGetDeviceInfoListDetail(deviceInfoSet) +} + +//sys setupDiCreateDeviceInfo(deviceInfoSet DevInfo, DeviceName *uint16, classGUID *GUID, DeviceDescription *uint16, hwndParent uintptr, CreationFlags DICD, deviceInfoData *DevInfoData) (err error) = setupapi.SetupDiCreateDeviceInfoW + +// SetupDiCreateDeviceInfo function creates a new device information element and adds it as a new member to the specified device information set. +func SetupDiCreateDeviceInfo(deviceInfoSet DevInfo, deviceName string, classGUID *GUID, deviceDescription string, hwndParent uintptr, creationFlags DICD) (deviceInfoData *DevInfoData, err error) { + deviceNameUTF16, err := UTF16PtrFromString(deviceName) + if err != nil { + return + } + + var deviceDescriptionUTF16 *uint16 + if deviceDescription != "" { + deviceDescriptionUTF16, err = UTF16PtrFromString(deviceDescription) + if err != nil { + return + } + } + + data := &DevInfoData{} + data.size = uint32(unsafe.Sizeof(*data)) + + return data, setupDiCreateDeviceInfo(deviceInfoSet, deviceNameUTF16, classGUID, deviceDescriptionUTF16, hwndParent, creationFlags, data) +} + +// CreateDeviceInfo method creates a new device information element and adds it as a new member to the specified device information set. +func (deviceInfoSet DevInfo) CreateDeviceInfo(deviceName string, classGUID *GUID, deviceDescription string, hwndParent uintptr, creationFlags DICD) (*DevInfoData, error) { + return SetupDiCreateDeviceInfo(deviceInfoSet, deviceName, classGUID, deviceDescription, hwndParent, creationFlags) +} + +//sys setupDiEnumDeviceInfo(deviceInfoSet DevInfo, memberIndex uint32, deviceInfoData *DevInfoData) (err error) = setupapi.SetupDiEnumDeviceInfo + +// SetupDiEnumDeviceInfo function returns a DevInfoData structure that specifies a device information element in a device information set. +func SetupDiEnumDeviceInfo(deviceInfoSet DevInfo, memberIndex int) (*DevInfoData, error) { + data := &DevInfoData{} + data.size = uint32(unsafe.Sizeof(*data)) + + return data, setupDiEnumDeviceInfo(deviceInfoSet, uint32(memberIndex), data) +} + +// EnumDeviceInfo method returns a DevInfoData structure that specifies a device information element in a device information set. +func (deviceInfoSet DevInfo) EnumDeviceInfo(memberIndex int) (*DevInfoData, error) { + return SetupDiEnumDeviceInfo(deviceInfoSet, memberIndex) +} + +// SetupDiDestroyDeviceInfoList function deletes a device information set and frees all associated memory. +//sys SetupDiDestroyDeviceInfoList(deviceInfoSet DevInfo) (err error) = setupapi.SetupDiDestroyDeviceInfoList + +// Close method deletes a device information set and frees all associated memory. +func (deviceInfoSet DevInfo) Close() error { + return SetupDiDestroyDeviceInfoList(deviceInfoSet) +} + +//sys SetupDiBuildDriverInfoList(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, driverType SPDIT) (err error) = setupapi.SetupDiBuildDriverInfoList + +// BuildDriverInfoList method builds a list of drivers that is associated with a specific device or with the global class driver list for a device information set. +func (deviceInfoSet DevInfo) BuildDriverInfoList(deviceInfoData *DevInfoData, driverType SPDIT) error { + return SetupDiBuildDriverInfoList(deviceInfoSet, deviceInfoData, driverType) +} + +//sys SetupDiCancelDriverInfoSearch(deviceInfoSet DevInfo) (err error) = setupapi.SetupDiCancelDriverInfoSearch + +// CancelDriverInfoSearch method cancels a driver list search that is currently in progress in a different thread. +func (deviceInfoSet DevInfo) CancelDriverInfoSearch() error { + return SetupDiCancelDriverInfoSearch(deviceInfoSet) +} + +//sys setupDiEnumDriverInfo(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, driverType SPDIT, memberIndex uint32, driverInfoData *DrvInfoData) (err error) = setupapi.SetupDiEnumDriverInfoW + +// SetupDiEnumDriverInfo function enumerates the members of a driver list. +func SetupDiEnumDriverInfo(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, driverType SPDIT, memberIndex int) (*DrvInfoData, error) { + data := &DrvInfoData{} + data.size = uint32(unsafe.Sizeof(*data)) + + return data, setupDiEnumDriverInfo(deviceInfoSet, deviceInfoData, driverType, uint32(memberIndex), data) +} + +// EnumDriverInfo method enumerates the members of a driver list. +func (deviceInfoSet DevInfo) EnumDriverInfo(deviceInfoData *DevInfoData, driverType SPDIT, memberIndex int) (*DrvInfoData, error) { + return SetupDiEnumDriverInfo(deviceInfoSet, deviceInfoData, driverType, memberIndex) +} + +//sys setupDiGetSelectedDriver(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, driverInfoData *DrvInfoData) (err error) = setupapi.SetupDiGetSelectedDriverW + +// SetupDiGetSelectedDriver function retrieves the selected driver for a device information set or a particular device information element. +func SetupDiGetSelectedDriver(deviceInfoSet DevInfo, deviceInfoData *DevInfoData) (*DrvInfoData, error) { + data := &DrvInfoData{} + data.size = uint32(unsafe.Sizeof(*data)) + + return data, setupDiGetSelectedDriver(deviceInfoSet, deviceInfoData, data) +} + +// SelectedDriver method retrieves the selected driver for a device information set or a particular device information element. +func (deviceInfoSet DevInfo) SelectedDriver(deviceInfoData *DevInfoData) (*DrvInfoData, error) { + return SetupDiGetSelectedDriver(deviceInfoSet, deviceInfoData) +} + +//sys SetupDiSetSelectedDriver(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, driverInfoData *DrvInfoData) (err error) = setupapi.SetupDiSetSelectedDriverW + +// SetSelectedDriver method sets, or resets, the selected driver for a device information element or the selected class driver for a device information set. +func (deviceInfoSet DevInfo) SetSelectedDriver(deviceInfoData *DevInfoData, driverInfoData *DrvInfoData) error { + return SetupDiSetSelectedDriver(deviceInfoSet, deviceInfoData, driverInfoData) +} + +//sys setupDiGetDriverInfoDetail(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, driverInfoData *DrvInfoData, driverInfoDetailData *DrvInfoDetailData, driverInfoDetailDataSize uint32, requiredSize *uint32) (err error) = setupapi.SetupDiGetDriverInfoDetailW + +// SetupDiGetDriverInfoDetail function retrieves driver information detail for a device information set or a particular device information element in the device information set. +func SetupDiGetDriverInfoDetail(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, driverInfoData *DrvInfoData) (*DrvInfoDetailData, error) { + reqSize := uint32(2048) + for { + buf := make([]byte, reqSize) + data := (*DrvInfoDetailData)(unsafe.Pointer(&buf[0])) + data.size = data.unsafeSizeOf() + err := setupDiGetDriverInfoDetail(deviceInfoSet, deviceInfoData, driverInfoData, data, uint32(len(buf)), &reqSize) + if err == ERROR_INSUFFICIENT_BUFFER { + continue + } + if err != nil { + return nil, err + } + data.size = reqSize + return data, nil + } +} + +// DriverInfoDetail method retrieves driver information detail for a device information set or a particular device information element in the device information set. +func (deviceInfoSet DevInfo) DriverInfoDetail(deviceInfoData *DevInfoData, driverInfoData *DrvInfoData) (*DrvInfoDetailData, error) { + return SetupDiGetDriverInfoDetail(deviceInfoSet, deviceInfoData, driverInfoData) +} + +//sys SetupDiDestroyDriverInfoList(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, driverType SPDIT) (err error) = setupapi.SetupDiDestroyDriverInfoList + +// DestroyDriverInfoList method deletes a driver list. +func (deviceInfoSet DevInfo) DestroyDriverInfoList(deviceInfoData *DevInfoData, driverType SPDIT) error { + return SetupDiDestroyDriverInfoList(deviceInfoSet, deviceInfoData, driverType) +} + +//sys setupDiGetClassDevsEx(classGUID *GUID, Enumerator *uint16, hwndParent uintptr, Flags DIGCF, deviceInfoSet DevInfo, machineName *uint16, reserved uintptr) (handle DevInfo, err error) [failretval==DevInfo(InvalidHandle)] = setupapi.SetupDiGetClassDevsExW + +// SetupDiGetClassDevsEx function returns a handle to a device information set that contains requested device information elements for a local or a remote computer. +func SetupDiGetClassDevsEx(classGUID *GUID, enumerator string, hwndParent uintptr, flags DIGCF, deviceInfoSet DevInfo, machineName string) (handle DevInfo, err error) { + var enumeratorUTF16 *uint16 + if enumerator != "" { + enumeratorUTF16, err = UTF16PtrFromString(enumerator) + if err != nil { + return + } + } + var machineNameUTF16 *uint16 + if machineName != "" { + machineNameUTF16, err = UTF16PtrFromString(machineName) + if err != nil { + return + } + } + return setupDiGetClassDevsEx(classGUID, enumeratorUTF16, hwndParent, flags, deviceInfoSet, machineNameUTF16, 0) +} + +// SetupDiCallClassInstaller function calls the appropriate class installer, and any registered co-installers, with the specified installation request (DIF code). +//sys SetupDiCallClassInstaller(installFunction DI_FUNCTION, deviceInfoSet DevInfo, deviceInfoData *DevInfoData) (err error) = setupapi.SetupDiCallClassInstaller + +// CallClassInstaller member calls the appropriate class installer, and any registered co-installers, with the specified installation request (DIF code). +func (deviceInfoSet DevInfo) CallClassInstaller(installFunction DI_FUNCTION, deviceInfoData *DevInfoData) error { + return SetupDiCallClassInstaller(installFunction, deviceInfoSet, deviceInfoData) +} + +// SetupDiOpenDevRegKey function opens a registry key for device-specific configuration information. +//sys SetupDiOpenDevRegKey(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, Scope DICS_FLAG, HwProfile uint32, KeyType DIREG, samDesired uint32) (key Handle, err error) [failretval==InvalidHandle] = setupapi.SetupDiOpenDevRegKey + +// OpenDevRegKey method opens a registry key for device-specific configuration information. +func (deviceInfoSet DevInfo) OpenDevRegKey(DeviceInfoData *DevInfoData, Scope DICS_FLAG, HwProfile uint32, KeyType DIREG, samDesired uint32) (Handle, error) { + return SetupDiOpenDevRegKey(deviceInfoSet, DeviceInfoData, Scope, HwProfile, KeyType, samDesired) +} + +//sys setupDiGetDeviceProperty(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, propertyKey *DEVPROPKEY, propertyType *DEVPROPTYPE, propertyBuffer *byte, propertyBufferSize uint32, requiredSize *uint32, flags uint32) (err error) = setupapi.SetupDiGetDevicePropertyW + +// SetupDiGetDeviceProperty function retrieves a specified device instance property. +func SetupDiGetDeviceProperty(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, propertyKey *DEVPROPKEY) (value interface{}, err error) { + reqSize := uint32(256) + for { + var dataType DEVPROPTYPE + buf := make([]byte, reqSize) + err = setupDiGetDeviceProperty(deviceInfoSet, deviceInfoData, propertyKey, &dataType, &buf[0], uint32(len(buf)), &reqSize, 0) + if err == ERROR_INSUFFICIENT_BUFFER { + continue + } + if err != nil { + return + } + switch dataType { + case DEVPROP_TYPE_STRING: + ret := UTF16ToString(bufToUTF16(buf)) + runtime.KeepAlive(buf) + return ret, nil + } + return nil, errors.New("unimplemented property type") + } +} + +//sys setupDiGetDeviceRegistryProperty(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, property SPDRP, propertyRegDataType *uint32, propertyBuffer *byte, propertyBufferSize uint32, requiredSize *uint32) (err error) = setupapi.SetupDiGetDeviceRegistryPropertyW + +// SetupDiGetDeviceRegistryProperty function retrieves a specified Plug and Play device property. +func SetupDiGetDeviceRegistryProperty(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, property SPDRP) (value interface{}, err error) { + reqSize := uint32(256) + for { + var dataType uint32 + buf := make([]byte, reqSize) + err = setupDiGetDeviceRegistryProperty(deviceInfoSet, deviceInfoData, property, &dataType, &buf[0], uint32(len(buf)), &reqSize) + if err == ERROR_INSUFFICIENT_BUFFER { + continue + } + if err != nil { + return + } + return getRegistryValue(buf[:reqSize], dataType) + } +} + +func getRegistryValue(buf []byte, dataType uint32) (interface{}, error) { + switch dataType { + case REG_SZ: + ret := UTF16ToString(bufToUTF16(buf)) + runtime.KeepAlive(buf) + return ret, nil + case REG_EXPAND_SZ: + value := UTF16ToString(bufToUTF16(buf)) + if value == "" { + return "", nil + } + p, err := syscall.UTF16PtrFromString(value) + if err != nil { + return "", err + } + ret := make([]uint16, 100) + for { + n, err := ExpandEnvironmentStrings(p, &ret[0], uint32(len(ret))) + if err != nil { + return "", err + } + if n <= uint32(len(ret)) { + return UTF16ToString(ret[:n]), nil + } + ret = make([]uint16, n) + } + case REG_BINARY: + return buf, nil + case REG_DWORD_LITTLE_ENDIAN: + return binary.LittleEndian.Uint32(buf), nil + case REG_DWORD_BIG_ENDIAN: + return binary.BigEndian.Uint32(buf), nil + case REG_MULTI_SZ: + bufW := bufToUTF16(buf) + a := []string{} + for i := 0; i < len(bufW); { + j := i + wcslen(bufW[i:]) + if i < j { + a = append(a, UTF16ToString(bufW[i:j])) + } + i = j + 1 + } + runtime.KeepAlive(buf) + return a, nil + case REG_QWORD_LITTLE_ENDIAN: + return binary.LittleEndian.Uint64(buf), nil + default: + return nil, fmt.Errorf("Unsupported registry value type: %v", dataType) + } +} + +// bufToUTF16 function reinterprets []byte buffer as []uint16 +func bufToUTF16(buf []byte) []uint16 { + sl := struct { + addr *uint16 + len int + cap int + }{(*uint16)(unsafe.Pointer(&buf[0])), len(buf) / 2, cap(buf) / 2} + return *(*[]uint16)(unsafe.Pointer(&sl)) +} + +// utf16ToBuf function reinterprets []uint16 as []byte +func utf16ToBuf(buf []uint16) []byte { + sl := struct { + addr *byte + len int + cap int + }{(*byte)(unsafe.Pointer(&buf[0])), len(buf) * 2, cap(buf) * 2} + return *(*[]byte)(unsafe.Pointer(&sl)) +} + +func wcslen(str []uint16) int { + for i := 0; i < len(str); i++ { + if str[i] == 0 { + return i + } + } + return len(str) +} + +// DeviceRegistryProperty method retrieves a specified Plug and Play device property. +func (deviceInfoSet DevInfo) DeviceRegistryProperty(deviceInfoData *DevInfoData, property SPDRP) (interface{}, error) { + return SetupDiGetDeviceRegistryProperty(deviceInfoSet, deviceInfoData, property) +} + +//sys setupDiSetDeviceRegistryProperty(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, property SPDRP, propertyBuffer *byte, propertyBufferSize uint32) (err error) = setupapi.SetupDiSetDeviceRegistryPropertyW + +// SetupDiSetDeviceRegistryProperty function sets a Plug and Play device property for a device. +func SetupDiSetDeviceRegistryProperty(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, property SPDRP, propertyBuffers []byte) error { + return setupDiSetDeviceRegistryProperty(deviceInfoSet, deviceInfoData, property, &propertyBuffers[0], uint32(len(propertyBuffers))) +} + +// SetDeviceRegistryProperty function sets a Plug and Play device property for a device. +func (deviceInfoSet DevInfo) SetDeviceRegistryProperty(deviceInfoData *DevInfoData, property SPDRP, propertyBuffers []byte) error { + return SetupDiSetDeviceRegistryProperty(deviceInfoSet, deviceInfoData, property, propertyBuffers) +} + +// SetDeviceRegistryPropertyString method sets a Plug and Play device property string for a device. +func (deviceInfoSet DevInfo) SetDeviceRegistryPropertyString(deviceInfoData *DevInfoData, property SPDRP, str string) error { + str16, err := UTF16FromString(str) + if err != nil { + return err + } + err = SetupDiSetDeviceRegistryProperty(deviceInfoSet, deviceInfoData, property, utf16ToBuf(append(str16, 0))) + runtime.KeepAlive(str16) + return err +} + +//sys setupDiGetDeviceInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, deviceInstallParams *DevInstallParams) (err error) = setupapi.SetupDiGetDeviceInstallParamsW + +// SetupDiGetDeviceInstallParams function retrieves device installation parameters for a device information set or a particular device information element. +func SetupDiGetDeviceInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData) (*DevInstallParams, error) { + params := &DevInstallParams{} + params.size = uint32(unsafe.Sizeof(*params)) + + return params, setupDiGetDeviceInstallParams(deviceInfoSet, deviceInfoData, params) +} + +// DeviceInstallParams method retrieves device installation parameters for a device information set or a particular device information element. +func (deviceInfoSet DevInfo) DeviceInstallParams(deviceInfoData *DevInfoData) (*DevInstallParams, error) { + return SetupDiGetDeviceInstallParams(deviceInfoSet, deviceInfoData) +} + +//sys setupDiGetDeviceInstanceId(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, instanceId *uint16, instanceIdSize uint32, instanceIdRequiredSize *uint32) (err error) = setupapi.SetupDiGetDeviceInstanceIdW + +// SetupDiGetDeviceInstanceId function retrieves the instance ID of the device. +func SetupDiGetDeviceInstanceId(deviceInfoSet DevInfo, deviceInfoData *DevInfoData) (string, error) { + reqSize := uint32(1024) + for { + buf := make([]uint16, reqSize) + err := setupDiGetDeviceInstanceId(deviceInfoSet, deviceInfoData, &buf[0], uint32(len(buf)), &reqSize) + if err == ERROR_INSUFFICIENT_BUFFER { + continue + } + if err != nil { + return "", err + } + return UTF16ToString(buf), nil + } +} + +// DeviceInstanceID method retrieves the instance ID of the device. +func (deviceInfoSet DevInfo) DeviceInstanceID(deviceInfoData *DevInfoData) (string, error) { + return SetupDiGetDeviceInstanceId(deviceInfoSet, deviceInfoData) +} + +// SetupDiGetClassInstallParams function retrieves class installation parameters for a device information set or a particular device information element. +//sys SetupDiGetClassInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, classInstallParams *ClassInstallHeader, classInstallParamsSize uint32, requiredSize *uint32) (err error) = setupapi.SetupDiGetClassInstallParamsW + +// ClassInstallParams method retrieves class installation parameters for a device information set or a particular device information element. +func (deviceInfoSet DevInfo) ClassInstallParams(deviceInfoData *DevInfoData, classInstallParams *ClassInstallHeader, classInstallParamsSize uint32, requiredSize *uint32) error { + return SetupDiGetClassInstallParams(deviceInfoSet, deviceInfoData, classInstallParams, classInstallParamsSize, requiredSize) +} + +//sys SetupDiSetDeviceInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, deviceInstallParams *DevInstallParams) (err error) = setupapi.SetupDiSetDeviceInstallParamsW + +// SetDeviceInstallParams member sets device installation parameters for a device information set or a particular device information element. +func (deviceInfoSet DevInfo) SetDeviceInstallParams(deviceInfoData *DevInfoData, deviceInstallParams *DevInstallParams) error { + return SetupDiSetDeviceInstallParams(deviceInfoSet, deviceInfoData, deviceInstallParams) +} + +// SetupDiSetClassInstallParams function sets or clears class install parameters for a device information set or a particular device information element. +//sys SetupDiSetClassInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, classInstallParams *ClassInstallHeader, classInstallParamsSize uint32) (err error) = setupapi.SetupDiSetClassInstallParamsW + +// SetClassInstallParams method sets or clears class install parameters for a device information set or a particular device information element. +func (deviceInfoSet DevInfo) SetClassInstallParams(deviceInfoData *DevInfoData, classInstallParams *ClassInstallHeader, classInstallParamsSize uint32) error { + return SetupDiSetClassInstallParams(deviceInfoSet, deviceInfoData, classInstallParams, classInstallParamsSize) +} + +//sys setupDiClassNameFromGuidEx(classGUID *GUID, className *uint16, classNameSize uint32, requiredSize *uint32, machineName *uint16, reserved uintptr) (err error) = setupapi.SetupDiClassNameFromGuidExW + +// SetupDiClassNameFromGuidEx function retrieves the class name associated with a class GUID. The class can be installed on a local or remote computer. +func SetupDiClassNameFromGuidEx(classGUID *GUID, machineName string) (className string, err error) { + var classNameUTF16 [MAX_CLASS_NAME_LEN]uint16 + + var machineNameUTF16 *uint16 + if machineName != "" { + machineNameUTF16, err = UTF16PtrFromString(machineName) + if err != nil { + return + } + } + + err = setupDiClassNameFromGuidEx(classGUID, &classNameUTF16[0], MAX_CLASS_NAME_LEN, nil, machineNameUTF16, 0) + if err != nil { + return + } + + className = UTF16ToString(classNameUTF16[:]) + return +} + +//sys setupDiClassGuidsFromNameEx(className *uint16, classGuidList *GUID, classGuidListSize uint32, requiredSize *uint32, machineName *uint16, reserved uintptr) (err error) = setupapi.SetupDiClassGuidsFromNameExW + +// SetupDiClassGuidsFromNameEx function retrieves the GUIDs associated with the specified class name. This resulting list contains the classes currently installed on a local or remote computer. +func SetupDiClassGuidsFromNameEx(className string, machineName string) ([]GUID, error) { + classNameUTF16, err := UTF16PtrFromString(className) + if err != nil { + return nil, err + } + + var machineNameUTF16 *uint16 + if machineName != "" { + machineNameUTF16, err = UTF16PtrFromString(machineName) + if err != nil { + return nil, err + } + } + + reqSize := uint32(4) + for { + buf := make([]GUID, reqSize) + err = setupDiClassGuidsFromNameEx(classNameUTF16, &buf[0], uint32(len(buf)), &reqSize, machineNameUTF16, 0) + if err == ERROR_INSUFFICIENT_BUFFER { + continue + } + if err != nil { + return nil, err + } + return buf[:reqSize], nil + } +} + +//sys setupDiGetSelectedDevice(deviceInfoSet DevInfo, deviceInfoData *DevInfoData) (err error) = setupapi.SetupDiGetSelectedDevice + +// SetupDiGetSelectedDevice function retrieves the selected device information element in a device information set. +func SetupDiGetSelectedDevice(deviceInfoSet DevInfo) (*DevInfoData, error) { + data := &DevInfoData{} + data.size = uint32(unsafe.Sizeof(*data)) + + return data, setupDiGetSelectedDevice(deviceInfoSet, data) +} + +// SelectedDevice method retrieves the selected device information element in a device information set. +func (deviceInfoSet DevInfo) SelectedDevice() (*DevInfoData, error) { + return SetupDiGetSelectedDevice(deviceInfoSet) +} + +// SetupDiSetSelectedDevice function sets a device information element as the selected member of a device information set. This function is typically used by an installation wizard. +//sys SetupDiSetSelectedDevice(deviceInfoSet DevInfo, deviceInfoData *DevInfoData) (err error) = setupapi.SetupDiSetSelectedDevice + +// SetSelectedDevice method sets a device information element as the selected member of a device information set. This function is typically used by an installation wizard. +func (deviceInfoSet DevInfo) SetSelectedDevice(deviceInfoData *DevInfoData) error { + return SetupDiSetSelectedDevice(deviceInfoSet, deviceInfoData) +} + +//sys setupUninstallOEMInf(infFileName *uint16, flags SUOI, reserved uintptr) (err error) = setupapi.SetupUninstallOEMInfW + +// SetupUninstallOEMInf uninstalls the specified driver. +func SetupUninstallOEMInf(infFileName string, flags SUOI) error { + infFileName16, err := UTF16PtrFromString(infFileName) + if err != nil { + return err + } + return setupUninstallOEMInf(infFileName16, flags, 0) +} + +//sys cm_MapCrToWin32Err(configRet CONFIGRET, defaultWin32Error Errno) (ret Errno) = CfgMgr32.CM_MapCrToWin32Err + +//sys cm_Get_Device_Interface_List_Size(len *uint32, interfaceClass *GUID, deviceID *uint16, flags uint32) (ret CONFIGRET) = CfgMgr32.CM_Get_Device_Interface_List_SizeW +//sys cm_Get_Device_Interface_List(interfaceClass *GUID, deviceID *uint16, buffer *uint16, bufferLen uint32, flags uint32) (ret CONFIGRET) = CfgMgr32.CM_Get_Device_Interface_ListW + +func CM_Get_Device_Interface_List(deviceID string, interfaceClass *GUID, flags uint32) ([]string, error) { + deviceID16, err := UTF16PtrFromString(deviceID) + if err != nil { + return nil, err + } + var buf []uint16 + var buflen uint32 + for { + if ret := cm_Get_Device_Interface_List_Size(&buflen, interfaceClass, deviceID16, flags); ret != CR_SUCCESS { + return nil, ret + } + buf = make([]uint16, buflen) + if ret := cm_Get_Device_Interface_List(interfaceClass, deviceID16, &buf[0], buflen, flags); ret == CR_SUCCESS { + break + } else if ret != CR_BUFFER_SMALL { + return nil, ret + } + } + var interfaces []string + for i := 0; i < len(buf); { + j := i + wcslen(buf[i:]) + if i < j { + interfaces = append(interfaces, UTF16ToString(buf[i:j])) + } + i = j + 1 + } + if interfaces == nil { + return nil, ERROR_NO_SUCH_DEVICE_INTERFACE + } + return interfaces, nil +} + +//sys cm_Get_DevNode_Status(status *uint32, problemNumber *uint32, devInst DEVINST, flags uint32) (ret CONFIGRET) = CfgMgr32.CM_Get_DevNode_Status + +func CM_Get_DevNode_Status(status *uint32, problemNumber *uint32, devInst DEVINST, flags uint32) error { + ret := cm_Get_DevNode_Status(status, problemNumber, devInst, flags) + if ret == CR_SUCCESS { + return nil + } + return ret +} diff --git a/vendor/golang.org/x/sys/windows/setupapierrors_windows.go b/vendor/golang.org/x/sys/windows/setupapierrors_windows.go deleted file mode 100644 index 1681810e048..00000000000 --- a/vendor/golang.org/x/sys/windows/setupapierrors_windows.go +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright 2020 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package windows - -import "syscall" - -const ( - ERROR_EXPECTED_SECTION_NAME syscall.Errno = 0x20000000 | 0xC0000000 | 0 - ERROR_BAD_SECTION_NAME_LINE syscall.Errno = 0x20000000 | 0xC0000000 | 1 - ERROR_SECTION_NAME_TOO_LONG syscall.Errno = 0x20000000 | 0xC0000000 | 2 - ERROR_GENERAL_SYNTAX syscall.Errno = 0x20000000 | 0xC0000000 | 3 - ERROR_WRONG_INF_STYLE syscall.Errno = 0x20000000 | 0xC0000000 | 0x100 - ERROR_SECTION_NOT_FOUND syscall.Errno = 0x20000000 | 0xC0000000 | 0x101 - ERROR_LINE_NOT_FOUND syscall.Errno = 0x20000000 | 0xC0000000 | 0x102 - ERROR_NO_BACKUP syscall.Errno = 0x20000000 | 0xC0000000 | 0x103 - ERROR_NO_ASSOCIATED_CLASS syscall.Errno = 0x20000000 | 0xC0000000 | 0x200 - ERROR_CLASS_MISMATCH syscall.Errno = 0x20000000 | 0xC0000000 | 0x201 - ERROR_DUPLICATE_FOUND syscall.Errno = 0x20000000 | 0xC0000000 | 0x202 - ERROR_NO_DRIVER_SELECTED syscall.Errno = 0x20000000 | 0xC0000000 | 0x203 - ERROR_KEY_DOES_NOT_EXIST syscall.Errno = 0x20000000 | 0xC0000000 | 0x204 - ERROR_INVALID_DEVINST_NAME syscall.Errno = 0x20000000 | 0xC0000000 | 0x205 - ERROR_INVALID_CLASS syscall.Errno = 0x20000000 | 0xC0000000 | 0x206 - ERROR_DEVINST_ALREADY_EXISTS syscall.Errno = 0x20000000 | 0xC0000000 | 0x207 - ERROR_DEVINFO_NOT_REGISTERED syscall.Errno = 0x20000000 | 0xC0000000 | 0x208 - ERROR_INVALID_REG_PROPERTY syscall.Errno = 0x20000000 | 0xC0000000 | 0x209 - ERROR_NO_INF syscall.Errno = 0x20000000 | 0xC0000000 | 0x20A - ERROR_NO_SUCH_DEVINST syscall.Errno = 0x20000000 | 0xC0000000 | 0x20B - ERROR_CANT_LOAD_CLASS_ICON syscall.Errno = 0x20000000 | 0xC0000000 | 0x20C - ERROR_INVALID_CLASS_INSTALLER syscall.Errno = 0x20000000 | 0xC0000000 | 0x20D - ERROR_DI_DO_DEFAULT syscall.Errno = 0x20000000 | 0xC0000000 | 0x20E - ERROR_DI_NOFILECOPY syscall.Errno = 0x20000000 | 0xC0000000 | 0x20F - ERROR_INVALID_HWPROFILE syscall.Errno = 0x20000000 | 0xC0000000 | 0x210 - ERROR_NO_DEVICE_SELECTED syscall.Errno = 0x20000000 | 0xC0000000 | 0x211 - ERROR_DEVINFO_LIST_LOCKED syscall.Errno = 0x20000000 | 0xC0000000 | 0x212 - ERROR_DEVINFO_DATA_LOCKED syscall.Errno = 0x20000000 | 0xC0000000 | 0x213 - ERROR_DI_BAD_PATH syscall.Errno = 0x20000000 | 0xC0000000 | 0x214 - ERROR_NO_CLASSINSTALL_PARAMS syscall.Errno = 0x20000000 | 0xC0000000 | 0x215 - ERROR_FILEQUEUE_LOCKED syscall.Errno = 0x20000000 | 0xC0000000 | 0x216 - ERROR_BAD_SERVICE_INSTALLSECT syscall.Errno = 0x20000000 | 0xC0000000 | 0x217 - ERROR_NO_CLASS_DRIVER_LIST syscall.Errno = 0x20000000 | 0xC0000000 | 0x218 - ERROR_NO_ASSOCIATED_SERVICE syscall.Errno = 0x20000000 | 0xC0000000 | 0x219 - ERROR_NO_DEFAULT_DEVICE_INTERFACE syscall.Errno = 0x20000000 | 0xC0000000 | 0x21A - ERROR_DEVICE_INTERFACE_ACTIVE syscall.Errno = 0x20000000 | 0xC0000000 | 0x21B - ERROR_DEVICE_INTERFACE_REMOVED syscall.Errno = 0x20000000 | 0xC0000000 | 0x21C - ERROR_BAD_INTERFACE_INSTALLSECT syscall.Errno = 0x20000000 | 0xC0000000 | 0x21D - ERROR_NO_SUCH_INTERFACE_CLASS syscall.Errno = 0x20000000 | 0xC0000000 | 0x21E - ERROR_INVALID_REFERENCE_STRING syscall.Errno = 0x20000000 | 0xC0000000 | 0x21F - ERROR_INVALID_MACHINENAME syscall.Errno = 0x20000000 | 0xC0000000 | 0x220 - ERROR_REMOTE_COMM_FAILURE syscall.Errno = 0x20000000 | 0xC0000000 | 0x221 - ERROR_MACHINE_UNAVAILABLE syscall.Errno = 0x20000000 | 0xC0000000 | 0x222 - ERROR_NO_CONFIGMGR_SERVICES syscall.Errno = 0x20000000 | 0xC0000000 | 0x223 - ERROR_INVALID_PROPPAGE_PROVIDER syscall.Errno = 0x20000000 | 0xC0000000 | 0x224 - ERROR_NO_SUCH_DEVICE_INTERFACE syscall.Errno = 0x20000000 | 0xC0000000 | 0x225 - ERROR_DI_POSTPROCESSING_REQUIRED syscall.Errno = 0x20000000 | 0xC0000000 | 0x226 - ERROR_INVALID_COINSTALLER syscall.Errno = 0x20000000 | 0xC0000000 | 0x227 - ERROR_NO_COMPAT_DRIVERS syscall.Errno = 0x20000000 | 0xC0000000 | 0x228 - ERROR_NO_DEVICE_ICON syscall.Errno = 0x20000000 | 0xC0000000 | 0x229 - ERROR_INVALID_INF_LOGCONFIG syscall.Errno = 0x20000000 | 0xC0000000 | 0x22A - ERROR_DI_DONT_INSTALL syscall.Errno = 0x20000000 | 0xC0000000 | 0x22B - ERROR_INVALID_FILTER_DRIVER syscall.Errno = 0x20000000 | 0xC0000000 | 0x22C - ERROR_NON_WINDOWS_NT_DRIVER syscall.Errno = 0x20000000 | 0xC0000000 | 0x22D - ERROR_NON_WINDOWS_DRIVER syscall.Errno = 0x20000000 | 0xC0000000 | 0x22E - ERROR_NO_CATALOG_FOR_OEM_INF syscall.Errno = 0x20000000 | 0xC0000000 | 0x22F - ERROR_DEVINSTALL_QUEUE_NONNATIVE syscall.Errno = 0x20000000 | 0xC0000000 | 0x230 - ERROR_NOT_DISABLEABLE syscall.Errno = 0x20000000 | 0xC0000000 | 0x231 - ERROR_CANT_REMOVE_DEVINST syscall.Errno = 0x20000000 | 0xC0000000 | 0x232 - ERROR_INVALID_TARGET syscall.Errno = 0x20000000 | 0xC0000000 | 0x233 - ERROR_DRIVER_NONNATIVE syscall.Errno = 0x20000000 | 0xC0000000 | 0x234 - ERROR_IN_WOW64 syscall.Errno = 0x20000000 | 0xC0000000 | 0x235 - ERROR_SET_SYSTEM_RESTORE_POINT syscall.Errno = 0x20000000 | 0xC0000000 | 0x236 - ERROR_SCE_DISABLED syscall.Errno = 0x20000000 | 0xC0000000 | 0x238 - ERROR_UNKNOWN_EXCEPTION syscall.Errno = 0x20000000 | 0xC0000000 | 0x239 - ERROR_PNP_REGISTRY_ERROR syscall.Errno = 0x20000000 | 0xC0000000 | 0x23A - ERROR_REMOTE_REQUEST_UNSUPPORTED syscall.Errno = 0x20000000 | 0xC0000000 | 0x23B - ERROR_NOT_AN_INSTALLED_OEM_INF syscall.Errno = 0x20000000 | 0xC0000000 | 0x23C - ERROR_INF_IN_USE_BY_DEVICES syscall.Errno = 0x20000000 | 0xC0000000 | 0x23D - ERROR_DI_FUNCTION_OBSOLETE syscall.Errno = 0x20000000 | 0xC0000000 | 0x23E - ERROR_NO_AUTHENTICODE_CATALOG syscall.Errno = 0x20000000 | 0xC0000000 | 0x23F - ERROR_AUTHENTICODE_DISALLOWED syscall.Errno = 0x20000000 | 0xC0000000 | 0x240 - ERROR_AUTHENTICODE_TRUSTED_PUBLISHER syscall.Errno = 0x20000000 | 0xC0000000 | 0x241 - ERROR_AUTHENTICODE_TRUST_NOT_ESTABLISHED syscall.Errno = 0x20000000 | 0xC0000000 | 0x242 - ERROR_AUTHENTICODE_PUBLISHER_NOT_TRUSTED syscall.Errno = 0x20000000 | 0xC0000000 | 0x243 - ERROR_SIGNATURE_OSATTRIBUTE_MISMATCH syscall.Errno = 0x20000000 | 0xC0000000 | 0x244 - ERROR_ONLY_VALIDATE_VIA_AUTHENTICODE syscall.Errno = 0x20000000 | 0xC0000000 | 0x245 - ERROR_DEVICE_INSTALLER_NOT_READY syscall.Errno = 0x20000000 | 0xC0000000 | 0x246 - ERROR_DRIVER_STORE_ADD_FAILED syscall.Errno = 0x20000000 | 0xC0000000 | 0x247 - ERROR_DEVICE_INSTALL_BLOCKED syscall.Errno = 0x20000000 | 0xC0000000 | 0x248 - ERROR_DRIVER_INSTALL_BLOCKED syscall.Errno = 0x20000000 | 0xC0000000 | 0x249 - ERROR_WRONG_INF_TYPE syscall.Errno = 0x20000000 | 0xC0000000 | 0x24A - ERROR_FILE_HASH_NOT_IN_CATALOG syscall.Errno = 0x20000000 | 0xC0000000 | 0x24B - ERROR_DRIVER_STORE_DELETE_FAILED syscall.Errno = 0x20000000 | 0xC0000000 | 0x24C - ERROR_UNRECOVERABLE_STACK_OVERFLOW syscall.Errno = 0x20000000 | 0xC0000000 | 0x300 - EXCEPTION_SPAPI_UNRECOVERABLE_STACK_OVERFLOW syscall.Errno = ERROR_UNRECOVERABLE_STACK_OVERFLOW - ERROR_NO_DEFAULT_INTERFACE_DEVICE syscall.Errno = ERROR_NO_DEFAULT_DEVICE_INTERFACE - ERROR_INTERFACE_DEVICE_ACTIVE syscall.Errno = ERROR_DEVICE_INTERFACE_ACTIVE - ERROR_INTERFACE_DEVICE_REMOVED syscall.Errno = ERROR_DEVICE_INTERFACE_REMOVED - ERROR_NO_SUCH_INTERFACE_DEVICE syscall.Errno = ERROR_NO_SUCH_DEVICE_INTERFACE -) diff --git a/vendor/golang.org/x/sys/windows/syscall_windows.go b/vendor/golang.org/x/sys/windows/syscall_windows.go index 53ee74e08b5..200b62a0032 100644 --- a/vendor/golang.org/x/sys/windows/syscall_windows.go +++ b/vendor/golang.org/x/sys/windows/syscall_windows.go @@ -248,6 +248,7 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys FreeEnvironmentStrings(envs *uint16) (err error) = kernel32.FreeEnvironmentStringsW //sys GetEnvironmentVariable(name *uint16, buffer *uint16, size uint32) (n uint32, err error) = kernel32.GetEnvironmentVariableW //sys SetEnvironmentVariable(name *uint16, value *uint16) (err error) = kernel32.SetEnvironmentVariableW +//sys ExpandEnvironmentStrings(src *uint16, dst *uint16, size uint32) (n uint32, err error) = kernel32.ExpandEnvironmentStringsW //sys CreateEnvironmentBlock(block **uint16, token Token, inheritExisting bool) (err error) = userenv.CreateEnvironmentBlock //sys DestroyEnvironmentBlock(block *uint16) (err error) = userenv.DestroyEnvironmentBlock //sys getTickCount64() (ms uint64) = kernel32.GetTickCount64 @@ -322,6 +323,8 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) = kernel32.WriteConsoleW //sys ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) = kernel32.ReadConsoleW //sys CreateToolhelp32Snapshot(flags uint32, processId uint32) (handle Handle, err error) [failretval==InvalidHandle] = kernel32.CreateToolhelp32Snapshot +//sys Module32First(snapshot Handle, moduleEntry *ModuleEntry32) (err error) = kernel32.Module32FirstW +//sys Module32Next(snapshot Handle, moduleEntry *ModuleEntry32) (err error) = kernel32.Module32NextW //sys Process32First(snapshot Handle, procEntry *ProcessEntry32) (err error) = kernel32.Process32FirstW //sys Process32Next(snapshot Handle, procEntry *ProcessEntry32) (err error) = kernel32.Process32NextW //sys Thread32First(snapshot Handle, threadEntry *ThreadEntry32) (err error) @@ -893,9 +896,7 @@ func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, int32, error) { p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), int32(unsafe.Sizeof(sa.raw)), nil } @@ -915,9 +916,7 @@ func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, int32, error) { p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) sa.raw.Scope_id = sa.ZoneId - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } + sa.raw.Addr = sa.Addr return unsafe.Pointer(&sa.raw), int32(unsafe.Sizeof(sa.raw)), nil } @@ -990,9 +989,7 @@ func (rsa *RawSockaddrAny) Sockaddr() (Sockaddr, error) { sa := new(SockaddrInet4) p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil case AF_INET6: @@ -1001,9 +998,7 @@ func (rsa *RawSockaddrAny) Sockaddr() (Sockaddr, error) { p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) sa.ZoneId = pp.Scope_id - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } + sa.Addr = pp.Addr return sa, nil } return nil, syscall.EAFNOSUPPORT diff --git a/vendor/golang.org/x/sys/windows/types_windows.go b/vendor/golang.org/x/sys/windows/types_windows.go index 286dd1eab95..bb31abda416 100644 --- a/vendor/golang.org/x/sys/windows/types_windows.go +++ b/vendor/golang.org/x/sys/windows/types_windows.go @@ -156,6 +156,8 @@ const ( MAX_PATH = 260 MAX_LONG_PATH = 32768 + MAX_MODULE_NAME32 = 255 + MAX_COMPUTERNAME_LENGTH = 15 TIME_ZONE_ID_UNKNOWN = 0 @@ -936,8 +938,8 @@ type StartupInfoEx struct { type ProcThreadAttributeList struct{} type ProcThreadAttributeListContainer struct { - data *ProcThreadAttributeList - heapAllocations []uintptr + data *ProcThreadAttributeList + pointers []unsafe.Pointer } type ProcessInformation struct { @@ -970,6 +972,21 @@ type ThreadEntry32 struct { Flags uint32 } +type ModuleEntry32 struct { + Size uint32 + ModuleID uint32 + ProcessID uint32 + GlblcntUsage uint32 + ProccntUsage uint32 + ModBaseAddr uintptr + ModBaseSize uint32 + ModuleHandle Handle + Module [MAX_MODULE_NAME32 + 1]uint16 + ExePath [MAX_PATH]uint16 +} + +const SizeofModuleEntry32 = unsafe.Sizeof(ModuleEntry32{}) + type Systemtime struct { Year uint16 Month uint16 @@ -2732,6 +2749,43 @@ type PROCESS_BASIC_INFORMATION struct { InheritedFromUniqueProcessId uintptr } +type SYSTEM_PROCESS_INFORMATION struct { + NextEntryOffset uint32 + NumberOfThreads uint32 + WorkingSetPrivateSize int64 + HardFaultCount uint32 + NumberOfThreadsHighWatermark uint32 + CycleTime uint64 + CreateTime int64 + UserTime int64 + KernelTime int64 + ImageName NTUnicodeString + BasePriority int32 + UniqueProcessID uintptr + InheritedFromUniqueProcessID uintptr + HandleCount uint32 + SessionID uint32 + UniqueProcessKey *uint32 + PeakVirtualSize uintptr + VirtualSize uintptr + PageFaultCount uint32 + PeakWorkingSetSize uintptr + WorkingSetSize uintptr + QuotaPeakPagedPoolUsage uintptr + QuotaPagedPoolUsage uintptr + QuotaPeakNonPagedPoolUsage uintptr + QuotaNonPagedPoolUsage uintptr + PagefileUsage uintptr + PeakPagefileUsage uintptr + PrivatePageCount uintptr + ReadOperationCount int64 + WriteOperationCount int64 + OtherOperationCount int64 + ReadTransferCount int64 + WriteTransferCount int64 + OtherTransferCount int64 +} + // SystemInformationClasses for NtQuerySystemInformation and NtSetSystemInformation const ( SystemBasicInformation = iota diff --git a/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/vendor/golang.org/x/sys/windows/zsyscall_windows.go index 91817d6dcbb..1055d47ed33 100644 --- a/vendor/golang.org/x/sys/windows/zsyscall_windows.go +++ b/vendor/golang.org/x/sys/windows/zsyscall_windows.go @@ -36,6 +36,7 @@ func errnoErr(e syscall.Errno) error { } var ( + modCfgMgr32 = NewLazySystemDLL("CfgMgr32.dll") modadvapi32 = NewLazySystemDLL("advapi32.dll") modcrypt32 = NewLazySystemDLL("crypt32.dll") moddnsapi = NewLazySystemDLL("dnsapi.dll") @@ -48,6 +49,7 @@ var ( modpsapi = NewLazySystemDLL("psapi.dll") modsechost = NewLazySystemDLL("sechost.dll") modsecur32 = NewLazySystemDLL("secur32.dll") + modsetupapi = NewLazySystemDLL("setupapi.dll") modshell32 = NewLazySystemDLL("shell32.dll") moduser32 = NewLazySystemDLL("user32.dll") moduserenv = NewLazySystemDLL("userenv.dll") @@ -56,6 +58,10 @@ var ( modws2_32 = NewLazySystemDLL("ws2_32.dll") modwtsapi32 = NewLazySystemDLL("wtsapi32.dll") + procCM_Get_DevNode_Status = modCfgMgr32.NewProc("CM_Get_DevNode_Status") + procCM_Get_Device_Interface_ListW = modCfgMgr32.NewProc("CM_Get_Device_Interface_ListW") + procCM_Get_Device_Interface_List_SizeW = modCfgMgr32.NewProc("CM_Get_Device_Interface_List_SizeW") + procCM_MapCrToWin32Err = modCfgMgr32.NewProc("CM_MapCrToWin32Err") procAdjustTokenGroups = modadvapi32.NewProc("AdjustTokenGroups") procAdjustTokenPrivileges = modadvapi32.NewProc("AdjustTokenPrivileges") procAllocateAndInitializeSid = modadvapi32.NewProc("AllocateAndInitializeSid") @@ -199,6 +205,7 @@ var ( procDeviceIoControl = modkernel32.NewProc("DeviceIoControl") procDuplicateHandle = modkernel32.NewProc("DuplicateHandle") procExitProcess = modkernel32.NewProc("ExitProcess") + procExpandEnvironmentStringsW = modkernel32.NewProc("ExpandEnvironmentStringsW") procFindClose = modkernel32.NewProc("FindClose") procFindCloseChangeNotification = modkernel32.NewProc("FindCloseChangeNotification") procFindFirstChangeNotificationW = modkernel32.NewProc("FindFirstChangeNotificationW") @@ -288,6 +295,8 @@ var ( procLockFileEx = modkernel32.NewProc("LockFileEx") procLockResource = modkernel32.NewProc("LockResource") procMapViewOfFile = modkernel32.NewProc("MapViewOfFile") + procModule32FirstW = modkernel32.NewProc("Module32FirstW") + procModule32NextW = modkernel32.NewProc("Module32NextW") procMoveFileExW = modkernel32.NewProc("MoveFileExW") procMoveFileW = modkernel32.NewProc("MoveFileW") procMultiByteToWideChar = modkernel32.NewProc("MultiByteToWideChar") @@ -400,6 +409,34 @@ var ( procUnsubscribeServiceChangeNotifications = modsechost.NewProc("UnsubscribeServiceChangeNotifications") procGetUserNameExW = modsecur32.NewProc("GetUserNameExW") procTranslateNameW = modsecur32.NewProc("TranslateNameW") + procSetupDiBuildDriverInfoList = modsetupapi.NewProc("SetupDiBuildDriverInfoList") + procSetupDiCallClassInstaller = modsetupapi.NewProc("SetupDiCallClassInstaller") + procSetupDiCancelDriverInfoSearch = modsetupapi.NewProc("SetupDiCancelDriverInfoSearch") + procSetupDiClassGuidsFromNameExW = modsetupapi.NewProc("SetupDiClassGuidsFromNameExW") + procSetupDiClassNameFromGuidExW = modsetupapi.NewProc("SetupDiClassNameFromGuidExW") + procSetupDiCreateDeviceInfoListExW = modsetupapi.NewProc("SetupDiCreateDeviceInfoListExW") + procSetupDiCreateDeviceInfoW = modsetupapi.NewProc("SetupDiCreateDeviceInfoW") + procSetupDiDestroyDeviceInfoList = modsetupapi.NewProc("SetupDiDestroyDeviceInfoList") + procSetupDiDestroyDriverInfoList = modsetupapi.NewProc("SetupDiDestroyDriverInfoList") + procSetupDiEnumDeviceInfo = modsetupapi.NewProc("SetupDiEnumDeviceInfo") + procSetupDiEnumDriverInfoW = modsetupapi.NewProc("SetupDiEnumDriverInfoW") + procSetupDiGetClassDevsExW = modsetupapi.NewProc("SetupDiGetClassDevsExW") + procSetupDiGetClassInstallParamsW = modsetupapi.NewProc("SetupDiGetClassInstallParamsW") + procSetupDiGetDeviceInfoListDetailW = modsetupapi.NewProc("SetupDiGetDeviceInfoListDetailW") + procSetupDiGetDeviceInstallParamsW = modsetupapi.NewProc("SetupDiGetDeviceInstallParamsW") + procSetupDiGetDeviceInstanceIdW = modsetupapi.NewProc("SetupDiGetDeviceInstanceIdW") + procSetupDiGetDevicePropertyW = modsetupapi.NewProc("SetupDiGetDevicePropertyW") + procSetupDiGetDeviceRegistryPropertyW = modsetupapi.NewProc("SetupDiGetDeviceRegistryPropertyW") + procSetupDiGetDriverInfoDetailW = modsetupapi.NewProc("SetupDiGetDriverInfoDetailW") + procSetupDiGetSelectedDevice = modsetupapi.NewProc("SetupDiGetSelectedDevice") + procSetupDiGetSelectedDriverW = modsetupapi.NewProc("SetupDiGetSelectedDriverW") + procSetupDiOpenDevRegKey = modsetupapi.NewProc("SetupDiOpenDevRegKey") + procSetupDiSetClassInstallParamsW = modsetupapi.NewProc("SetupDiSetClassInstallParamsW") + procSetupDiSetDeviceInstallParamsW = modsetupapi.NewProc("SetupDiSetDeviceInstallParamsW") + procSetupDiSetDeviceRegistryPropertyW = modsetupapi.NewProc("SetupDiSetDeviceRegistryPropertyW") + procSetupDiSetSelectedDevice = modsetupapi.NewProc("SetupDiSetSelectedDevice") + procSetupDiSetSelectedDriverW = modsetupapi.NewProc("SetupDiSetSelectedDriverW") + procSetupUninstallOEMInfW = modsetupapi.NewProc("SetupUninstallOEMInfW") procCommandLineToArgvW = modshell32.NewProc("CommandLineToArgvW") procSHGetKnownFolderPath = modshell32.NewProc("SHGetKnownFolderPath") procShellExecuteW = modshell32.NewProc("ShellExecuteW") @@ -447,6 +484,30 @@ var ( procWTSQueryUserToken = modwtsapi32.NewProc("WTSQueryUserToken") ) +func cm_Get_DevNode_Status(status *uint32, problemNumber *uint32, devInst DEVINST, flags uint32) (ret CONFIGRET) { + r0, _, _ := syscall.Syscall6(procCM_Get_DevNode_Status.Addr(), 4, uintptr(unsafe.Pointer(status)), uintptr(unsafe.Pointer(problemNumber)), uintptr(devInst), uintptr(flags), 0, 0) + ret = CONFIGRET(r0) + return +} + +func cm_Get_Device_Interface_List(interfaceClass *GUID, deviceID *uint16, buffer *uint16, bufferLen uint32, flags uint32) (ret CONFIGRET) { + r0, _, _ := syscall.Syscall6(procCM_Get_Device_Interface_ListW.Addr(), 5, uintptr(unsafe.Pointer(interfaceClass)), uintptr(unsafe.Pointer(deviceID)), uintptr(unsafe.Pointer(buffer)), uintptr(bufferLen), uintptr(flags), 0) + ret = CONFIGRET(r0) + return +} + +func cm_Get_Device_Interface_List_Size(len *uint32, interfaceClass *GUID, deviceID *uint16, flags uint32) (ret CONFIGRET) { + r0, _, _ := syscall.Syscall6(procCM_Get_Device_Interface_List_SizeW.Addr(), 4, uintptr(unsafe.Pointer(len)), uintptr(unsafe.Pointer(interfaceClass)), uintptr(unsafe.Pointer(deviceID)), uintptr(flags), 0, 0) + ret = CONFIGRET(r0) + return +} + +func cm_MapCrToWin32Err(configRet CONFIGRET, defaultWin32Error Errno) (ret Errno) { + r0, _, _ := syscall.Syscall(procCM_MapCrToWin32Err.Addr(), 2, uintptr(configRet), uintptr(defaultWin32Error), 0) + ret = Errno(r0) + return +} + func AdjustTokenGroups(token Token, resetToDefault bool, newstate *Tokengroups, buflen uint32, prevstate *Tokengroups, returnlen *uint32) (err error) { var _p0 uint32 if resetToDefault { @@ -1716,6 +1777,15 @@ func ExitProcess(exitcode uint32) { return } +func ExpandEnvironmentStrings(src *uint16, dst *uint16, size uint32) (n uint32, err error) { + r0, _, e1 := syscall.Syscall(procExpandEnvironmentStringsW.Addr(), 3, uintptr(unsafe.Pointer(src)), uintptr(unsafe.Pointer(dst)), uintptr(size)) + n = uint32(r0) + if n == 0 { + err = errnoErr(e1) + } + return +} + func FindClose(handle Handle) (err error) { r1, _, e1 := syscall.Syscall(procFindClose.Addr(), 1, uintptr(handle), 0, 0) if r1 == 0 { @@ -2499,6 +2569,22 @@ func MapViewOfFile(handle Handle, access uint32, offsetHigh uint32, offsetLow ui return } +func Module32First(snapshot Handle, moduleEntry *ModuleEntry32) (err error) { + r1, _, e1 := syscall.Syscall(procModule32FirstW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(moduleEntry)), 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + +func Module32Next(snapshot Handle, moduleEntry *ModuleEntry32) (err error) { + r1, _, e1 := syscall.Syscall(procModule32NextW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(moduleEntry)), 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) { r1, _, e1 := syscall.Syscall(procMoveFileExW.Addr(), 3, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), uintptr(flags)) if r1 == 0 { @@ -3432,6 +3518,233 @@ func TranslateName(accName *uint16, accNameFormat uint32, desiredNameFormat uint return } +func SetupDiBuildDriverInfoList(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, driverType SPDIT) (err error) { + r1, _, e1 := syscall.Syscall(procSetupDiBuildDriverInfoList.Addr(), 3, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(driverType)) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + +func SetupDiCallClassInstaller(installFunction DI_FUNCTION, deviceInfoSet DevInfo, deviceInfoData *DevInfoData) (err error) { + r1, _, e1 := syscall.Syscall(procSetupDiCallClassInstaller.Addr(), 3, uintptr(installFunction), uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData))) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + +func SetupDiCancelDriverInfoSearch(deviceInfoSet DevInfo) (err error) { + r1, _, e1 := syscall.Syscall(procSetupDiCancelDriverInfoSearch.Addr(), 1, uintptr(deviceInfoSet), 0, 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + +func setupDiClassGuidsFromNameEx(className *uint16, classGuidList *GUID, classGuidListSize uint32, requiredSize *uint32, machineName *uint16, reserved uintptr) (err error) { + r1, _, e1 := syscall.Syscall6(procSetupDiClassGuidsFromNameExW.Addr(), 6, uintptr(unsafe.Pointer(className)), uintptr(unsafe.Pointer(classGuidList)), uintptr(classGuidListSize), uintptr(unsafe.Pointer(requiredSize)), uintptr(unsafe.Pointer(machineName)), uintptr(reserved)) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + +func setupDiClassNameFromGuidEx(classGUID *GUID, className *uint16, classNameSize uint32, requiredSize *uint32, machineName *uint16, reserved uintptr) (err error) { + r1, _, e1 := syscall.Syscall6(procSetupDiClassNameFromGuidExW.Addr(), 6, uintptr(unsafe.Pointer(classGUID)), uintptr(unsafe.Pointer(className)), uintptr(classNameSize), uintptr(unsafe.Pointer(requiredSize)), uintptr(unsafe.Pointer(machineName)), uintptr(reserved)) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + +func setupDiCreateDeviceInfoListEx(classGUID *GUID, hwndParent uintptr, machineName *uint16, reserved uintptr) (handle DevInfo, err error) { + r0, _, e1 := syscall.Syscall6(procSetupDiCreateDeviceInfoListExW.Addr(), 4, uintptr(unsafe.Pointer(classGUID)), uintptr(hwndParent), uintptr(unsafe.Pointer(machineName)), uintptr(reserved), 0, 0) + handle = DevInfo(r0) + if handle == DevInfo(InvalidHandle) { + err = errnoErr(e1) + } + return +} + +func setupDiCreateDeviceInfo(deviceInfoSet DevInfo, DeviceName *uint16, classGUID *GUID, DeviceDescription *uint16, hwndParent uintptr, CreationFlags DICD, deviceInfoData *DevInfoData) (err error) { + r1, _, e1 := syscall.Syscall9(procSetupDiCreateDeviceInfoW.Addr(), 7, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(DeviceName)), uintptr(unsafe.Pointer(classGUID)), uintptr(unsafe.Pointer(DeviceDescription)), uintptr(hwndParent), uintptr(CreationFlags), uintptr(unsafe.Pointer(deviceInfoData)), 0, 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + +func SetupDiDestroyDeviceInfoList(deviceInfoSet DevInfo) (err error) { + r1, _, e1 := syscall.Syscall(procSetupDiDestroyDeviceInfoList.Addr(), 1, uintptr(deviceInfoSet), 0, 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + +func SetupDiDestroyDriverInfoList(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, driverType SPDIT) (err error) { + r1, _, e1 := syscall.Syscall(procSetupDiDestroyDriverInfoList.Addr(), 3, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(driverType)) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + +func setupDiEnumDeviceInfo(deviceInfoSet DevInfo, memberIndex uint32, deviceInfoData *DevInfoData) (err error) { + r1, _, e1 := syscall.Syscall(procSetupDiEnumDeviceInfo.Addr(), 3, uintptr(deviceInfoSet), uintptr(memberIndex), uintptr(unsafe.Pointer(deviceInfoData))) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + +func setupDiEnumDriverInfo(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, driverType SPDIT, memberIndex uint32, driverInfoData *DrvInfoData) (err error) { + r1, _, e1 := syscall.Syscall6(procSetupDiEnumDriverInfoW.Addr(), 5, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(driverType), uintptr(memberIndex), uintptr(unsafe.Pointer(driverInfoData)), 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + +func setupDiGetClassDevsEx(classGUID *GUID, Enumerator *uint16, hwndParent uintptr, Flags DIGCF, deviceInfoSet DevInfo, machineName *uint16, reserved uintptr) (handle DevInfo, err error) { + r0, _, e1 := syscall.Syscall9(procSetupDiGetClassDevsExW.Addr(), 7, uintptr(unsafe.Pointer(classGUID)), uintptr(unsafe.Pointer(Enumerator)), uintptr(hwndParent), uintptr(Flags), uintptr(deviceInfoSet), uintptr(unsafe.Pointer(machineName)), uintptr(reserved), 0, 0) + handle = DevInfo(r0) + if handle == DevInfo(InvalidHandle) { + err = errnoErr(e1) + } + return +} + +func SetupDiGetClassInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, classInstallParams *ClassInstallHeader, classInstallParamsSize uint32, requiredSize *uint32) (err error) { + r1, _, e1 := syscall.Syscall6(procSetupDiGetClassInstallParamsW.Addr(), 5, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(unsafe.Pointer(classInstallParams)), uintptr(classInstallParamsSize), uintptr(unsafe.Pointer(requiredSize)), 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + +func setupDiGetDeviceInfoListDetail(deviceInfoSet DevInfo, deviceInfoSetDetailData *DevInfoListDetailData) (err error) { + r1, _, e1 := syscall.Syscall(procSetupDiGetDeviceInfoListDetailW.Addr(), 2, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoSetDetailData)), 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + +func setupDiGetDeviceInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, deviceInstallParams *DevInstallParams) (err error) { + r1, _, e1 := syscall.Syscall(procSetupDiGetDeviceInstallParamsW.Addr(), 3, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(unsafe.Pointer(deviceInstallParams))) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + +func setupDiGetDeviceInstanceId(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, instanceId *uint16, instanceIdSize uint32, instanceIdRequiredSize *uint32) (err error) { + r1, _, e1 := syscall.Syscall6(procSetupDiGetDeviceInstanceIdW.Addr(), 5, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(unsafe.Pointer(instanceId)), uintptr(instanceIdSize), uintptr(unsafe.Pointer(instanceIdRequiredSize)), 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + +func setupDiGetDeviceProperty(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, propertyKey *DEVPROPKEY, propertyType *DEVPROPTYPE, propertyBuffer *byte, propertyBufferSize uint32, requiredSize *uint32, flags uint32) (err error) { + r1, _, e1 := syscall.Syscall9(procSetupDiGetDevicePropertyW.Addr(), 8, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(unsafe.Pointer(propertyKey)), uintptr(unsafe.Pointer(propertyType)), uintptr(unsafe.Pointer(propertyBuffer)), uintptr(propertyBufferSize), uintptr(unsafe.Pointer(requiredSize)), uintptr(flags), 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + +func setupDiGetDeviceRegistryProperty(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, property SPDRP, propertyRegDataType *uint32, propertyBuffer *byte, propertyBufferSize uint32, requiredSize *uint32) (err error) { + r1, _, e1 := syscall.Syscall9(procSetupDiGetDeviceRegistryPropertyW.Addr(), 7, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(property), uintptr(unsafe.Pointer(propertyRegDataType)), uintptr(unsafe.Pointer(propertyBuffer)), uintptr(propertyBufferSize), uintptr(unsafe.Pointer(requiredSize)), 0, 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + +func setupDiGetDriverInfoDetail(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, driverInfoData *DrvInfoData, driverInfoDetailData *DrvInfoDetailData, driverInfoDetailDataSize uint32, requiredSize *uint32) (err error) { + r1, _, e1 := syscall.Syscall6(procSetupDiGetDriverInfoDetailW.Addr(), 6, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(unsafe.Pointer(driverInfoData)), uintptr(unsafe.Pointer(driverInfoDetailData)), uintptr(driverInfoDetailDataSize), uintptr(unsafe.Pointer(requiredSize))) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + +func setupDiGetSelectedDevice(deviceInfoSet DevInfo, deviceInfoData *DevInfoData) (err error) { + r1, _, e1 := syscall.Syscall(procSetupDiGetSelectedDevice.Addr(), 2, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + +func setupDiGetSelectedDriver(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, driverInfoData *DrvInfoData) (err error) { + r1, _, e1 := syscall.Syscall(procSetupDiGetSelectedDriverW.Addr(), 3, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(unsafe.Pointer(driverInfoData))) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + +func SetupDiOpenDevRegKey(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, Scope DICS_FLAG, HwProfile uint32, KeyType DIREG, samDesired uint32) (key Handle, err error) { + r0, _, e1 := syscall.Syscall6(procSetupDiOpenDevRegKey.Addr(), 6, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(Scope), uintptr(HwProfile), uintptr(KeyType), uintptr(samDesired)) + key = Handle(r0) + if key == InvalidHandle { + err = errnoErr(e1) + } + return +} + +func SetupDiSetClassInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, classInstallParams *ClassInstallHeader, classInstallParamsSize uint32) (err error) { + r1, _, e1 := syscall.Syscall6(procSetupDiSetClassInstallParamsW.Addr(), 4, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(unsafe.Pointer(classInstallParams)), uintptr(classInstallParamsSize), 0, 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + +func SetupDiSetDeviceInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, deviceInstallParams *DevInstallParams) (err error) { + r1, _, e1 := syscall.Syscall(procSetupDiSetDeviceInstallParamsW.Addr(), 3, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(unsafe.Pointer(deviceInstallParams))) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + +func setupDiSetDeviceRegistryProperty(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, property SPDRP, propertyBuffer *byte, propertyBufferSize uint32) (err error) { + r1, _, e1 := syscall.Syscall6(procSetupDiSetDeviceRegistryPropertyW.Addr(), 5, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(property), uintptr(unsafe.Pointer(propertyBuffer)), uintptr(propertyBufferSize), 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + +func SetupDiSetSelectedDevice(deviceInfoSet DevInfo, deviceInfoData *DevInfoData) (err error) { + r1, _, e1 := syscall.Syscall(procSetupDiSetSelectedDevice.Addr(), 2, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + +func SetupDiSetSelectedDriver(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, driverInfoData *DrvInfoData) (err error) { + r1, _, e1 := syscall.Syscall(procSetupDiSetSelectedDriverW.Addr(), 3, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(unsafe.Pointer(driverInfoData))) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + +func setupUninstallOEMInf(infFileName *uint16, flags SUOI, reserved uintptr) (err error) { + r1, _, e1 := syscall.Syscall(procSetupUninstallOEMInfW.Addr(), 3, uintptr(unsafe.Pointer(infFileName)), uintptr(flags), uintptr(reserved)) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func CommandLineToArgv(cmd *uint16, argc *int32) (argv *[8192]*[8192]uint16, err error) { r0, _, e1 := syscall.Syscall(procCommandLineToArgvW.Addr(), 2, uintptr(unsafe.Pointer(cmd)), uintptr(unsafe.Pointer(argc)), 0) argv = (*[8192]*[8192]uint16)(unsafe.Pointer(r0)) diff --git a/vendor/golang.org/x/term/codereview.cfg b/vendor/golang.org/x/term/codereview.cfg new file mode 100644 index 00000000000..3f8b14b64e8 --- /dev/null +++ b/vendor/golang.org/x/term/codereview.cfg @@ -0,0 +1 @@ +issuerepo: golang/go diff --git a/vendor/golang.org/x/term/term.go b/vendor/golang.org/x/term/term.go index 1f6a38fad2a..d5927088082 100644 --- a/vendor/golang.org/x/term/term.go +++ b/vendor/golang.org/x/term/term.go @@ -12,6 +12,8 @@ // panic(err) // } // defer term.Restore(int(os.Stdin.Fd()), oldState) +// +// Note that on non-Unix systems os.Stdin.Fd() may not be 0. package term // State contains the state of a terminal. diff --git a/vendor/k8s.io/utils/clock/clock.go b/vendor/k8s.io/utils/clock/clock.go index dd181ce8d8b..b8b6af5c817 100644 --- a/vendor/k8s.io/utils/clock/clock.go +++ b/vendor/k8s.io/utils/clock/clock.go @@ -63,6 +63,16 @@ type WithDelayedExecution interface { AfterFunc(d time.Duration, f func()) Timer } +// WithTickerAndDelayedExecution allows for injecting fake or real clocks +// into code that needs Ticker and AfterFunc functionality +type WithTickerAndDelayedExecution interface { + WithTicker + // AfterFunc executes f in its own goroutine after waiting + // for d duration and returns a Timer whose channel can be + // closed by calling Stop() on the Timer. + AfterFunc(d time.Duration, f func()) Timer +} + // Ticker defines the Ticker interface. type Ticker interface { C() <-chan time.Time diff --git a/vendor/k8s.io/utils/clock/testing/fake_clock.go b/vendor/k8s.io/utils/clock/testing/fake_clock.go index fb493c4baba..a2b42bbcf6d 100644 --- a/vendor/k8s.io/utils/clock/testing/fake_clock.go +++ b/vendor/k8s.io/utils/clock/testing/fake_clock.go @@ -282,9 +282,9 @@ func (*IntervalClock) Tick(d time.Duration) <-chan time.Time { // NewTicker has no implementation yet and is omitted. // TODO: make interval clock use FakeClock so this can be implemented. -//func (*IntervalClock) NewTicker(d time.Duration) clock.Ticker { -// panic("IntervalClock doesn't implement NewTicker") -//} +func (*IntervalClock) NewTicker(d time.Duration) clock.Ticker { + panic("IntervalClock doesn't implement NewTicker") +} // Sleep is unimplemented, will panic. func (*IntervalClock) Sleep(d time.Duration) { diff --git a/vendor/modules.txt b/vendor/modules.txt index 7f515526550..2579f8d8057 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -60,14 +60,50 @@ github.com/Azure/go-autorest/tracing # github.com/BurntSushi/toml v0.3.1 ## explicit github.com/BurntSushi/toml -# github.com/IBM-Cloud/bluemix-go v0.0.0-20210611051827-cdc80c935c05 +# github.com/IBM-Cloud/bluemix-go v0.0.0-20211102075456-ffc4e11dfb16 ## explicit; go 1.13 github.com/IBM-Cloud/bluemix-go/crn +# github.com/IBM-Cloud/power-go-client v1.1.4 +## explicit; go 1.17 +github.com/IBM-Cloud/power-go-client/helpers +github.com/IBM-Cloud/power-go-client/ibmpisession +github.com/IBM-Cloud/power-go-client/power/client +github.com/IBM-Cloud/power-go-client/power/client/authentication +github.com/IBM-Cloud/power-go-client/power/client/bluemix_service_instances +github.com/IBM-Cloud/power-go-client/power/client/catalog +github.com/IBM-Cloud/power-go-client/power/client/hardware_platforms +github.com/IBM-Cloud/power-go-client/power/client/iaas_service_broker +github.com/IBM-Cloud/power-go-client/power/client/internal_storage_regions +github.com/IBM-Cloud/power-go-client/power/client/open_stacks +github.com/IBM-Cloud/power-go-client/power/client/p_cloud_cloud_connections +github.com/IBM-Cloud/power-go-client/power/client/p_cloud_events +github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images +github.com/IBM-Cloud/power-go-client/power/client/p_cloud_instances +github.com/IBM-Cloud/power-go-client/power/client/p_cloud_jobs +github.com/IBM-Cloud/power-go-client/power/client/p_cloud_networks +github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances +github.com/IBM-Cloud/power-go-client/power/client/p_cloud_placement_groups +github.com/IBM-Cloud/power-go-client/power/client/p_cloud_s_a_p +github.com/IBM-Cloud/power-go-client/power/client/p_cloud_service_d_h_c_p +github.com/IBM-Cloud/power-go-client/power/client/p_cloud_snapshots +github.com/IBM-Cloud/power-go-client/power/client/p_cloud_storage_capacity +github.com/IBM-Cloud/power-go-client/power/client/p_cloud_system_pools +github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tasks +github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants +github.com/IBM-Cloud/power-go-client/power/client/p_cloud_tenants_ssh_keys +github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_connections +github.com/IBM-Cloud/power-go-client/power/client/p_cloud_v_p_n_policies +github.com/IBM-Cloud/power-go-client/power/client/p_cloud_volumes +github.com/IBM-Cloud/power-go-client/power/client/service_bindings +github.com/IBM-Cloud/power-go-client/power/client/service_instances +github.com/IBM-Cloud/power-go-client/power/client/storage_types +github.com/IBM-Cloud/power-go-client/power/client/swagger_spec +github.com/IBM-Cloud/power-go-client/power/models # github.com/IBM/go-sdk-core/v4 v4.9.0 ## explicit; go 1.12 github.com/IBM/go-sdk-core/v4/core -# github.com/IBM/go-sdk-core/v5 v5.4.3 -## explicit; go 1.12 +# github.com/IBM/go-sdk-core/v5 v5.9.1 +## explicit; go 1.14 github.com/IBM/go-sdk-core/v5/core # github.com/IBM/networking-go-sdk v0.14.0 ## explicit; go 1.14 @@ -85,6 +121,12 @@ github.com/IBM/platform-services-go-sdk/resourcemanagerv2 ## explicit; go 1.14 github.com/IBM/vpc-go-sdk/common github.com/IBM/vpc-go-sdk/vpcv1 +# github.com/PuerkitoBio/purell v1.1.1 +## explicit +github.com/PuerkitoBio/purell +# github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 +## explicit +github.com/PuerkitoBio/urlesc # github.com/aliyun/alibaba-cloud-sdk-go v1.61.1264 ## explicit; go 1.13 github.com/aliyun/alibaba-cloud-sdk-go/sdk @@ -111,7 +153,7 @@ github.com/aliyun/aliyun-oss-go-sdk/oss # github.com/apparentlymart/go-cidr v1.1.0 ## explicit github.com/apparentlymart/go-cidr/cidr -# github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef +# github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d ## explicit; go 1.13 github.com/asaskevich/govalidator # github.com/awalterschulze/gographviz v0.0.0-20190522210029-fa59802746ab @@ -232,8 +274,8 @@ github.com/dimchansky/utfbom # github.com/evanphx/json-patch v4.12.0+incompatible ## explicit github.com/evanphx/json-patch -# github.com/fatih/color v1.7.0 -## explicit +# github.com/fatih/color v1.12.0 +## explicit; go 1.13 github.com/fatih/color # github.com/form3tech-oss/jwt-go v3.2.3+incompatible ## explicit @@ -244,29 +286,67 @@ github.com/fsnotify/fsnotify # github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 ## explicit github.com/ghodss/yaml -# github.com/go-logr/logr v1.2.0 +# github.com/go-logr/logr v1.2.2 ## explicit; go 1.16 github.com/go-logr/logr -# github.com/go-openapi/errors v0.19.8 +# github.com/go-openapi/analysis v0.21.2 +## explicit; go 1.13 +github.com/go-openapi/analysis +github.com/go-openapi/analysis/internal/debug +github.com/go-openapi/analysis/internal/flatten/normalize +github.com/go-openapi/analysis/internal/flatten/operations +github.com/go-openapi/analysis/internal/flatten/replace +github.com/go-openapi/analysis/internal/flatten/schutils +github.com/go-openapi/analysis/internal/flatten/sortref +# github.com/go-openapi/errors v0.20.2 ## explicit; go 1.14 github.com/go-openapi/errors -# github.com/go-openapi/strfmt v0.20.1 +# github.com/go-openapi/jsonpointer v0.19.5 +## explicit; go 1.13 +github.com/go-openapi/jsonpointer +# github.com/go-openapi/jsonreference v0.19.6 +## explicit; go 1.13 +github.com/go-openapi/jsonreference +# github.com/go-openapi/loads v0.21.1 +## explicit; go 1.13 +github.com/go-openapi/loads +# github.com/go-openapi/runtime v0.23.0 +## explicit; go 1.15 +github.com/go-openapi/runtime +github.com/go-openapi/runtime/client +github.com/go-openapi/runtime/logger +github.com/go-openapi/runtime/middleware +github.com/go-openapi/runtime/middleware/denco +github.com/go-openapi/runtime/middleware/header +github.com/go-openapi/runtime/middleware/untyped +github.com/go-openapi/runtime/security +github.com/go-openapi/runtime/yamlpc +# github.com/go-openapi/spec v0.20.4 +## explicit; go 1.13 +github.com/go-openapi/spec +# github.com/go-openapi/strfmt v0.21.2 ## explicit; go 1.13 github.com/go-openapi/strfmt -# github.com/go-playground/locales v0.13.0 +# github.com/go-openapi/swag v0.21.1 +## explicit; go 1.11 +github.com/go-openapi/swag +# github.com/go-openapi/validate v0.20.3 +## explicit; go 1.14 +github.com/go-openapi/validate +# github.com/go-playground/locales v0.14.0 ## explicit; go 1.13 github.com/go-playground/locales github.com/go-playground/locales/currency -# github.com/go-playground/universal-translator v0.17.0 +# github.com/go-playground/universal-translator v0.18.0 ## explicit; go 1.13 github.com/go-playground/universal-translator # github.com/go-playground/validator/v10 v10.2.0 ## explicit; go 1.13 github.com/go-playground/validator/v10 -# github.com/go-stack/stack v1.8.0 -## explicit +# github.com/go-stack/stack v1.8.1 +## explicit; go 1.17 github.com/go-stack/stack -# github.com/gobuffalo/flect v0.2.2 +# github.com/gobuffalo/flect v0.2.3 ## explicit; go 1.13 github.com/gobuffalo/flect # github.com/gogo/protobuf v1.3.2 @@ -295,9 +375,10 @@ github.com/google/go-cmp/cmp/internal/diff github.com/google/go-cmp/cmp/internal/flags github.com/google/go-cmp/cmp/internal/function github.com/google/go-cmp/cmp/internal/value -# github.com/google/gofuzz v1.1.0 +# github.com/google/gofuzz v1.2.0 ## explicit; go 1.12 github.com/google/gofuzz +github.com/google/gofuzz/bytesource # github.com/google/renameio v1.0.0 ## explicit; go 1.13 github.com/google/renameio @@ -379,7 +460,7 @@ github.com/h2non/filetype/types # github.com/hashicorp/go-cleanhttp v0.5.2 ## explicit; go 1.13 github.com/hashicorp/go-cleanhttp -# github.com/hashicorp/go-retryablehttp v0.6.6 +# github.com/hashicorp/go-retryablehttp v0.7.0 ## explicit; go 1.13 github.com/hashicorp/go-retryablehttp # github.com/hashicorp/go-version v1.4.0 @@ -401,6 +482,9 @@ github.com/inconshreveable/mousetrap # github.com/jmespath/go-jmespath v0.4.0 ## explicit; go 1.14 github.com/jmespath/go-jmespath +# github.com/josharian/intern v1.0.0 +## explicit; go 1.5 +github.com/josharian/intern # github.com/json-iterator/go v1.1.12 ## explicit; go 1.12 github.com/json-iterator/go @@ -410,14 +494,19 @@ github.com/kballard/go-shellquote # github.com/kr/fs v0.1.0 ## explicit github.com/kr/fs -# github.com/leodido/go-urn v1.2.0 +# github.com/leodido/go-urn v1.2.1 ## explicit; go 1.13 github.com/leodido/go-urn # github.com/libvirt/libvirt-go v5.10.0+incompatible ## explicit github.com/libvirt/libvirt-go -# github.com/mattn/go-colorable v0.1.2 -## explicit +# github.com/mailru/easyjson v0.7.7 +## explicit; go 1.12 +github.com/mailru/easyjson/buffer +github.com/mailru/easyjson/jlexer +github.com/mailru/easyjson/jwriter +# github.com/mattn/go-colorable v0.1.8 +## explicit; go 1.13 github.com/mattn/go-colorable # github.com/mattn/go-isatty v0.0.12 ## explicit; go 1.12 @@ -440,7 +529,7 @@ github.com/mgutz/ansi # github.com/mitchellh/go-homedir v1.1.0 ## explicit github.com/mitchellh/go-homedir -# github.com/mitchellh/mapstructure v1.4.1 +# github.com/mitchellh/mapstructure v1.4.3 ## explicit; go 1.14 github.com/mitchellh/mapstructure # github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd @@ -467,7 +556,7 @@ github.com/openshift/api/machine/v1beta1 github.com/openshift/api/operator/v1 github.com/openshift/api/operator/v1alpha1 github.com/openshift/api/route/v1 -# github.com/openshift/client-go v0.0.0-20211025111749-96ca2abfc56c +# github.com/openshift/client-go v0.0.0-20211209144617-7385dd6338e3 ## explicit; go 1.16 github.com/openshift/client-go/config/clientset/versioned github.com/openshift/client-go/config/clientset/versioned/scheme @@ -507,6 +596,11 @@ github.com/openshift/library-go/pkg/route/routeapihelpers # github.com/openshift/machine-config-operator v0.0.0 => github.com/openshift/machine-config-operator v0.0.1-0.20201009041932-4fe8559913b8 ## explicit; go 1.13 github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1 +# github.com/opentracing/opentracing-go v1.2.0 +## explicit; go 1.14 +github.com/opentracing/opentracing-go +github.com/opentracing/opentracing-go/ext +github.com/opentracing/opentracing-go/log # github.com/ovirt/go-ovirt v0.0.0-20210308100159-ac0bcbc88d7c ## explicit; go 1.12 github.com/ovirt/go-ovirt @@ -602,7 +696,7 @@ github.com/vmware/govmomi/vim25/xml ## explicit; go 1.12 github.com/zclconf/go-cty/cty github.com/zclconf/go-cty/cty/set -# go.mongodb.org/mongo-driver v1.5.1 +# go.mongodb.org/mongo-driver v1.8.3 ## explicit; go 1.10 go.mongodb.org/mongo-driver/bson go.mongodb.org/mongo-driver/bson/bsoncodec @@ -656,7 +750,7 @@ golang.org/x/mod/internal/lazyregexp golang.org/x/mod/modfile golang.org/x/mod/module golang.org/x/mod/semver -# golang.org/x/net v0.0.0-20210825183410-e898025ed96a +# golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd ## explicit; go 1.17 golang.org/x/net/context golang.org/x/net/context/ctxhttp @@ -677,7 +771,7 @@ golang.org/x/oauth2/google/internal/externalaccount golang.org/x/oauth2/internal golang.org/x/oauth2/jws golang.org/x/oauth2/jwt -# golang.org/x/sys v0.0.0-20211029165221-6e7872819dc8 +# golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e ## explicit; go 1.17 golang.org/x/sys/cpu golang.org/x/sys/execabs @@ -685,7 +779,7 @@ golang.org/x/sys/internal/unsafeheader golang.org/x/sys/plan9 golang.org/x/sys/unix golang.org/x/sys/windows -# golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b +# golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 ## explicit; go 1.17 golang.org/x/term # golang.org/x/text v0.3.7 @@ -1131,7 +1225,7 @@ k8s.io/klog/v2 ## explicit; go 1.16 k8s.io/kube-openapi/pkg/schemaconv k8s.io/kube-openapi/pkg/util/proto -# k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b +# k8s.io/utils v0.0.0-20211208161948-7d6a63dca704 ## explicit; go 1.12 k8s.io/utils/buffer k8s.io/utils/clock @@ -1207,8 +1301,8 @@ sigs.k8s.io/controller-tools/pkg/schemapatcher sigs.k8s.io/controller-tools/pkg/schemapatcher/internal/yaml sigs.k8s.io/controller-tools/pkg/version sigs.k8s.io/controller-tools/pkg/webhook -# sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 -## explicit; go 1.16 +# sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 +## explicit; go 1.17 sigs.k8s.io/json sigs.k8s.io/json/internal/golang/encoding/json # sigs.k8s.io/structured-merge-diff/v4 v4.2.0 diff --git a/vendor/sigs.k8s.io/json/internal/golang/encoding/json/decode.go b/vendor/sigs.k8s.io/json/internal/golang/encoding/json/decode.go index a047d981bfe..3a8b64547da 100644 --- a/vendor/sigs.k8s.io/json/internal/golang/encoding/json/decode.go +++ b/vendor/sigs.k8s.io/json/internal/golang/encoding/json/decode.go @@ -234,6 +234,7 @@ type decodeState struct { savedStrictErrors []error seenStrictErrors map[string]struct{} + strictFieldStack []string caseSensitive bool @@ -261,6 +262,8 @@ func (d *decodeState) init(data []byte) *decodeState { // Reuse the allocated space for the FieldStack slice. d.errorContext.FieldStack = d.errorContext.FieldStack[:0] } + // Reuse the allocated space for the strict FieldStack slice. + d.strictFieldStack = d.strictFieldStack[:0] return d } @@ -555,6 +558,12 @@ func (d *decodeState) array(v reflect.Value) error { break } + origStrictFieldStackLen := len(d.strictFieldStack) + defer func() { + // Reset to original length and reuse the allocated space for the strict FieldStack slice. + d.strictFieldStack = d.strictFieldStack[:origStrictFieldStackLen] + }() + i := 0 for { // Look ahead for ] - can only happen on first iteration. @@ -580,6 +589,7 @@ func (d *decodeState) array(v reflect.Value) error { } } + d.appendStrictFieldStackIndex(i) if i < v.Len() { // Decode into element. if err := d.value(v.Index(i)); err != nil { @@ -591,6 +601,8 @@ func (d *decodeState) array(v reflect.Value) error { return err } } + // Reset to original length and reuse the allocated space for the strict FieldStack slice. + d.strictFieldStack = d.strictFieldStack[:origStrictFieldStackLen] i++ // Next token must be , or ]. @@ -683,7 +695,7 @@ func (d *decodeState) object(v reflect.Value) error { seenKeys = map[string]struct{}{} } if _, seen := seenKeys[fieldName]; seen { - d.saveStrictError(fmt.Errorf("duplicate field %q", fieldName)) + d.saveStrictError(d.newFieldError("duplicate field", fieldName)) } else { seenKeys[fieldName] = struct{}{} } @@ -699,7 +711,7 @@ func (d *decodeState) object(v reflect.Value) error { var seenKeys uint64 checkDuplicateField = func(fieldNameIndex int, fieldName string) { if seenKeys&(1< 0 { + return fmt.Errorf("%s %q", msg, strings.Join(d.strictFieldStack, "")+"."+field) + } else { + return fmt.Errorf("%s %q", msg, field) + } +} + // saveStrictError saves a strict decoding error, // for reporting at the end of the unmarshal if no other errors occurred. func (d *decodeState) saveStrictError(err error) { @@ -90,6 +100,24 @@ func (d *decodeState) saveStrictError(err error) { d.savedStrictErrors = append(d.savedStrictErrors, err) } +func (d *decodeState) appendStrictFieldStackKey(key string) { + if !d.disallowDuplicateFields && !d.disallowUnknownFields { + return + } + if len(d.strictFieldStack) > 0 { + d.strictFieldStack = append(d.strictFieldStack, ".", key) + } else { + d.strictFieldStack = append(d.strictFieldStack, key) + } +} + +func (d *decodeState) appendStrictFieldStackIndex(i int) { + if !d.disallowDuplicateFields && !d.disallowUnknownFields { + return + } + d.strictFieldStack = append(d.strictFieldStack, "[", strconv.Itoa(i), "]") +} + // UnmarshalStrictError holds errors resulting from use of strict disallow___ decoder directives. // If this is returned from Unmarshal(), it means the decoding was successful in all other respects. type UnmarshalStrictError struct {