From bc3cb8ee3c65ed8d9a8df6f5a58babd544343a29 Mon Sep 17 00:00:00 2001 From: Philipp Sauter <46172817+sauterp@users.noreply.github.com> Date: Wed, 17 Jul 2024 13:34:09 +0200 Subject: [PATCH] egoscale/v3: use separate module v3.1.0 (#621) --- CHANGELOG.md | 4 + go.mod | 3 +- go.sum | 6 +- .../exoscale/egoscale/v2/staticcheck.conf | 2 + .../github.com/exoscale/egoscale/v3/LICENSE | 201 +++++++ .../github.com/exoscale/egoscale/v3/README.md | 2 +- vendor/github.com/exoscale/egoscale/v3/api.go | 49 -- .../github.com/exoscale/egoscale/v3/client.go | 3 +- .../github.com/exoscale/egoscale/v3/errors.go | 125 ++++ .../exoscale/egoscale/v3/operations.go | 567 ++++++++---------- .../exoscale/egoscale/v3/schemas.go | 148 +++-- .../exoscale/egoscale/v3/version.go | 4 + vendor/modules.txt | 8 +- 13 files changed, 697 insertions(+), 425 deletions(-) create mode 100644 vendor/github.com/exoscale/egoscale/v2/staticcheck.conf create mode 100644 vendor/github.com/exoscale/egoscale/v3/LICENSE create mode 100644 vendor/github.com/exoscale/egoscale/v3/errors.go create mode 100644 vendor/github.com/exoscale/egoscale/v3/version.go diff --git a/CHANGELOG.md b/CHANGELOG.md index f26cfc657..2b9a45399 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ - output template: use text/template #617 +### Improvements + +- egoscale/v3: use separate module v3.1.0 #621 + ## 1.78.3 ### Improvements diff --git a/go.mod b/go.mod index 7989945a0..8d7114748 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,8 @@ require ( github.com/aws/aws-sdk-go-v2/service/s3 v1.2.0 github.com/aws/smithy-go v1.1.0 github.com/dustin/go-humanize v1.0.1 - github.com/exoscale/egoscale v0.102.4-0.20240506093113-3ae83713b097 + github.com/exoscale/egoscale v0.102.4 + github.com/exoscale/egoscale/v3 v3.1.0 github.com/exoscale/openapi-cli-generator v1.1.0 github.com/fatih/camelcase v1.0.0 github.com/google/uuid v1.4.0 diff --git a/go.sum b/go.sum index f1f9c465c..00994b315 100644 --- a/go.sum +++ b/go.sum @@ -195,8 +195,10 @@ github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go. github.com/envoyproxy/go-control-plane v0.10.1/go.mod h1:AY7fTTXNdv/aJ2O5jwpxAPOWUZ7hQAEvzN5Pf27BkQQ= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/envoyproxy/protoc-gen-validate v0.6.2/go.mod h1:2t7qjJNvHPx8IjnBOzl9E9/baC+qXE/TeeyBRzgJDws= -github.com/exoscale/egoscale v0.102.4-0.20240506093113-3ae83713b097 h1:nr8gLscG7DHFUIPuyLebhrtGcd6OM+LUjcAX3erF7Y4= -github.com/exoscale/egoscale v0.102.4-0.20240506093113-3ae83713b097/go.mod h1:20KZJQlNJktQon39FWSKXET1h+OicXsyLzNdjc7bNuY= +github.com/exoscale/egoscale v0.102.4 h1:GBKsZMIOzwBfSu+4ZmWka3Ejf2JLiaBDHp4CQUgvp2E= +github.com/exoscale/egoscale v0.102.4/go.mod h1:ROSmPtle0wvf91iLZb09++N/9BH2Jo9XxIpAEumvocA= +github.com/exoscale/egoscale/v3 v3.1.0 h1:8MSA0j4TZbUiE6iIzTmoY0URa3RoGGuHhX5oamCql4o= +github.com/exoscale/egoscale/v3 v3.1.0/go.mod h1:lPsza7G+giSxdzvzaHSEcjEAYz/YTiu2bEEha9KVAc4= github.com/exoscale/openapi-cli-generator v1.1.0 h1:fYjmPqHR5vxlOBrbvde7eo7bISNQIFxsGn4A5/acwKA= github.com/exoscale/openapi-cli-generator v1.1.0/go.mod h1:TZBnbT7f3hJ5ImyUphJwRM+X5xF/zCQZ6o8a42gQeTs= github.com/fatih/camelcase v1.0.0 h1:hxNvNX/xYBp0ovncs8WyWZrOrpBNub/JfaMvbURyft8= diff --git a/vendor/github.com/exoscale/egoscale/v2/staticcheck.conf b/vendor/github.com/exoscale/egoscale/v2/staticcheck.conf new file mode 100644 index 000000000..c83ec0768 --- /dev/null +++ b/vendor/github.com/exoscale/egoscale/v2/staticcheck.conf @@ -0,0 +1,2 @@ +# egoscale v2 is about to be deprecated so no linting is needed. +checks = ["-all"] diff --git a/vendor/github.com/exoscale/egoscale/v3/LICENSE b/vendor/github.com/exoscale/egoscale/v3/LICENSE new file mode 100644 index 000000000..327ecb823 --- /dev/null +++ b/vendor/github.com/exoscale/egoscale/v3/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 2014 exoscale(tm) + + 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/exoscale/egoscale/v3/README.md b/vendor/github.com/exoscale/egoscale/v3/README.md index 0fd26ce83..cae793dcd 100644 --- a/vendor/github.com/exoscale/egoscale/v3/README.md +++ b/vendor/github.com/exoscale/egoscale/v3/README.md @@ -1,4 +1,4 @@ -# Egoscale v3 (Alpha) +# Egoscale v3 Exoscale API Golang wrapper diff --git a/vendor/github.com/exoscale/egoscale/v3/api.go b/vendor/github.com/exoscale/egoscale/v3/api.go index 8efd97f43..5a5691942 100644 --- a/vendor/github.com/exoscale/egoscale/v3/api.go +++ b/vendor/github.com/exoscale/egoscale/v3/api.go @@ -7,7 +7,6 @@ import ( "crypto/sha256" "encoding/base64" "encoding/json" - "errors" "fmt" "io" "net/http" @@ -21,20 +20,6 @@ import ( "github.com/google/uuid" ) -var ( - // ErrNotFound represents an error indicating a non-existent resource. - ErrNotFound = errors.New("resource not found") - - // ErrTooManyFound represents an error indicating multiple results found for a single resource. - ErrTooManyFound = errors.New("multiple resources found") - - // ErrInvalidRequest represents an error indicating that the caller's request is invalid. - ErrInvalidRequest = errors.New("invalid request") - - // ErrAPIError represents an error indicating an API-side issue. - ErrAPIError = errors.New("API error") -) - type UUID string func (u UUID) String() string { @@ -256,40 +241,6 @@ func extractRequestParameters(req *http.Request) ([]string, string) { return names, values } -func handleHTTPErrorResp(resp *http.Response) error { - if resp.StatusCode >= 400 && resp.StatusCode <= 599 { - var res struct { - Message string `json:"message"` - } - - data, err := io.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("error reading response body: %s", err) - } - - if json.Valid(data) { - if err = json.Unmarshal(data, &res); err != nil { - return fmt.Errorf("error unmarshaling response: %s", err) - } - } else { - res.Message = string(data) - } - - switch { - case resp.StatusCode == http.StatusNotFound: - return ErrNotFound - - case resp.StatusCode >= 400 && resp.StatusCode < 500: - return fmt.Errorf("%w: %s", ErrInvalidRequest, res.Message) - - case resp.StatusCode >= 500: - return fmt.Errorf("%w: %s", ErrAPIError, res.Message) - } - } - - return nil -} - func dumpRequest(req *http.Request, operationID string) { if req != nil { if dump, err := httputil.DumpRequest(req, true); err == nil { diff --git a/vendor/github.com/exoscale/egoscale/v3/client.go b/vendor/github.com/exoscale/egoscale/v3/client.go index ed16d92a0..912271d57 100644 --- a/vendor/github.com/exoscale/egoscale/v3/client.go +++ b/vendor/github.com/exoscale/egoscale/v3/client.go @@ -11,7 +11,6 @@ import ( "time" "github.com/exoscale/egoscale/v3/credentials" - "github.com/exoscale/egoscale/version" "github.com/go-playground/validator/v10" ) @@ -76,7 +75,7 @@ type RequestInterceptorFn func(ctx context.Context, req *http.Request) error // UserAgent is the "User-Agent" HTTP request header added to outgoing HTTP requests. var UserAgent = fmt.Sprintf("egoscale/%s (%s; %s/%s)", - version.Version, + Version, runtime.Version(), runtime.GOOS, runtime.GOARCH) diff --git a/vendor/github.com/exoscale/egoscale/v3/errors.go b/vendor/github.com/exoscale/egoscale/v3/errors.go new file mode 100644 index 000000000..39ba09dff --- /dev/null +++ b/vendor/github.com/exoscale/egoscale/v3/errors.go @@ -0,0 +1,125 @@ +package v3 + +import ( + "encoding/json" + "errors" + "fmt" + "io" + "net/http" +) + +var ( + ErrBadRequest = errors.New(http.StatusText(http.StatusBadRequest)) + ErrUnauthorized = errors.New(http.StatusText(http.StatusUnauthorized)) + ErrPaymentRequired = errors.New(http.StatusText(http.StatusPaymentRequired)) + ErrForbidden = errors.New(http.StatusText(http.StatusForbidden)) + ErrNotFound = errors.New(http.StatusText(http.StatusNotFound)) + ErrMethodNotAllowed = errors.New(http.StatusText(http.StatusMethodNotAllowed)) + ErrNotAcceptable = errors.New(http.StatusText(http.StatusNotAcceptable)) + ErrProxyAuthRequired = errors.New(http.StatusText(http.StatusProxyAuthRequired)) + ErrRequestTimeout = errors.New(http.StatusText(http.StatusRequestTimeout)) + ErrConflict = errors.New(http.StatusText(http.StatusConflict)) + ErrGone = errors.New(http.StatusText(http.StatusGone)) + ErrLengthRequired = errors.New(http.StatusText(http.StatusLengthRequired)) + ErrPreconditionFailed = errors.New(http.StatusText(http.StatusPreconditionFailed)) + ErrRequestEntityTooLarge = errors.New(http.StatusText(http.StatusRequestEntityTooLarge)) + ErrRequestURITooLong = errors.New(http.StatusText(http.StatusRequestURITooLong)) + ErrUnsupportedMediaType = errors.New(http.StatusText(http.StatusUnsupportedMediaType)) + ErrRequestedRangeNotSatisfiable = errors.New(http.StatusText(http.StatusRequestedRangeNotSatisfiable)) + ErrExpectationFailed = errors.New(http.StatusText(http.StatusExpectationFailed)) + ErrTeapot = errors.New(http.StatusText(http.StatusTeapot)) + ErrMisdirectedRequest = errors.New(http.StatusText(http.StatusMisdirectedRequest)) + ErrUnprocessableEntity = errors.New(http.StatusText(http.StatusUnprocessableEntity)) + ErrLocked = errors.New(http.StatusText(http.StatusLocked)) + ErrFailedDependency = errors.New(http.StatusText(http.StatusFailedDependency)) + ErrTooEarly = errors.New(http.StatusText(http.StatusTooEarly)) + ErrUpgradeRequired = errors.New(http.StatusText(http.StatusUpgradeRequired)) + ErrPreconditionRequired = errors.New(http.StatusText(http.StatusPreconditionRequired)) + ErrTooManyRequests = errors.New(http.StatusText(http.StatusTooManyRequests)) + ErrRequestHeaderFieldsTooLarge = errors.New(http.StatusText(http.StatusRequestHeaderFieldsTooLarge)) + ErrUnavailableForLegalReasons = errors.New(http.StatusText(http.StatusUnavailableForLegalReasons)) + ErrInternalServerError = errors.New(http.StatusText(http.StatusInternalServerError)) + ErrNotImplemented = errors.New(http.StatusText(http.StatusNotImplemented)) + ErrBadGateway = errors.New(http.StatusText(http.StatusBadGateway)) + ErrServiceUnavailable = errors.New(http.StatusText(http.StatusServiceUnavailable)) + ErrGatewayTimeout = errors.New(http.StatusText(http.StatusGatewayTimeout)) + ErrHTTPVersionNotSupported = errors.New(http.StatusText(http.StatusHTTPVersionNotSupported)) + ErrVariantAlsoNegotiates = errors.New(http.StatusText(http.StatusVariantAlsoNegotiates)) + ErrInsufficientStorage = errors.New(http.StatusText(http.StatusInsufficientStorage)) + ErrLoopDetected = errors.New(http.StatusText(http.StatusLoopDetected)) + ErrNotExtended = errors.New(http.StatusText(http.StatusNotExtended)) + ErrNetworkAuthenticationRequired = errors.New(http.StatusText(http.StatusNetworkAuthenticationRequired)) +) + +var httpStatusCodeErrors = map[int]error{ + http.StatusBadRequest: ErrBadRequest, + http.StatusUnauthorized: ErrUnauthorized, + http.StatusPaymentRequired: ErrPaymentRequired, + http.StatusForbidden: ErrForbidden, + http.StatusNotFound: ErrNotFound, + http.StatusMethodNotAllowed: ErrMethodNotAllowed, + http.StatusNotAcceptable: ErrNotAcceptable, + http.StatusProxyAuthRequired: ErrProxyAuthRequired, + http.StatusRequestTimeout: ErrRequestTimeout, + http.StatusConflict: ErrConflict, + http.StatusGone: ErrGone, + http.StatusLengthRequired: ErrLengthRequired, + http.StatusPreconditionFailed: ErrPreconditionFailed, + http.StatusRequestEntityTooLarge: ErrRequestEntityTooLarge, + http.StatusRequestURITooLong: ErrRequestURITooLong, + http.StatusUnsupportedMediaType: ErrUnsupportedMediaType, + http.StatusRequestedRangeNotSatisfiable: ErrRequestedRangeNotSatisfiable, + http.StatusExpectationFailed: ErrExpectationFailed, + http.StatusTeapot: ErrTeapot, + http.StatusMisdirectedRequest: ErrMisdirectedRequest, + http.StatusUnprocessableEntity: ErrUnprocessableEntity, + http.StatusLocked: ErrLocked, + http.StatusFailedDependency: ErrFailedDependency, + http.StatusTooEarly: ErrTooEarly, + http.StatusUpgradeRequired: ErrUpgradeRequired, + http.StatusPreconditionRequired: ErrPreconditionRequired, + http.StatusTooManyRequests: ErrTooManyRequests, + http.StatusRequestHeaderFieldsTooLarge: ErrRequestHeaderFieldsTooLarge, + http.StatusUnavailableForLegalReasons: ErrUnavailableForLegalReasons, + http.StatusInternalServerError: ErrInternalServerError, + http.StatusNotImplemented: ErrNotImplemented, + http.StatusBadGateway: ErrBadGateway, + http.StatusServiceUnavailable: ErrServiceUnavailable, + http.StatusGatewayTimeout: ErrGatewayTimeout, + http.StatusHTTPVersionNotSupported: ErrHTTPVersionNotSupported, + http.StatusVariantAlsoNegotiates: ErrVariantAlsoNegotiates, + http.StatusInsufficientStorage: ErrInsufficientStorage, + http.StatusLoopDetected: ErrLoopDetected, + http.StatusNotExtended: ErrNotExtended, + http.StatusNetworkAuthenticationRequired: ErrNetworkAuthenticationRequired, +} + +func handleHTTPErrorResp(resp *http.Response) error { + if resp.StatusCode >= 400 && resp.StatusCode <= 599 { + var res struct { + Message string `json:"message"` + } + + data, err := io.ReadAll(resp.Body) + if err != nil { + return fmt.Errorf("error reading response body: %s", err) + } + + if json.Valid(data) { + if err = json.Unmarshal(data, &res); err != nil { + return fmt.Errorf("error unmarshaling response: %s", err) + } + } else { + res.Message = string(data) + } + + err, ok := httpStatusCodeErrors[resp.StatusCode] + if ok { + return fmt.Errorf("%w: %s", err, res.Message) + } + + return fmt.Errorf("unmapped HTTP error: status code %d, message: %s", resp.StatusCode, res.Message) + } + + return nil +} diff --git a/vendor/github.com/exoscale/egoscale/v3/operations.go b/vendor/github.com/exoscale/egoscale/v3/operations.go index ac4c7eae8..df0383c0e 100644 --- a/vendor/github.com/exoscale/egoscale/v3/operations.go +++ b/vendor/github.com/exoscale/egoscale/v3/operations.go @@ -12,295 +12,6 @@ import ( "time" ) -type ListAccessKeysResponse struct { - AccessKeys []AccessKey `json:"access-keys,omitempty"` -} - -// List IAM Access Keys -func (c Client) ListAccessKeys(ctx context.Context) (*ListAccessKeysResponse, error) { - path := "/access-key" - - request, err := http.NewRequestWithContext(ctx, "GET", c.serverEndpoint+path, nil) - if err != nil { - return nil, fmt.Errorf("ListAccessKeys: new request: %w", err) - } - request.Header.Add("User-Agent", UserAgent) - - if err := c.executeRequestInterceptors(ctx, request); err != nil { - return nil, fmt.Errorf("ListAccessKeys: execute request editors: %w", err) - } - - if err := c.signRequest(request); err != nil { - return nil, fmt.Errorf("ListAccessKeys: sign request: %w", err) - } - - if c.trace { - dumpRequest(request, "list-access-keys") - } - - response, err := c.httpClient.Do(request) - if err != nil { - return nil, fmt.Errorf("ListAccessKeys: http client do: %w", err) - } - - if c.trace { - dumpResponse(response) - } - - if err := handleHTTPErrorResp(response); err != nil { - return nil, fmt.Errorf("ListAccessKeys: http response: %w", err) - } - - bodyresp := &ListAccessKeysResponse{} - if err := prepareJSONResponse(response, bodyresp); err != nil { - return nil, fmt.Errorf("ListAccessKeys: prepare Json response: %w", err) - } - - return bodyresp, nil -} - -// IAM Access Key -type CreateAccessKeyRequest struct { - // IAM Access Key name - Name string `json:"name,omitempty"` - // IAM Access Key operations - Operations []string `json:"operations,omitempty"` - // IAM Access Key Resources - Resources []AccessKeyResource `json:"resources,omitempty"` - // IAM Access Key tags - Tags []string `json:"tags,omitempty"` -} - -// This operation creates a legacy IAM Access Key, to create a key for use with IAM roles use the api-key endpoint.The corresponding secret is only available in the response returned by this operation, the caller must take care of storing it safely as there is no other way to retrieve it. -func (c Client) CreateAccessKey(ctx context.Context, req CreateAccessKeyRequest) (*AccessKey, error) { - path := "/access-key" - - body, err := prepareJSONBody(req) - if err != nil { - return nil, fmt.Errorf("CreateAccessKey: prepare Json body: %w", err) - } - - request, err := http.NewRequestWithContext(ctx, "POST", c.serverEndpoint+path, body) - if err != nil { - return nil, fmt.Errorf("CreateAccessKey: new request: %w", err) - } - request.Header.Add("User-Agent", UserAgent) - - request.Header.Add("Content-Type", "application/json") - - if err := c.executeRequestInterceptors(ctx, request); err != nil { - return nil, fmt.Errorf("CreateAccessKey: execute request editors: %w", err) - } - - if err := c.signRequest(request); err != nil { - return nil, fmt.Errorf("CreateAccessKey: sign request: %w", err) - } - - if c.trace { - dumpRequest(request, "create-access-key") - } - - response, err := c.httpClient.Do(request) - if err != nil { - return nil, fmt.Errorf("CreateAccessKey: http client do: %w", err) - } - - if c.trace { - dumpResponse(response) - } - - if err := handleHTTPErrorResp(response); err != nil { - return nil, fmt.Errorf("CreateAccessKey: http response: %w", err) - } - - bodyresp := &AccessKey{} - if err := prepareJSONResponse(response, bodyresp); err != nil { - return nil, fmt.Errorf("CreateAccessKey: prepare Json response: %w", err) - } - - return bodyresp, nil -} - -type ListAccessKeyKnownOperationsResponse struct { - AccessKeyOperations []AccessKeyOperation `json:"access-key-operations,omitempty"` -} - -// Retrieve all known available IAM Access Key operations and associated tags -func (c Client) ListAccessKeyKnownOperations(ctx context.Context) (*ListAccessKeyKnownOperationsResponse, error) { - path := "/access-key-known-operations" - - request, err := http.NewRequestWithContext(ctx, "GET", c.serverEndpoint+path, nil) - if err != nil { - return nil, fmt.Errorf("ListAccessKeyKnownOperations: new request: %w", err) - } - request.Header.Add("User-Agent", UserAgent) - - if err := c.executeRequestInterceptors(ctx, request); err != nil { - return nil, fmt.Errorf("ListAccessKeyKnownOperations: execute request editors: %w", err) - } - - if err := c.signRequest(request); err != nil { - return nil, fmt.Errorf("ListAccessKeyKnownOperations: sign request: %w", err) - } - - if c.trace { - dumpRequest(request, "list-access-key-known-operations") - } - - response, err := c.httpClient.Do(request) - if err != nil { - return nil, fmt.Errorf("ListAccessKeyKnownOperations: http client do: %w", err) - } - - if c.trace { - dumpResponse(response) - } - - if err := handleHTTPErrorResp(response); err != nil { - return nil, fmt.Errorf("ListAccessKeyKnownOperations: http response: %w", err) - } - - bodyresp := &ListAccessKeyKnownOperationsResponse{} - if err := prepareJSONResponse(response, bodyresp); err != nil { - return nil, fmt.Errorf("ListAccessKeyKnownOperations: prepare Json response: %w", err) - } - - return bodyresp, nil -} - -type ListAccessKeyOperationsResponse struct { - AccessKeyOperations []AccessKeyOperation `json:"access-key-operations,omitempty"` -} - -// Retrieve IAM Access Key operations and associated tags for the signing key -func (c Client) ListAccessKeyOperations(ctx context.Context) (*ListAccessKeyOperationsResponse, error) { - path := "/access-key-operations" - - request, err := http.NewRequestWithContext(ctx, "GET", c.serverEndpoint+path, nil) - if err != nil { - return nil, fmt.Errorf("ListAccessKeyOperations: new request: %w", err) - } - request.Header.Add("User-Agent", UserAgent) - - if err := c.executeRequestInterceptors(ctx, request); err != nil { - return nil, fmt.Errorf("ListAccessKeyOperations: execute request editors: %w", err) - } - - if err := c.signRequest(request); err != nil { - return nil, fmt.Errorf("ListAccessKeyOperations: sign request: %w", err) - } - - if c.trace { - dumpRequest(request, "list-access-key-operations") - } - - response, err := c.httpClient.Do(request) - if err != nil { - return nil, fmt.Errorf("ListAccessKeyOperations: http client do: %w", err) - } - - if c.trace { - dumpResponse(response) - } - - if err := handleHTTPErrorResp(response); err != nil { - return nil, fmt.Errorf("ListAccessKeyOperations: http response: %w", err) - } - - bodyresp := &ListAccessKeyOperationsResponse{} - if err := prepareJSONResponse(response, bodyresp); err != nil { - return nil, fmt.Errorf("ListAccessKeyOperations: prepare Json response: %w", err) - } - - return bodyresp, nil -} - -// This operation revokes the specified IAM Access Key. Access Keys created by the revoked Access Key will not be revoked. -func (c Client) RevokeAccessKey(ctx context.Context, key string) (*Operation, error) { - path := fmt.Sprintf("/access-key/%v", key) - - request, err := http.NewRequestWithContext(ctx, "DELETE", c.serverEndpoint+path, nil) - if err != nil { - return nil, fmt.Errorf("RevokeAccessKey: new request: %w", err) - } - request.Header.Add("User-Agent", UserAgent) - - if err := c.executeRequestInterceptors(ctx, request); err != nil { - return nil, fmt.Errorf("RevokeAccessKey: execute request editors: %w", err) - } - - if err := c.signRequest(request); err != nil { - return nil, fmt.Errorf("RevokeAccessKey: sign request: %w", err) - } - - if c.trace { - dumpRequest(request, "revoke-access-key") - } - - response, err := c.httpClient.Do(request) - if err != nil { - return nil, fmt.Errorf("RevokeAccessKey: http client do: %w", err) - } - - if c.trace { - dumpResponse(response) - } - - if err := handleHTTPErrorResp(response); err != nil { - return nil, fmt.Errorf("RevokeAccessKey: http response: %w", err) - } - - bodyresp := &Operation{} - if err := prepareJSONResponse(response, bodyresp); err != nil { - return nil, fmt.Errorf("RevokeAccessKey: prepare Json response: %w", err) - } - - return bodyresp, nil -} - -// Retrieve IAM Access Key details -func (c Client) GetAccessKey(ctx context.Context, key string) (*AccessKey, error) { - path := fmt.Sprintf("/access-key/%v", key) - - request, err := http.NewRequestWithContext(ctx, "GET", c.serverEndpoint+path, nil) - if err != nil { - return nil, fmt.Errorf("GetAccessKey: new request: %w", err) - } - request.Header.Add("User-Agent", UserAgent) - - if err := c.executeRequestInterceptors(ctx, request); err != nil { - return nil, fmt.Errorf("GetAccessKey: execute request editors: %w", err) - } - - if err := c.signRequest(request); err != nil { - return nil, fmt.Errorf("GetAccessKey: sign request: %w", err) - } - - if c.trace { - dumpRequest(request, "get-access-key") - } - - response, err := c.httpClient.Do(request) - if err != nil { - return nil, fmt.Errorf("GetAccessKey: http client do: %w", err) - } - - if c.trace { - dumpResponse(response) - } - - if err := handleHTTPErrorResp(response); err != nil { - return nil, fmt.Errorf("GetAccessKey: http response: %w", err) - } - - bodyresp := &AccessKey{} - if err := prepareJSONResponse(response, bodyresp); err != nil { - return nil, fmt.Errorf("GetAccessKey: prepare Json response: %w", err) - } - - return bodyresp, nil -} - type ListAntiAffinityGroupsResponse struct { AntiAffinityGroups []AntiAffinityGroup `json:"anti-affinity-groups,omitempty"` } @@ -772,7 +483,7 @@ type CreateBlockStorageVolumeRequest struct { Labels Labels `json:"labels,omitempty"` // Volume name Name string `json:"name,omitempty" validate:"omitempty,lte=255"` - // Volume size in GB. + // Volume size in GiB. // When a snapshot ID is supplied, this defaults to the size of the source volume, but can be set to a larger value. Size int64 `json:"size,omitempty" validate:"omitempty,gte=10"` } @@ -1324,7 +1035,7 @@ func (c Client) DetachBlockStorageVolume(ctx context.Context, id UUID) (*Operati } type ResizeBlockStorageVolumeRequest struct { - // Volume size in GB + // Volume size in GiB Size int64 `json:"size" validate:"required,gte=11"` } @@ -1378,6 +1089,55 @@ func (c Client) ResizeBlockStorageVolume(ctx context.Context, id UUID, req Resiz return bodyresp, nil } +type GetConsoleProxyURLResponse struct { + Host string `json:"host,omitempty"` + Path string `json:"path,omitempty"` + URL string `json:"url,omitempty"` +} + +// Retrieve signed url valid for 60 seconds to connect via console-proxy websocket to VM VNC console. +func (c Client) GetConsoleProxyURL(ctx context.Context, id UUID) (*GetConsoleProxyURLResponse, error) { + path := fmt.Sprintf("/console/%v", id) + + request, err := http.NewRequestWithContext(ctx, "GET", c.serverEndpoint+path, nil) + if err != nil { + return nil, fmt.Errorf("GetConsoleProxyURL: new request: %w", err) + } + request.Header.Add("User-Agent", UserAgent) + + if err := c.executeRequestInterceptors(ctx, request); err != nil { + return nil, fmt.Errorf("GetConsoleProxyURL: execute request editors: %w", err) + } + + if err := c.signRequest(request); err != nil { + return nil, fmt.Errorf("GetConsoleProxyURL: sign request: %w", err) + } + + if c.trace { + dumpRequest(request, "get-console-proxy-url") + } + + response, err := c.httpClient.Do(request) + if err != nil { + return nil, fmt.Errorf("GetConsoleProxyURL: http client do: %w", err) + } + + if c.trace { + dumpResponse(response) + } + + if err := handleHTTPErrorResp(response); err != nil { + return nil, fmt.Errorf("GetConsoleProxyURL: http response: %w", err) + } + + bodyresp := &GetConsoleProxyURLResponse{} + if err := prepareJSONResponse(response, bodyresp); err != nil { + return nil, fmt.Errorf("GetConsoleProxyURL: prepare Json response: %w", err) + } + + return bodyresp, nil +} + type GetDBAASCACertificateResponse struct { Certificate string `json:"certificate,omitempty"` } @@ -1723,6 +1483,103 @@ func (c Client) StartDBAASGrafanaMaintenance(ctx context.Context, name string) ( return bodyresp, nil } +type ResetDBAASGrafanaUserPasswordRequest struct { + Password DBAASUserPassword `json:"password,omitempty" validate:"omitempty,gte=8,lte=256"` +} + +// If no password is provided one will be generated automatically. +func (c Client) ResetDBAASGrafanaUserPassword(ctx context.Context, serviceName string, username string, req ResetDBAASGrafanaUserPasswordRequest) (*Operation, error) { + path := fmt.Sprintf("/dbaas-grafana/%v/user/%v/password/reset", serviceName, username) + + body, err := prepareJSONBody(req) + if err != nil { + return nil, fmt.Errorf("ResetDBAASGrafanaUserPassword: prepare Json body: %w", err) + } + + request, err := http.NewRequestWithContext(ctx, "PUT", c.serverEndpoint+path, body) + if err != nil { + return nil, fmt.Errorf("ResetDBAASGrafanaUserPassword: new request: %w", err) + } + request.Header.Add("User-Agent", UserAgent) + + request.Header.Add("Content-Type", "application/json") + + if err := c.executeRequestInterceptors(ctx, request); err != nil { + return nil, fmt.Errorf("ResetDBAASGrafanaUserPassword: execute request editors: %w", err) + } + + if err := c.signRequest(request); err != nil { + return nil, fmt.Errorf("ResetDBAASGrafanaUserPassword: sign request: %w", err) + } + + if c.trace { + dumpRequest(request, "reset-dbaas-grafana-user-password") + } + + response, err := c.httpClient.Do(request) + if err != nil { + return nil, fmt.Errorf("ResetDBAASGrafanaUserPassword: http client do: %w", err) + } + + if c.trace { + dumpResponse(response) + } + + if err := handleHTTPErrorResp(response); err != nil { + return nil, fmt.Errorf("ResetDBAASGrafanaUserPassword: http response: %w", err) + } + + bodyresp := &Operation{} + if err := prepareJSONResponse(response, bodyresp); err != nil { + return nil, fmt.Errorf("ResetDBAASGrafanaUserPassword: prepare Json response: %w", err) + } + + return bodyresp, nil +} + +// Reveal the secrets of a DBaaS Grafana user +func (c Client) RevealDBAASGrafanaUserPassword(ctx context.Context, serviceName string, username string) (*DBAASUserGrafanaSecrets, error) { + path := fmt.Sprintf("/dbaas-grafana/%v/user/%v/password/reveal", serviceName, username) + + request, err := http.NewRequestWithContext(ctx, "GET", c.serverEndpoint+path, nil) + if err != nil { + return nil, fmt.Errorf("RevealDBAASGrafanaUserPassword: new request: %w", err) + } + request.Header.Add("User-Agent", UserAgent) + + if err := c.executeRequestInterceptors(ctx, request); err != nil { + return nil, fmt.Errorf("RevealDBAASGrafanaUserPassword: execute request editors: %w", err) + } + + if err := c.signRequest(request); err != nil { + return nil, fmt.Errorf("RevealDBAASGrafanaUserPassword: sign request: %w", err) + } + + if c.trace { + dumpRequest(request, "reveal-dbaas-grafana-user-password") + } + + response, err := c.httpClient.Do(request) + if err != nil { + return nil, fmt.Errorf("RevealDBAASGrafanaUserPassword: http client do: %w", err) + } + + if c.trace { + dumpResponse(response) + } + + if err := handleHTTPErrorResp(response); err != nil { + return nil, fmt.Errorf("RevealDBAASGrafanaUserPassword: http response: %w", err) + } + + bodyresp := &DBAASUserGrafanaSecrets{} + if err := prepareJSONResponse(response, bodyresp); err != nil { + return nil, fmt.Errorf("RevealDBAASGrafanaUserPassword: prepare Json response: %w", err) + } + + return bodyresp, nil +} + type CreateDBAASIntegrationRequest struct { DestService DBAASServiceName `json:"dest-service" validate:"required,gte=0,lte=63"` IntegrationType EnumIntegrationTypes `json:"integration-type" validate:"required"` @@ -4405,10 +4262,10 @@ type CreateDBAASServicePGRequest struct { Migration *CreateDBAASServicePGRequestMigration `json:"migration,omitempty"` // postgresql.conf configuration values PGSettings JSONSchemaPG `json:"pg-settings,omitempty"` - // PGBouncer connection pooling settings - PgbouncerSettings JSONSchemaPgbouncer `json:"pgbouncer-settings,omitempty"` - // PGLookout settings - PglookoutSettings JSONSchemaPglookout `json:"pglookout-settings,omitempty"` + // System-wide settings for pgbouncer. + PgbouncerSettings *JSONSchemaPgbouncer `json:"pgbouncer-settings,omitempty"` + // System-wide settings for pglookout. + PglookoutSettings *JSONSchemaPglookout `json:"pglookout-settings,omitempty"` // Subscription plan Plan string `json:"plan" validate:"required,gte=1,lte=128"` // ISO time of a backup to recover from for services that support arbitrary times @@ -4418,10 +4275,10 @@ type CreateDBAASServicePGRequest struct { SynchronousReplication EnumPGSynchronousReplication `json:"synchronous-replication,omitempty"` // Service is protected against termination and powering off TerminationProtection *bool `json:"termination-protection,omitempty"` - // TimescaleDB extension configuration values - TimescaledbSettings JSONSchemaTimescaledb `json:"timescaledb-settings,omitempty"` - Variant EnumPGVariant `json:"variant,omitempty"` - Version DBAASPGTargetVersions `json:"version,omitempty"` + // System-wide settings for the timescaledb extension + TimescaledbSettings *JSONSchemaTimescaledb `json:"timescaledb-settings,omitempty"` + Variant EnumPGVariant `json:"variant,omitempty"` + Version DBAASPGTargetVersions `json:"version,omitempty"` // Sets the maximum amount of memory to be used by a query operation (such as a sort or hash table) before writing to temporary disk files, in MB. Default is 1MB + 0.075% of total RAM (up to 32MB). WorkMem int64 `json:"work-mem,omitempty" validate:"omitempty,gte=1,lte=1024"` } @@ -4533,10 +4390,10 @@ type UpdateDBAASServicePGRequest struct { Migration *UpdateDBAASServicePGRequestMigration `json:"migration,omitempty"` // postgresql.conf configuration values PGSettings JSONSchemaPG `json:"pg-settings,omitempty"` - // PGBouncer connection pooling settings - PgbouncerSettings JSONSchemaPgbouncer `json:"pgbouncer-settings,omitempty"` - // PGLookout settings - PglookoutSettings JSONSchemaPglookout `json:"pglookout-settings,omitempty"` + // System-wide settings for pgbouncer. + PgbouncerSettings *JSONSchemaPgbouncer `json:"pgbouncer-settings,omitempty"` + // System-wide settings for pglookout. + PglookoutSettings *JSONSchemaPglookout `json:"pglookout-settings,omitempty"` // Subscription plan Plan string `json:"plan,omitempty" validate:"omitempty,gte=1,lte=128"` // Percentage of total RAM that the database server uses for shared memory buffers. Valid range is 20-60 (float), which corresponds to 20% - 60%. This setting adjusts the shared_buffers configuration value. @@ -4544,9 +4401,9 @@ type UpdateDBAASServicePGRequest struct { SynchronousReplication EnumPGSynchronousReplication `json:"synchronous-replication,omitempty"` // Service is protected against termination and powering off TerminationProtection *bool `json:"termination-protection,omitempty"` - // TimescaleDB extension configuration values - TimescaledbSettings JSONSchemaTimescaledb `json:"timescaledb-settings,omitempty"` - Variant EnumPGVariant `json:"variant,omitempty"` + // System-wide settings for the timescaledb extension + TimescaledbSettings *JSONSchemaTimescaledb `json:"timescaledb-settings,omitempty"` + Variant EnumPGVariant `json:"variant,omitempty"` // Version Version string `json:"version,omitempty"` // Sets the maximum amount of memory to be used by a query operation (such as a sort or hash table) before writing to temporary disk files, in MB. Default is 1MB + 0.075% of total RAM (up to 32MB). @@ -8316,8 +8173,8 @@ type CreateInstanceRequest struct { AutoStart *bool `json:"auto-start,omitempty"` // Deploy target DeployTarget *DeployTarget `json:"deploy-target,omitempty"` - // Instance disk size in GB - DiskSize int64 `json:"disk-size" validate:"required,gte=10,lte=50000"` + // Instance disk size in GiB + DiskSize int64 `json:"disk-size" validate:"required,gte=10,lte=51200"` // Compute instance type InstanceType *InstanceType `json:"instance-type" validate:"required"` // Enable IPv6. DEPRECATED: use `public-ip-assignments`. @@ -8446,6 +8303,14 @@ func (c Client) ListInstancePools(ctx context.Context) (*ListInstancePoolsRespon return bodyresp, nil } +type CreateInstancePoolRequestPublicIPAssignment string + +const ( + CreateInstancePoolRequestPublicIPAssignmentInet4 CreateInstancePoolRequestPublicIPAssignment = "inet4" + CreateInstancePoolRequestPublicIPAssignmentDual CreateInstancePoolRequestPublicIPAssignment = "dual" + CreateInstancePoolRequestPublicIPAssignmentNone CreateInstancePoolRequestPublicIPAssignment = "none" +) + type CreateInstancePoolRequest struct { // Instance Pool Anti-affinity Groups AntiAffinityGroups []AntiAffinityGroup `json:"anti-affinity-groups,omitempty"` @@ -8453,8 +8318,8 @@ type CreateInstancePoolRequest struct { DeployTarget *DeployTarget `json:"deploy-target,omitempty"` // Instance Pool description Description string `json:"description,omitempty" validate:"omitempty,lte=255"` - // Instances disk size in GB - DiskSize int64 `json:"disk-size" validate:"required,gte=10,lte=50000"` + // Instances disk size in GiB + DiskSize int64 `json:"disk-size" validate:"required,gte=10,lte=51200"` // Instances Elastic IPs ElasticIPS []ElasticIP `json:"elastic-ips,omitempty"` // Prefix to apply to Instances names (default: pool) @@ -8469,8 +8334,9 @@ type CreateInstancePoolRequest struct { // Instance Pool name Name string `json:"name" validate:"required,gte=1,lte=255"` // Instance Pool Private Networks - PrivateNetworks []PrivateNetwork `json:"private-networks,omitempty"` - PublicIPAssignment PublicIPAssignment `json:"public-ip-assignment,omitempty"` + PrivateNetworks []PrivateNetwork `json:"private-networks,omitempty"` + // Determines public IP assignment of the Instances. Type `none` is final and can't be changed later on. + PublicIPAssignment CreateInstancePoolRequestPublicIPAssignment `json:"public-ip-assignment,omitempty"` // Instance Pool Security Groups SecurityGroups []SecurityGroup `json:"security-groups,omitempty"` // Number of Instances @@ -8621,6 +8487,13 @@ func (c Client) GetInstancePool(ctx context.Context, id UUID) (*InstancePool, er return bodyresp, nil } +type UpdateInstancePoolRequestPublicIPAssignment string + +const ( + UpdateInstancePoolRequestPublicIPAssignmentInet4 UpdateInstancePoolRequestPublicIPAssignment = "inet4" + UpdateInstancePoolRequestPublicIPAssignmentDual UpdateInstancePoolRequestPublicIPAssignment = "dual" +) + type UpdateInstancePoolRequest struct { // Instance Pool Anti-affinity Groups AntiAffinityGroups []AntiAffinityGroup `json:"anti-affinity-groups"` @@ -8628,8 +8501,8 @@ type UpdateInstancePoolRequest struct { DeployTarget *DeployTarget `json:"deploy-target"` // Instance Pool description Description string `json:"description,omitempty" validate:"omitempty,lte=255"` - // Instances disk size in GB - DiskSize int64 `json:"disk-size,omitempty" validate:"omitempty,gte=10,lte=50000"` + // Instances disk size in GiB + DiskSize int64 `json:"disk-size,omitempty" validate:"omitempty,gte=10,lte=51200"` // Instances Elastic IPs ElasticIPS []ElasticIP `json:"elastic-ips"` // Prefix to apply to Instances names (default: pool) @@ -8644,8 +8517,9 @@ type UpdateInstancePoolRequest struct { // Instance Pool name Name string `json:"name,omitempty" validate:"omitempty,gte=1,lte=255"` // Instance Pool Private Networks - PrivateNetworks []PrivateNetwork `json:"private-networks"` - PublicIPAssignment PublicIPAssignment `json:"public-ip-assignment,omitempty"` + PrivateNetworks []PrivateNetwork `json:"private-networks"` + // Determines public IP assignment of the Instances. + PublicIPAssignment UpdateInstancePoolRequestPublicIPAssignment `json:"public-ip-assignment,omitempty"` // Instance Pool Security Groups SecurityGroups []SecurityGroup `json:"security-groups"` // SSH key @@ -9379,8 +9253,8 @@ func (c Client) RemoveInstanceProtection(ctx context.Context, id UUID) (*Operati } type ResetInstanceRequest struct { - // Instance disk size in GB - DiskSize int64 `json:"disk-size,omitempty" validate:"omitempty,gte=10,lte=50000"` + // Instance disk size in GiB + DiskSize int64 `json:"disk-size,omitempty" validate:"omitempty,gte=10,lte=51200"` // Instance template Template *Template `json:"template,omitempty"` } @@ -9479,8 +9353,8 @@ func (c Client) ResetInstancePassword(ctx context.Context, id UUID) (*Operation, } type ResizeInstanceDiskRequest struct { - // Instance disk size in GB - DiskSize int64 `json:"disk-size" validate:"required,gte=10,lte=50000"` + // Instance disk size in GiB + DiskSize int64 `json:"disk-size" validate:"required,gte=10,lte=51200"` } // This operation resizes a Compute instance's disk volume. Note: the disk can only grow, cannot be shrunk. @@ -10020,6 +9894,7 @@ type AddServiceToLoadBalancerRequestStrategy string const ( AddServiceToLoadBalancerRequestStrategyRoundRobin AddServiceToLoadBalancerRequestStrategy = "round-robin" + AddServiceToLoadBalancerRequestStrategyMaglevHash AddServiceToLoadBalancerRequestStrategy = "maglev-hash" AddServiceToLoadBalancerRequestStrategySourceHash AddServiceToLoadBalancerRequestStrategy = "source-hash" ) @@ -10189,6 +10064,7 @@ type UpdateLoadBalancerServiceRequestStrategy string const ( UpdateLoadBalancerServiceRequestStrategyRoundRobin UpdateLoadBalancerServiceRequestStrategy = "round-robin" + UpdateLoadBalancerServiceRequestStrategyMaglevHash UpdateLoadBalancerServiceRequestStrategy = "maglev-hash" UpdateLoadBalancerServiceRequestStrategySourceHash UpdateLoadBalancerServiceRequestStrategy = "source-hash" ) @@ -10401,6 +10277,49 @@ func (c Client) GetOperation(ctx context.Context, id UUID) (*Operation, error) { return bodyresp, nil } +// Retrieve an organization +func (c Client) GetOrganization(ctx context.Context) (*Organization, error) { + path := "/organization" + + request, err := http.NewRequestWithContext(ctx, "GET", c.serverEndpoint+path, nil) + if err != nil { + return nil, fmt.Errorf("GetOrganization: new request: %w", err) + } + request.Header.Add("User-Agent", UserAgent) + + if err := c.executeRequestInterceptors(ctx, request); err != nil { + return nil, fmt.Errorf("GetOrganization: execute request editors: %w", err) + } + + if err := c.signRequest(request); err != nil { + return nil, fmt.Errorf("GetOrganization: sign request: %w", err) + } + + if c.trace { + dumpRequest(request, "get-organization") + } + + response, err := c.httpClient.Do(request) + if err != nil { + return nil, fmt.Errorf("GetOrganization: http client do: %w", err) + } + + if c.trace { + dumpResponse(response) + } + + if err := handleHTTPErrorResp(response); err != nil { + return nil, fmt.Errorf("GetOrganization: http response: %w", err) + } + + bodyresp := &Organization{} + if err := prepareJSONResponse(response, bodyresp); err != nil { + return nil, fmt.Errorf("GetOrganization: prepare Json response: %w", err) + } + + return bodyresp, nil +} + type ListPrivateNetworksResponse struct { PrivateNetworks []PrivateNetwork `json:"private-networks,omitempty"` } @@ -12417,8 +12336,8 @@ type CreateSKSNodepoolRequest struct { DeployTarget *DeployTarget `json:"deploy-target,omitempty"` // Nodepool description Description string `json:"description,omitempty" validate:"omitempty,lte=255"` - // Nodepool instances disk size in GB - DiskSize int64 `json:"disk-size" validate:"required,gte=20,lte=50000"` + // Nodepool instances disk size in GiB + DiskSize int64 `json:"disk-size" validate:"required,gte=20,lte=51200"` // Prefix to apply to instances names (default: pool) InstancePrefix string `json:"instance-prefix,omitempty" validate:"omitempty,gte=1,lte=30"` // Compute instance type @@ -12580,8 +12499,8 @@ type UpdateSKSNodepoolRequest struct { DeployTarget *DeployTarget `json:"deploy-target"` // Nodepool description Description string `json:"description,omitempty" validate:"omitempty,lte=255"` - // Nodepool instances disk size in GB - DiskSize int64 `json:"disk-size,omitempty" validate:"omitempty,gte=20,lte=50000"` + // Nodepool instances disk size in GiB + DiskSize int64 `json:"disk-size,omitempty" validate:"omitempty,gte=20,lte=51200"` // Prefix to apply to managed instances names (default: pool) InstancePrefix string `json:"instance-prefix,omitempty" validate:"omitempty,gte=1,lte=30"` // Compute instance type diff --git a/vendor/github.com/exoscale/egoscale/v3/schemas.go b/vendor/github.com/exoscale/egoscale/v3/schemas.go index 862dcdd42..5fee16027 100644 --- a/vendor/github.com/exoscale/egoscale/v3/schemas.go +++ b/vendor/github.com/exoscale/egoscale/v3/schemas.go @@ -165,24 +165,6 @@ type BlockStorageVolumeTarget struct { ID UUID `json:"id,omitempty"` } -type CdnConfigurationStatus string - -const ( - CdnConfigurationStatusDeactivated CdnConfigurationStatus = "deactivated" - CdnConfigurationStatusPending CdnConfigurationStatus = "pending" - CdnConfigurationStatusActivated CdnConfigurationStatus = "activated" -) - -// CDN configuration -type CdnConfiguration struct { - // CDN configuration bucket name - Bucket string `json:"bucket,omitempty"` - // FQDN that serves the bucket contents - Fqdn string `json:"fqdn,omitempty"` - // CDN configuration status - Status CdnConfigurationStatus `json:"status,omitempty"` -} - // DBaaS plan backup config type DBAASBackupConfig struct { // Interval of taking a frequent backup in service types supporting different backup schedules @@ -1091,10 +1073,10 @@ type DBAASServicePG struct { Notifications []DBAASServiceNotification `json:"notifications,omitempty"` // postgresql.conf configuration values PGSettings JSONSchemaPG `json:"pg-settings,omitempty"` - // PGBouncer connection pooling settings - PgbouncerSettings JSONSchemaPgbouncer `json:"pgbouncer-settings,omitempty"` - // PGLookout settings - PglookoutSettings JSONSchemaPglookout `json:"pglookout-settings,omitempty"` + // System-wide settings for pgbouncer. + PgbouncerSettings *JSONSchemaPgbouncer `json:"pgbouncer-settings,omitempty"` + // System-wide settings for pglookout. + PglookoutSettings *JSONSchemaPglookout `json:"pglookout-settings,omitempty"` // Subscription plan Plan string `json:"plan" validate:"required"` // Percentage of total RAM that the database server uses for shared memory buffers. Valid range is 20-60 (float), which corresponds to 20% - 60%. This setting adjusts the shared_buffers configuration value. @@ -1103,9 +1085,9 @@ type DBAASServicePG struct { SynchronousReplication EnumPGSynchronousReplication `json:"synchronous-replication,omitempty"` // Service is protected against termination and powering off TerminationProtection *bool `json:"termination-protection,omitempty"` - // TimescaleDB extension configuration values - TimescaledbSettings JSONSchemaTimescaledb `json:"timescaledb-settings,omitempty"` - Type DBAASServiceTypeName `json:"type" validate:"required,gte=0,lte=64"` + // System-wide settings for the timescaledb extension + TimescaledbSettings *JSONSchemaTimescaledb `json:"timescaledb-settings,omitempty"` + Type DBAASServiceTypeName `json:"type" validate:"required,gte=0,lte=64"` // Service last update timestamp (ISO 8601) UpdatedAT time.Time `json:"updated-at,omitempty"` // URI for connecting to the service (may be absent) @@ -1249,6 +1231,14 @@ type DBAASTask struct { TaskType string `json:"task-type,omitempty"` } +// Grafana User secrets +type DBAASUserGrafanaSecrets struct { + // Grafana password + Password string `json:"password,omitempty"` + // Grafana username + Username string `json:"username,omitempty"` +} + // Kafka User secrets type DBAASUserKafkaSecrets struct { // Kafka certificate @@ -1547,6 +1537,8 @@ type Event struct { IAMAPIKey *IAMAPIKey `json:"iam-api-key,omitempty"` // IAM Role IAMRole *IAMRole `json:"iam-role,omitempty"` + // User + IAMUser *User `json:"iam-user,omitempty"` // Operation message Message string `json:"message,omitempty"` // URI path parameters (free form map) @@ -1661,8 +1653,8 @@ type Instance struct { CreatedAT time.Time `json:"created-at,omitempty"` // Deploy target DeployTarget *DeployTarget `json:"deploy-target,omitempty"` - // Instance disk size in GB - DiskSize int64 `json:"disk-size,omitempty" validate:"omitempty,gte=10,lte=50000"` + // Instance disk size in GiB + DiskSize int64 `json:"disk-size,omitempty" validate:"omitempty,gte=10,lte=51200"` // Instance Elastic IPs ElasticIPS []ElasticIP `json:"elastic-ips,omitempty"` // Instance ID @@ -1724,8 +1716,8 @@ type InstancePool struct { DeployTarget *DeployTarget `json:"deploy-target,omitempty"` // Instance Pool description Description string `json:"description,omitempty" validate:"omitempty,gte=1,lte=255"` - // Instances disk size in GB - DiskSize int64 `json:"disk-size,omitempty" validate:"omitempty,gte=10,lte=50000"` + // Instances disk size in GiB + DiskSize int64 `json:"disk-size,omitempty" validate:"omitempty,gte=10,lte=51200"` // Instances Elastic IPs ElasticIPS []ElasticIP `json:"elastic-ips,omitempty"` // Instance Pool ID @@ -1913,10 +1905,8 @@ type JSONSchemaGrafana struct { MetricsEnabled *bool `json:"metrics_enabled,omitempty"` // Enforce user lookup based on email instead of the unique ID provided by the IdP OauthAllowInsecureEmailLookup *bool `json:"oauth_allow_insecure_email_lookup,omitempty"` - // Allow access to selected service components through Privatelink - PrivatelinkAccess map[string]any `json:"privatelink_access,omitempty"` - // Name of the basebackup to restore in forked service - RecoveryBasebackupName string `json:"recovery_basebackup_name,omitempty" validate:"omitempty,lte=128"` + // Store logs for the service so that they are available in the HTTP API and console. + ServiceLog *bool `json:"service_log,omitempty"` // SMTP server settings SMTPServer map[string]any `json:"smtp_server,omitempty"` // Enable or disable Grafana unified alerting functionality. By default this is enabled and any legacy alerts will be migrated on upgrade to Grafana 9+. To stay on legacy alerting, set unified_alerting_enabled to false and alerting_enabled to true. See https://grafana.com/docs/grafana/latest/alerting/set-up/migrating-alerts/ for more details. @@ -1947,11 +1937,41 @@ type JSONSchemaOpensearch map[string]any // postgresql.conf configuration values type JSONSchemaPG map[string]any -// PGBouncer connection pooling settings -type JSONSchemaPgbouncer map[string]any +type JSONSchemaPgbouncerAutodbPoolMode string -// PGLookout settings -type JSONSchemaPglookout map[string]any +const ( + JSONSchemaPgbouncerAutodbPoolModeTransaction JSONSchemaPgbouncerAutodbPoolMode = "transaction" + JSONSchemaPgbouncerAutodbPoolModeSession JSONSchemaPgbouncerAutodbPoolMode = "session" + JSONSchemaPgbouncerAutodbPoolModeStatement JSONSchemaPgbouncerAutodbPoolMode = "statement" +) + +// System-wide settings for pgbouncer. +type JSONSchemaPgbouncer struct { + // If the automatically created database pools have been unused this many seconds, they are freed. If 0 then timeout is disabled. [seconds] + AutodbIdleTimeout int `json:"autodb_idle_timeout,omitempty" validate:"omitempty,gte=0,lte=86400"` + // Do not allow more than this many server connections per database (regardless of user). Setting it to 0 means unlimited. + AutodbMaxDBConnections int `json:"autodb_max_db_connections,omitempty" validate:"omitempty,gte=0,lte=2.147483647e+09"` + // PGBouncer pool mode + AutodbPoolMode JSONSchemaPgbouncerAutodbPoolMode `json:"autodb_pool_mode,omitempty"` + // If non-zero then create automatically a pool of that size per user when a pool doesn't exist. + AutodbPoolSize int `json:"autodb_pool_size,omitempty" validate:"omitempty,gte=0,lte=10000"` + // List of parameters to ignore when given in startup packet + IgnoreStartupParameters []string `json:"ignore_startup_parameters,omitempty"` + // Add more server connections to pool if below this number. Improves behavior when usual load comes suddenly back after period of total inactivity. The value is effectively capped at the pool size. + MinPoolSize int `json:"min_pool_size,omitempty" validate:"omitempty,gte=0,lte=10000"` + // If a server connection has been idle more than this many seconds it will be dropped. If 0 then timeout is disabled. [seconds] + ServerIdleTimeout int `json:"server_idle_timeout,omitempty" validate:"omitempty,gte=0,lte=86400"` + // The pooler will close an unused server connection that has been connected longer than this. [seconds] + ServerLifetime int `json:"server_lifetime,omitempty" validate:"omitempty,gte=60,lte=86400"` + // Run server_reset_query (DISCARD ALL) in all pooling modes + ServerResetQueryAlways *bool `json:"server_reset_query_always,omitempty"` +} + +// System-wide settings for pglookout. +type JSONSchemaPglookout struct { + // Number of seconds of master unavailability before triggering database failover to standby + MaxFailoverReplicationTimeLag int `json:"max_failover_replication_time_lag,omitempty" validate:"omitempty,gte=10,lte=9.223372036854776e+18"` +} type JSONSchemaRedisAclChannelsDefault string @@ -2009,8 +2029,11 @@ type JSONSchemaRedis struct { // Schema Registry configuration type JSONSchemaSchemaRegistry map[string]any -// TimescaleDB extension configuration values -type JSONSchemaTimescaledb map[string]any +// System-wide settings for the timescaledb extension +type JSONSchemaTimescaledb struct { + // The number of background workers for timescaledb operations. You should configure this setting to the sum of your number of databases and the total number of concurrent background workers you want running at any given point in time. + MaxBackgroundWorkers int `json:"max_background_workers,omitempty" validate:"omitempty,gte=1,lte=4096"` +} // Kubelet image GC options type KubeletImageGC struct { @@ -2087,6 +2110,7 @@ type LoadBalancerServiceStrategy string const ( LoadBalancerServiceStrategyRoundRobin LoadBalancerServiceStrategy = "round-robin" + LoadBalancerServiceStrategyMaglevHash LoadBalancerServiceStrategy = "maglev-hash" LoadBalancerServiceStrategySourceHash LoadBalancerServiceStrategy = "source-hash" ) @@ -2206,6 +2230,26 @@ type Operation struct { State OperationState `json:"state,omitempty"` } +// Organization +type Organization struct { + // Organization address + Address string `json:"address,omitempty"` + // Organization balance + Balance float64 `json:"balance,omitempty"` + // Organization city + City string `json:"city,omitempty"` + // Organization country + Country string `json:"country,omitempty"` + // Organization currency + Currency string `json:"currency,omitempty"` + // Organization ID + ID UUID `json:"id,omitempty"` + // Organization name + Name string `json:"name,omitempty"` + // Organization postcode + Postcode string `json:"postcode,omitempty"` +} + // Private Network type PrivateNetwork struct { // Private Network description @@ -2223,6 +2267,8 @@ type PrivateNetwork struct { Netmask net.IP `json:"netmask,omitempty"` // Private Network start IP address StartIP net.IP `json:"start-ip,omitempty"` + // Private Network VXLAN ID + Vni int64 `json:"vni,omitempty" validate:"omitempty,gt=0"` } // Private Network leased IP address @@ -2435,8 +2481,8 @@ type SKSNodepool struct { DeployTarget *DeployTarget `json:"deploy-target,omitempty"` // Nodepool description Description string `json:"description,omitempty" validate:"omitempty,lte=255"` - // Nodepool instances disk size in GB - DiskSize int64 `json:"disk-size,omitempty" validate:"omitempty,gte=20,lte=50000"` + // Nodepool instances disk size in GiB + DiskSize int64 `json:"disk-size,omitempty" validate:"omitempty,gte=20,lte=51200"` // Nodepool ID ID UUID `json:"id,omitempty"` // Instance Pool @@ -2533,8 +2579,8 @@ type Snapshot struct { Instance *Instance `json:"instance,omitempty"` // Snapshot name Name string `json:"name,omitempty" validate:"omitempty,gte=1,lte=255"` - // Snapshot size in GB - Size int64 `json:"size,omitempty" validate:"omitempty,gte=10,lte=50000"` + // Snapshot size in GiB + Size int64 `json:"size,omitempty" validate:"omitempty,gte=10,lte=51200"` // Snapshot state State SnapshotState `json:"state,omitempty"` } @@ -2610,6 +2656,22 @@ type Template struct { Zones []ZoneName `json:"zones,omitempty"` } +// User +type User struct { + // User Email + Email string `json:"email" validate:"required"` + // User ID + ID UUID `json:"id,omitempty"` + // True if the user has not yet created an Exoscale account + Pending *bool `json:"pending,omitempty"` + // IAM Role + Role *IAMRole `json:"role" validate:"required"` + // SSO enabled + Sso *bool `json:"sso,omitempty"` + // Two Factor Authentication enabled + TwoFactorAuthentication *bool `json:"two-factor-authentication,omitempty"` +} + // Zone type Zone struct { // Zone API endpoint diff --git a/vendor/github.com/exoscale/egoscale/v3/version.go b/vendor/github.com/exoscale/egoscale/v3/version.go new file mode 100644 index 000000000..909a039a1 --- /dev/null +++ b/vendor/github.com/exoscale/egoscale/v3/version.go @@ -0,0 +1,4 @@ +package v3 + +// Version represents the current egoscale v3 version. +const Version = "v3.1.0" diff --git a/vendor/modules.txt b/vendor/modules.txt index f7bbfbf6f..da07b495c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -214,14 +214,16 @@ github.com/dlclark/regexp2/syntax # github.com/dustin/go-humanize v1.0.1 ## explicit; go 1.16 github.com/dustin/go-humanize -# github.com/exoscale/egoscale v0.102.4-0.20240506093113-3ae83713b097 -## explicit; go 1.21 +# github.com/exoscale/egoscale v0.102.4 +## explicit; go 1.22 github.com/exoscale/egoscale/v2 github.com/exoscale/egoscale/v2/api github.com/exoscale/egoscale/v2/oapi +github.com/exoscale/egoscale/version +# github.com/exoscale/egoscale/v3 v3.1.0 +## explicit; go 1.22 github.com/exoscale/egoscale/v3 github.com/exoscale/egoscale/v3/credentials -github.com/exoscale/egoscale/version # github.com/exoscale/openapi-cli-generator v1.1.0 ## explicit; go 1.12 github.com/exoscale/openapi-cli-generator/cli