~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/Azure/azure-sdk-for-go/arm/web/usageoperations.go

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package web
 
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 0.12.0.0
 
18
// Changes may cause incorrect behavior and will be lost if the code is
 
19
// regenerated.
 
20
 
 
21
import (
 
22
        "github.com/Azure/azure-sdk-for-go/Godeps/_workspace/src/github.com/Azure/go-autorest/autorest"
 
23
        "net/http"
 
24
        "net/url"
 
25
)
 
26
 
 
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 {
 
36
        ManagementClient
 
37
}
 
38
 
 
39
// NewUsageOperationsClient creates an instance of the UsageOperationsClient
 
40
// client.
 
41
func NewUsageOperationsClient(subscriptionID string) UsageOperationsClient {
 
42
        return NewUsageOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID)
 
43
}
 
44
 
 
45
// NewUsageOperationsClientWithBaseURI creates an instance of the
 
46
// UsageOperationsClient client.
 
47
func NewUsageOperationsClientWithBaseURI(baseURI string, subscriptionID string) UsageOperationsClient {
 
48
        return UsageOperationsClient{NewWithBaseURI(baseURI, subscriptionID)}
 
49
}
 
50
 
 
51
// GetUsage sends the get usage request.
 
52
//
 
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)
 
58
        if err != nil {
 
59
                return result, autorest.NewErrorWithError(err, "web/UsageOperationsClient", "GetUsage", "Failure preparing request")
 
60
        }
 
61
 
 
62
        resp, err := client.GetUsageSender(req)
 
63
        if err != nil {
 
64
                result.Response = autorest.Response{Response: resp}
 
65
                return result, autorest.NewErrorWithError(err, "web/UsageOperationsClient", "GetUsage", "Failure sending request")
 
66
        }
 
67
 
 
68
        result, err = client.GetUsageResponder(resp)
 
69
        if err != nil {
 
70
                ae = autorest.NewErrorWithError(err, "web/UsageOperationsClient", "GetUsage", "Failure responding to request")
 
71
        }
 
72
 
 
73
        return
 
74
}
 
75
 
 
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),
 
82
        }
 
83
 
 
84
        queryParameters := map[string]interface{}{
 
85
                "api-version": APIVersion,
 
86
                "batchSize":   batchSize,
 
87
                "lastId":      lastID,
 
88
        }
 
89
 
 
90
        return autorest.Prepare(&http.Request{},
 
91
                autorest.AsJSON(),
 
92
                autorest.AsGet(),
 
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))
 
97
}
 
98
 
 
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)
 
103
}
 
104
 
 
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(
 
109
                resp,
 
110
                client.ByInspecting(),
 
111
                autorest.WithErrorUnlessStatusCode(http.StatusOK),
 
112
                autorest.ByUnmarshallingJSON(&result.Value),
 
113
                autorest.ByClosing())
 
114
        result.Response = autorest.Response{Response: resp}
 
115
        return
 
116
}