diff --git a/sdk/postgresql/armpostgresqlflexibleservers/CHANGELOG.md b/sdk/postgresql/armpostgresqlflexibleservers/CHANGELOG.md new file mode 100644 index 000000000000..c7196df9ed8b --- /dev/null +++ b/sdk/postgresql/armpostgresqlflexibleservers/CHANGELOG.md @@ -0,0 +1,3 @@ +# Release History + +## v0.1.0 (released) diff --git a/sdk/postgresql/armpostgresqlflexibleservers/LICENSE.txt b/sdk/postgresql/armpostgresqlflexibleservers/LICENSE.txt new file mode 100644 index 000000000000..ccb63b166732 --- /dev/null +++ b/sdk/postgresql/armpostgresqlflexibleservers/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2021 Microsoft + +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. \ No newline at end of file diff --git a/sdk/postgresql/armpostgresqlflexibleservers/README.md b/sdk/postgresql/armpostgresqlflexibleservers/README.md new file mode 100644 index 000000000000..6ef966bccb4e --- /dev/null +++ b/sdk/postgresql/armpostgresqlflexibleservers/README.md @@ -0,0 +1,76 @@ +# Azure Azure Database for PostgreSQL Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/postgresql/armpostgresqlflexibleservers)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/postgresql/armpostgresqlflexibleservers) + +The `armpostgresqlflexibleservers` module provides operations for working with Azure Azure Database for PostgreSQL. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/postgresql/armpostgresqlflexibleservers) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.13 or above + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Azure Database for PostgreSQL module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/postgresql/armpostgresqlflexibleservers +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Azure Database for PostgreSQL. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +cred, err := azidentity.NewDefaultAzureCredential(nil) +``` + +For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). + +## Connecting to Azure Azure Database for PostgreSQL + +Once you have a credential, create a connection to the desired ARM endpoint. The `armcore` module provides facilities for connecting with ARM endpoints including public and sovereign clouds as well as Azure Stack. + +```go +con := armcore.NewDefaultConnection(cred, nil) +``` + +For more information on ARM connections, please see the documentation for `armcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/armcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/armcore). + +## Clients + +Azure Azure Database for PostgreSQL modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your `armcore.Connection`. + +```go +client := armpostgresqlflexibleservers.NewDatabasesClient(con, "") +``` + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Azure Database for PostgreSQL` label. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information, see the +[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. \ No newline at end of file diff --git a/sdk/postgresql/armpostgresqlflexibleservers/autorest.md b/sdk/postgresql/armpostgresqlflexibleservers/autorest.md new file mode 100644 index 000000000000..c7b493aaf767 --- /dev/null +++ b/sdk/postgresql/armpostgresqlflexibleservers/autorest.md @@ -0,0 +1,11 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +require: +- https://github.com/Azure/azure-rest-api-specs/blob/dec9c6c39c2c24aa51a3f70c0b1133912653b180/specification/postgresql/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/dec9c6c39c2c24aa51a3f70c0b1133912653b180/specification/postgresql/resource-manager/readme.go.md +module-version: 0.1.0 +package-flexibleservers: true +``` \ No newline at end of file diff --git a/sdk/postgresql/armpostgresqlflexibleservers/build.go b/sdk/postgresql/armpostgresqlflexibleservers/build.go new file mode 100644 index 000000000000..1ea8fe7d0ca9 --- /dev/null +++ b/sdk/postgresql/armpostgresqlflexibleservers/build.go @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file enables 'go generate' to regenerate this specific SDK +//go:generate pwsh.exe ../../../eng/scripts/build.ps1 -skipBuild -format -tidy -generate armpostgresqlflexibleservers + +package armpostgresqlflexibleservers diff --git a/sdk/postgresql/armpostgresqlflexibleservers/ci.yml b/sdk/postgresql/armpostgresqlflexibleservers/ci.yml new file mode 100644 index 000000000000..3f1c2527bb4a --- /dev/null +++ b/sdk/postgresql/armpostgresqlflexibleservers/ci.yml @@ -0,0 +1,15 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + paths: + include: + - sdk/postgresql/armpostgresqlflexibleservers/ + +pr: + paths: + include: + - sdk/postgresql/armpostgresqlflexibleservers/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'postgresql/armpostgresqlflexibleservers' diff --git a/sdk/postgresql/armpostgresqlflexibleservers/go.mod b/sdk/postgresql/armpostgresqlflexibleservers/go.mod new file mode 100644 index 000000000000..ef4c062692e4 --- /dev/null +++ b/sdk/postgresql/armpostgresqlflexibleservers/go.mod @@ -0,0 +1,9 @@ +module github.com/Azure/azure-sdk-for-go/sdk/postgresql/armpostgresqlflexibleservers + +go 1.13 + +require ( + github.com/Azure/azure-sdk-for-go v56.1.0+incompatible + github.com/Azure/azure-sdk-for-go/sdk/armcore v0.8.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.16.2 +) diff --git a/sdk/postgresql/armpostgresqlflexibleservers/go.sum b/sdk/postgresql/armpostgresqlflexibleservers/go.sum new file mode 100644 index 000000000000..9e02912957fd --- /dev/null +++ b/sdk/postgresql/armpostgresqlflexibleservers/go.sum @@ -0,0 +1,20 @@ +github.com/Azure/azure-sdk-for-go v56.1.0+incompatible h1:Ofcecdw3F1ZqnpDEZcLzH9Hq0P4Y5Si8+EioXJSamJs= +github.com/Azure/azure-sdk-for-go v56.1.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/azure-sdk-for-go/sdk/armcore v0.8.0 h1:HQQoaSGOh32mpoRkpLDjkngMwYJqkxu93FRx0epdLHE= +github.com/Azure/azure-sdk-for-go/sdk/armcore v0.8.0/go.mod h1:BSKvHb/5cy8j4hahIInXH92X/2zGJ3TxKF6b9pw1Btg= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.16.2 h1:UC4vfOhW2l0f2QOCQpOxJS4/K6oKFy2tQZE+uWU1MEo= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.16.2/go.mod h1:MVdrcUC4Hup35qHym3VdzoW+NBgBxrta9Vei97jRtM8= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.5.1 h1:vx8McI56N5oLSQu8xa+xdiE0fjQq8W8Zt49vHP8Rygw= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.5.1/go.mod h1:k4KbFSunV/+0hOHL1vyFaPsiYQ1Vmvy1TBpmtvCDLZM= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20201010224723-4f7140c49acb h1:mUVeFHoDKis5nxCAzoAi7E8Ghb86EXh/RK6wtvJIqRY= +golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/sdk/postgresql/armpostgresqlflexibleservers/go_mod_tidy_hack.go b/sdk/postgresql/armpostgresqlflexibleservers/go_mod_tidy_hack.go new file mode 100644 index 000000000000..7b8f8a67abb2 --- /dev/null +++ b/sdk/postgresql/armpostgresqlflexibleservers/go_mod_tidy_hack.go @@ -0,0 +1,12 @@ +// +build modhack + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file, and the github.com/Azure/azure-sdk-for-go import, won't actually become part of +// the resultant binary. + +package armpostgresqlflexibleservers + +// Necessary for safely adding multi-module repo. See: https://github.com/golang/go/wiki/Modules#is-it-possible-to-add-a-module-to-a-multi-module-repository +import _ "github.com/Azure/azure-sdk-for-go" diff --git a/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_checknameavailability_client.go b/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_checknameavailability_client.go new file mode 100644 index 000000000000..28e0ade6c995 --- /dev/null +++ b/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_checknameavailability_client.go @@ -0,0 +1,89 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armpostgresqlflexibleservers + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// CheckNameAvailabilityClient contains the methods for the CheckNameAvailability group. +// Don't use this type directly, use NewCheckNameAvailabilityClient() instead. +type CheckNameAvailabilityClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewCheckNameAvailabilityClient creates a new instance of CheckNameAvailabilityClient with the specified values. +func NewCheckNameAvailabilityClient(con *armcore.Connection, subscriptionID string) *CheckNameAvailabilityClient { + return &CheckNameAvailabilityClient{con: con, subscriptionID: subscriptionID} +} + +// Execute - Check the availability of name for resource +// If the operation fails it returns the *CloudError error type. +func (client *CheckNameAvailabilityClient) Execute(ctx context.Context, nameAvailabilityRequest NameAvailabilityRequest, options *CheckNameAvailabilityExecuteOptions) (CheckNameAvailabilityExecuteResponse, error) { + req, err := client.executeCreateRequest(ctx, nameAvailabilityRequest, options) + if err != nil { + return CheckNameAvailabilityExecuteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return CheckNameAvailabilityExecuteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return CheckNameAvailabilityExecuteResponse{}, client.executeHandleError(resp) + } + return client.executeHandleResponse(resp) +} + +// executeCreateRequest creates the Execute request. +func (client *CheckNameAvailabilityClient) executeCreateRequest(ctx context.Context, nameAvailabilityRequest NameAvailabilityRequest, options *CheckNameAvailabilityExecuteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DBforPostgreSQL/checkNameAvailability" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(nameAvailabilityRequest) +} + +// executeHandleResponse handles the Execute response. +func (client *CheckNameAvailabilityClient) executeHandleResponse(resp *azcore.Response) (CheckNameAvailabilityExecuteResponse, error) { + result := CheckNameAvailabilityExecuteResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.NameAvailability); err != nil { + return CheckNameAvailabilityExecuteResponse{}, err + } + return result, nil +} + +// executeHandleError handles the Execute error response. +func (client *CheckNameAvailabilityClient) executeHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudError{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_configurations_client.go b/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_configurations_client.go new file mode 100644 index 000000000000..fc6b684692b1 --- /dev/null +++ b/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_configurations_client.go @@ -0,0 +1,383 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armpostgresqlflexibleservers + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" + "time" +) + +// ConfigurationsClient contains the methods for the Configurations group. +// Don't use this type directly, use NewConfigurationsClient() instead. +type ConfigurationsClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewConfigurationsClient creates a new instance of ConfigurationsClient with the specified values. +func NewConfigurationsClient(con *armcore.Connection, subscriptionID string) *ConfigurationsClient { + return &ConfigurationsClient{con: con, subscriptionID: subscriptionID} +} + +// Get - Gets information about a configuration of server. +// If the operation fails it returns the *CloudError error type. +func (client *ConfigurationsClient) Get(ctx context.Context, resourceGroupName string, serverName string, configurationName string, options *ConfigurationsGetOptions) (ConfigurationsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, configurationName, options) + if err != nil { + return ConfigurationsGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ConfigurationsGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ConfigurationsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ConfigurationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, serverName string, configurationName string, options *ConfigurationsGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/configurations/{configurationName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serverName == "" { + return nil, errors.New("parameter serverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) + if configurationName == "" { + return nil, errors.New("parameter configurationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{configurationName}", url.PathEscape(configurationName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ConfigurationsClient) getHandleResponse(resp *azcore.Response) (ConfigurationsGetResponse, error) { + result := ConfigurationsGetResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.Configuration); err != nil { + return ConfigurationsGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *ConfigurationsClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudError{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByServer - List all the configurations in a given server. +// If the operation fails it returns the *CloudError error type. +func (client *ConfigurationsClient) ListByServer(resourceGroupName string, serverName string, options *ConfigurationsListByServerOptions) ConfigurationsListByServerPager { + return &configurationsListByServerPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServerCreateRequest(ctx, resourceGroupName, serverName, options) + }, + advancer: func(ctx context.Context, resp ConfigurationsListByServerResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.ConfigurationListResult.NextLink) + }, + } +} + +// listByServerCreateRequest creates the ListByServer request. +func (client *ConfigurationsClient) listByServerCreateRequest(ctx context.Context, resourceGroupName string, serverName string, options *ConfigurationsListByServerOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/configurations" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serverName == "" { + return nil, errors.New("parameter serverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServerHandleResponse handles the ListByServer response. +func (client *ConfigurationsClient) listByServerHandleResponse(resp *azcore.Response) (ConfigurationsListByServerResponse, error) { + result := ConfigurationsListByServerResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.ConfigurationListResult); err != nil { + return ConfigurationsListByServerResponse{}, err + } + return result, nil +} + +// listByServerHandleError handles the ListByServer error response. +func (client *ConfigurationsClient) listByServerHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudError{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginPut - Updates a configuration of a server. +// If the operation fails it returns the *CloudError error type. +func (client *ConfigurationsClient) BeginPut(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration, options *ConfigurationsBeginPutOptions) (ConfigurationsPutPollerResponse, error) { + resp, err := client.put(ctx, resourceGroupName, serverName, configurationName, parameters, options) + if err != nil { + return ConfigurationsPutPollerResponse{}, err + } + result := ConfigurationsPutPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("ConfigurationsClient.Put", "", resp, client.con.Pipeline(), client.putHandleError) + if err != nil { + return ConfigurationsPutPollerResponse{}, err + } + poller := &configurationsPutPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ConfigurationsPutResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumePut creates a new ConfigurationsPutPoller from the specified resume token. +// token - The value must come from a previous call to ConfigurationsPutPoller.ResumeToken(). +func (client *ConfigurationsClient) ResumePut(ctx context.Context, token string) (ConfigurationsPutPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("ConfigurationsClient.Put", token, client.con.Pipeline(), client.putHandleError) + if err != nil { + return ConfigurationsPutPollerResponse{}, err + } + poller := &configurationsPutPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return ConfigurationsPutPollerResponse{}, err + } + result := ConfigurationsPutPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ConfigurationsPutResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Put - Updates a configuration of a server. +// If the operation fails it returns the *CloudError error type. +func (client *ConfigurationsClient) put(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration, options *ConfigurationsBeginPutOptions) (*azcore.Response, error) { + req, err := client.putCreateRequest(ctx, resourceGroupName, serverName, configurationName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted) { + return nil, client.putHandleError(resp) + } + return resp, nil +} + +// putCreateRequest creates the Put request. +func (client *ConfigurationsClient) putCreateRequest(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration, options *ConfigurationsBeginPutOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/configurations/{configurationName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serverName == "" { + return nil, errors.New("parameter serverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) + if configurationName == "" { + return nil, errors.New("parameter configurationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{configurationName}", url.PathEscape(configurationName)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// putHandleError handles the Put error response. +func (client *ConfigurationsClient) putHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudError{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginUpdate - Updates a configuration of a server. +// If the operation fails it returns the *CloudError error type. +func (client *ConfigurationsClient) BeginUpdate(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration, options *ConfigurationsBeginUpdateOptions) (ConfigurationsUpdatePollerResponse, error) { + resp, err := client.update(ctx, resourceGroupName, serverName, configurationName, parameters, options) + if err != nil { + return ConfigurationsUpdatePollerResponse{}, err + } + result := ConfigurationsUpdatePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("ConfigurationsClient.Update", "", resp, client.con.Pipeline(), client.updateHandleError) + if err != nil { + return ConfigurationsUpdatePollerResponse{}, err + } + poller := &configurationsUpdatePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ConfigurationsUpdateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeUpdate creates a new ConfigurationsUpdatePoller from the specified resume token. +// token - The value must come from a previous call to ConfigurationsUpdatePoller.ResumeToken(). +func (client *ConfigurationsClient) ResumeUpdate(ctx context.Context, token string) (ConfigurationsUpdatePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("ConfigurationsClient.Update", token, client.con.Pipeline(), client.updateHandleError) + if err != nil { + return ConfigurationsUpdatePollerResponse{}, err + } + poller := &configurationsUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return ConfigurationsUpdatePollerResponse{}, err + } + result := ConfigurationsUpdatePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ConfigurationsUpdateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Update - Updates a configuration of a server. +// If the operation fails it returns the *CloudError error type. +func (client *ConfigurationsClient) update(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration, options *ConfigurationsBeginUpdateOptions) (*azcore.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, serverName, configurationName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted) { + return nil, client.updateHandleError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *ConfigurationsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration, options *ConfigurationsBeginUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/configurations/{configurationName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serverName == "" { + return nil, errors.New("parameter serverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) + if configurationName == "" { + return nil, errors.New("parameter configurationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{configurationName}", url.PathEscape(configurationName)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleError handles the Update error response. +func (client *ConfigurationsClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudError{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_constants.go b/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_constants.go new file mode 100644 index 000000000000..89de2f0f816e --- /dev/null +++ b/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_constants.go @@ -0,0 +1,298 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armpostgresqlflexibleservers + +const telemetryInfo = "azsdk-go-armpostgresqlflexibleservers/v0.1.0" + +// ConfigurationDataType - Data type of the configuration. +type ConfigurationDataType string + +const ( + ConfigurationDataTypeBoolean ConfigurationDataType = "Boolean" + ConfigurationDataTypeEnumeration ConfigurationDataType = "Enumeration" + ConfigurationDataTypeInteger ConfigurationDataType = "Integer" + ConfigurationDataTypeNumeric ConfigurationDataType = "Numeric" +) + +// PossibleConfigurationDataTypeValues returns the possible values for the ConfigurationDataType const type. +func PossibleConfigurationDataTypeValues() []ConfigurationDataType { + return []ConfigurationDataType{ + ConfigurationDataTypeBoolean, + ConfigurationDataTypeEnumeration, + ConfigurationDataTypeInteger, + ConfigurationDataTypeNumeric, + } +} + +// ToPtr returns a *ConfigurationDataType pointing to the current value. +func (c ConfigurationDataType) ToPtr() *ConfigurationDataType { + return &c +} + +// CreateMode - The mode to create a new PostgreSQL server. +type CreateMode string + +const ( + CreateModeCreate CreateMode = "Create" + CreateModeDefault CreateMode = "Default" + CreateModePointInTimeRestore CreateMode = "PointInTimeRestore" + CreateModeUpdate CreateMode = "Update" +) + +// PossibleCreateModeValues returns the possible values for the CreateMode const type. +func PossibleCreateModeValues() []CreateMode { + return []CreateMode{ + CreateModeCreate, + CreateModeDefault, + CreateModePointInTimeRestore, + CreateModeUpdate, + } +} + +// ToPtr returns a *CreateMode pointing to the current value. +func (c CreateMode) ToPtr() *CreateMode { + return &c +} + +// CreateModeForUpdate - The mode to update a new PostgreSQL server. +type CreateModeForUpdate string + +const ( + CreateModeForUpdateDefault CreateModeForUpdate = "Default" + CreateModeForUpdateUpdate CreateModeForUpdate = "Update" +) + +// PossibleCreateModeForUpdateValues returns the possible values for the CreateModeForUpdate const type. +func PossibleCreateModeForUpdateValues() []CreateModeForUpdate { + return []CreateModeForUpdate{ + CreateModeForUpdateDefault, + CreateModeForUpdateUpdate, + } +} + +// ToPtr returns a *CreateModeForUpdate pointing to the current value. +func (c CreateModeForUpdate) ToPtr() *CreateModeForUpdate { + return &c +} + +// CreatedByType - The type of identity that created the resource. +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{ + CreatedByTypeApplication, + CreatedByTypeKey, + CreatedByTypeManagedIdentity, + CreatedByTypeUser, + } +} + +// ToPtr returns a *CreatedByType pointing to the current value. +func (c CreatedByType) ToPtr() *CreatedByType { + return &c +} + +// GeoRedundantBackupEnum - A value indicating whether Geo-Redundant backup is enabled on the server. +type GeoRedundantBackupEnum string + +const ( + GeoRedundantBackupEnumDisabled GeoRedundantBackupEnum = "Disabled" + GeoRedundantBackupEnumEnabled GeoRedundantBackupEnum = "Enabled" +) + +// PossibleGeoRedundantBackupEnumValues returns the possible values for the GeoRedundantBackupEnum const type. +func PossibleGeoRedundantBackupEnumValues() []GeoRedundantBackupEnum { + return []GeoRedundantBackupEnum{ + GeoRedundantBackupEnumDisabled, + GeoRedundantBackupEnumEnabled, + } +} + +// ToPtr returns a *GeoRedundantBackupEnum pointing to the current value. +func (c GeoRedundantBackupEnum) ToPtr() *GeoRedundantBackupEnum { + return &c +} + +// HighAvailabilityMode - The HA mode for the server. +type HighAvailabilityMode string + +const ( + HighAvailabilityModeDisabled HighAvailabilityMode = "Disabled" + HighAvailabilityModeZoneRedundant HighAvailabilityMode = "ZoneRedundant" +) + +// PossibleHighAvailabilityModeValues returns the possible values for the HighAvailabilityMode const type. +func PossibleHighAvailabilityModeValues() []HighAvailabilityMode { + return []HighAvailabilityMode{ + HighAvailabilityModeDisabled, + HighAvailabilityModeZoneRedundant, + } +} + +// ToPtr returns a *HighAvailabilityMode pointing to the current value. +func (c HighAvailabilityMode) ToPtr() *HighAvailabilityMode { + return &c +} + +// OperationOrigin - The intended executor of the operation. +type OperationOrigin string + +const ( + OperationOriginNotSpecified OperationOrigin = "NotSpecified" + OperationOriginSystem OperationOrigin = "system" + OperationOriginUser OperationOrigin = "user" +) + +// PossibleOperationOriginValues returns the possible values for the OperationOrigin const type. +func PossibleOperationOriginValues() []OperationOrigin { + return []OperationOrigin{ + OperationOriginNotSpecified, + OperationOriginSystem, + OperationOriginUser, + } +} + +// ToPtr returns a *OperationOrigin pointing to the current value. +func (c OperationOrigin) ToPtr() *OperationOrigin { + return &c +} + +// SKUTier - The tier of the particular SKU, e.g. Burstable. +type SKUTier string + +const ( + SKUTierBurstable SKUTier = "Burstable" + SKUTierGeneralPurpose SKUTier = "GeneralPurpose" + SKUTierMemoryOptimized SKUTier = "MemoryOptimized" +) + +// PossibleSKUTierValues returns the possible values for the SKUTier const type. +func PossibleSKUTierValues() []SKUTier { + return []SKUTier{ + SKUTierBurstable, + SKUTierGeneralPurpose, + SKUTierMemoryOptimized, + } +} + +// ToPtr returns a *SKUTier pointing to the current value. +func (c SKUTier) ToPtr() *SKUTier { + return &c +} + +// ServerHAState - A state of a HA server that is visible to user. +type ServerHAState string + +const ( + ServerHAStateCreatingStandby ServerHAState = "CreatingStandby" + ServerHAStateFailingOver ServerHAState = "FailingOver" + ServerHAStateHealthy ServerHAState = "Healthy" + ServerHAStateNotEnabled ServerHAState = "NotEnabled" + ServerHAStateRemovingStandby ServerHAState = "RemovingStandby" + ServerHAStateReplicatingData ServerHAState = "ReplicatingData" +) + +// PossibleServerHAStateValues returns the possible values for the ServerHAState const type. +func PossibleServerHAStateValues() []ServerHAState { + return []ServerHAState{ + ServerHAStateCreatingStandby, + ServerHAStateFailingOver, + ServerHAStateHealthy, + ServerHAStateNotEnabled, + ServerHAStateRemovingStandby, + ServerHAStateReplicatingData, + } +} + +// ToPtr returns a *ServerHAState pointing to the current value. +func (c ServerHAState) ToPtr() *ServerHAState { + return &c +} + +// ServerPublicNetworkAccessState - public network access is enabled or not +type ServerPublicNetworkAccessState string + +const ( + ServerPublicNetworkAccessStateDisabled ServerPublicNetworkAccessState = "Disabled" + ServerPublicNetworkAccessStateEnabled ServerPublicNetworkAccessState = "Enabled" +) + +// PossibleServerPublicNetworkAccessStateValues returns the possible values for the ServerPublicNetworkAccessState const type. +func PossibleServerPublicNetworkAccessStateValues() []ServerPublicNetworkAccessState { + return []ServerPublicNetworkAccessState{ + ServerPublicNetworkAccessStateDisabled, + ServerPublicNetworkAccessStateEnabled, + } +} + +// ToPtr returns a *ServerPublicNetworkAccessState pointing to the current value. +func (c ServerPublicNetworkAccessState) ToPtr() *ServerPublicNetworkAccessState { + return &c +} + +// ServerState - A state of a server that is visible to user. +type ServerState string + +const ( + ServerStateDisabled ServerState = "Disabled" + ServerStateDropping ServerState = "Dropping" + ServerStateReady ServerState = "Ready" + ServerStateStarting ServerState = "Starting" + ServerStateStopped ServerState = "Stopped" + ServerStateStopping ServerState = "Stopping" + ServerStateUpdating ServerState = "Updating" +) + +// PossibleServerStateValues returns the possible values for the ServerState const type. +func PossibleServerStateValues() []ServerState { + return []ServerState{ + ServerStateDisabled, + ServerStateDropping, + ServerStateReady, + ServerStateStarting, + ServerStateStopped, + ServerStateStopping, + ServerStateUpdating, + } +} + +// ToPtr returns a *ServerState pointing to the current value. +func (c ServerState) ToPtr() *ServerState { + return &c +} + +// ServerVersion - The version of a server. +type ServerVersion string + +const ( + ServerVersionEleven ServerVersion = "11" + ServerVersionThirteen ServerVersion = "13" + ServerVersionTwelve ServerVersion = "12" +) + +// PossibleServerVersionValues returns the possible values for the ServerVersion const type. +func PossibleServerVersionValues() []ServerVersion { + return []ServerVersion{ + ServerVersionEleven, + ServerVersionThirteen, + ServerVersionTwelve, + } +} + +// ToPtr returns a *ServerVersion pointing to the current value. +func (c ServerVersion) ToPtr() *ServerVersion { + return &c +} diff --git a/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_databases_client.go b/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_databases_client.go new file mode 100644 index 000000000000..254c7aef335e --- /dev/null +++ b/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_databases_client.go @@ -0,0 +1,383 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armpostgresqlflexibleservers + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" + "time" +) + +// DatabasesClient contains the methods for the Databases group. +// Don't use this type directly, use NewDatabasesClient() instead. +type DatabasesClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewDatabasesClient creates a new instance of DatabasesClient with the specified values. +func NewDatabasesClient(con *armcore.Connection, subscriptionID string) *DatabasesClient { + return &DatabasesClient{con: con, subscriptionID: subscriptionID} +} + +// BeginCreate - Creates a new database or updates an existing database. +// If the operation fails it returns the *CloudError error type. +func (client *DatabasesClient) BeginCreate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters Database, options *DatabasesBeginCreateOptions) (DatabasesCreatePollerResponse, error) { + resp, err := client.create(ctx, resourceGroupName, serverName, databaseName, parameters, options) + if err != nil { + return DatabasesCreatePollerResponse{}, err + } + result := DatabasesCreatePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("DatabasesClient.Create", "", resp, client.con.Pipeline(), client.createHandleError) + if err != nil { + return DatabasesCreatePollerResponse{}, err + } + poller := &databasesCreatePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (DatabasesCreateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeCreate creates a new DatabasesCreatePoller from the specified resume token. +// token - The value must come from a previous call to DatabasesCreatePoller.ResumeToken(). +func (client *DatabasesClient) ResumeCreate(ctx context.Context, token string) (DatabasesCreatePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("DatabasesClient.Create", token, client.con.Pipeline(), client.createHandleError) + if err != nil { + return DatabasesCreatePollerResponse{}, err + } + poller := &databasesCreatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return DatabasesCreatePollerResponse{}, err + } + result := DatabasesCreatePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (DatabasesCreateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Create - Creates a new database or updates an existing database. +// If the operation fails it returns the *CloudError error type. +func (client *DatabasesClient) create(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters Database, options *DatabasesBeginCreateOptions) (*azcore.Response, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, serverName, databaseName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted) { + return nil, client.createHandleError(resp) + } + return resp, nil +} + +// createCreateRequest creates the Create request. +func (client *DatabasesClient) createCreateRequest(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters Database, options *DatabasesBeginCreateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/databases/{databaseName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serverName == "" { + return nil, errors.New("parameter serverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) + if databaseName == "" { + return nil, errors.New("parameter databaseName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createHandleError handles the Create error response. +func (client *DatabasesClient) createHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudError{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginDelete - Deletes a database. +// If the operation fails it returns the *CloudError error type. +func (client *DatabasesClient) BeginDelete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, options *DatabasesBeginDeleteOptions) (DatabasesDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, serverName, databaseName, options) + if err != nil { + return DatabasesDeletePollerResponse{}, err + } + result := DatabasesDeletePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("DatabasesClient.Delete", "", resp, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return DatabasesDeletePollerResponse{}, err + } + poller := &databasesDeletePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (DatabasesDeleteResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeDelete creates a new DatabasesDeletePoller from the specified resume token. +// token - The value must come from a previous call to DatabasesDeletePoller.ResumeToken(). +func (client *DatabasesClient) ResumeDelete(ctx context.Context, token string) (DatabasesDeletePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("DatabasesClient.Delete", token, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return DatabasesDeletePollerResponse{}, err + } + poller := &databasesDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return DatabasesDeletePollerResponse{}, err + } + result := DatabasesDeletePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (DatabasesDeleteResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Delete - Deletes a database. +// If the operation fails it returns the *CloudError error type. +func (client *DatabasesClient) deleteOperation(ctx context.Context, resourceGroupName string, serverName string, databaseName string, options *DatabasesBeginDeleteOptions) (*azcore.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serverName, databaseName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *DatabasesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serverName string, databaseName string, options *DatabasesBeginDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/databases/{databaseName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serverName == "" { + return nil, errors.New("parameter serverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) + if databaseName == "" { + return nil, errors.New("parameter databaseName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *DatabasesClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudError{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets information about a database. +// If the operation fails it returns the *CloudError error type. +func (client *DatabasesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, options *DatabasesGetOptions) (DatabasesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, databaseName, options) + if err != nil { + return DatabasesGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DatabasesGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return DatabasesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *DatabasesClient) getCreateRequest(ctx context.Context, resourceGroupName string, serverName string, databaseName string, options *DatabasesGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/databases/{databaseName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serverName == "" { + return nil, errors.New("parameter serverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) + if databaseName == "" { + return nil, errors.New("parameter databaseName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DatabasesClient) getHandleResponse(resp *azcore.Response) (DatabasesGetResponse, error) { + result := DatabasesGetResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.Database); err != nil { + return DatabasesGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *DatabasesClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudError{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByServer - List all the databases in a given server. +// If the operation fails it returns the *CloudError error type. +func (client *DatabasesClient) ListByServer(resourceGroupName string, serverName string, options *DatabasesListByServerOptions) DatabasesListByServerPager { + return &databasesListByServerPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServerCreateRequest(ctx, resourceGroupName, serverName, options) + }, + advancer: func(ctx context.Context, resp DatabasesListByServerResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.DatabaseListResult.NextLink) + }, + } +} + +// listByServerCreateRequest creates the ListByServer request. +func (client *DatabasesClient) listByServerCreateRequest(ctx context.Context, resourceGroupName string, serverName string, options *DatabasesListByServerOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/databases" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serverName == "" { + return nil, errors.New("parameter serverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServerHandleResponse handles the ListByServer response. +func (client *DatabasesClient) listByServerHandleResponse(resp *azcore.Response) (DatabasesListByServerResponse, error) { + result := DatabasesListByServerResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.DatabaseListResult); err != nil { + return DatabasesListByServerResponse{}, err + } + return result, nil +} + +// listByServerHandleError handles the ListByServer error response. +func (client *DatabasesClient) listByServerHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudError{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_firewallrules_client.go b/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_firewallrules_client.go new file mode 100644 index 000000000000..c70f264a5e35 --- /dev/null +++ b/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_firewallrules_client.go @@ -0,0 +1,383 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armpostgresqlflexibleservers + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" + "time" +) + +// FirewallRulesClient contains the methods for the FirewallRules group. +// Don't use this type directly, use NewFirewallRulesClient() instead. +type FirewallRulesClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewFirewallRulesClient creates a new instance of FirewallRulesClient with the specified values. +func NewFirewallRulesClient(con *armcore.Connection, subscriptionID string) *FirewallRulesClient { + return &FirewallRulesClient{con: con, subscriptionID: subscriptionID} +} + +// BeginCreateOrUpdate - Creates a new firewall rule or updates an existing firewall rule. +// If the operation fails it returns the *CloudError error type. +func (client *FirewallRulesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters FirewallRule, options *FirewallRulesBeginCreateOrUpdateOptions) (FirewallRulesCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, serverName, firewallRuleName, parameters, options) + if err != nil { + return FirewallRulesCreateOrUpdatePollerResponse{}, err + } + result := FirewallRulesCreateOrUpdatePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("FirewallRulesClient.CreateOrUpdate", "", resp, client.con.Pipeline(), client.createOrUpdateHandleError) + if err != nil { + return FirewallRulesCreateOrUpdatePollerResponse{}, err + } + poller := &firewallRulesCreateOrUpdatePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (FirewallRulesCreateOrUpdateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeCreateOrUpdate creates a new FirewallRulesCreateOrUpdatePoller from the specified resume token. +// token - The value must come from a previous call to FirewallRulesCreateOrUpdatePoller.ResumeToken(). +func (client *FirewallRulesClient) ResumeCreateOrUpdate(ctx context.Context, token string) (FirewallRulesCreateOrUpdatePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("FirewallRulesClient.CreateOrUpdate", token, client.con.Pipeline(), client.createOrUpdateHandleError) + if err != nil { + return FirewallRulesCreateOrUpdatePollerResponse{}, err + } + poller := &firewallRulesCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return FirewallRulesCreateOrUpdatePollerResponse{}, err + } + result := FirewallRulesCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (FirewallRulesCreateOrUpdateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// CreateOrUpdate - Creates a new firewall rule or updates an existing firewall rule. +// If the operation fails it returns the *CloudError error type. +func (client *FirewallRulesClient) createOrUpdate(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters FirewallRule, options *FirewallRulesBeginCreateOrUpdateOptions) (*azcore.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serverName, firewallRuleName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *FirewallRulesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters FirewallRule, options *FirewallRulesBeginCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/firewallRules/{firewallRuleName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serverName == "" { + return nil, errors.New("parameter serverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) + if firewallRuleName == "" { + return nil, errors.New("parameter firewallRuleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{firewallRuleName}", url.PathEscape(firewallRuleName)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *FirewallRulesClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudError{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginDelete - Deletes a PostgreSQL server firewall rule. +// If the operation fails it returns the *CloudError error type. +func (client *FirewallRulesClient) BeginDelete(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, options *FirewallRulesBeginDeleteOptions) (FirewallRulesDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, serverName, firewallRuleName, options) + if err != nil { + return FirewallRulesDeletePollerResponse{}, err + } + result := FirewallRulesDeletePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("FirewallRulesClient.Delete", "", resp, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return FirewallRulesDeletePollerResponse{}, err + } + poller := &firewallRulesDeletePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (FirewallRulesDeleteResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeDelete creates a new FirewallRulesDeletePoller from the specified resume token. +// token - The value must come from a previous call to FirewallRulesDeletePoller.ResumeToken(). +func (client *FirewallRulesClient) ResumeDelete(ctx context.Context, token string) (FirewallRulesDeletePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("FirewallRulesClient.Delete", token, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return FirewallRulesDeletePollerResponse{}, err + } + poller := &firewallRulesDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return FirewallRulesDeletePollerResponse{}, err + } + result := FirewallRulesDeletePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (FirewallRulesDeleteResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Delete - Deletes a PostgreSQL server firewall rule. +// If the operation fails it returns the *CloudError error type. +func (client *FirewallRulesClient) deleteOperation(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, options *FirewallRulesBeginDeleteOptions) (*azcore.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serverName, firewallRuleName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *FirewallRulesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, options *FirewallRulesBeginDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/firewallRules/{firewallRuleName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serverName == "" { + return nil, errors.New("parameter serverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) + if firewallRuleName == "" { + return nil, errors.New("parameter firewallRuleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{firewallRuleName}", url.PathEscape(firewallRuleName)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *FirewallRulesClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudError{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - List all the firewall rules in a given server. +// If the operation fails it returns the *CloudError error type. +func (client *FirewallRulesClient) Get(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, options *FirewallRulesGetOptions) (FirewallRulesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, firewallRuleName, options) + if err != nil { + return FirewallRulesGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return FirewallRulesGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return FirewallRulesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *FirewallRulesClient) getCreateRequest(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, options *FirewallRulesGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/firewallRules/{firewallRuleName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serverName == "" { + return nil, errors.New("parameter serverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) + if firewallRuleName == "" { + return nil, errors.New("parameter firewallRuleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{firewallRuleName}", url.PathEscape(firewallRuleName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *FirewallRulesClient) getHandleResponse(resp *azcore.Response) (FirewallRulesGetResponse, error) { + result := FirewallRulesGetResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.FirewallRule); err != nil { + return FirewallRulesGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *FirewallRulesClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudError{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByServer - List all the firewall rules in a given PostgreSQL server. +// If the operation fails it returns the *CloudError error type. +func (client *FirewallRulesClient) ListByServer(resourceGroupName string, serverName string, options *FirewallRulesListByServerOptions) FirewallRulesListByServerPager { + return &firewallRulesListByServerPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServerCreateRequest(ctx, resourceGroupName, serverName, options) + }, + advancer: func(ctx context.Context, resp FirewallRulesListByServerResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.FirewallRuleListResult.NextLink) + }, + } +} + +// listByServerCreateRequest creates the ListByServer request. +func (client *FirewallRulesClient) listByServerCreateRequest(ctx context.Context, resourceGroupName string, serverName string, options *FirewallRulesListByServerOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/firewallRules" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serverName == "" { + return nil, errors.New("parameter serverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServerHandleResponse handles the ListByServer response. +func (client *FirewallRulesClient) listByServerHandleResponse(resp *azcore.Response) (FirewallRulesListByServerResponse, error) { + result := FirewallRulesListByServerResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.FirewallRuleListResult); err != nil { + return FirewallRulesListByServerResponse{}, err + } + return result, nil +} + +// listByServerHandleError handles the ListByServer error response. +func (client *FirewallRulesClient) listByServerHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudError{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_getprivatednszonesuffix_client.go b/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_getprivatednszonesuffix_client.go new file mode 100644 index 000000000000..fd8e90ca5bc7 --- /dev/null +++ b/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_getprivatednszonesuffix_client.go @@ -0,0 +1,81 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armpostgresqlflexibleservers + +import ( + "context" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" +) + +// GetPrivateDNSZoneSuffixClient contains the methods for the GetPrivateDNSZoneSuffix group. +// Don't use this type directly, use NewGetPrivateDNSZoneSuffixClient() instead. +type GetPrivateDNSZoneSuffixClient struct { + con *armcore.Connection +} + +// NewGetPrivateDNSZoneSuffixClient creates a new instance of GetPrivateDNSZoneSuffixClient with the specified values. +func NewGetPrivateDNSZoneSuffixClient(con *armcore.Connection) *GetPrivateDNSZoneSuffixClient { + return &GetPrivateDNSZoneSuffixClient{con: con} +} + +// Execute - Get private DNS zone suffix in the cloud +// If the operation fails it returns the *CloudError error type. +func (client *GetPrivateDNSZoneSuffixClient) Execute(ctx context.Context, options *GetPrivateDNSZoneSuffixExecuteOptions) (GetPrivateDNSZoneSuffixExecuteResponse, error) { + req, err := client.executeCreateRequest(ctx, options) + if err != nil { + return GetPrivateDNSZoneSuffixExecuteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return GetPrivateDNSZoneSuffixExecuteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return GetPrivateDNSZoneSuffixExecuteResponse{}, client.executeHandleError(resp) + } + return client.executeHandleResponse(resp) +} + +// executeCreateRequest creates the Execute request. +func (client *GetPrivateDNSZoneSuffixClient) executeCreateRequest(ctx context.Context, options *GetPrivateDNSZoneSuffixExecuteOptions) (*azcore.Request, error) { + urlPath := "/providers/Microsoft.DBforPostgreSQL/getPrivateDnsZoneSuffix" + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// executeHandleResponse handles the Execute response. +func (client *GetPrivateDNSZoneSuffixClient) executeHandleResponse(resp *azcore.Response) (GetPrivateDNSZoneSuffixExecuteResponse, error) { + result := GetPrivateDNSZoneSuffixExecuteResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.Value); err != nil { + return GetPrivateDNSZoneSuffixExecuteResponse{}, err + } + return result, nil +} + +// executeHandleError handles the Execute error response. +func (client *GetPrivateDNSZoneSuffixClient) executeHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudError{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_locationbasedcapabilities_client.go b/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_locationbasedcapabilities_client.go new file mode 100644 index 000000000000..d73bbd4ad9e8 --- /dev/null +++ b/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_locationbasedcapabilities_client.go @@ -0,0 +1,90 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armpostgresqlflexibleservers + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// LocationBasedCapabilitiesClient contains the methods for the LocationBasedCapabilities group. +// Don't use this type directly, use NewLocationBasedCapabilitiesClient() instead. +type LocationBasedCapabilitiesClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewLocationBasedCapabilitiesClient creates a new instance of LocationBasedCapabilitiesClient with the specified values. +func NewLocationBasedCapabilitiesClient(con *armcore.Connection, subscriptionID string) *LocationBasedCapabilitiesClient { + return &LocationBasedCapabilitiesClient{con: con, subscriptionID: subscriptionID} +} + +// Execute - Get capabilities at specified location in a given subscription. +// If the operation fails it returns the *CloudError error type. +func (client *LocationBasedCapabilitiesClient) Execute(locationName string, options *LocationBasedCapabilitiesExecuteOptions) LocationBasedCapabilitiesExecutePager { + return &locationBasedCapabilitiesExecutePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.executeCreateRequest(ctx, locationName, options) + }, + advancer: func(ctx context.Context, resp LocationBasedCapabilitiesExecuteResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.CapabilitiesListResult.NextLink) + }, + } +} + +// executeCreateRequest creates the Execute request. +func (client *LocationBasedCapabilitiesClient) executeCreateRequest(ctx context.Context, locationName string, options *LocationBasedCapabilitiesExecuteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DBforPostgreSQL/locations/{locationName}/capabilities" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if locationName == "" { + return nil, errors.New("parameter locationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{locationName}", url.PathEscape(locationName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// executeHandleResponse handles the Execute response. +func (client *LocationBasedCapabilitiesClient) executeHandleResponse(resp *azcore.Response) (LocationBasedCapabilitiesExecuteResponse, error) { + result := LocationBasedCapabilitiesExecuteResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.CapabilitiesListResult); err != nil { + return LocationBasedCapabilitiesExecuteResponse{}, err + } + return result, nil +} + +// executeHandleError handles the Execute error response. +func (client *LocationBasedCapabilitiesClient) executeHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudError{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_models.go b/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_models.go new file mode 100644 index 000000000000..f28e9c46688b --- /dev/null +++ b/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_models.go @@ -0,0 +1,1136 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armpostgresqlflexibleservers + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "time" +) + +// Backup properties of a server +type Backup struct { + // Backup retention days for the server. + BackupRetentionDays *int32 `json:"backupRetentionDays,omitempty"` + + // A value indicating whether Geo-Redundant backup is enabled on the server. + GeoRedundantBackup *GeoRedundantBackupEnum `json:"geoRedundantBackup,omitempty"` + + // READ-ONLY; The earliest restore point time (ISO8601 format) for server. + EarliestRestoreDate *time.Time `json:"earliestRestoreDate,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Backup. +func (b Backup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "backupRetentionDays", b.BackupRetentionDays) + populate(objectMap, "earliestRestoreDate", (*timeRFC3339)(b.EarliestRestoreDate)) + populate(objectMap, "geoRedundantBackup", b.GeoRedundantBackup) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Backup. +func (b *Backup) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "backupRetentionDays": + err = unpopulate(val, &b.BackupRetentionDays) + delete(rawMsg, key) + case "earliestRestoreDate": + var aux timeRFC3339 + err = unpopulate(val, &aux) + b.EarliestRestoreDate = (*time.Time)(&aux) + delete(rawMsg, key) + case "geoRedundantBackup": + err = unpopulate(val, &b.GeoRedundantBackup) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// CapabilitiesListResult - location capability +type CapabilitiesListResult struct { + // READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; A list of supported capabilities. + Value []*CapabilityProperties `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type CapabilitiesListResult. +func (c CapabilitiesListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// CapabilityProperties - Location capabilities. +type CapabilityProperties struct { + // READ-ONLY; A value indicating whether a new server in this region can have geo-backups to paired region. + GeoBackupSupported *bool `json:"geoBackupSupported,omitempty" azure:"ro"` + + // READ-ONLY; The status + Status *string `json:"status,omitempty" azure:"ro"` + + // READ-ONLY + SupportedFlexibleServerEditions []*FlexibleServerEditionCapability `json:"supportedFlexibleServerEditions,omitempty" azure:"ro"` + + // READ-ONLY + SupportedHyperscaleNodeEditions []*HyperscaleNodeEditionCapability `json:"supportedHyperscaleNodeEditions,omitempty" azure:"ro"` + + // READ-ONLY; zone name + Zone *string `json:"zone,omitempty" azure:"ro"` + + // READ-ONLY; A value indicating whether a new server in this region can have geo-backups to paired region. + ZoneRedundantHaAndGeoBackupSupported *bool `json:"zoneRedundantHaAndGeoBackupSupported,omitempty" azure:"ro"` + + // READ-ONLY; A value indicating whether a new server in this region can support multi zone HA. + ZoneRedundantHaSupported *bool `json:"zoneRedundantHaSupported,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type CapabilityProperties. +func (c CapabilityProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "geoBackupSupported", c.GeoBackupSupported) + populate(objectMap, "status", c.Status) + populate(objectMap, "supportedFlexibleServerEditions", c.SupportedFlexibleServerEditions) + populate(objectMap, "supportedHyperscaleNodeEditions", c.SupportedHyperscaleNodeEditions) + populate(objectMap, "zone", c.Zone) + populate(objectMap, "zoneRedundantHaAndGeoBackupSupported", c.ZoneRedundantHaAndGeoBackupSupported) + populate(objectMap, "zoneRedundantHaSupported", c.ZoneRedundantHaSupported) + return json.Marshal(objectMap) +} + +// CheckNameAvailabilityExecuteOptions contains the optional parameters for the CheckNameAvailability.Execute method. +type CheckNameAvailabilityExecuteOptions struct { + // placeholder for future optional parameters +} + +// CloudError - An error response from the Batch service. +// Implements the error and azcore.HTTPResponse interfaces. +type CloudError struct { + raw string + // Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response + // format.) + InnerError *ErrorResponse `json:"error,omitempty"` +} + +// Error implements the error interface for type CloudError. +// The contents of the error text are not contractual and subject to change. +func (e CloudError) Error() string { + return e.raw +} + +// Configuration - Represents a Configuration. +type Configuration struct { + ProxyResource + // The properties of a configuration. + Properties *ConfigurationProperties `json:"properties,omitempty"` + + // READ-ONLY; The system metadata relating to this resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Configuration. +func (c Configuration) MarshalJSON() ([]byte, error) { + objectMap := c.ProxyResource.marshalInternal() + populate(objectMap, "properties", c.Properties) + populate(objectMap, "systemData", c.SystemData) + return json.Marshal(objectMap) +} + +// ConfigurationListResult - A list of server configurations. +type ConfigurationListResult struct { + // The link used to get the next page of operations. + NextLink *string `json:"nextLink,omitempty"` + + // The list of server configurations. + Value []*Configuration `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ConfigurationListResult. +func (c ConfigurationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// ConfigurationProperties - The properties of a configuration. +type ConfigurationProperties struct { + // Source of the configuration. + Source *string `json:"source,omitempty"` + + // Value of the configuration. + Value *string `json:"value,omitempty"` + + // READ-ONLY; Allowed values of the configuration. + AllowedValues *string `json:"allowedValues,omitempty" azure:"ro"` + + // READ-ONLY; Data type of the configuration. + DataType *ConfigurationDataType `json:"dataType,omitempty" azure:"ro"` + + // READ-ONLY; Default value of the configuration. + DefaultValue *string `json:"defaultValue,omitempty" azure:"ro"` + + // READ-ONLY; Description of the configuration. + Description *string `json:"description,omitempty" azure:"ro"` +} + +// ConfigurationsBeginPutOptions contains the optional parameters for the Configurations.BeginPut method. +type ConfigurationsBeginPutOptions struct { + // placeholder for future optional parameters +} + +// ConfigurationsBeginUpdateOptions contains the optional parameters for the Configurations.BeginUpdate method. +type ConfigurationsBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// ConfigurationsGetOptions contains the optional parameters for the Configurations.Get method. +type ConfigurationsGetOptions struct { + // placeholder for future optional parameters +} + +// ConfigurationsListByServerOptions contains the optional parameters for the Configurations.ListByServer method. +type ConfigurationsListByServerOptions struct { + // placeholder for future optional parameters +} + +// Database - Represents a Database. +type Database struct { + ProxyResource + // The properties of a database. + Properties *DatabaseProperties `json:"properties,omitempty"` + + // READ-ONLY; The system metadata relating to this resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Database. +func (d Database) MarshalJSON() ([]byte, error) { + objectMap := d.ProxyResource.marshalInternal() + populate(objectMap, "properties", d.Properties) + populate(objectMap, "systemData", d.SystemData) + return json.Marshal(objectMap) +} + +// DatabaseListResult - A List of databases. +type DatabaseListResult struct { + // The link used to get the next page of databases. + NextLink *string `json:"nextLink,omitempty"` + + // The list of databases housed in a server + Value []*Database `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DatabaseListResult. +func (d DatabaseListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// DatabaseProperties - The properties of a database. +type DatabaseProperties struct { + // The charset of the database. + Charset *string `json:"charset,omitempty"` + + // The collation of the database. + Collation *string `json:"collation,omitempty"` +} + +// DatabasesBeginCreateOptions contains the optional parameters for the Databases.BeginCreate method. +type DatabasesBeginCreateOptions struct { + // placeholder for future optional parameters +} + +// DatabasesBeginDeleteOptions contains the optional parameters for the Databases.BeginDelete method. +type DatabasesBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// DatabasesGetOptions contains the optional parameters for the Databases.Get method. +type DatabasesGetOptions struct { + // placeholder for future optional parameters +} + +// DatabasesListByServerOptions contains the optional parameters for the Databases.ListByServer method. +type DatabasesListByServerOptions struct { + // placeholder for future optional parameters +} + +// DelegatedSubnetUsage - Delegated subnet usage data. +type DelegatedSubnetUsage struct { + // READ-ONLY; name of the subnet + SubnetName *string `json:"subnetName,omitempty" azure:"ro"` + + // READ-ONLY; Number of used delegated subnets + Usage *int64 `json:"usage,omitempty" azure:"ro"` +} + +// ErrorAdditionalInfo - The resource management error additional info. +type ErrorAdditionalInfo struct { + // READ-ONLY; The additional info. + Info map[string]interface{} `json:"info,omitempty" azure:"ro"` + + // READ-ONLY; The additional info type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ErrorResponse - Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData +// error response format.) +type ErrorResponse struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo `json:"additionalInfo,omitempty" azure:"ro"` + + // READ-ONLY; The error code. + Code *string `json:"code,omitempty" azure:"ro"` + + // READ-ONLY; The error details. + Details []*ErrorResponse `json:"details,omitempty" azure:"ro"` + + // READ-ONLY; The error message. + Message *string `json:"message,omitempty" azure:"ro"` + + // READ-ONLY; The error target. + Target *string `json:"target,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. +func (e ErrorResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// FirewallRule - Represents a server firewall rule. +type FirewallRule struct { + ProxyResource + // REQUIRED; The properties of a firewall rule. + Properties *FirewallRuleProperties `json:"properties,omitempty"` + + // READ-ONLY; The system metadata relating to this resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type FirewallRule. +func (f FirewallRule) MarshalJSON() ([]byte, error) { + objectMap := f.ProxyResource.marshalInternal() + populate(objectMap, "properties", f.Properties) + populate(objectMap, "systemData", f.SystemData) + return json.Marshal(objectMap) +} + +// FirewallRuleListResult - A list of firewall rules. +type FirewallRuleListResult struct { + // The link used to get the next page of operations. + NextLink *string `json:"nextLink,omitempty"` + + // The list of firewall rules in a server. + Value []*FirewallRule `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type FirewallRuleListResult. +func (f FirewallRuleListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", f.NextLink) + populate(objectMap, "value", f.Value) + return json.Marshal(objectMap) +} + +// FirewallRuleProperties - The properties of a server firewall rule. +type FirewallRuleProperties struct { + // REQUIRED; The end IP address of the server firewall rule. Must be IPv4 format. + EndIPAddress *string `json:"endIpAddress,omitempty"` + + // REQUIRED; The start IP address of the server firewall rule. Must be IPv4 format. + StartIPAddress *string `json:"startIpAddress,omitempty"` +} + +// FirewallRulesBeginCreateOrUpdateOptions contains the optional parameters for the FirewallRules.BeginCreateOrUpdate method. +type FirewallRulesBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// FirewallRulesBeginDeleteOptions contains the optional parameters for the FirewallRules.BeginDelete method. +type FirewallRulesBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// FirewallRulesGetOptions contains the optional parameters for the FirewallRules.Get method. +type FirewallRulesGetOptions struct { + // placeholder for future optional parameters +} + +// FirewallRulesListByServerOptions contains the optional parameters for the FirewallRules.ListByServer method. +type FirewallRulesListByServerOptions struct { + // placeholder for future optional parameters +} + +// FlexibleServerEditionCapability - Flexible server edition capabilities. +type FlexibleServerEditionCapability struct { + // READ-ONLY; Server edition name + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The status + Status *string `json:"status,omitempty" azure:"ro"` + + // READ-ONLY; The list of server versions supported by this server edition. + SupportedServerVersions []*ServerVersionCapability `json:"supportedServerVersions,omitempty" azure:"ro"` + + // READ-ONLY; The list of editions supported by this server edition. + SupportedStorageEditions []*StorageEditionCapability `json:"supportedStorageEditions,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type FlexibleServerEditionCapability. +func (f FlexibleServerEditionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", f.Name) + populate(objectMap, "status", f.Status) + populate(objectMap, "supportedServerVersions", f.SupportedServerVersions) + populate(objectMap, "supportedStorageEditions", f.SupportedStorageEditions) + return json.Marshal(objectMap) +} + +// GetPrivateDNSZoneSuffixExecuteOptions contains the optional parameters for the GetPrivateDNSZoneSuffix.Execute method. +type GetPrivateDNSZoneSuffixExecuteOptions struct { + // placeholder for future optional parameters +} + +// HighAvailability - High availability properties of a server +type HighAvailability struct { + // The HA mode for the server. + Mode *HighAvailabilityMode `json:"mode,omitempty"` + + // availability zone information of the standby. + StandbyAvailabilityZone *string `json:"standbyAvailabilityZone,omitempty"` + + // READ-ONLY; A state of a HA server that is visible to user. + State *ServerHAState `json:"state,omitempty" azure:"ro"` +} + +// HyperscaleNodeEditionCapability - Hyperscale node edition capabilities. +type HyperscaleNodeEditionCapability struct { + // READ-ONLY; Server edition name + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The status + Status *string `json:"status,omitempty" azure:"ro"` + + // READ-ONLY; The list of Node Types supported by this server edition. + SupportedNodeTypes []*NodeTypeCapability `json:"supportedNodeTypes,omitempty" azure:"ro"` + + // READ-ONLY; The list of server versions supported by this server edition. + SupportedServerVersions []*ServerVersionCapability `json:"supportedServerVersions,omitempty" azure:"ro"` + + // READ-ONLY; The list of editions supported by this server edition. + SupportedStorageEditions []*StorageEditionCapability `json:"supportedStorageEditions,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type HyperscaleNodeEditionCapability. +func (h HyperscaleNodeEditionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", h.Name) + populate(objectMap, "status", h.Status) + populate(objectMap, "supportedNodeTypes", h.SupportedNodeTypes) + populate(objectMap, "supportedServerVersions", h.SupportedServerVersions) + populate(objectMap, "supportedStorageEditions", h.SupportedStorageEditions) + return json.Marshal(objectMap) +} + +// LocationBasedCapabilitiesExecuteOptions contains the optional parameters for the LocationBasedCapabilities.Execute method. +type LocationBasedCapabilitiesExecuteOptions struct { + // placeholder for future optional parameters +} + +// MaintenanceWindow - Maintenance window properties of a server. +type MaintenanceWindow struct { + // indicates whether custom window is enabled or disabled + CustomWindow *string `json:"customWindow,omitempty"` + + // day of week for maintenance window + DayOfWeek *int32 `json:"dayOfWeek,omitempty"` + + // start hour for maintenance window + StartHour *int32 `json:"startHour,omitempty"` + + // start minute for maintenance window + StartMinute *int32 `json:"startMinute,omitempty"` +} + +// NameAvailability - Represents a resource name availability. +type NameAvailability struct { + // Error Message. + Message *string `json:"message,omitempty"` + + // name of the PostgreSQL server. + Name *string `json:"name,omitempty"` + + // Indicates whether the resource name is available. + NameAvailable *bool `json:"nameAvailable,omitempty"` + + // type of the server + Type *string `json:"type,omitempty"` +} + +// NameAvailabilityRequest - Request from client to check resource name availability. +type NameAvailabilityRequest struct { + // REQUIRED; Resource name to verify. + Name *string `json:"name,omitempty"` + + // Resource type used for verification. + Type *string `json:"type,omitempty"` +} + +// Network properties of a server +type Network struct { + // delegated subnet arm resource id. + DelegatedSubnetResourceID *string `json:"delegatedSubnetResourceId,omitempty"` + + // private dns zone arm resource id. + PrivateDNSZoneArmResourceID *string `json:"privateDnsZoneArmResourceId,omitempty"` + + // READ-ONLY; public network access is enabled or not + PublicNetworkAccess *ServerPublicNetworkAccessState `json:"publicNetworkAccess,omitempty" azure:"ro"` +} + +// NodeTypeCapability - node type capability +type NodeTypeCapability struct { + // READ-ONLY; note type name + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; note type + NodeType *string `json:"nodeType,omitempty" azure:"ro"` + + // READ-ONLY; The status + Status *string `json:"status,omitempty" azure:"ro"` +} + +// Operation - REST API operation definition. +type Operation struct { + // Indicates whether the operation is a data action + IsDataAction *bool `json:"isDataAction,omitempty"` + + // READ-ONLY; The localized display information for this particular operation or action. + Display *OperationDisplay `json:"display,omitempty" azure:"ro"` + + // READ-ONLY; The name of the operation being performed on this particular object. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The intended executor of the operation. + Origin *OperationOrigin `json:"origin,omitempty" azure:"ro"` + + // READ-ONLY; Additional descriptions for the operation. + Properties map[string]map[string]interface{} `json:"properties,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + populate(objectMap, "properties", o.Properties) + return json.Marshal(objectMap) +} + +// OperationDisplay - Display metadata associated with the operation. +type OperationDisplay struct { + // READ-ONLY; Operation description. + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; Localized friendly name for the operation. + Operation *string `json:"operation,omitempty" azure:"ro"` + + // READ-ONLY; Operation resource provider name. + Provider *string `json:"provider,omitempty" azure:"ro"` + + // READ-ONLY; Resource on which the operation is performed. + Resource *string `json:"resource,omitempty" azure:"ro"` +} + +// OperationListResult - A list of resource provider operations. +type OperationListResult struct { + // URL client should use to fetch the next page (per server side paging). It's null for now, added for future use. + NextLink *string `json:"nextLink,omitempty"` + + // Collection of available operation details + Value []*Operation `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// OperationsListOptions contains the optional parameters for the Operations.List method. +type OperationsListOptions struct { + // placeholder for future optional parameters +} + +// ProxyResource - The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location +type ProxyResource struct { + Resource +} + +func (p ProxyResource) marshalInternal() map[string]interface{} { + objectMap := p.Resource.marshalInternal() + return objectMap +} + +// Resource - Common fields that are returned in the response for all Azure Resource Manager resources +type Resource struct { + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := r.marshalInternal() + return json.Marshal(objectMap) +} + +func (r Resource) marshalInternal() map[string]interface{} { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "type", r.Type) + return objectMap +} + +// RestartParameter - Represents server restart parameters. +type RestartParameter struct { + // Failover mode. + FailoverMode *string `json:"failoverMode,omitempty"` + + // Indicates whether to restart the server with failover. + RestartWithFailover *bool `json:"restartWithFailover,omitempty"` +} + +// SKU - Sku information related properties of a server. +type SKU struct { + // REQUIRED; The name of the sku, typically, tier + family + cores, e.g. StandardD4sv3. + Name *string `json:"name,omitempty"` + + // REQUIRED; The tier of the particular SKU, e.g. Burstable. + Tier *SKUTier `json:"tier,omitempty"` +} + +// Server - Represents a server. +type Server struct { + TrackedResource + // Properties of the server. + Properties *ServerProperties `json:"properties,omitempty"` + + // The SKU (pricing tier) of the server. + SKU *SKU `json:"sku,omitempty"` + + // READ-ONLY; The system metadata relating to this resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Server. +func (s Server) MarshalJSON() ([]byte, error) { + objectMap := s.TrackedResource.marshalInternal() + populate(objectMap, "properties", s.Properties) + populate(objectMap, "sku", s.SKU) + populate(objectMap, "systemData", s.SystemData) + return json.Marshal(objectMap) +} + +// ServerForUpdate - Represents a server to be updated. +type ServerForUpdate struct { + // The location the resource resides in. + Location *string `json:"location,omitempty"` + + // Properties of the server. + Properties *ServerPropertiesForUpdate `json:"properties,omitempty"` + + // The SKU (pricing tier) of the server. + SKU *SKU `json:"sku,omitempty"` + + // Application-specific metadata in the form of key-value pairs. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ServerForUpdate. +func (s ServerForUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "location", s.Location) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "sku", s.SKU) + populate(objectMap, "tags", s.Tags) + return json.Marshal(objectMap) +} + +// ServerListResult - A list of servers. +type ServerListResult struct { + // The link used to get the next page of operations. + NextLink *string `json:"nextLink,omitempty"` + + // The list of flexible servers + Value []*Server `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ServerListResult. +func (s ServerListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// ServerProperties - The properties of a server. +type ServerProperties struct { + // The administrator's login name of a server. Can only be specified when the server is being created (and is required for creation). + AdministratorLogin *string `json:"administratorLogin,omitempty"` + + // The administrator login password (required for server creation). + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + + // availability zone information of the server. + AvailabilityZone *string `json:"availabilityZone,omitempty"` + + // Backup properties of a server. + Backup *Backup `json:"backup,omitempty"` + + // The mode to create a new PostgreSQL server. + CreateMode *CreateMode `json:"createMode,omitempty"` + + // High availability properties of a server. + HighAvailability *HighAvailability `json:"highAvailability,omitempty"` + + // Maintenance window properties of a server. + MaintenanceWindow *MaintenanceWindow `json:"maintenanceWindow,omitempty"` + + // Network properties of a server. + Network *Network `json:"network,omitempty"` + + // Restore point creation time (ISO8601 format), specifying the time to restore from. It's required when 'createMode' is 'PointInTimeRestore'. + PointInTimeUTC *time.Time `json:"pointInTimeUTC,omitempty"` + + // The source server resource ID to restore from. It's required when 'createMode' is 'PointInTimeRestore'. + SourceServerResourceID *string `json:"sourceServerResourceId,omitempty"` + + // Storage properties of a server. + Storage *Storage `json:"storage,omitempty"` + + // Application-specific metadata in the form of key-value pairs. + Tags map[string]*string `json:"tags,omitempty"` + + // PostgreSQL Server version. + Version *ServerVersion `json:"version,omitempty"` + + // READ-ONLY; The fully qualified domain name of a server. + FullyQualifiedDomainName *string `json:"fullyQualifiedDomainName,omitempty" azure:"ro"` + + // READ-ONLY; The minor version of the server. + MinorVersion *string `json:"minorVersion,omitempty" azure:"ro"` + + // READ-ONLY; A state of a server that is visible to user. + State *ServerState `json:"state,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ServerProperties. +func (s ServerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "administratorLogin", s.AdministratorLogin) + populate(objectMap, "administratorLoginPassword", s.AdministratorLoginPassword) + populate(objectMap, "availabilityZone", s.AvailabilityZone) + populate(objectMap, "backup", s.Backup) + populate(objectMap, "createMode", s.CreateMode) + populate(objectMap, "fullyQualifiedDomainName", s.FullyQualifiedDomainName) + populate(objectMap, "highAvailability", s.HighAvailability) + populate(objectMap, "maintenanceWindow", s.MaintenanceWindow) + populate(objectMap, "minorVersion", s.MinorVersion) + populate(objectMap, "network", s.Network) + populate(objectMap, "pointInTimeUTC", (*timeRFC3339)(s.PointInTimeUTC)) + populate(objectMap, "sourceServerResourceId", s.SourceServerResourceID) + populate(objectMap, "state", s.State) + populate(objectMap, "storage", s.Storage) + populate(objectMap, "tags", s.Tags) + populate(objectMap, "version", s.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerProperties. +func (s *ServerProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "administratorLogin": + err = unpopulate(val, &s.AdministratorLogin) + delete(rawMsg, key) + case "administratorLoginPassword": + err = unpopulate(val, &s.AdministratorLoginPassword) + delete(rawMsg, key) + case "availabilityZone": + err = unpopulate(val, &s.AvailabilityZone) + delete(rawMsg, key) + case "backup": + err = unpopulate(val, &s.Backup) + delete(rawMsg, key) + case "createMode": + err = unpopulate(val, &s.CreateMode) + delete(rawMsg, key) + case "fullyQualifiedDomainName": + err = unpopulate(val, &s.FullyQualifiedDomainName) + delete(rawMsg, key) + case "highAvailability": + err = unpopulate(val, &s.HighAvailability) + delete(rawMsg, key) + case "maintenanceWindow": + err = unpopulate(val, &s.MaintenanceWindow) + delete(rawMsg, key) + case "minorVersion": + err = unpopulate(val, &s.MinorVersion) + delete(rawMsg, key) + case "network": + err = unpopulate(val, &s.Network) + delete(rawMsg, key) + case "pointInTimeUTC": + var aux timeRFC3339 + err = unpopulate(val, &aux) + s.PointInTimeUTC = (*time.Time)(&aux) + delete(rawMsg, key) + case "sourceServerResourceId": + err = unpopulate(val, &s.SourceServerResourceID) + delete(rawMsg, key) + case "state": + err = unpopulate(val, &s.State) + delete(rawMsg, key) + case "storage": + err = unpopulate(val, &s.Storage) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, &s.Tags) + delete(rawMsg, key) + case "version": + err = unpopulate(val, &s.Version) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +type ServerPropertiesForUpdate struct { + // The password of the administrator login. + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + + // Backup properties of a server. + Backup *Backup `json:"backup,omitempty"` + + // The mode to update a new PostgreSQL server. + CreateMode *CreateModeForUpdate `json:"createMode,omitempty"` + + // High availability properties of a server. + HighAvailability *HighAvailability `json:"highAvailability,omitempty"` + + // Maintenance window properties of a server. + MaintenanceWindow *MaintenanceWindow `json:"maintenanceWindow,omitempty"` + + // Storage properties of a server. + Storage *Storage `json:"storage,omitempty"` +} + +// ServerVersionCapability - Server version capabilities. +type ServerVersionCapability struct { + // READ-ONLY; server version + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The status + Status *string `json:"status,omitempty" azure:"ro"` + + // READ-ONLY + SupportedVcores []*VcoreCapability `json:"supportedVcores,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ServerVersionCapability. +func (s ServerVersionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", s.Name) + populate(objectMap, "status", s.Status) + populate(objectMap, "supportedVcores", s.SupportedVcores) + return json.Marshal(objectMap) +} + +// ServersBeginCreateOptions contains the optional parameters for the Servers.BeginCreate method. +type ServersBeginCreateOptions struct { + // placeholder for future optional parameters +} + +// ServersBeginDeleteOptions contains the optional parameters for the Servers.BeginDelete method. +type ServersBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// ServersBeginRestartOptions contains the optional parameters for the Servers.BeginRestart method. +type ServersBeginRestartOptions struct { + // The parameters for restarting a server. + Parameters *RestartParameter +} + +// ServersBeginStartOptions contains the optional parameters for the Servers.BeginStart method. +type ServersBeginStartOptions struct { + // placeholder for future optional parameters +} + +// ServersBeginStopOptions contains the optional parameters for the Servers.BeginStop method. +type ServersBeginStopOptions struct { + // placeholder for future optional parameters +} + +// ServersBeginUpdateOptions contains the optional parameters for the Servers.BeginUpdate method. +type ServersBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// ServersGetOptions contains the optional parameters for the Servers.Get method. +type ServersGetOptions struct { + // placeholder for future optional parameters +} + +// ServersListByResourceGroupOptions contains the optional parameters for the Servers.ListByResourceGroup method. +type ServersListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// ServersListOptions contains the optional parameters for the Servers.List method. +type ServersListOptions struct { + // placeholder for future optional parameters +} + +// Storage properties of a server +type Storage struct { + // Max storage allowed for a server. + StorageSizeGB *int32 `json:"storageSizeGB,omitempty"` +} + +// StorageEditionCapability - storage edition capability +type StorageEditionCapability struct { + // READ-ONLY; storage edition name + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The status + Status *string `json:"status,omitempty" azure:"ro"` + + // READ-ONLY + SupportedStorageMB []*StorageMBCapability `json:"supportedStorageMB,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type StorageEditionCapability. +func (s StorageEditionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", s.Name) + populate(objectMap, "status", s.Status) + populate(objectMap, "supportedStorageMB", s.SupportedStorageMB) + return json.Marshal(objectMap) +} + +// StorageMBCapability - storage size in MB capability +type StorageMBCapability struct { + // READ-ONLY; storage MB name + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The status + Status *string `json:"status,omitempty" azure:"ro"` + + // READ-ONLY; storage size in MB + StorageSizeMB *int64 `json:"storageSizeMB,omitempty" azure:"ro"` + + // READ-ONLY; supported IOPS + SupportedIops *int64 `json:"supportedIops,omitempty" azure:"ro"` +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time `json:"createdAt,omitempty"` + + // The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + + // The type of identity that created the resource. + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + + // The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "createdAt", (*timeRFC3339)(s.CreatedAt)) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populate(objectMap, "lastModifiedAt", (*timeRFC3339)(s.LastModifiedAt)) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + var aux timeRFC3339 + err = unpopulate(val, &aux) + s.CreatedAt = (*time.Time)(&aux) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + var aux timeRFC3339 + err = unpopulate(val, &aux) + s.LastModifiedAt = (*time.Time)(&aux) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location' +type TrackedResource struct { + Resource + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TrackedResource. +func (t TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := t.marshalInternal() + return json.Marshal(objectMap) +} + +func (t TrackedResource) marshalInternal() map[string]interface{} { + objectMap := t.Resource.marshalInternal() + populate(objectMap, "location", t.Location) + populate(objectMap, "tags", t.Tags) + return objectMap +} + +// VcoreCapability - Vcores capability +type VcoreCapability struct { + // READ-ONLY; vCore name + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The status + Status *string `json:"status,omitempty" azure:"ro"` + + // READ-ONLY; supported IOPS + SupportedIops *int64 `json:"supportedIops,omitempty" azure:"ro"` + + // READ-ONLY; supported memory per vCore in MB + SupportedMemoryPerVcoreMB *int64 `json:"supportedMemoryPerVcoreMB,omitempty" azure:"ro"` + + // READ-ONLY; supported vCores + VCores *int64 `json:"vCores,omitempty" azure:"ro"` +} + +// VirtualNetworkSubnetUsageExecuteOptions contains the optional parameters for the VirtualNetworkSubnetUsage.Execute method. +type VirtualNetworkSubnetUsageExecuteOptions struct { + // placeholder for future optional parameters +} + +// VirtualNetworkSubnetUsageParameter - Virtual network subnet usage parameter +type VirtualNetworkSubnetUsageParameter struct { + // Virtual network resource id. + VirtualNetworkArmResourceID *string `json:"virtualNetworkArmResourceId,omitempty"` +} + +// VirtualNetworkSubnetUsageResult - Virtual network subnet usage data. +type VirtualNetworkSubnetUsageResult struct { + // READ-ONLY + DelegatedSubnetsUsage []*DelegatedSubnetUsage `json:"delegatedSubnetsUsage,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualNetworkSubnetUsageResult. +func (v VirtualNetworkSubnetUsageResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "delegatedSubnetsUsage", v.DelegatedSubnetsUsage) + return json.Marshal(objectMap) +} + +func populate(m map[string]interface{}, k string, v interface{}) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, v interface{}) error { + if data == nil { + return nil + } + return json.Unmarshal(data, v) +} diff --git a/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_operations_client.go b/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_operations_client.go new file mode 100644 index 000000000000..83ddcfef3a5a --- /dev/null +++ b/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_operations_client.go @@ -0,0 +1,81 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armpostgresqlflexibleservers + +import ( + "context" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + con *armcore.Connection +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +func NewOperationsClient(con *armcore.Connection) *OperationsClient { + return &OperationsClient{con: con} +} + +// List - Lists all of the available REST API operations. +// If the operation fails it returns the *CloudError error type. +func (client *OperationsClient) List(ctx context.Context, options *OperationsListOptions) (OperationsListResponse, error) { + req, err := client.listCreateRequest(ctx, options) + if err != nil { + return OperationsListResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return OperationsListResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return OperationsListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsListOptions) (*azcore.Request, error) { + urlPath := "/providers/Microsoft.DBforPostgreSQL/operations" + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *azcore.Response) (OperationsListResponse, error) { + result := OperationsListResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.OperationListResult); err != nil { + return OperationsListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *OperationsClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudError{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_pagers.go b/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_pagers.go new file mode 100644 index 000000000000..49f2cf13273e --- /dev/null +++ b/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_pagers.go @@ -0,0 +1,345 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armpostgresqlflexibleservers + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "reflect" +) + +type ConfigurationsListByServerPager interface { + azcore.Pager + // PageResponse returns the current ConfigurationsListByServerResponse. + PageResponse() ConfigurationsListByServerResponse +} + +type configurationsListByServerPager struct { + client *ConfigurationsClient + current ConfigurationsListByServerResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, ConfigurationsListByServerResponse) (*azcore.Request, error) +} + +func (p *configurationsListByServerPager) Err() error { + return p.err +} + +func (p *configurationsListByServerPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ConfigurationListResult.NextLink == nil || len(*p.current.ConfigurationListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServerHandleError(resp) + return false + } + result, err := p.client.listByServerHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *configurationsListByServerPager) PageResponse() ConfigurationsListByServerResponse { + return p.current +} + +type DatabasesListByServerPager interface { + azcore.Pager + // PageResponse returns the current DatabasesListByServerResponse. + PageResponse() DatabasesListByServerResponse +} + +type databasesListByServerPager struct { + client *DatabasesClient + current DatabasesListByServerResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, DatabasesListByServerResponse) (*azcore.Request, error) +} + +func (p *databasesListByServerPager) Err() error { + return p.err +} + +func (p *databasesListByServerPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.DatabaseListResult.NextLink == nil || len(*p.current.DatabaseListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServerHandleError(resp) + return false + } + result, err := p.client.listByServerHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *databasesListByServerPager) PageResponse() DatabasesListByServerResponse { + return p.current +} + +type FirewallRulesListByServerPager interface { + azcore.Pager + // PageResponse returns the current FirewallRulesListByServerResponse. + PageResponse() FirewallRulesListByServerResponse +} + +type firewallRulesListByServerPager struct { + client *FirewallRulesClient + current FirewallRulesListByServerResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, FirewallRulesListByServerResponse) (*azcore.Request, error) +} + +func (p *firewallRulesListByServerPager) Err() error { + return p.err +} + +func (p *firewallRulesListByServerPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.FirewallRuleListResult.NextLink == nil || len(*p.current.FirewallRuleListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServerHandleError(resp) + return false + } + result, err := p.client.listByServerHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *firewallRulesListByServerPager) PageResponse() FirewallRulesListByServerResponse { + return p.current +} + +type LocationBasedCapabilitiesExecutePager interface { + azcore.Pager + // PageResponse returns the current LocationBasedCapabilitiesExecuteResponse. + PageResponse() LocationBasedCapabilitiesExecuteResponse +} + +type locationBasedCapabilitiesExecutePager struct { + client *LocationBasedCapabilitiesClient + current LocationBasedCapabilitiesExecuteResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, LocationBasedCapabilitiesExecuteResponse) (*azcore.Request, error) +} + +func (p *locationBasedCapabilitiesExecutePager) Err() error { + return p.err +} + +func (p *locationBasedCapabilitiesExecutePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.CapabilitiesListResult.NextLink == nil || len(*p.current.CapabilitiesListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.executeHandleError(resp) + return false + } + result, err := p.client.executeHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *locationBasedCapabilitiesExecutePager) PageResponse() LocationBasedCapabilitiesExecuteResponse { + return p.current +} + +type ServersListByResourceGroupPager interface { + azcore.Pager + // PageResponse returns the current ServersListByResourceGroupResponse. + PageResponse() ServersListByResourceGroupResponse +} + +type serversListByResourceGroupPager struct { + client *ServersClient + current ServersListByResourceGroupResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, ServersListByResourceGroupResponse) (*azcore.Request, error) +} + +func (p *serversListByResourceGroupPager) Err() error { + return p.err +} + +func (p *serversListByResourceGroupPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ServerListResult.NextLink == nil || len(*p.current.ServerListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByResourceGroupHandleError(resp) + return false + } + result, err := p.client.listByResourceGroupHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *serversListByResourceGroupPager) PageResponse() ServersListByResourceGroupResponse { + return p.current +} + +type ServersListPager interface { + azcore.Pager + // PageResponse returns the current ServersListResponse. + PageResponse() ServersListResponse +} + +type serversListPager struct { + client *ServersClient + current ServersListResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, ServersListResponse) (*azcore.Request, error) +} + +func (p *serversListPager) Err() error { + return p.err +} + +func (p *serversListPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ServerListResult.NextLink == nil || len(*p.current.ServerListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *serversListPager) PageResponse() ServersListResponse { + return p.current +} diff --git a/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_pollers.go b/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_pollers.go new file mode 100644 index 000000000000..d1e41d5588cc --- /dev/null +++ b/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_pollers.go @@ -0,0 +1,556 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armpostgresqlflexibleservers + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "time" +) + +// ConfigurationsPutPoller provides polling facilities until the operation reaches a terminal state. +type ConfigurationsPutPoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final ConfigurationsPutResponse will be returned. + FinalResponse(ctx context.Context) (ConfigurationsPutResponse, error) +} + +type configurationsPutPoller struct { + pt *armcore.LROPoller +} + +func (p *configurationsPutPoller) Done() bool { + return p.pt.Done() +} + +func (p *configurationsPutPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *configurationsPutPoller) FinalResponse(ctx context.Context) (ConfigurationsPutResponse, error) { + respType := ConfigurationsPutResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.Configuration) + if err != nil { + return ConfigurationsPutResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *configurationsPutPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *configurationsPutPoller) pollUntilDone(ctx context.Context, freq time.Duration) (ConfigurationsPutResponse, error) { + respType := ConfigurationsPutResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, &respType.Configuration) + if err != nil { + return ConfigurationsPutResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ConfigurationsUpdatePoller provides polling facilities until the operation reaches a terminal state. +type ConfigurationsUpdatePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final ConfigurationsUpdateResponse will be returned. + FinalResponse(ctx context.Context) (ConfigurationsUpdateResponse, error) +} + +type configurationsUpdatePoller struct { + pt *armcore.LROPoller +} + +func (p *configurationsUpdatePoller) Done() bool { + return p.pt.Done() +} + +func (p *configurationsUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *configurationsUpdatePoller) FinalResponse(ctx context.Context) (ConfigurationsUpdateResponse, error) { + respType := ConfigurationsUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.Configuration) + if err != nil { + return ConfigurationsUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *configurationsUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *configurationsUpdatePoller) pollUntilDone(ctx context.Context, freq time.Duration) (ConfigurationsUpdateResponse, error) { + respType := ConfigurationsUpdateResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, &respType.Configuration) + if err != nil { + return ConfigurationsUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// DatabasesCreatePoller provides polling facilities until the operation reaches a terminal state. +type DatabasesCreatePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final DatabasesCreateResponse will be returned. + FinalResponse(ctx context.Context) (DatabasesCreateResponse, error) +} + +type databasesCreatePoller struct { + pt *armcore.LROPoller +} + +func (p *databasesCreatePoller) Done() bool { + return p.pt.Done() +} + +func (p *databasesCreatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *databasesCreatePoller) FinalResponse(ctx context.Context) (DatabasesCreateResponse, error) { + respType := DatabasesCreateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.Database) + if err != nil { + return DatabasesCreateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *databasesCreatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *databasesCreatePoller) pollUntilDone(ctx context.Context, freq time.Duration) (DatabasesCreateResponse, error) { + respType := DatabasesCreateResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, &respType.Database) + if err != nil { + return DatabasesCreateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// DatabasesDeletePoller provides polling facilities until the operation reaches a terminal state. +type DatabasesDeletePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final DatabasesDeleteResponse will be returned. + FinalResponse(ctx context.Context) (DatabasesDeleteResponse, error) +} + +type databasesDeletePoller struct { + pt *armcore.LROPoller +} + +func (p *databasesDeletePoller) Done() bool { + return p.pt.Done() +} + +func (p *databasesDeletePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *databasesDeletePoller) FinalResponse(ctx context.Context) (DatabasesDeleteResponse, error) { + respType := DatabasesDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return DatabasesDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *databasesDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *databasesDeletePoller) pollUntilDone(ctx context.Context, freq time.Duration) (DatabasesDeleteResponse, error) { + respType := DatabasesDeleteResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return DatabasesDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// FirewallRulesCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type FirewallRulesCreateOrUpdatePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final FirewallRulesCreateOrUpdateResponse will be returned. + FinalResponse(ctx context.Context) (FirewallRulesCreateOrUpdateResponse, error) +} + +type firewallRulesCreateOrUpdatePoller struct { + pt *armcore.LROPoller +} + +func (p *firewallRulesCreateOrUpdatePoller) Done() bool { + return p.pt.Done() +} + +func (p *firewallRulesCreateOrUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *firewallRulesCreateOrUpdatePoller) FinalResponse(ctx context.Context) (FirewallRulesCreateOrUpdateResponse, error) { + respType := FirewallRulesCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.FirewallRule) + if err != nil { + return FirewallRulesCreateOrUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *firewallRulesCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *firewallRulesCreateOrUpdatePoller) pollUntilDone(ctx context.Context, freq time.Duration) (FirewallRulesCreateOrUpdateResponse, error) { + respType := FirewallRulesCreateOrUpdateResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, &respType.FirewallRule) + if err != nil { + return FirewallRulesCreateOrUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// FirewallRulesDeletePoller provides polling facilities until the operation reaches a terminal state. +type FirewallRulesDeletePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final FirewallRulesDeleteResponse will be returned. + FinalResponse(ctx context.Context) (FirewallRulesDeleteResponse, error) +} + +type firewallRulesDeletePoller struct { + pt *armcore.LROPoller +} + +func (p *firewallRulesDeletePoller) Done() bool { + return p.pt.Done() +} + +func (p *firewallRulesDeletePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *firewallRulesDeletePoller) FinalResponse(ctx context.Context) (FirewallRulesDeleteResponse, error) { + respType := FirewallRulesDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return FirewallRulesDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *firewallRulesDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *firewallRulesDeletePoller) pollUntilDone(ctx context.Context, freq time.Duration) (FirewallRulesDeleteResponse, error) { + respType := FirewallRulesDeleteResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return FirewallRulesDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ServersCreatePoller provides polling facilities until the operation reaches a terminal state. +type ServersCreatePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final ServersCreateResponse will be returned. + FinalResponse(ctx context.Context) (ServersCreateResponse, error) +} + +type serversCreatePoller struct { + pt *armcore.LROPoller +} + +func (p *serversCreatePoller) Done() bool { + return p.pt.Done() +} + +func (p *serversCreatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *serversCreatePoller) FinalResponse(ctx context.Context) (ServersCreateResponse, error) { + respType := ServersCreateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.Server) + if err != nil { + return ServersCreateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *serversCreatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *serversCreatePoller) pollUntilDone(ctx context.Context, freq time.Duration) (ServersCreateResponse, error) { + respType := ServersCreateResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, &respType.Server) + if err != nil { + return ServersCreateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ServersDeletePoller provides polling facilities until the operation reaches a terminal state. +type ServersDeletePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final ServersDeleteResponse will be returned. + FinalResponse(ctx context.Context) (ServersDeleteResponse, error) +} + +type serversDeletePoller struct { + pt *armcore.LROPoller +} + +func (p *serversDeletePoller) Done() bool { + return p.pt.Done() +} + +func (p *serversDeletePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *serversDeletePoller) FinalResponse(ctx context.Context) (ServersDeleteResponse, error) { + respType := ServersDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return ServersDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *serversDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *serversDeletePoller) pollUntilDone(ctx context.Context, freq time.Duration) (ServersDeleteResponse, error) { + respType := ServersDeleteResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return ServersDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ServersRestartPoller provides polling facilities until the operation reaches a terminal state. +type ServersRestartPoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final ServersRestartResponse will be returned. + FinalResponse(ctx context.Context) (ServersRestartResponse, error) +} + +type serversRestartPoller struct { + pt *armcore.LROPoller +} + +func (p *serversRestartPoller) Done() bool { + return p.pt.Done() +} + +func (p *serversRestartPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *serversRestartPoller) FinalResponse(ctx context.Context) (ServersRestartResponse, error) { + respType := ServersRestartResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return ServersRestartResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *serversRestartPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *serversRestartPoller) pollUntilDone(ctx context.Context, freq time.Duration) (ServersRestartResponse, error) { + respType := ServersRestartResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return ServersRestartResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ServersStartPoller provides polling facilities until the operation reaches a terminal state. +type ServersStartPoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final ServersStartResponse will be returned. + FinalResponse(ctx context.Context) (ServersStartResponse, error) +} + +type serversStartPoller struct { + pt *armcore.LROPoller +} + +func (p *serversStartPoller) Done() bool { + return p.pt.Done() +} + +func (p *serversStartPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *serversStartPoller) FinalResponse(ctx context.Context) (ServersStartResponse, error) { + respType := ServersStartResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return ServersStartResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *serversStartPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *serversStartPoller) pollUntilDone(ctx context.Context, freq time.Duration) (ServersStartResponse, error) { + respType := ServersStartResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return ServersStartResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ServersStopPoller provides polling facilities until the operation reaches a terminal state. +type ServersStopPoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final ServersStopResponse will be returned. + FinalResponse(ctx context.Context) (ServersStopResponse, error) +} + +type serversStopPoller struct { + pt *armcore.LROPoller +} + +func (p *serversStopPoller) Done() bool { + return p.pt.Done() +} + +func (p *serversStopPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *serversStopPoller) FinalResponse(ctx context.Context) (ServersStopResponse, error) { + respType := ServersStopResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return ServersStopResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *serversStopPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *serversStopPoller) pollUntilDone(ctx context.Context, freq time.Duration) (ServersStopResponse, error) { + respType := ServersStopResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return ServersStopResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ServersUpdatePoller provides polling facilities until the operation reaches a terminal state. +type ServersUpdatePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final ServersUpdateResponse will be returned. + FinalResponse(ctx context.Context) (ServersUpdateResponse, error) +} + +type serversUpdatePoller struct { + pt *armcore.LROPoller +} + +func (p *serversUpdatePoller) Done() bool { + return p.pt.Done() +} + +func (p *serversUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *serversUpdatePoller) FinalResponse(ctx context.Context) (ServersUpdateResponse, error) { + respType := ServersUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.Server) + if err != nil { + return ServersUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *serversUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *serversUpdatePoller) pollUntilDone(ctx context.Context, freq time.Duration) (ServersUpdateResponse, error) { + respType := ServersUpdateResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, &respType.Server) + if err != nil { + return ServersUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} diff --git a/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_response_types.go b/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_response_types.go new file mode 100644 index 000000000000..28472a03fd67 --- /dev/null +++ b/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_response_types.go @@ -0,0 +1,435 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armpostgresqlflexibleservers + +import ( + "context" + "net/http" + "time" +) + +// CheckNameAvailabilityExecuteResponse contains the response from method CheckNameAvailability.Execute. +type CheckNameAvailabilityExecuteResponse struct { + CheckNameAvailabilityExecuteResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CheckNameAvailabilityExecuteResult contains the result from method CheckNameAvailability.Execute. +type CheckNameAvailabilityExecuteResult struct { + NameAvailability +} + +// ConfigurationsGetResponse contains the response from method Configurations.Get. +type ConfigurationsGetResponse struct { + ConfigurationsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ConfigurationsGetResult contains the result from method Configurations.Get. +type ConfigurationsGetResult struct { + Configuration +} + +// ConfigurationsListByServerResponse contains the response from method Configurations.ListByServer. +type ConfigurationsListByServerResponse struct { + ConfigurationsListByServerResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ConfigurationsListByServerResult contains the result from method Configurations.ListByServer. +type ConfigurationsListByServerResult struct { + ConfigurationListResult +} + +// ConfigurationsPutPollerResponse contains the response from method Configurations.Put. +type ConfigurationsPutPollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (ConfigurationsPutResponse, error) + + // Poller contains an initialized poller. + Poller ConfigurationsPutPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ConfigurationsPutResponse contains the response from method Configurations.Put. +type ConfigurationsPutResponse struct { + ConfigurationsPutResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ConfigurationsPutResult contains the result from method Configurations.Put. +type ConfigurationsPutResult struct { + Configuration +} + +// ConfigurationsUpdatePollerResponse contains the response from method Configurations.Update. +type ConfigurationsUpdatePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (ConfigurationsUpdateResponse, error) + + // Poller contains an initialized poller. + Poller ConfigurationsUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ConfigurationsUpdateResponse contains the response from method Configurations.Update. +type ConfigurationsUpdateResponse struct { + ConfigurationsUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ConfigurationsUpdateResult contains the result from method Configurations.Update. +type ConfigurationsUpdateResult struct { + Configuration +} + +// DatabasesCreatePollerResponse contains the response from method Databases.Create. +type DatabasesCreatePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (DatabasesCreateResponse, error) + + // Poller contains an initialized poller. + Poller DatabasesCreatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DatabasesCreateResponse contains the response from method Databases.Create. +type DatabasesCreateResponse struct { + DatabasesCreateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DatabasesCreateResult contains the result from method Databases.Create. +type DatabasesCreateResult struct { + Database +} + +// DatabasesDeletePollerResponse contains the response from method Databases.Delete. +type DatabasesDeletePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (DatabasesDeleteResponse, error) + + // Poller contains an initialized poller. + Poller DatabasesDeletePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DatabasesDeleteResponse contains the response from method Databases.Delete. +type DatabasesDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DatabasesGetResponse contains the response from method Databases.Get. +type DatabasesGetResponse struct { + DatabasesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DatabasesGetResult contains the result from method Databases.Get. +type DatabasesGetResult struct { + Database +} + +// DatabasesListByServerResponse contains the response from method Databases.ListByServer. +type DatabasesListByServerResponse struct { + DatabasesListByServerResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DatabasesListByServerResult contains the result from method Databases.ListByServer. +type DatabasesListByServerResult struct { + DatabaseListResult +} + +// FirewallRulesCreateOrUpdatePollerResponse contains the response from method FirewallRules.CreateOrUpdate. +type FirewallRulesCreateOrUpdatePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (FirewallRulesCreateOrUpdateResponse, error) + + // Poller contains an initialized poller. + Poller FirewallRulesCreateOrUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// FirewallRulesCreateOrUpdateResponse contains the response from method FirewallRules.CreateOrUpdate. +type FirewallRulesCreateOrUpdateResponse struct { + FirewallRulesCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// FirewallRulesCreateOrUpdateResult contains the result from method FirewallRules.CreateOrUpdate. +type FirewallRulesCreateOrUpdateResult struct { + FirewallRule +} + +// FirewallRulesDeletePollerResponse contains the response from method FirewallRules.Delete. +type FirewallRulesDeletePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (FirewallRulesDeleteResponse, error) + + // Poller contains an initialized poller. + Poller FirewallRulesDeletePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// FirewallRulesDeleteResponse contains the response from method FirewallRules.Delete. +type FirewallRulesDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// FirewallRulesGetResponse contains the response from method FirewallRules.Get. +type FirewallRulesGetResponse struct { + FirewallRulesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// FirewallRulesGetResult contains the result from method FirewallRules.Get. +type FirewallRulesGetResult struct { + FirewallRule +} + +// FirewallRulesListByServerResponse contains the response from method FirewallRules.ListByServer. +type FirewallRulesListByServerResponse struct { + FirewallRulesListByServerResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// FirewallRulesListByServerResult contains the result from method FirewallRules.ListByServer. +type FirewallRulesListByServerResult struct { + FirewallRuleListResult +} + +// GetPrivateDNSZoneSuffixExecuteResponse contains the response from method GetPrivateDNSZoneSuffix.Execute. +type GetPrivateDNSZoneSuffixExecuteResponse struct { + GetPrivateDNSZoneSuffixExecuteResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GetPrivateDNSZoneSuffixExecuteResult contains the result from method GetPrivateDNSZoneSuffix.Execute. +type GetPrivateDNSZoneSuffixExecuteResult struct { + // Represents a resource name availability. + Value *string +} + +// LocationBasedCapabilitiesExecuteResponse contains the response from method LocationBasedCapabilities.Execute. +type LocationBasedCapabilitiesExecuteResponse struct { + LocationBasedCapabilitiesExecuteResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LocationBasedCapabilitiesExecuteResult contains the result from method LocationBasedCapabilities.Execute. +type LocationBasedCapabilitiesExecuteResult struct { + CapabilitiesListResult +} + +// OperationsListResponse contains the response from method Operations.List. +type OperationsListResponse struct { + OperationsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationsListResult contains the result from method Operations.List. +type OperationsListResult struct { + OperationListResult +} + +// ServersCreatePollerResponse contains the response from method Servers.Create. +type ServersCreatePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (ServersCreateResponse, error) + + // Poller contains an initialized poller. + Poller ServersCreatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ServersCreateResponse contains the response from method Servers.Create. +type ServersCreateResponse struct { + ServersCreateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ServersCreateResult contains the result from method Servers.Create. +type ServersCreateResult struct { + Server +} + +// ServersDeletePollerResponse contains the response from method Servers.Delete. +type ServersDeletePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (ServersDeleteResponse, error) + + // Poller contains an initialized poller. + Poller ServersDeletePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ServersDeleteResponse contains the response from method Servers.Delete. +type ServersDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ServersGetResponse contains the response from method Servers.Get. +type ServersGetResponse struct { + ServersGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ServersGetResult contains the result from method Servers.Get. +type ServersGetResult struct { + Server +} + +// ServersListByResourceGroupResponse contains the response from method Servers.ListByResourceGroup. +type ServersListByResourceGroupResponse struct { + ServersListByResourceGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ServersListByResourceGroupResult contains the result from method Servers.ListByResourceGroup. +type ServersListByResourceGroupResult struct { + ServerListResult +} + +// ServersListResponse contains the response from method Servers.List. +type ServersListResponse struct { + ServersListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ServersListResult contains the result from method Servers.List. +type ServersListResult struct { + ServerListResult +} + +// ServersRestartPollerResponse contains the response from method Servers.Restart. +type ServersRestartPollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (ServersRestartResponse, error) + + // Poller contains an initialized poller. + Poller ServersRestartPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ServersRestartResponse contains the response from method Servers.Restart. +type ServersRestartResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ServersStartPollerResponse contains the response from method Servers.Start. +type ServersStartPollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (ServersStartResponse, error) + + // Poller contains an initialized poller. + Poller ServersStartPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ServersStartResponse contains the response from method Servers.Start. +type ServersStartResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ServersStopPollerResponse contains the response from method Servers.Stop. +type ServersStopPollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (ServersStopResponse, error) + + // Poller contains an initialized poller. + Poller ServersStopPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ServersStopResponse contains the response from method Servers.Stop. +type ServersStopResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ServersUpdatePollerResponse contains the response from method Servers.Update. +type ServersUpdatePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (ServersUpdateResponse, error) + + // Poller contains an initialized poller. + Poller ServersUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ServersUpdateResponse contains the response from method Servers.Update. +type ServersUpdateResponse struct { + ServersUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ServersUpdateResult contains the result from method Servers.Update. +type ServersUpdateResult struct { + Server +} + +// VirtualNetworkSubnetUsageExecuteResponse contains the response from method VirtualNetworkSubnetUsage.Execute. +type VirtualNetworkSubnetUsageExecuteResponse struct { + VirtualNetworkSubnetUsageExecuteResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// VirtualNetworkSubnetUsageExecuteResult contains the result from method VirtualNetworkSubnetUsage.Execute. +type VirtualNetworkSubnetUsageExecuteResult struct { + VirtualNetworkSubnetUsageResult +} diff --git a/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_servers_client.go b/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_servers_client.go new file mode 100644 index 000000000000..415d16b9ec5d --- /dev/null +++ b/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_servers_client.go @@ -0,0 +1,845 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armpostgresqlflexibleservers + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" + "time" +) + +// ServersClient contains the methods for the Servers group. +// Don't use this type directly, use NewServersClient() instead. +type ServersClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewServersClient creates a new instance of ServersClient with the specified values. +func NewServersClient(con *armcore.Connection, subscriptionID string) *ServersClient { + return &ServersClient{con: con, subscriptionID: subscriptionID} +} + +// BeginCreate - Creates a new server. +// If the operation fails it returns the *CloudError error type. +func (client *ServersClient) BeginCreate(ctx context.Context, resourceGroupName string, serverName string, parameters Server, options *ServersBeginCreateOptions) (ServersCreatePollerResponse, error) { + resp, err := client.create(ctx, resourceGroupName, serverName, parameters, options) + if err != nil { + return ServersCreatePollerResponse{}, err + } + result := ServersCreatePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("ServersClient.Create", "", resp, client.con.Pipeline(), client.createHandleError) + if err != nil { + return ServersCreatePollerResponse{}, err + } + poller := &serversCreatePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ServersCreateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeCreate creates a new ServersCreatePoller from the specified resume token. +// token - The value must come from a previous call to ServersCreatePoller.ResumeToken(). +func (client *ServersClient) ResumeCreate(ctx context.Context, token string) (ServersCreatePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("ServersClient.Create", token, client.con.Pipeline(), client.createHandleError) + if err != nil { + return ServersCreatePollerResponse{}, err + } + poller := &serversCreatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return ServersCreatePollerResponse{}, err + } + result := ServersCreatePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ServersCreateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Create - Creates a new server. +// If the operation fails it returns the *CloudError error type. +func (client *ServersClient) create(ctx context.Context, resourceGroupName string, serverName string, parameters Server, options *ServersBeginCreateOptions) (*azcore.Response, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, serverName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted) { + return nil, client.createHandleError(resp) + } + return resp, nil +} + +// createCreateRequest creates the Create request. +func (client *ServersClient) createCreateRequest(ctx context.Context, resourceGroupName string, serverName string, parameters Server, options *ServersBeginCreateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serverName == "" { + return nil, errors.New("parameter serverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createHandleError handles the Create error response. +func (client *ServersClient) createHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudError{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginDelete - Deletes a server. +// If the operation fails it returns the *CloudError error type. +func (client *ServersClient) BeginDelete(ctx context.Context, resourceGroupName string, serverName string, options *ServersBeginDeleteOptions) (ServersDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, serverName, options) + if err != nil { + return ServersDeletePollerResponse{}, err + } + result := ServersDeletePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("ServersClient.Delete", "", resp, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return ServersDeletePollerResponse{}, err + } + poller := &serversDeletePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ServersDeleteResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeDelete creates a new ServersDeletePoller from the specified resume token. +// token - The value must come from a previous call to ServersDeletePoller.ResumeToken(). +func (client *ServersClient) ResumeDelete(ctx context.Context, token string) (ServersDeletePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("ServersClient.Delete", token, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return ServersDeletePollerResponse{}, err + } + poller := &serversDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return ServersDeletePollerResponse{}, err + } + result := ServersDeletePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ServersDeleteResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Delete - Deletes a server. +// If the operation fails it returns the *CloudError error type. +func (client *ServersClient) deleteOperation(ctx context.Context, resourceGroupName string, serverName string, options *ServersBeginDeleteOptions) (*azcore.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serverName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ServersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serverName string, options *ServersBeginDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serverName == "" { + return nil, errors.New("parameter serverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ServersClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudError{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets information about a server. +// If the operation fails it returns the *CloudError error type. +func (client *ServersClient) Get(ctx context.Context, resourceGroupName string, serverName string, options *ServersGetOptions) (ServersGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, options) + if err != nil { + return ServersGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ServersGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ServersGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ServersClient) getCreateRequest(ctx context.Context, resourceGroupName string, serverName string, options *ServersGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serverName == "" { + return nil, errors.New("parameter serverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ServersClient) getHandleResponse(resp *azcore.Response) (ServersGetResponse, error) { + result := ServersGetResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.Server); err != nil { + return ServersGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *ServersClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudError{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// List - List all the servers in a given subscription. +// If the operation fails it returns the *CloudError error type. +func (client *ServersClient) List(options *ServersListOptions) ServersListPager { + return &serversListPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp ServersListResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.ServerListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *ServersClient) listCreateRequest(ctx context.Context, options *ServersListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DBforPostgreSQL/flexibleServers" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ServersClient) listHandleResponse(resp *azcore.Response) (ServersListResponse, error) { + result := ServersListResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.ServerListResult); err != nil { + return ServersListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *ServersClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudError{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByResourceGroup - List all the servers in a given resource group. +// If the operation fails it returns the *CloudError error type. +func (client *ServersClient) ListByResourceGroup(resourceGroupName string, options *ServersListByResourceGroupOptions) ServersListByResourceGroupPager { + return &serversListByResourceGroupPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, + advancer: func(ctx context.Context, resp ServersListByResourceGroupResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.ServerListResult.NextLink) + }, + } +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *ServersClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ServersListByResourceGroupOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *ServersClient) listByResourceGroupHandleResponse(resp *azcore.Response) (ServersListByResourceGroupResponse, error) { + result := ServersListByResourceGroupResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.ServerListResult); err != nil { + return ServersListByResourceGroupResponse{}, err + } + return result, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *ServersClient) listByResourceGroupHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudError{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginRestart - Restarts a server. +// If the operation fails it returns the *CloudError error type. +func (client *ServersClient) BeginRestart(ctx context.Context, resourceGroupName string, serverName string, options *ServersBeginRestartOptions) (ServersRestartPollerResponse, error) { + resp, err := client.restart(ctx, resourceGroupName, serverName, options) + if err != nil { + return ServersRestartPollerResponse{}, err + } + result := ServersRestartPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("ServersClient.Restart", "", resp, client.con.Pipeline(), client.restartHandleError) + if err != nil { + return ServersRestartPollerResponse{}, err + } + poller := &serversRestartPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ServersRestartResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeRestart creates a new ServersRestartPoller from the specified resume token. +// token - The value must come from a previous call to ServersRestartPoller.ResumeToken(). +func (client *ServersClient) ResumeRestart(ctx context.Context, token string) (ServersRestartPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("ServersClient.Restart", token, client.con.Pipeline(), client.restartHandleError) + if err != nil { + return ServersRestartPollerResponse{}, err + } + poller := &serversRestartPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return ServersRestartPollerResponse{}, err + } + result := ServersRestartPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ServersRestartResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Restart - Restarts a server. +// If the operation fails it returns the *CloudError error type. +func (client *ServersClient) restart(ctx context.Context, resourceGroupName string, serverName string, options *ServersBeginRestartOptions) (*azcore.Response, error) { + req, err := client.restartCreateRequest(ctx, resourceGroupName, serverName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted) { + return nil, client.restartHandleError(resp) + } + return resp, nil +} + +// restartCreateRequest creates the Restart request. +func (client *ServersClient) restartCreateRequest(ctx context.Context, resourceGroupName string, serverName string, options *ServersBeginRestartOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/restart" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serverName == "" { + return nil, errors.New("parameter serverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + if options != nil && options.Parameters != nil { + return req, req.MarshalAsJSON(*options.Parameters) + } + return req, nil +} + +// restartHandleError handles the Restart error response. +func (client *ServersClient) restartHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudError{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginStart - Starts a server. +// If the operation fails it returns the *CloudError error type. +func (client *ServersClient) BeginStart(ctx context.Context, resourceGroupName string, serverName string, options *ServersBeginStartOptions) (ServersStartPollerResponse, error) { + resp, err := client.start(ctx, resourceGroupName, serverName, options) + if err != nil { + return ServersStartPollerResponse{}, err + } + result := ServersStartPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("ServersClient.Start", "", resp, client.con.Pipeline(), client.startHandleError) + if err != nil { + return ServersStartPollerResponse{}, err + } + poller := &serversStartPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ServersStartResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeStart creates a new ServersStartPoller from the specified resume token. +// token - The value must come from a previous call to ServersStartPoller.ResumeToken(). +func (client *ServersClient) ResumeStart(ctx context.Context, token string) (ServersStartPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("ServersClient.Start", token, client.con.Pipeline(), client.startHandleError) + if err != nil { + return ServersStartPollerResponse{}, err + } + poller := &serversStartPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return ServersStartPollerResponse{}, err + } + result := ServersStartPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ServersStartResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Start - Starts a server. +// If the operation fails it returns the *CloudError error type. +func (client *ServersClient) start(ctx context.Context, resourceGroupName string, serverName string, options *ServersBeginStartOptions) (*azcore.Response, error) { + req, err := client.startCreateRequest(ctx, resourceGroupName, serverName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted) { + return nil, client.startHandleError(resp) + } + return resp, nil +} + +// startCreateRequest creates the Start request. +func (client *ServersClient) startCreateRequest(ctx context.Context, resourceGroupName string, serverName string, options *ServersBeginStartOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/start" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serverName == "" { + return nil, errors.New("parameter serverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// startHandleError handles the Start error response. +func (client *ServersClient) startHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudError{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginStop - Stops a server. +// If the operation fails it returns the *CloudError error type. +func (client *ServersClient) BeginStop(ctx context.Context, resourceGroupName string, serverName string, options *ServersBeginStopOptions) (ServersStopPollerResponse, error) { + resp, err := client.stop(ctx, resourceGroupName, serverName, options) + if err != nil { + return ServersStopPollerResponse{}, err + } + result := ServersStopPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("ServersClient.Stop", "", resp, client.con.Pipeline(), client.stopHandleError) + if err != nil { + return ServersStopPollerResponse{}, err + } + poller := &serversStopPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ServersStopResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeStop creates a new ServersStopPoller from the specified resume token. +// token - The value must come from a previous call to ServersStopPoller.ResumeToken(). +func (client *ServersClient) ResumeStop(ctx context.Context, token string) (ServersStopPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("ServersClient.Stop", token, client.con.Pipeline(), client.stopHandleError) + if err != nil { + return ServersStopPollerResponse{}, err + } + poller := &serversStopPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return ServersStopPollerResponse{}, err + } + result := ServersStopPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ServersStopResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Stop - Stops a server. +// If the operation fails it returns the *CloudError error type. +func (client *ServersClient) stop(ctx context.Context, resourceGroupName string, serverName string, options *ServersBeginStopOptions) (*azcore.Response, error) { + req, err := client.stopCreateRequest(ctx, resourceGroupName, serverName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted) { + return nil, client.stopHandleError(resp) + } + return resp, nil +} + +// stopCreateRequest creates the Stop request. +func (client *ServersClient) stopCreateRequest(ctx context.Context, resourceGroupName string, serverName string, options *ServersBeginStopOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/stop" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serverName == "" { + return nil, errors.New("parameter serverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// stopHandleError handles the Stop error response. +func (client *ServersClient) stopHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudError{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginUpdate - Updates an existing server. The request body can contain one to many of the properties present in the normal server definition. +// If the operation fails it returns the *CloudError error type. +func (client *ServersClient) BeginUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters ServerForUpdate, options *ServersBeginUpdateOptions) (ServersUpdatePollerResponse, error) { + resp, err := client.update(ctx, resourceGroupName, serverName, parameters, options) + if err != nil { + return ServersUpdatePollerResponse{}, err + } + result := ServersUpdatePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("ServersClient.Update", "", resp, client.con.Pipeline(), client.updateHandleError) + if err != nil { + return ServersUpdatePollerResponse{}, err + } + poller := &serversUpdatePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ServersUpdateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeUpdate creates a new ServersUpdatePoller from the specified resume token. +// token - The value must come from a previous call to ServersUpdatePoller.ResumeToken(). +func (client *ServersClient) ResumeUpdate(ctx context.Context, token string) (ServersUpdatePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("ServersClient.Update", token, client.con.Pipeline(), client.updateHandleError) + if err != nil { + return ServersUpdatePollerResponse{}, err + } + poller := &serversUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return ServersUpdatePollerResponse{}, err + } + result := ServersUpdatePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ServersUpdateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Update - Updates an existing server. The request body can contain one to many of the properties present in the normal server definition. +// If the operation fails it returns the *CloudError error type. +func (client *ServersClient) update(ctx context.Context, resourceGroupName string, serverName string, parameters ServerForUpdate, options *ServersBeginUpdateOptions) (*azcore.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, serverName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted) { + return nil, client.updateHandleError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *ServersClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serverName string, parameters ServerForUpdate, options *ServersBeginUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serverName == "" { + return nil, errors.New("parameter serverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleError handles the Update error response. +func (client *ServersClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudError{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_time_rfc3339.go b/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..0c0964501869 --- /dev/null +++ b/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_time_rfc3339.go @@ -0,0 +1,57 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armpostgresqlflexibleservers + +import ( + "regexp" + "strings" + "time" +) + +const ( + utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` + utcLayout = "2006-01-02T15:04:05.999999999" + rfc3339JSON = `"` + time.RFC3339Nano + `"` +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) + +type timeRFC3339 time.Time + +func (t timeRFC3339) MarshalJSON() (json []byte, err error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t timeRFC3339) MarshalText() (text []byte, err error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *timeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcLayoutJSON + if tzOffsetRegex.Match(data) { + layout = rfc3339JSON + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { + layout := utcLayout + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = timeRFC3339(p) + return err +} diff --git a/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_virtualnetworksubnetusage_client.go b/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_virtualnetworksubnetusage_client.go new file mode 100644 index 000000000000..b9724042a8c0 --- /dev/null +++ b/sdk/postgresql/armpostgresqlflexibleservers/zz_generated_virtualnetworksubnetusage_client.go @@ -0,0 +1,93 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armpostgresqlflexibleservers + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// VirtualNetworkSubnetUsageClient contains the methods for the VirtualNetworkSubnetUsage group. +// Don't use this type directly, use NewVirtualNetworkSubnetUsageClient() instead. +type VirtualNetworkSubnetUsageClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewVirtualNetworkSubnetUsageClient creates a new instance of VirtualNetworkSubnetUsageClient with the specified values. +func NewVirtualNetworkSubnetUsageClient(con *armcore.Connection, subscriptionID string) *VirtualNetworkSubnetUsageClient { + return &VirtualNetworkSubnetUsageClient{con: con, subscriptionID: subscriptionID} +} + +// Execute - Get virtual network subnet usage for a given vNet resource id. +// If the operation fails it returns the *CloudError error type. +func (client *VirtualNetworkSubnetUsageClient) Execute(ctx context.Context, locationName string, parameters VirtualNetworkSubnetUsageParameter, options *VirtualNetworkSubnetUsageExecuteOptions) (VirtualNetworkSubnetUsageExecuteResponse, error) { + req, err := client.executeCreateRequest(ctx, locationName, parameters, options) + if err != nil { + return VirtualNetworkSubnetUsageExecuteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return VirtualNetworkSubnetUsageExecuteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return VirtualNetworkSubnetUsageExecuteResponse{}, client.executeHandleError(resp) + } + return client.executeHandleResponse(resp) +} + +// executeCreateRequest creates the Execute request. +func (client *VirtualNetworkSubnetUsageClient) executeCreateRequest(ctx context.Context, locationName string, parameters VirtualNetworkSubnetUsageParameter, options *VirtualNetworkSubnetUsageExecuteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DBforPostgreSQL/locations/{locationName}/checkVirtualNetworkSubnetUsage" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if locationName == "" { + return nil, errors.New("parameter locationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{locationName}", url.PathEscape(locationName)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// executeHandleResponse handles the Execute response. +func (client *VirtualNetworkSubnetUsageClient) executeHandleResponse(resp *azcore.Response) (VirtualNetworkSubnetUsageExecuteResponse, error) { + result := VirtualNetworkSubnetUsageExecuteResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.VirtualNetworkSubnetUsageResult); err != nil { + return VirtualNetworkSubnetUsageExecuteResponse{}, err + } + return result, nil +} + +// executeHandleError handles the Execute error response. +func (client *VirtualNetworkSubnetUsageClient) executeHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudError{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +}