1package postgresql 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/autorest/validation" 14 "github.com/Azure/go-autorest/tracing" 15 "net/http" 16) 17 18// ServerParametersClient is the the Microsoft Azure management API provides create, read, update, and delete 19// functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security 20// alert policies, log files and configurations with new business model. 21type ServerParametersClient struct { 22 BaseClient 23} 24 25// NewServerParametersClient creates an instance of the ServerParametersClient client. 26func NewServerParametersClient(subscriptionID string) ServerParametersClient { 27 return NewServerParametersClientWithBaseURI(DefaultBaseURI, subscriptionID) 28} 29 30// NewServerParametersClientWithBaseURI creates an instance of the ServerParametersClient client using a custom 31// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure 32// stack). 33func NewServerParametersClientWithBaseURI(baseURI string, subscriptionID string) ServerParametersClient { 34 return ServerParametersClient{NewWithBaseURI(baseURI, subscriptionID)} 35} 36 37// ListUpdateConfigurations update a list of configurations in a given server. 38// Parameters: 39// resourceGroupName - the name of the resource group. The name is case insensitive. 40// serverName - the name of the server. 41// value - the parameters for updating a list of server configuration. 42func (client ServerParametersClient) ListUpdateConfigurations(ctx context.Context, resourceGroupName string, serverName string, value ConfigurationListResult) (result ServerParametersListUpdateConfigurationsFuture, err error) { 43 if tracing.IsEnabled() { 44 ctx = tracing.StartSpan(ctx, fqdn+"/ServerParametersClient.ListUpdateConfigurations") 45 defer func() { 46 sc := -1 47 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 48 sc = result.FutureAPI.Response().StatusCode 49 } 50 tracing.EndSpan(ctx, sc, err) 51 }() 52 } 53 if err := validation.Validate([]validation.Validation{ 54 {TargetValue: client.SubscriptionID, 55 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 56 {TargetValue: resourceGroupName, 57 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 58 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { 59 return result, validation.NewError("postgresql.ServerParametersClient", "ListUpdateConfigurations", err.Error()) 60 } 61 62 req, err := client.ListUpdateConfigurationsPreparer(ctx, resourceGroupName, serverName, value) 63 if err != nil { 64 err = autorest.NewErrorWithError(err, "postgresql.ServerParametersClient", "ListUpdateConfigurations", nil, "Failure preparing request") 65 return 66 } 67 68 result, err = client.ListUpdateConfigurationsSender(req) 69 if err != nil { 70 err = autorest.NewErrorWithError(err, "postgresql.ServerParametersClient", "ListUpdateConfigurations", nil, "Failure sending request") 71 return 72 } 73 74 return 75} 76 77// ListUpdateConfigurationsPreparer prepares the ListUpdateConfigurations request. 78func (client ServerParametersClient) ListUpdateConfigurationsPreparer(ctx context.Context, resourceGroupName string, serverName string, value ConfigurationListResult) (*http.Request, error) { 79 pathParameters := map[string]interface{}{ 80 "resourceGroupName": autorest.Encode("path", resourceGroupName), 81 "serverName": autorest.Encode("path", serverName), 82 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 83 } 84 85 const APIVersion = "2017-12-01" 86 queryParameters := map[string]interface{}{ 87 "api-version": APIVersion, 88 } 89 90 preparer := autorest.CreatePreparer( 91 autorest.AsContentType("application/json; charset=utf-8"), 92 autorest.AsPost(), 93 autorest.WithBaseURL(client.BaseURI), 94 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/servers/{serverName}/updateConfigurations", pathParameters), 95 autorest.WithJSON(value), 96 autorest.WithQueryParameters(queryParameters)) 97 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 98} 99 100// ListUpdateConfigurationsSender sends the ListUpdateConfigurations request. The method will close the 101// http.Response Body if it receives an error. 102func (client ServerParametersClient) ListUpdateConfigurationsSender(req *http.Request) (future ServerParametersListUpdateConfigurationsFuture, err error) { 103 var resp *http.Response 104 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 105 if err != nil { 106 return 107 } 108 var azf azure.Future 109 azf, err = azure.NewFutureFromResponse(resp) 110 future.FutureAPI = &azf 111 future.Result = future.result 112 return 113} 114 115// ListUpdateConfigurationsResponder handles the response to the ListUpdateConfigurations request. The method always 116// closes the http.Response Body. 117func (client ServerParametersClient) ListUpdateConfigurationsResponder(resp *http.Response) (result ConfigurationListResult, err error) { 118 err = autorest.Respond( 119 resp, 120 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 121 autorest.ByUnmarshallingJSON(&result), 122 autorest.ByClosing()) 123 result.Response = autorest.Response{Response: resp} 124 return 125} 126