3
// Copyright (c) Microsoft and contributors. All rights reserved.
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
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.
14
// See the License for the specific language governing permissions and
15
// limitations under the License.
17
// Code generated by Microsoft (R) AutoRest Code Generator 0.12.0.0
18
// Changes may cause incorrect behavior and will be lost if the code is
22
"github.com/Azure/azure-sdk-for-go/Godeps/_workspace/src/github.com/Azure/go-autorest/autorest"
27
// UsageOperationsClient is the use these APIs to manage Azure Websites
28
// resources through the Azure Resource Manager. All task operations conform
29
// to the HTTP/1.1 protocol specification and each operation returns an
30
// x-ms-request-id header that can be used to obtain information about the
31
// request. You must make sure that requests made to these resources are
32
// secure. For more information, see <a
33
// href="https://msdn.microsoft.com/en-us/library/azure/dn790557.aspx">Authenticating
34
// Azure Resource Manager requests.</a>
35
type UsageOperationsClient struct {
39
// NewUsageOperationsClient creates an instance of the UsageOperationsClient
41
func NewUsageOperationsClient(subscriptionID string) UsageOperationsClient {
42
return NewUsageOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID)
45
// NewUsageOperationsClientWithBaseURI creates an instance of the
46
// UsageOperationsClient client.
47
func NewUsageOperationsClientWithBaseURI(baseURI string, subscriptionID string) UsageOperationsClient {
48
return UsageOperationsClient{NewWithBaseURI(baseURI, subscriptionID)}
51
// GetUsage sends the get usage request.
53
// resourceGroupName is name of resource group environmentName is environment
54
// name lastID is last marker that was returned from the batch batchSize is
55
// size of the batch to be returned.
56
func (client UsageOperationsClient) GetUsage(resourceGroupName string, environmentName string, lastID string, batchSize int) (result ObjectSet, ae error) {
57
req, err := client.GetUsagePreparer(resourceGroupName, environmentName, lastID, batchSize)
59
return result, autorest.NewErrorWithError(err, "web/UsageOperationsClient", "GetUsage", "Failure preparing request")
62
resp, err := client.GetUsageSender(req)
64
result.Response = autorest.Response{Response: resp}
65
return result, autorest.NewErrorWithError(err, "web/UsageOperationsClient", "GetUsage", "Failure sending request")
68
result, err = client.GetUsageResponder(resp)
70
ae = autorest.NewErrorWithError(err, "web/UsageOperationsClient", "GetUsage", "Failure responding to request")
76
// GetUsagePreparer prepares the GetUsage request.
77
func (client UsageOperationsClient) GetUsagePreparer(resourceGroupName string, environmentName string, lastID string, batchSize int) (*http.Request, error) {
78
pathParameters := map[string]interface{}{
79
"environmentName": url.QueryEscape(environmentName),
80
"resourceGroupName": url.QueryEscape(resourceGroupName),
81
"subscriptionId": url.QueryEscape(client.SubscriptionID),
84
queryParameters := map[string]interface{}{
85
"api-version": APIVersion,
86
"batchSize": batchSize,
90
return autorest.Prepare(&http.Request{},
93
autorest.WithBaseURL(client.BaseURI),
94
autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web.Admin/environments/{environmentName}/usage"),
95
autorest.WithPathParameters(pathParameters),
96
autorest.WithQueryParameters(queryParameters))
99
// GetUsageSender sends the GetUsage request. The method will close the
100
// http.Response Body if it receives an error.
101
func (client UsageOperationsClient) GetUsageSender(req *http.Request) (*http.Response, error) {
102
return client.Send(req, http.StatusOK)
105
// GetUsageResponder handles the response to the GetUsage request. The method always
106
// closes the http.Response Body.
107
func (client UsageOperationsClient) GetUsageResponder(resp *http.Response) (result ObjectSet, err error) {
108
err = autorest.Respond(
110
client.ByInspecting(),
111
autorest.WithErrorUnlessStatusCode(http.StatusOK),
112
autorest.ByUnmarshallingJSON(&result.Value),
113
autorest.ByClosing())
114
result.Response = autorest.Response{Response: resp}