1 package insights
2
3
4
5
6
7
8
9 import (
10 "context"
11 "github.com/Azure/go-autorest/autorest"
12 "github.com/Azure/go-autorest/autorest/azure"
13 "github.com/Azure/go-autorest/autorest/validation"
14 "github.com/Azure/go-autorest/tracing"
15 "net/http"
16 )
17
18
19 type ComponentCurrentBillingFeaturesClient struct {
20 BaseClient
21 }
22
23
24 func NewComponentCurrentBillingFeaturesClient(subscriptionID string) ComponentCurrentBillingFeaturesClient {
25 return NewComponentCurrentBillingFeaturesClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30
31 func NewComponentCurrentBillingFeaturesClientWithBaseURI(baseURI string, subscriptionID string) ComponentCurrentBillingFeaturesClient {
32 return ComponentCurrentBillingFeaturesClient{NewWithBaseURI(baseURI, subscriptionID)}
33 }
34
35
36
37
38
39 func (client ComponentCurrentBillingFeaturesClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result ApplicationInsightsComponentBillingFeatures, err error) {
40 if tracing.IsEnabled() {
41 ctx = tracing.StartSpan(ctx, fqdn+"/ComponentCurrentBillingFeaturesClient.Get")
42 defer func() {
43 sc := -1
44 if result.Response.Response != nil {
45 sc = result.Response.Response.StatusCode
46 }
47 tracing.EndSpan(ctx, sc, err)
48 }()
49 }
50 if err := validation.Validate([]validation.Validation{
51 {TargetValue: resourceGroupName,
52 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
53 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
54 {TargetValue: client.SubscriptionID,
55 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
56 return result, validation.NewError("insights.ComponentCurrentBillingFeaturesClient", "Get", err.Error())
57 }
58
59 req, err := client.GetPreparer(ctx, resourceGroupName, resourceName)
60 if err != nil {
61 err = autorest.NewErrorWithError(err, "insights.ComponentCurrentBillingFeaturesClient", "Get", nil, "Failure preparing request")
62 return
63 }
64
65 resp, err := client.GetSender(req)
66 if err != nil {
67 result.Response = autorest.Response{Response: resp}
68 err = autorest.NewErrorWithError(err, "insights.ComponentCurrentBillingFeaturesClient", "Get", resp, "Failure sending request")
69 return
70 }
71
72 result, err = client.GetResponder(resp)
73 if err != nil {
74 err = autorest.NewErrorWithError(err, "insights.ComponentCurrentBillingFeaturesClient", "Get", resp, "Failure responding to request")
75 return
76 }
77
78 return
79 }
80
81
82 func (client ComponentCurrentBillingFeaturesClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) {
83 pathParameters := map[string]interface{}{
84 "resourceGroupName": autorest.Encode("path", resourceGroupName),
85 "resourceName": autorest.Encode("path", resourceName),
86 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
87 }
88
89 const APIVersion = "2015-05-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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/currentbillingfeatures", pathParameters),
98 autorest.WithQueryParameters(queryParameters))
99 return preparer.Prepare((&http.Request{}).WithContext(ctx))
100 }
101
102
103
104 func (client ComponentCurrentBillingFeaturesClient) GetSender(req *http.Request) (*http.Response, error) {
105 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
106 }
107
108
109
110 func (client ComponentCurrentBillingFeaturesClient) GetResponder(resp *http.Response) (result ApplicationInsightsComponentBillingFeatures, 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
120
121
122
123
124
125
126 func (client ComponentCurrentBillingFeaturesClient) Update(ctx context.Context, resourceGroupName string, resourceName string, billingFeaturesProperties ApplicationInsightsComponentBillingFeatures) (result ApplicationInsightsComponentBillingFeatures, err error) {
127 if tracing.IsEnabled() {
128 ctx = tracing.StartSpan(ctx, fqdn+"/ComponentCurrentBillingFeaturesClient.Update")
129 defer func() {
130 sc := -1
131 if result.Response.Response != nil {
132 sc = result.Response.Response.StatusCode
133 }
134 tracing.EndSpan(ctx, sc, err)
135 }()
136 }
137 if err := validation.Validate([]validation.Validation{
138 {TargetValue: resourceGroupName,
139 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
140 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
141 {TargetValue: client.SubscriptionID,
142 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
143 return result, validation.NewError("insights.ComponentCurrentBillingFeaturesClient", "Update", err.Error())
144 }
145
146 req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, billingFeaturesProperties)
147 if err != nil {
148 err = autorest.NewErrorWithError(err, "insights.ComponentCurrentBillingFeaturesClient", "Update", nil, "Failure preparing request")
149 return
150 }
151
152 resp, err := client.UpdateSender(req)
153 if err != nil {
154 result.Response = autorest.Response{Response: resp}
155 err = autorest.NewErrorWithError(err, "insights.ComponentCurrentBillingFeaturesClient", "Update", resp, "Failure sending request")
156 return
157 }
158
159 result, err = client.UpdateResponder(resp)
160 if err != nil {
161 err = autorest.NewErrorWithError(err, "insights.ComponentCurrentBillingFeaturesClient", "Update", resp, "Failure responding to request")
162 return
163 }
164
165 return
166 }
167
168
169 func (client ComponentCurrentBillingFeaturesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, billingFeaturesProperties ApplicationInsightsComponentBillingFeatures) (*http.Request, error) {
170 pathParameters := map[string]interface{}{
171 "resourceGroupName": autorest.Encode("path", resourceGroupName),
172 "resourceName": autorest.Encode("path", resourceName),
173 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
174 }
175
176 const APIVersion = "2015-05-01"
177 queryParameters := map[string]interface{}{
178 "api-version": APIVersion,
179 }
180
181 preparer := autorest.CreatePreparer(
182 autorest.AsContentType("application/json; charset=utf-8"),
183 autorest.AsPut(),
184 autorest.WithBaseURL(client.BaseURI),
185 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/currentbillingfeatures", pathParameters),
186 autorest.WithJSON(billingFeaturesProperties),
187 autorest.WithQueryParameters(queryParameters))
188 return preparer.Prepare((&http.Request{}).WithContext(ctx))
189 }
190
191
192
193 func (client ComponentCurrentBillingFeaturesClient) UpdateSender(req *http.Request) (*http.Response, error) {
194 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
195 }
196
197
198
199 func (client ComponentCurrentBillingFeaturesClient) UpdateResponder(resp *http.Response) (result ApplicationInsightsComponentBillingFeatures, err error) {
200 err = autorest.Respond(
201 resp,
202 azure.WithErrorUnlessStatusCode(http.StatusOK),
203 autorest.ByUnmarshallingJSON(&result),
204 autorest.ByClosing())
205 result.Response = autorest.Response{Response: resp}
206 return
207 }
208
View as plain text