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 "net/http" 25) 26 27// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2017-03-01-preview/sql instead. 28// DatabaseUsagesClient is the the Azure SQL Database management API provides a RESTful set of web services that 29// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, 30// and delete databases. 31type DatabaseUsagesClient struct { 32 BaseClient 33} 34 35// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2017-03-01-preview/sql instead. 36// NewDatabaseUsagesClient creates an instance of the DatabaseUsagesClient client. 37func NewDatabaseUsagesClient(subscriptionID string) DatabaseUsagesClient { 38 return NewDatabaseUsagesClientWithBaseURI(DefaultBaseURI, subscriptionID) 39} 40 41// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2017-03-01-preview/sql instead. 42// NewDatabaseUsagesClientWithBaseURI creates an instance of the DatabaseUsagesClient client. 43func NewDatabaseUsagesClientWithBaseURI(baseURI string, subscriptionID string) DatabaseUsagesClient { 44 return DatabaseUsagesClient{NewWithBaseURI(baseURI, subscriptionID)} 45} 46 47// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2017-03-01-preview/sql instead. 48// ListByDatabase returns database usages. 49// 50// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from 51// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of 52// the database. 53func (client DatabaseUsagesClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseUsageListResult, err error) { 54 req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) 55 if err != nil { 56 err = autorest.NewErrorWithError(err, "sql.DatabaseUsagesClient", "ListByDatabase", nil, "Failure preparing request") 57 return 58 } 59 60 resp, err := client.ListByDatabaseSender(req) 61 if err != nil { 62 result.Response = autorest.Response{Response: resp} 63 err = autorest.NewErrorWithError(err, "sql.DatabaseUsagesClient", "ListByDatabase", resp, "Failure sending request") 64 return 65 } 66 67 result, err = client.ListByDatabaseResponder(resp) 68 if err != nil { 69 err = autorest.NewErrorWithError(err, "sql.DatabaseUsagesClient", "ListByDatabase", resp, "Failure responding to request") 70 } 71 72 return 73} 74 75// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2017-03-01-preview/sql instead. 76// ListByDatabasePreparer prepares the ListByDatabase request. 77func (client DatabaseUsagesClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { 78 pathParameters := map[string]interface{}{ 79 "databaseName": autorest.Encode("path", databaseName), 80 "resourceGroupName": autorest.Encode("path", resourceGroupName), 81 "serverName": autorest.Encode("path", serverName), 82 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 83 } 84 85 const APIVersion = "2014-04-01" 86 queryParameters := map[string]interface{}{ 87 "api-version": APIVersion, 88 } 89 90 preparer := autorest.CreatePreparer( 91 autorest.AsGet(), 92 autorest.WithBaseURL(client.BaseURI), 93 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/usages", pathParameters), 94 autorest.WithQueryParameters(queryParameters)) 95 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 96} 97 98// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2017-03-01-preview/sql instead. 99// ListByDatabaseSender sends the ListByDatabase request. The method will close the 100// http.Response Body if it receives an error. 101func (client DatabaseUsagesClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { 102 return autorest.SendWithSender(client, req, 103 azure.DoRetryWithRegistration(client.Client)) 104} 105 106// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2017-03-01-preview/sql instead. 107// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always 108// closes the http.Response Body. 109func (client DatabaseUsagesClient) ListByDatabaseResponder(resp *http.Response) (result DatabaseUsageListResult, err error) { 110 err = autorest.Respond( 111 resp, 112 client.ByInspecting(), 113 azure.WithErrorUnlessStatusCode(http.StatusOK), 114 autorest.ByUnmarshallingJSON(&result), 115 autorest.ByClosing()) 116 result.Response = autorest.Response{Response: resp} 117 return 118} 119