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