1package postgresqlflexibleservers 2 3// Copyright (c) Microsoft Corporation. All rights reserved. 4// Licensed under the MIT License. See License.txt in the project root for license information. 5// 6// Code generated by Microsoft (R) AutoRest Code Generator. 7// Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 9import ( 10 "context" 11 "github.com/Azure/go-autorest/autorest" 12 "github.com/Azure/go-autorest/autorest/azure" 13 "github.com/Azure/go-autorest/tracing" 14 "net/http" 15) 16 17// OperationsClient is the the Microsoft Azure management API provides create, read, update, and delete functionality 18// for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security alert policies, 19// log files and configurations with new business model. 20type OperationsClient struct { 21 BaseClient 22} 23 24// NewOperationsClient creates an instance of the OperationsClient client. 25func NewOperationsClient(subscriptionID string) OperationsClient { 26 return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) 27} 28 29// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this 30// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 31func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { 32 return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} 33} 34 35// List lists all of the available REST API operations. 36func (client OperationsClient) List(ctx context.Context) (result OperationListResult, err error) { 37 if tracing.IsEnabled() { 38 ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") 39 defer func() { 40 sc := -1 41 if result.Response.Response != nil { 42 sc = result.Response.Response.StatusCode 43 } 44 tracing.EndSpan(ctx, sc, err) 45 }() 46 } 47 req, err := client.ListPreparer(ctx) 48 if err != nil { 49 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.OperationsClient", "List", nil, "Failure preparing request") 50 return 51 } 52 53 resp, err := client.ListSender(req) 54 if err != nil { 55 result.Response = autorest.Response{Response: resp} 56 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.OperationsClient", "List", resp, "Failure sending request") 57 return 58 } 59 60 result, err = client.ListResponder(resp) 61 if err != nil { 62 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.OperationsClient", "List", resp, "Failure responding to request") 63 return 64 } 65 66 return 67} 68 69// ListPreparer prepares the List request. 70func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { 71 const APIVersion = "2020-02-14-preview" 72 queryParameters := map[string]interface{}{ 73 "api-version": APIVersion, 74 } 75 76 preparer := autorest.CreatePreparer( 77 autorest.AsGet(), 78 autorest.WithBaseURL(client.BaseURI), 79 autorest.WithPath("/providers/Microsoft.DBForPostgreSql/operations"), 80 autorest.WithQueryParameters(queryParameters)) 81 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 82} 83 84// ListSender sends the List request. The method will close the 85// http.Response Body if it receives an error. 86func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { 87 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 88} 89 90// ListResponder handles the response to the List request. The method always 91// closes the http.Response Body. 92func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { 93 err = autorest.Respond( 94 resp, 95 azure.WithErrorUnlessStatusCode(http.StatusOK), 96 autorest.ByUnmarshallingJSON(&result), 97 autorest.ByClosing()) 98 result.Response = autorest.Response{Response: resp} 99 return 100} 101