1package sql 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// CapabilitiesClient is the the Azure SQL Database management API provides a RESTful set of web services that interact 18// with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, and 19// delete databases. 20type CapabilitiesClient struct { 21 BaseClient 22} 23 24// NewCapabilitiesClient creates an instance of the CapabilitiesClient client. 25func NewCapabilitiesClient(subscriptionID string) CapabilitiesClient { 26 return NewCapabilitiesClientWithBaseURI(DefaultBaseURI, subscriptionID) 27} 28 29// NewCapabilitiesClientWithBaseURI creates an instance of the CapabilitiesClient client using a custom endpoint. Use 30// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 31func NewCapabilitiesClientWithBaseURI(baseURI string, subscriptionID string) CapabilitiesClient { 32 return CapabilitiesClient{NewWithBaseURI(baseURI, subscriptionID)} 33} 34 35// ListByLocation gets the subscription capabilities available for the specified location. 36// Parameters: 37// locationName - the location name whose capabilities are retrieved. 38func (client CapabilitiesClient) ListByLocation(ctx context.Context, locationName string) (result LocationCapabilities, err error) { 39 if tracing.IsEnabled() { 40 ctx = tracing.StartSpan(ctx, fqdn+"/CapabilitiesClient.ListByLocation") 41 defer func() { 42 sc := -1 43 if result.Response.Response != nil { 44 sc = result.Response.Response.StatusCode 45 } 46 tracing.EndSpan(ctx, sc, err) 47 }() 48 } 49 req, err := client.ListByLocationPreparer(ctx, locationName) 50 if err != nil { 51 err = autorest.NewErrorWithError(err, "sql.CapabilitiesClient", "ListByLocation", nil, "Failure preparing request") 52 return 53 } 54 55 resp, err := client.ListByLocationSender(req) 56 if err != nil { 57 result.Response = autorest.Response{Response: resp} 58 err = autorest.NewErrorWithError(err, "sql.CapabilitiesClient", "ListByLocation", resp, "Failure sending request") 59 return 60 } 61 62 result, err = client.ListByLocationResponder(resp) 63 if err != nil { 64 err = autorest.NewErrorWithError(err, "sql.CapabilitiesClient", "ListByLocation", resp, "Failure responding to request") 65 return 66 } 67 68 return 69} 70 71// ListByLocationPreparer prepares the ListByLocation request. 72func (client CapabilitiesClient) ListByLocationPreparer(ctx context.Context, locationName string) (*http.Request, error) { 73 pathParameters := map[string]interface{}{ 74 "locationName": autorest.Encode("path", locationName), 75 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 76 } 77 78 const APIVersion = "2015-05-01" 79 queryParameters := map[string]interface{}{ 80 "api-version": APIVersion, 81 } 82 83 preparer := autorest.CreatePreparer( 84 autorest.AsGet(), 85 autorest.WithBaseURL(client.BaseURI), 86 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/capabilities", pathParameters), 87 autorest.WithQueryParameters(queryParameters)) 88 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 89} 90 91// ListByLocationSender sends the ListByLocation request. The method will close the 92// http.Response Body if it receives an error. 93func (client CapabilitiesClient) ListByLocationSender(req *http.Request) (*http.Response, error) { 94 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 95} 96 97// ListByLocationResponder handles the response to the ListByLocation request. The method always 98// closes the http.Response Body. 99func (client CapabilitiesClient) ListByLocationResponder(resp *http.Response) (result LocationCapabilities, err error) { 100 err = autorest.Respond( 101 resp, 102 azure.WithErrorUnlessStatusCode(http.StatusOK), 103 autorest.ByUnmarshallingJSON(&result), 104 autorest.ByClosing()) 105 result.Response = autorest.Response{Response: resp} 106 return 107} 108