1package sql 2 3// Copyright (c) Microsoft and contributors. All rights reserved. 4// 5// Licensed under the Apache License, Version 2.0 (the "License"); 6// you may not use this file except in compliance with the License. 7// You may obtain a copy of the License at 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// 14// See the License for the specific language governing permissions and 15// limitations under the License. 16// 17// Code generated by Microsoft (R) AutoRest Code Generator. 18// Changes may cause incorrect behavior and will be lost if the code is regenerated. 19 20import ( 21 "context" 22 "github.com/Azure/go-autorest/autorest" 23 "github.com/Azure/go-autorest/autorest/azure" 24 "github.com/Azure/go-autorest/tracing" 25 "net/http" 26) 27 28// CapabilitiesClient is the the Azure SQL Database management API provides a RESTful set of web services that interact 29// with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, and 30// delete databases. 31type CapabilitiesClient struct { 32 BaseClient 33} 34 35// NewCapabilitiesClient creates an instance of the CapabilitiesClient client. 36func NewCapabilitiesClient(subscriptionID string) CapabilitiesClient { 37 return NewCapabilitiesClientWithBaseURI(DefaultBaseURI, subscriptionID) 38} 39 40// NewCapabilitiesClientWithBaseURI creates an instance of the CapabilitiesClient client using a custom endpoint. Use 41// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 42func NewCapabilitiesClientWithBaseURI(baseURI string, subscriptionID string) CapabilitiesClient { 43 return CapabilitiesClient{NewWithBaseURI(baseURI, subscriptionID)} 44} 45 46// ListByLocation gets the capabilities available for the specified location. 47// Parameters: 48// locationID - the location id whose capabilities are retrieved. 49func (client CapabilitiesClient) ListByLocation(ctx context.Context, locationID string) (result LocationCapabilities, err error) { 50 if tracing.IsEnabled() { 51 ctx = tracing.StartSpan(ctx, fqdn+"/CapabilitiesClient.ListByLocation") 52 defer func() { 53 sc := -1 54 if result.Response.Response != nil { 55 sc = result.Response.Response.StatusCode 56 } 57 tracing.EndSpan(ctx, sc, err) 58 }() 59 } 60 req, err := client.ListByLocationPreparer(ctx, locationID) 61 if err != nil { 62 err = autorest.NewErrorWithError(err, "sql.CapabilitiesClient", "ListByLocation", nil, "Failure preparing request") 63 return 64 } 65 66 resp, err := client.ListByLocationSender(req) 67 if err != nil { 68 result.Response = autorest.Response{Response: resp} 69 err = autorest.NewErrorWithError(err, "sql.CapabilitiesClient", "ListByLocation", resp, "Failure sending request") 70 return 71 } 72 73 result, err = client.ListByLocationResponder(resp) 74 if err != nil { 75 err = autorest.NewErrorWithError(err, "sql.CapabilitiesClient", "ListByLocation", resp, "Failure responding to request") 76 return 77 } 78 79 return 80} 81 82// ListByLocationPreparer prepares the ListByLocation request. 83func (client CapabilitiesClient) ListByLocationPreparer(ctx context.Context, locationID string) (*http.Request, error) { 84 pathParameters := map[string]interface{}{ 85 "locationId": autorest.Encode("path", locationID), 86 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 87 } 88 89 const APIVersion = "2014-04-01" 90 queryParameters := map[string]interface{}{ 91 "api-version": APIVersion, 92 } 93 94 preparer := autorest.CreatePreparer( 95 autorest.AsGet(), 96 autorest.WithBaseURL(client.BaseURI), 97 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationId}/capabilities", pathParameters), 98 autorest.WithQueryParameters(queryParameters)) 99 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 100} 101 102// ListByLocationSender sends the ListByLocation request. The method will close the 103// http.Response Body if it receives an error. 104func (client CapabilitiesClient) ListByLocationSender(req *http.Request) (*http.Response, error) { 105 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 106} 107 108// ListByLocationResponder handles the response to the ListByLocation request. The method always 109// closes the http.Response Body. 110func (client CapabilitiesClient) ListByLocationResponder(resp *http.Response) (result LocationCapabilities, err error) { 111 err = autorest.Respond( 112 resp, 113 azure.WithErrorUnlessStatusCode(http.StatusOK), 114 autorest.ByUnmarshallingJSON(&result), 115 autorest.ByClosing()) 116 result.Response = autorest.Response{Response: resp} 117 return 118} 119