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 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
55 {TargetValue: client.SubscriptionID,
56 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
57 return result, validation.NewError("insights.ComponentCurrentBillingFeaturesClient", "Get", err.Error())
58 }
59
60 req, err := client.GetPreparer(ctx, resourceGroupName, resourceName)
61 if err != nil {
62 err = autorest.NewErrorWithError(err, "insights.ComponentCurrentBillingFeaturesClient", "Get", nil, "Failure preparing request")
63 return
64 }
65
66 resp, err := client.GetSender(req)
67 if err != nil {
68 result.Response = autorest.Response{Response: resp}
69 err = autorest.NewErrorWithError(err, "insights.ComponentCurrentBillingFeaturesClient", "Get", resp, "Failure sending request")
70 return
71 }
72
73 result, err = client.GetResponder(resp)
74 if err != nil {
75 err = autorest.NewErrorWithError(err, "insights.ComponentCurrentBillingFeaturesClient", "Get", resp, "Failure responding to request")
76 return
77 }
78
79 return
80 }
81
82
83 func (client ComponentCurrentBillingFeaturesClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) {
84 pathParameters := map[string]interface{}{
85 "resourceGroupName": autorest.Encode("path", resourceGroupName),
86 "resourceName": autorest.Encode("path", resourceName),
87 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
88 }
89
90 const APIVersion = "2015-05-01"
91 queryParameters := map[string]interface{}{
92 "api-version": APIVersion,
93 }
94
95 preparer := autorest.CreatePreparer(
96 autorest.AsGet(),
97 autorest.WithBaseURL(client.BaseURI),
98 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/currentbillingfeatures", pathParameters),
99 autorest.WithQueryParameters(queryParameters))
100 return preparer.Prepare((&http.Request{}).WithContext(ctx))
101 }
102
103
104
105 func (client ComponentCurrentBillingFeaturesClient) GetSender(req *http.Request) (*http.Response, error) {
106 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
107 }
108
109
110
111 func (client ComponentCurrentBillingFeaturesClient) GetResponder(resp *http.Response) (result ApplicationInsightsComponentBillingFeatures, err error) {
112 err = autorest.Respond(
113 resp,
114 azure.WithErrorUnlessStatusCode(http.StatusOK),
115 autorest.ByUnmarshallingJSON(&result),
116 autorest.ByClosing())
117 result.Response = autorest.Response{Response: resp}
118 return
119 }
120
121
122
123
124
125
126
127 func (client ComponentCurrentBillingFeaturesClient) Update(ctx context.Context, resourceGroupName string, resourceName string, billingFeaturesProperties ApplicationInsightsComponentBillingFeatures) (result ApplicationInsightsComponentBillingFeatures, err error) {
128 if tracing.IsEnabled() {
129 ctx = tracing.StartSpan(ctx, fqdn+"/ComponentCurrentBillingFeaturesClient.Update")
130 defer func() {
131 sc := -1
132 if result.Response.Response != nil {
133 sc = result.Response.Response.StatusCode
134 }
135 tracing.EndSpan(ctx, sc, err)
136 }()
137 }
138 if err := validation.Validate([]validation.Validation{
139 {TargetValue: resourceGroupName,
140 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
141 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
142 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
143 {TargetValue: client.SubscriptionID,
144 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
145 return result, validation.NewError("insights.ComponentCurrentBillingFeaturesClient", "Update", err.Error())
146 }
147
148 req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, billingFeaturesProperties)
149 if err != nil {
150 err = autorest.NewErrorWithError(err, "insights.ComponentCurrentBillingFeaturesClient", "Update", nil, "Failure preparing request")
151 return
152 }
153
154 resp, err := client.UpdateSender(req)
155 if err != nil {
156 result.Response = autorest.Response{Response: resp}
157 err = autorest.NewErrorWithError(err, "insights.ComponentCurrentBillingFeaturesClient", "Update", resp, "Failure sending request")
158 return
159 }
160
161 result, err = client.UpdateResponder(resp)
162 if err != nil {
163 err = autorest.NewErrorWithError(err, "insights.ComponentCurrentBillingFeaturesClient", "Update", resp, "Failure responding to request")
164 return
165 }
166
167 return
168 }
169
170
171 func (client ComponentCurrentBillingFeaturesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, billingFeaturesProperties ApplicationInsightsComponentBillingFeatures) (*http.Request, error) {
172 pathParameters := map[string]interface{}{
173 "resourceGroupName": autorest.Encode("path", resourceGroupName),
174 "resourceName": autorest.Encode("path", resourceName),
175 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
176 }
177
178 const APIVersion = "2015-05-01"
179 queryParameters := map[string]interface{}{
180 "api-version": APIVersion,
181 }
182
183 preparer := autorest.CreatePreparer(
184 autorest.AsContentType("application/json; charset=utf-8"),
185 autorest.AsPut(),
186 autorest.WithBaseURL(client.BaseURI),
187 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/currentbillingfeatures", pathParameters),
188 autorest.WithJSON(billingFeaturesProperties),
189 autorest.WithQueryParameters(queryParameters))
190 return preparer.Prepare((&http.Request{}).WithContext(ctx))
191 }
192
193
194
195 func (client ComponentCurrentBillingFeaturesClient) UpdateSender(req *http.Request) (*http.Response, error) {
196 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
197 }
198
199
200
201 func (client ComponentCurrentBillingFeaturesClient) UpdateResponder(resp *http.Response) (result ApplicationInsightsComponentBillingFeatures, err error) {
202 err = autorest.Respond(
203 resp,
204 azure.WithErrorUnlessStatusCode(http.StatusOK),
205 autorest.ByUnmarshallingJSON(&result),
206 autorest.ByClosing())
207 result.Response = autorest.Response{Response: resp}
208 return
209 }
210
View as plain text