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 ComponentsClient struct {
20 BaseClient
21 }
22
23
24 func NewComponentsClient(subscriptionID string) ComponentsClient {
25 return NewComponentsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30 func NewComponentsClientWithBaseURI(baseURI string, subscriptionID string) ComponentsClient {
31 return ComponentsClient{NewWithBaseURI(baseURI, subscriptionID)}
32 }
33
34
35
36
37
38
39
40 func (client ComponentsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, insightProperties ApplicationInsightsComponent) (result ApplicationInsightsComponent, err error) {
41 if tracing.IsEnabled() {
42 ctx = tracing.StartSpan(ctx, fqdn+"/ComponentsClient.CreateOrUpdate")
43 defer func() {
44 sc := -1
45 if result.Response.Response != nil {
46 sc = result.Response.Response.StatusCode
47 }
48 tracing.EndSpan(ctx, sc, err)
49 }()
50 }
51 if err := validation.Validate([]validation.Validation{
52 {TargetValue: resourceGroupName,
53 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
54 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
55 {TargetValue: client.SubscriptionID,
56 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
57 {TargetValue: insightProperties,
58 Constraints: []validation.Constraint{{Target: "insightProperties.Kind", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
59 return result, validation.NewError("insights.ComponentsClient", "CreateOrUpdate", err.Error())
60 }
61
62 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, insightProperties)
63 if err != nil {
64 err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "CreateOrUpdate", nil, "Failure preparing request")
65 return
66 }
67
68 resp, err := client.CreateOrUpdateSender(req)
69 if err != nil {
70 result.Response = autorest.Response{Response: resp}
71 err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "CreateOrUpdate", resp, "Failure sending request")
72 return
73 }
74
75 result, err = client.CreateOrUpdateResponder(resp)
76 if err != nil {
77 err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "CreateOrUpdate", resp, "Failure responding to request")
78 return
79 }
80
81 return
82 }
83
84
85 func (client ComponentsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, insightProperties ApplicationInsightsComponent) (*http.Request, error) {
86 pathParameters := map[string]interface{}{
87 "resourceGroupName": autorest.Encode("path", resourceGroupName),
88 "resourceName": autorest.Encode("path", resourceName),
89 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
90 }
91
92 const APIVersion = "2018-05-01-preview"
93 queryParameters := map[string]interface{}{
94 "api-version": APIVersion,
95 }
96
97 preparer := autorest.CreatePreparer(
98 autorest.AsContentType("application/json; charset=utf-8"),
99 autorest.AsPut(),
100 autorest.WithBaseURL(client.BaseURI),
101 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}", pathParameters),
102 autorest.WithJSON(insightProperties),
103 autorest.WithQueryParameters(queryParameters))
104 return preparer.Prepare((&http.Request{}).WithContext(ctx))
105 }
106
107
108
109 func (client ComponentsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
110 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
111 }
112
113
114
115 func (client ComponentsClient) CreateOrUpdateResponder(resp *http.Response) (result ApplicationInsightsComponent, err error) {
116 err = autorest.Respond(
117 resp,
118 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
119 autorest.ByUnmarshallingJSON(&result),
120 autorest.ByClosing())
121 result.Response = autorest.Response{Response: resp}
122 return
123 }
124
125
126
127
128
129 func (client ComponentsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result autorest.Response, err error) {
130 if tracing.IsEnabled() {
131 ctx = tracing.StartSpan(ctx, fqdn+"/ComponentsClient.Delete")
132 defer func() {
133 sc := -1
134 if result.Response != nil {
135 sc = result.Response.StatusCode
136 }
137 tracing.EndSpan(ctx, sc, err)
138 }()
139 }
140 if err := validation.Validate([]validation.Validation{
141 {TargetValue: resourceGroupName,
142 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
143 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
144 {TargetValue: client.SubscriptionID,
145 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
146 return result, validation.NewError("insights.ComponentsClient", "Delete", err.Error())
147 }
148
149 req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName)
150 if err != nil {
151 err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "Delete", nil, "Failure preparing request")
152 return
153 }
154
155 resp, err := client.DeleteSender(req)
156 if err != nil {
157 result.Response = resp
158 err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "Delete", resp, "Failure sending request")
159 return
160 }
161
162 result, err = client.DeleteResponder(resp)
163 if err != nil {
164 err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "Delete", resp, "Failure responding to request")
165 return
166 }
167
168 return
169 }
170
171
172 func (client ComponentsClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) {
173 pathParameters := map[string]interface{}{
174 "resourceGroupName": autorest.Encode("path", resourceGroupName),
175 "resourceName": autorest.Encode("path", resourceName),
176 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
177 }
178
179 const APIVersion = "2018-05-01-preview"
180 queryParameters := map[string]interface{}{
181 "api-version": APIVersion,
182 }
183
184 preparer := autorest.CreatePreparer(
185 autorest.AsDelete(),
186 autorest.WithBaseURL(client.BaseURI),
187 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}", pathParameters),
188 autorest.WithQueryParameters(queryParameters))
189 return preparer.Prepare((&http.Request{}).WithContext(ctx))
190 }
191
192
193
194 func (client ComponentsClient) DeleteSender(req *http.Request) (*http.Response, error) {
195 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
196 }
197
198
199
200 func (client ComponentsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
201 err = autorest.Respond(
202 resp,
203 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
204 autorest.ByClosing())
205 result.Response = resp
206 return
207 }
208
209
210
211
212
213 func (client ComponentsClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result ApplicationInsightsComponent, err error) {
214 if tracing.IsEnabled() {
215 ctx = tracing.StartSpan(ctx, fqdn+"/ComponentsClient.Get")
216 defer func() {
217 sc := -1
218 if result.Response.Response != nil {
219 sc = result.Response.Response.StatusCode
220 }
221 tracing.EndSpan(ctx, sc, err)
222 }()
223 }
224 if err := validation.Validate([]validation.Validation{
225 {TargetValue: resourceGroupName,
226 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
227 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
228 {TargetValue: client.SubscriptionID,
229 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
230 return result, validation.NewError("insights.ComponentsClient", "Get", err.Error())
231 }
232
233 req, err := client.GetPreparer(ctx, resourceGroupName, resourceName)
234 if err != nil {
235 err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "Get", nil, "Failure preparing request")
236 return
237 }
238
239 resp, err := client.GetSender(req)
240 if err != nil {
241 result.Response = autorest.Response{Response: resp}
242 err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "Get", resp, "Failure sending request")
243 return
244 }
245
246 result, err = client.GetResponder(resp)
247 if err != nil {
248 err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "Get", resp, "Failure responding to request")
249 return
250 }
251
252 return
253 }
254
255
256 func (client ComponentsClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) {
257 pathParameters := map[string]interface{}{
258 "resourceGroupName": autorest.Encode("path", resourceGroupName),
259 "resourceName": autorest.Encode("path", resourceName),
260 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
261 }
262
263 const APIVersion = "2018-05-01-preview"
264 queryParameters := map[string]interface{}{
265 "api-version": APIVersion,
266 }
267
268 preparer := autorest.CreatePreparer(
269 autorest.AsGet(),
270 autorest.WithBaseURL(client.BaseURI),
271 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}", pathParameters),
272 autorest.WithQueryParameters(queryParameters))
273 return preparer.Prepare((&http.Request{}).WithContext(ctx))
274 }
275
276
277
278 func (client ComponentsClient) GetSender(req *http.Request) (*http.Response, error) {
279 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
280 }
281
282
283
284 func (client ComponentsClient) GetResponder(resp *http.Response) (result ApplicationInsightsComponent, err error) {
285 err = autorest.Respond(
286 resp,
287 azure.WithErrorUnlessStatusCode(http.StatusOK),
288 autorest.ByUnmarshallingJSON(&result),
289 autorest.ByClosing())
290 result.Response = autorest.Response{Response: resp}
291 return
292 }
293
294
295
296
297
298
299 func (client ComponentsClient) GetPurgeStatus(ctx context.Context, resourceGroupName string, resourceName string, purgeID string) (result ComponentPurgeStatusResponse, err error) {
300 if tracing.IsEnabled() {
301 ctx = tracing.StartSpan(ctx, fqdn+"/ComponentsClient.GetPurgeStatus")
302 defer func() {
303 sc := -1
304 if result.Response.Response != nil {
305 sc = result.Response.Response.StatusCode
306 }
307 tracing.EndSpan(ctx, sc, err)
308 }()
309 }
310 if err := validation.Validate([]validation.Validation{
311 {TargetValue: resourceGroupName,
312 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
313 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
314 {TargetValue: client.SubscriptionID,
315 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
316 return result, validation.NewError("insights.ComponentsClient", "GetPurgeStatus", err.Error())
317 }
318
319 req, err := client.GetPurgeStatusPreparer(ctx, resourceGroupName, resourceName, purgeID)
320 if err != nil {
321 err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "GetPurgeStatus", nil, "Failure preparing request")
322 return
323 }
324
325 resp, err := client.GetPurgeStatusSender(req)
326 if err != nil {
327 result.Response = autorest.Response{Response: resp}
328 err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "GetPurgeStatus", resp, "Failure sending request")
329 return
330 }
331
332 result, err = client.GetPurgeStatusResponder(resp)
333 if err != nil {
334 err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "GetPurgeStatus", resp, "Failure responding to request")
335 return
336 }
337
338 return
339 }
340
341
342 func (client ComponentsClient) GetPurgeStatusPreparer(ctx context.Context, resourceGroupName string, resourceName string, purgeID string) (*http.Request, error) {
343 pathParameters := map[string]interface{}{
344 "purgeId": autorest.Encode("path", purgeID),
345 "resourceGroupName": autorest.Encode("path", resourceGroupName),
346 "resourceName": autorest.Encode("path", resourceName),
347 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
348 }
349
350 const APIVersion = "2018-05-01-preview"
351 queryParameters := map[string]interface{}{
352 "api-version": APIVersion,
353 }
354
355 preparer := autorest.CreatePreparer(
356 autorest.AsGet(),
357 autorest.WithBaseURL(client.BaseURI),
358 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/operations/{purgeId}", pathParameters),
359 autorest.WithQueryParameters(queryParameters))
360 return preparer.Prepare((&http.Request{}).WithContext(ctx))
361 }
362
363
364
365 func (client ComponentsClient) GetPurgeStatusSender(req *http.Request) (*http.Response, error) {
366 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
367 }
368
369
370
371 func (client ComponentsClient) GetPurgeStatusResponder(resp *http.Response) (result ComponentPurgeStatusResponse, err error) {
372 err = autorest.Respond(
373 resp,
374 azure.WithErrorUnlessStatusCode(http.StatusOK),
375 autorest.ByUnmarshallingJSON(&result),
376 autorest.ByClosing())
377 result.Response = autorest.Response{Response: resp}
378 return
379 }
380
381
382 func (client ComponentsClient) List(ctx context.Context) (result ApplicationInsightsComponentListResultPage, err error) {
383 if tracing.IsEnabled() {
384 ctx = tracing.StartSpan(ctx, fqdn+"/ComponentsClient.List")
385 defer func() {
386 sc := -1
387 if result.aiclr.Response.Response != nil {
388 sc = result.aiclr.Response.Response.StatusCode
389 }
390 tracing.EndSpan(ctx, sc, err)
391 }()
392 }
393 if err := validation.Validate([]validation.Validation{
394 {TargetValue: client.SubscriptionID,
395 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
396 return result, validation.NewError("insights.ComponentsClient", "List", err.Error())
397 }
398
399 result.fn = client.listNextResults
400 req, err := client.ListPreparer(ctx)
401 if err != nil {
402 err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "List", nil, "Failure preparing request")
403 return
404 }
405
406 resp, err := client.ListSender(req)
407 if err != nil {
408 result.aiclr.Response = autorest.Response{Response: resp}
409 err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "List", resp, "Failure sending request")
410 return
411 }
412
413 result.aiclr, err = client.ListResponder(resp)
414 if err != nil {
415 err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "List", resp, "Failure responding to request")
416 return
417 }
418 if result.aiclr.hasNextLink() && result.aiclr.IsEmpty() {
419 err = result.NextWithContext(ctx)
420 return
421 }
422
423 return
424 }
425
426
427 func (client ComponentsClient) ListPreparer(ctx context.Context) (*http.Request, error) {
428 pathParameters := map[string]interface{}{
429 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
430 }
431
432 const APIVersion = "2018-05-01-preview"
433 queryParameters := map[string]interface{}{
434 "api-version": APIVersion,
435 }
436
437 preparer := autorest.CreatePreparer(
438 autorest.AsGet(),
439 autorest.WithBaseURL(client.BaseURI),
440 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Insights/components", pathParameters),
441 autorest.WithQueryParameters(queryParameters))
442 return preparer.Prepare((&http.Request{}).WithContext(ctx))
443 }
444
445
446
447 func (client ComponentsClient) ListSender(req *http.Request) (*http.Response, error) {
448 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
449 }
450
451
452
453 func (client ComponentsClient) ListResponder(resp *http.Response) (result ApplicationInsightsComponentListResult, err error) {
454 err = autorest.Respond(
455 resp,
456 azure.WithErrorUnlessStatusCode(http.StatusOK),
457 autorest.ByUnmarshallingJSON(&result),
458 autorest.ByClosing())
459 result.Response = autorest.Response{Response: resp}
460 return
461 }
462
463
464 func (client ComponentsClient) listNextResults(ctx context.Context, lastResults ApplicationInsightsComponentListResult) (result ApplicationInsightsComponentListResult, err error) {
465 req, err := lastResults.applicationInsightsComponentListResultPreparer(ctx)
466 if err != nil {
467 return result, autorest.NewErrorWithError(err, "insights.ComponentsClient", "listNextResults", nil, "Failure preparing next results request")
468 }
469 if req == nil {
470 return
471 }
472 resp, err := client.ListSender(req)
473 if err != nil {
474 result.Response = autorest.Response{Response: resp}
475 return result, autorest.NewErrorWithError(err, "insights.ComponentsClient", "listNextResults", resp, "Failure sending next results request")
476 }
477 result, err = client.ListResponder(resp)
478 if err != nil {
479 err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "listNextResults", resp, "Failure responding to next results request")
480 }
481 return
482 }
483
484
485 func (client ComponentsClient) ListComplete(ctx context.Context) (result ApplicationInsightsComponentListResultIterator, err error) {
486 if tracing.IsEnabled() {
487 ctx = tracing.StartSpan(ctx, fqdn+"/ComponentsClient.List")
488 defer func() {
489 sc := -1
490 if result.Response().Response.Response != nil {
491 sc = result.page.Response().Response.Response.StatusCode
492 }
493 tracing.EndSpan(ctx, sc, err)
494 }()
495 }
496 result.page, err = client.List(ctx)
497 return
498 }
499
500
501
502
503 func (client ComponentsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ApplicationInsightsComponentListResultPage, err error) {
504 if tracing.IsEnabled() {
505 ctx = tracing.StartSpan(ctx, fqdn+"/ComponentsClient.ListByResourceGroup")
506 defer func() {
507 sc := -1
508 if result.aiclr.Response.Response != nil {
509 sc = result.aiclr.Response.Response.StatusCode
510 }
511 tracing.EndSpan(ctx, sc, err)
512 }()
513 }
514 if err := validation.Validate([]validation.Validation{
515 {TargetValue: resourceGroupName,
516 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
517 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
518 {TargetValue: client.SubscriptionID,
519 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
520 return result, validation.NewError("insights.ComponentsClient", "ListByResourceGroup", err.Error())
521 }
522
523 result.fn = client.listByResourceGroupNextResults
524 req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
525 if err != nil {
526 err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "ListByResourceGroup", nil, "Failure preparing request")
527 return
528 }
529
530 resp, err := client.ListByResourceGroupSender(req)
531 if err != nil {
532 result.aiclr.Response = autorest.Response{Response: resp}
533 err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "ListByResourceGroup", resp, "Failure sending request")
534 return
535 }
536
537 result.aiclr, err = client.ListByResourceGroupResponder(resp)
538 if err != nil {
539 err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "ListByResourceGroup", resp, "Failure responding to request")
540 return
541 }
542 if result.aiclr.hasNextLink() && result.aiclr.IsEmpty() {
543 err = result.NextWithContext(ctx)
544 return
545 }
546
547 return
548 }
549
550
551 func (client ComponentsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
552 pathParameters := map[string]interface{}{
553 "resourceGroupName": autorest.Encode("path", resourceGroupName),
554 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
555 }
556
557 const APIVersion = "2018-05-01-preview"
558 queryParameters := map[string]interface{}{
559 "api-version": APIVersion,
560 }
561
562 preparer := autorest.CreatePreparer(
563 autorest.AsGet(),
564 autorest.WithBaseURL(client.BaseURI),
565 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components", pathParameters),
566 autorest.WithQueryParameters(queryParameters))
567 return preparer.Prepare((&http.Request{}).WithContext(ctx))
568 }
569
570
571
572 func (client ComponentsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
573 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
574 }
575
576
577
578 func (client ComponentsClient) ListByResourceGroupResponder(resp *http.Response) (result ApplicationInsightsComponentListResult, err error) {
579 err = autorest.Respond(
580 resp,
581 azure.WithErrorUnlessStatusCode(http.StatusOK),
582 autorest.ByUnmarshallingJSON(&result),
583 autorest.ByClosing())
584 result.Response = autorest.Response{Response: resp}
585 return
586 }
587
588
589 func (client ComponentsClient) listByResourceGroupNextResults(ctx context.Context, lastResults ApplicationInsightsComponentListResult) (result ApplicationInsightsComponentListResult, err error) {
590 req, err := lastResults.applicationInsightsComponentListResultPreparer(ctx)
591 if err != nil {
592 return result, autorest.NewErrorWithError(err, "insights.ComponentsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
593 }
594 if req == nil {
595 return
596 }
597 resp, err := client.ListByResourceGroupSender(req)
598 if err != nil {
599 result.Response = autorest.Response{Response: resp}
600 return result, autorest.NewErrorWithError(err, "insights.ComponentsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
601 }
602 result, err = client.ListByResourceGroupResponder(resp)
603 if err != nil {
604 err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
605 }
606 return
607 }
608
609
610 func (client ComponentsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ApplicationInsightsComponentListResultIterator, err error) {
611 if tracing.IsEnabled() {
612 ctx = tracing.StartSpan(ctx, fqdn+"/ComponentsClient.ListByResourceGroup")
613 defer func() {
614 sc := -1
615 if result.Response().Response.Response != nil {
616 sc = result.page.Response().Response.Response.StatusCode
617 }
618 tracing.EndSpan(ctx, sc, err)
619 }()
620 }
621 result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
622 return
623 }
624
625
626
627
628
629
630
631
632
633
634
635 func (client ComponentsClient) Purge(ctx context.Context, resourceGroupName string, resourceName string, body ComponentPurgeBody) (result ComponentPurgeResponse, err error) {
636 if tracing.IsEnabled() {
637 ctx = tracing.StartSpan(ctx, fqdn+"/ComponentsClient.Purge")
638 defer func() {
639 sc := -1
640 if result.Response.Response != nil {
641 sc = result.Response.Response.StatusCode
642 }
643 tracing.EndSpan(ctx, sc, err)
644 }()
645 }
646 if err := validation.Validate([]validation.Validation{
647 {TargetValue: resourceGroupName,
648 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
649 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
650 {TargetValue: client.SubscriptionID,
651 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
652 {TargetValue: body,
653 Constraints: []validation.Constraint{{Target: "body.Table", Name: validation.Null, Rule: true, Chain: nil},
654 {Target: "body.Filters", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
655 return result, validation.NewError("insights.ComponentsClient", "Purge", err.Error())
656 }
657
658 req, err := client.PurgePreparer(ctx, resourceGroupName, resourceName, body)
659 if err != nil {
660 err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "Purge", nil, "Failure preparing request")
661 return
662 }
663
664 resp, err := client.PurgeSender(req)
665 if err != nil {
666 result.Response = autorest.Response{Response: resp}
667 err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "Purge", resp, "Failure sending request")
668 return
669 }
670
671 result, err = client.PurgeResponder(resp)
672 if err != nil {
673 err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "Purge", resp, "Failure responding to request")
674 return
675 }
676
677 return
678 }
679
680
681 func (client ComponentsClient) PurgePreparer(ctx context.Context, resourceGroupName string, resourceName string, body ComponentPurgeBody) (*http.Request, error) {
682 pathParameters := map[string]interface{}{
683 "resourceGroupName": autorest.Encode("path", resourceGroupName),
684 "resourceName": autorest.Encode("path", resourceName),
685 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
686 }
687
688 const APIVersion = "2018-05-01-preview"
689 queryParameters := map[string]interface{}{
690 "api-version": APIVersion,
691 }
692
693 preparer := autorest.CreatePreparer(
694 autorest.AsContentType("application/json; charset=utf-8"),
695 autorest.AsPost(),
696 autorest.WithBaseURL(client.BaseURI),
697 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/purge", pathParameters),
698 autorest.WithJSON(body),
699 autorest.WithQueryParameters(queryParameters))
700 return preparer.Prepare((&http.Request{}).WithContext(ctx))
701 }
702
703
704
705 func (client ComponentsClient) PurgeSender(req *http.Request) (*http.Response, error) {
706 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
707 }
708
709
710
711 func (client ComponentsClient) PurgeResponder(resp *http.Response) (result ComponentPurgeResponse, err error) {
712 err = autorest.Respond(
713 resp,
714 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
715 autorest.ByUnmarshallingJSON(&result),
716 autorest.ByClosing())
717 result.Response = autorest.Response{Response: resp}
718 return
719 }
720
721
722
723
724
725
726 func (client ComponentsClient) UpdateTags(ctx context.Context, resourceGroupName string, resourceName string, componentTags TagsResource) (result ApplicationInsightsComponent, err error) {
727 if tracing.IsEnabled() {
728 ctx = tracing.StartSpan(ctx, fqdn+"/ComponentsClient.UpdateTags")
729 defer func() {
730 sc := -1
731 if result.Response.Response != nil {
732 sc = result.Response.Response.StatusCode
733 }
734 tracing.EndSpan(ctx, sc, err)
735 }()
736 }
737 if err := validation.Validate([]validation.Validation{
738 {TargetValue: resourceGroupName,
739 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
740 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
741 {TargetValue: client.SubscriptionID,
742 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
743 return result, validation.NewError("insights.ComponentsClient", "UpdateTags", err.Error())
744 }
745
746 req, err := client.UpdateTagsPreparer(ctx, resourceGroupName, resourceName, componentTags)
747 if err != nil {
748 err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "UpdateTags", nil, "Failure preparing request")
749 return
750 }
751
752 resp, err := client.UpdateTagsSender(req)
753 if err != nil {
754 result.Response = autorest.Response{Response: resp}
755 err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "UpdateTags", resp, "Failure sending request")
756 return
757 }
758
759 result, err = client.UpdateTagsResponder(resp)
760 if err != nil {
761 err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "UpdateTags", resp, "Failure responding to request")
762 return
763 }
764
765 return
766 }
767
768
769 func (client ComponentsClient) UpdateTagsPreparer(ctx context.Context, resourceGroupName string, resourceName string, componentTags TagsResource) (*http.Request, error) {
770 pathParameters := map[string]interface{}{
771 "resourceGroupName": autorest.Encode("path", resourceGroupName),
772 "resourceName": autorest.Encode("path", resourceName),
773 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
774 }
775
776 const APIVersion = "2018-05-01-preview"
777 queryParameters := map[string]interface{}{
778 "api-version": APIVersion,
779 }
780
781 preparer := autorest.CreatePreparer(
782 autorest.AsContentType("application/json; charset=utf-8"),
783 autorest.AsPatch(),
784 autorest.WithBaseURL(client.BaseURI),
785 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}", pathParameters),
786 autorest.WithJSON(componentTags),
787 autorest.WithQueryParameters(queryParameters))
788 return preparer.Prepare((&http.Request{}).WithContext(ctx))
789 }
790
791
792
793 func (client ComponentsClient) UpdateTagsSender(req *http.Request) (*http.Response, error) {
794 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
795 }
796
797
798
799 func (client ComponentsClient) UpdateTagsResponder(resp *http.Response) (result ApplicationInsightsComponent, err error) {
800 err = autorest.Respond(
801 resp,
802 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
803 autorest.ByUnmarshallingJSON(&result),
804 autorest.ByClosing())
805 result.Response = autorest.Response{Response: resp}
806 return
807 }
808
View as plain text