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 AnalyticsItemsClient struct {
20 BaseClient
21 }
22
23
24 func NewAnalyticsItemsClient(subscriptionID string) AnalyticsItemsClient {
25 return NewAnalyticsItemsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30 func NewAnalyticsItemsClientWithBaseURI(baseURI string, subscriptionID string) AnalyticsItemsClient {
31 return AnalyticsItemsClient{NewWithBaseURI(baseURI, subscriptionID)}
32 }
33
34
35
36
37
38
39
40
41
42 func (client AnalyticsItemsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, scopePath ItemScopePath, ID string, name string) (result autorest.Response, err error) {
43 if tracing.IsEnabled() {
44 ctx = tracing.StartSpan(ctx, fqdn+"/AnalyticsItemsClient.Delete")
45 defer func() {
46 sc := -1
47 if result.Response != nil {
48 sc = result.Response.StatusCode
49 }
50 tracing.EndSpan(ctx, sc, err)
51 }()
52 }
53 if err := validation.Validate([]validation.Validation{
54 {TargetValue: client.SubscriptionID,
55 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
56 {TargetValue: resourceGroupName,
57 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
58 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
59 return result, validation.NewError("insights.AnalyticsItemsClient", "Delete", err.Error())
60 }
61
62 req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName, scopePath, ID, name)
63 if err != nil {
64 err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "Delete", nil, "Failure preparing request")
65 return
66 }
67
68 resp, err := client.DeleteSender(req)
69 if err != nil {
70 result.Response = resp
71 err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "Delete", resp, "Failure sending request")
72 return
73 }
74
75 result, err = client.DeleteResponder(resp)
76 if err != nil {
77 err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "Delete", resp, "Failure responding to request")
78 return
79 }
80
81 return
82 }
83
84
85 func (client AnalyticsItemsClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string, scopePath ItemScopePath, ID string, name string) (*http.Request, error) {
86 pathParameters := map[string]interface{}{
87 "resourceGroupName": autorest.Encode("path", resourceGroupName),
88 "resourceName": autorest.Encode("path", resourceName),
89 "scopePath": autorest.Encode("path", scopePath),
90 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
91 }
92
93 const APIVersion = "2015-05-01"
94 queryParameters := map[string]interface{}{
95 "api-version": APIVersion,
96 }
97 if len(ID) > 0 {
98 queryParameters["id"] = autorest.Encode("query", ID)
99 }
100 if len(name) > 0 {
101 queryParameters["name"] = autorest.Encode("query", name)
102 }
103
104 preparer := autorest.CreatePreparer(
105 autorest.AsDelete(),
106 autorest.WithBaseURL(client.BaseURI),
107 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item", pathParameters),
108 autorest.WithQueryParameters(queryParameters))
109 return preparer.Prepare((&http.Request{}).WithContext(ctx))
110 }
111
112
113
114 func (client AnalyticsItemsClient) DeleteSender(req *http.Request) (*http.Response, error) {
115 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
116 }
117
118
119
120 func (client AnalyticsItemsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
121 err = autorest.Respond(
122 resp,
123 azure.WithErrorUnlessStatusCode(http.StatusOK),
124 autorest.ByClosing())
125 result.Response = resp
126 return
127 }
128
129
130
131
132
133
134
135
136
137 func (client AnalyticsItemsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, scopePath ItemScopePath, ID string, name string) (result ApplicationInsightsComponentAnalyticsItem, err error) {
138 if tracing.IsEnabled() {
139 ctx = tracing.StartSpan(ctx, fqdn+"/AnalyticsItemsClient.Get")
140 defer func() {
141 sc := -1
142 if result.Response.Response != nil {
143 sc = result.Response.Response.StatusCode
144 }
145 tracing.EndSpan(ctx, sc, err)
146 }()
147 }
148 if err := validation.Validate([]validation.Validation{
149 {TargetValue: client.SubscriptionID,
150 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
151 {TargetValue: resourceGroupName,
152 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
153 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
154 return result, validation.NewError("insights.AnalyticsItemsClient", "Get", err.Error())
155 }
156
157 req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, scopePath, ID, name)
158 if err != nil {
159 err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "Get", nil, "Failure preparing request")
160 return
161 }
162
163 resp, err := client.GetSender(req)
164 if err != nil {
165 result.Response = autorest.Response{Response: resp}
166 err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "Get", resp, "Failure sending request")
167 return
168 }
169
170 result, err = client.GetResponder(resp)
171 if err != nil {
172 err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "Get", resp, "Failure responding to request")
173 return
174 }
175
176 return
177 }
178
179
180 func (client AnalyticsItemsClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, scopePath ItemScopePath, ID string, name string) (*http.Request, error) {
181 pathParameters := map[string]interface{}{
182 "resourceGroupName": autorest.Encode("path", resourceGroupName),
183 "resourceName": autorest.Encode("path", resourceName),
184 "scopePath": autorest.Encode("path", scopePath),
185 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
186 }
187
188 const APIVersion = "2015-05-01"
189 queryParameters := map[string]interface{}{
190 "api-version": APIVersion,
191 }
192 if len(ID) > 0 {
193 queryParameters["id"] = autorest.Encode("query", ID)
194 }
195 if len(name) > 0 {
196 queryParameters["name"] = autorest.Encode("query", name)
197 }
198
199 preparer := autorest.CreatePreparer(
200 autorest.AsGet(),
201 autorest.WithBaseURL(client.BaseURI),
202 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item", pathParameters),
203 autorest.WithQueryParameters(queryParameters))
204 return preparer.Prepare((&http.Request{}).WithContext(ctx))
205 }
206
207
208
209 func (client AnalyticsItemsClient) GetSender(req *http.Request) (*http.Response, error) {
210 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
211 }
212
213
214
215 func (client AnalyticsItemsClient) GetResponder(resp *http.Response) (result ApplicationInsightsComponentAnalyticsItem, err error) {
216 err = autorest.Respond(
217 resp,
218 azure.WithErrorUnlessStatusCode(http.StatusOK),
219 autorest.ByUnmarshallingJSON(&result),
220 autorest.ByClosing())
221 result.Response = autorest.Response{Response: resp}
222 return
223 }
224
225
226
227
228
229
230
231
232
233
234
235
236 func (client AnalyticsItemsClient) List(ctx context.Context, resourceGroupName string, resourceName string, scopePath ItemScopePath, scope ItemScope, typeParameter ItemTypeParameter, includeContent *bool) (result ListApplicationInsightsComponentAnalyticsItem, err error) {
237 if tracing.IsEnabled() {
238 ctx = tracing.StartSpan(ctx, fqdn+"/AnalyticsItemsClient.List")
239 defer func() {
240 sc := -1
241 if result.Response.Response != nil {
242 sc = result.Response.Response.StatusCode
243 }
244 tracing.EndSpan(ctx, sc, err)
245 }()
246 }
247 if err := validation.Validate([]validation.Validation{
248 {TargetValue: client.SubscriptionID,
249 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
250 {TargetValue: resourceGroupName,
251 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
252 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
253 return result, validation.NewError("insights.AnalyticsItemsClient", "List", err.Error())
254 }
255
256 req, err := client.ListPreparer(ctx, resourceGroupName, resourceName, scopePath, scope, typeParameter, includeContent)
257 if err != nil {
258 err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "List", nil, "Failure preparing request")
259 return
260 }
261
262 resp, err := client.ListSender(req)
263 if err != nil {
264 result.Response = autorest.Response{Response: resp}
265 err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "List", resp, "Failure sending request")
266 return
267 }
268
269 result, err = client.ListResponder(resp)
270 if err != nil {
271 err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "List", resp, "Failure responding to request")
272 return
273 }
274
275 return
276 }
277
278
279 func (client AnalyticsItemsClient) ListPreparer(ctx context.Context, resourceGroupName string, resourceName string, scopePath ItemScopePath, scope ItemScope, typeParameter ItemTypeParameter, includeContent *bool) (*http.Request, error) {
280 pathParameters := map[string]interface{}{
281 "resourceGroupName": autorest.Encode("path", resourceGroupName),
282 "resourceName": autorest.Encode("path", resourceName),
283 "scopePath": autorest.Encode("path", scopePath),
284 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
285 }
286
287 const APIVersion = "2015-05-01"
288 queryParameters := map[string]interface{}{
289 "api-version": APIVersion,
290 }
291 if len(string(scope)) > 0 {
292 queryParameters["scope"] = autorest.Encode("query", scope)
293 } else {
294 queryParameters["scope"] = autorest.Encode("query", "shared")
295 }
296 if len(string(typeParameter)) > 0 {
297 queryParameters["type"] = autorest.Encode("query", typeParameter)
298 } else {
299 queryParameters["type"] = autorest.Encode("query", "none")
300 }
301 if includeContent != nil {
302 queryParameters["includeContent"] = autorest.Encode("query", *includeContent)
303 }
304
305 preparer := autorest.CreatePreparer(
306 autorest.AsGet(),
307 autorest.WithBaseURL(client.BaseURI),
308 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}", pathParameters),
309 autorest.WithQueryParameters(queryParameters))
310 return preparer.Prepare((&http.Request{}).WithContext(ctx))
311 }
312
313
314
315 func (client AnalyticsItemsClient) ListSender(req *http.Request) (*http.Response, error) {
316 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
317 }
318
319
320
321 func (client AnalyticsItemsClient) ListResponder(resp *http.Response) (result ListApplicationInsightsComponentAnalyticsItem, err error) {
322 err = autorest.Respond(
323 resp,
324 azure.WithErrorUnlessStatusCode(http.StatusOK),
325 autorest.ByUnmarshallingJSON(&result.Value),
326 autorest.ByClosing())
327 result.Response = autorest.Response{Response: resp}
328 return
329 }
330
331
332
333
334
335
336
337
338
339
340
341 func (client AnalyticsItemsClient) Put(ctx context.Context, resourceGroupName string, resourceName string, scopePath ItemScopePath, itemProperties ApplicationInsightsComponentAnalyticsItem, overrideItem *bool) (result ApplicationInsightsComponentAnalyticsItem, err error) {
342 if tracing.IsEnabled() {
343 ctx = tracing.StartSpan(ctx, fqdn+"/AnalyticsItemsClient.Put")
344 defer func() {
345 sc := -1
346 if result.Response.Response != nil {
347 sc = result.Response.Response.StatusCode
348 }
349 tracing.EndSpan(ctx, sc, err)
350 }()
351 }
352 if err := validation.Validate([]validation.Validation{
353 {TargetValue: client.SubscriptionID,
354 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
355 {TargetValue: resourceGroupName,
356 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
357 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
358 return result, validation.NewError("insights.AnalyticsItemsClient", "Put", err.Error())
359 }
360
361 req, err := client.PutPreparer(ctx, resourceGroupName, resourceName, scopePath, itemProperties, overrideItem)
362 if err != nil {
363 err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "Put", nil, "Failure preparing request")
364 return
365 }
366
367 resp, err := client.PutSender(req)
368 if err != nil {
369 result.Response = autorest.Response{Response: resp}
370 err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "Put", resp, "Failure sending request")
371 return
372 }
373
374 result, err = client.PutResponder(resp)
375 if err != nil {
376 err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "Put", resp, "Failure responding to request")
377 return
378 }
379
380 return
381 }
382
383
384 func (client AnalyticsItemsClient) PutPreparer(ctx context.Context, resourceGroupName string, resourceName string, scopePath ItemScopePath, itemProperties ApplicationInsightsComponentAnalyticsItem, overrideItem *bool) (*http.Request, error) {
385 pathParameters := map[string]interface{}{
386 "resourceGroupName": autorest.Encode("path", resourceGroupName),
387 "resourceName": autorest.Encode("path", resourceName),
388 "scopePath": autorest.Encode("path", scopePath),
389 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
390 }
391
392 const APIVersion = "2015-05-01"
393 queryParameters := map[string]interface{}{
394 "api-version": APIVersion,
395 }
396 if overrideItem != nil {
397 queryParameters["overrideItem"] = autorest.Encode("query", *overrideItem)
398 }
399
400 itemProperties.Version = nil
401 itemProperties.TimeCreated = nil
402 itemProperties.TimeModified = nil
403 preparer := autorest.CreatePreparer(
404 autorest.AsContentType("application/json; charset=utf-8"),
405 autorest.AsPut(),
406 autorest.WithBaseURL(client.BaseURI),
407 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item", pathParameters),
408 autorest.WithJSON(itemProperties),
409 autorest.WithQueryParameters(queryParameters))
410 return preparer.Prepare((&http.Request{}).WithContext(ctx))
411 }
412
413
414
415 func (client AnalyticsItemsClient) PutSender(req *http.Request) (*http.Response, error) {
416 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
417 }
418
419
420
421 func (client AnalyticsItemsClient) PutResponder(resp *http.Response) (result ApplicationInsightsComponentAnalyticsItem, err error) {
422 err = autorest.Respond(
423 resp,
424 azure.WithErrorUnlessStatusCode(http.StatusOK),
425 autorest.ByUnmarshallingJSON(&result),
426 autorest.ByClosing())
427 result.Response = autorest.Response{Response: resp}
428 return
429 }
430
View as plain text