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 DataCollectionRuleAssociationsClient struct {
20 BaseClient
21 }
22
23
24 func NewDataCollectionRuleAssociationsClient(subscriptionID string) DataCollectionRuleAssociationsClient {
25 return NewDataCollectionRuleAssociationsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30
31 func NewDataCollectionRuleAssociationsClientWithBaseURI(baseURI string, subscriptionID string) DataCollectionRuleAssociationsClient {
32 return DataCollectionRuleAssociationsClient{NewWithBaseURI(baseURI, subscriptionID)}
33 }
34
35
36
37
38
39
40 func (client DataCollectionRuleAssociationsClient) Create(ctx context.Context, resourceURI string, associationName string, body *DataCollectionRuleAssociationProxyOnlyResource) (result DataCollectionRuleAssociationProxyOnlyResource, err error) {
41 if tracing.IsEnabled() {
42 ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRuleAssociationsClient.Create")
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: resourceURI,
53 Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
54 return result, validation.NewError("insights.DataCollectionRuleAssociationsClient", "Create", err.Error())
55 }
56
57 req, err := client.CreatePreparer(ctx, resourceURI, associationName, body)
58 if err != nil {
59 err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "Create", nil, "Failure preparing request")
60 return
61 }
62
63 resp, err := client.CreateSender(req)
64 if err != nil {
65 result.Response = autorest.Response{Response: resp}
66 err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "Create", resp, "Failure sending request")
67 return
68 }
69
70 result, err = client.CreateResponder(resp)
71 if err != nil {
72 err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "Create", resp, "Failure responding to request")
73 return
74 }
75
76 return
77 }
78
79
80 func (client DataCollectionRuleAssociationsClient) CreatePreparer(ctx context.Context, resourceURI string, associationName string, body *DataCollectionRuleAssociationProxyOnlyResource) (*http.Request, error) {
81 pathParameters := map[string]interface{}{
82 "associationName": autorest.Encode("path", associationName),
83 "resourceUri": resourceURI,
84 }
85
86 const APIVersion = "2021-09-01-preview"
87 queryParameters := map[string]interface{}{
88 "api-version": APIVersion,
89 }
90
91 body.ID = nil
92 body.Name = nil
93 body.Type = nil
94 body.Etag = nil
95 body.SystemData = nil
96 preparer := autorest.CreatePreparer(
97 autorest.AsContentType("application/json; charset=utf-8"),
98 autorest.AsPut(),
99 autorest.WithBaseURL(client.BaseURI),
100 autorest.WithPathParameters("/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}", pathParameters),
101 autorest.WithQueryParameters(queryParameters))
102 if body != nil {
103 preparer = autorest.DecoratePreparer(preparer,
104 autorest.WithJSON(body))
105 }
106 return preparer.Prepare((&http.Request{}).WithContext(ctx))
107 }
108
109
110
111 func (client DataCollectionRuleAssociationsClient) CreateSender(req *http.Request) (*http.Response, error) {
112 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
113 }
114
115
116
117 func (client DataCollectionRuleAssociationsClient) CreateResponder(resp *http.Response) (result DataCollectionRuleAssociationProxyOnlyResource, err error) {
118 err = autorest.Respond(
119 resp,
120 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
121 autorest.ByUnmarshallingJSON(&result),
122 autorest.ByClosing())
123 result.Response = autorest.Response{Response: resp}
124 return
125 }
126
127
128
129
130
131 func (client DataCollectionRuleAssociationsClient) Delete(ctx context.Context, resourceURI string, associationName string) (result autorest.Response, err error) {
132 if tracing.IsEnabled() {
133 ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRuleAssociationsClient.Delete")
134 defer func() {
135 sc := -1
136 if result.Response != nil {
137 sc = result.Response.StatusCode
138 }
139 tracing.EndSpan(ctx, sc, err)
140 }()
141 }
142 if err := validation.Validate([]validation.Validation{
143 {TargetValue: resourceURI,
144 Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
145 return result, validation.NewError("insights.DataCollectionRuleAssociationsClient", "Delete", err.Error())
146 }
147
148 req, err := client.DeletePreparer(ctx, resourceURI, associationName)
149 if err != nil {
150 err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "Delete", nil, "Failure preparing request")
151 return
152 }
153
154 resp, err := client.DeleteSender(req)
155 if err != nil {
156 result.Response = resp
157 err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "Delete", resp, "Failure sending request")
158 return
159 }
160
161 result, err = client.DeleteResponder(resp)
162 if err != nil {
163 err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "Delete", resp, "Failure responding to request")
164 return
165 }
166
167 return
168 }
169
170
171 func (client DataCollectionRuleAssociationsClient) DeletePreparer(ctx context.Context, resourceURI string, associationName string) (*http.Request, error) {
172 pathParameters := map[string]interface{}{
173 "associationName": autorest.Encode("path", associationName),
174 "resourceUri": resourceURI,
175 }
176
177 const APIVersion = "2021-09-01-preview"
178 queryParameters := map[string]interface{}{
179 "api-version": APIVersion,
180 }
181
182 preparer := autorest.CreatePreparer(
183 autorest.AsDelete(),
184 autorest.WithBaseURL(client.BaseURI),
185 autorest.WithPathParameters("/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}", pathParameters),
186 autorest.WithQueryParameters(queryParameters))
187 return preparer.Prepare((&http.Request{}).WithContext(ctx))
188 }
189
190
191
192 func (client DataCollectionRuleAssociationsClient) DeleteSender(req *http.Request) (*http.Response, error) {
193 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
194 }
195
196
197
198 func (client DataCollectionRuleAssociationsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
199 err = autorest.Respond(
200 resp,
201 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
202 autorest.ByClosing())
203 result.Response = resp
204 return
205 }
206
207
208
209
210
211 func (client DataCollectionRuleAssociationsClient) Get(ctx context.Context, resourceURI string, associationName string) (result DataCollectionRuleAssociationProxyOnlyResource, err error) {
212 if tracing.IsEnabled() {
213 ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRuleAssociationsClient.Get")
214 defer func() {
215 sc := -1
216 if result.Response.Response != nil {
217 sc = result.Response.Response.StatusCode
218 }
219 tracing.EndSpan(ctx, sc, err)
220 }()
221 }
222 if err := validation.Validate([]validation.Validation{
223 {TargetValue: resourceURI,
224 Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
225 return result, validation.NewError("insights.DataCollectionRuleAssociationsClient", "Get", err.Error())
226 }
227
228 req, err := client.GetPreparer(ctx, resourceURI, associationName)
229 if err != nil {
230 err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "Get", nil, "Failure preparing request")
231 return
232 }
233
234 resp, err := client.GetSender(req)
235 if err != nil {
236 result.Response = autorest.Response{Response: resp}
237 err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "Get", resp, "Failure sending request")
238 return
239 }
240
241 result, err = client.GetResponder(resp)
242 if err != nil {
243 err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "Get", resp, "Failure responding to request")
244 return
245 }
246
247 return
248 }
249
250
251 func (client DataCollectionRuleAssociationsClient) GetPreparer(ctx context.Context, resourceURI string, associationName string) (*http.Request, error) {
252 pathParameters := map[string]interface{}{
253 "associationName": autorest.Encode("path", associationName),
254 "resourceUri": resourceURI,
255 }
256
257 const APIVersion = "2021-09-01-preview"
258 queryParameters := map[string]interface{}{
259 "api-version": APIVersion,
260 }
261
262 preparer := autorest.CreatePreparer(
263 autorest.AsGet(),
264 autorest.WithBaseURL(client.BaseURI),
265 autorest.WithPathParameters("/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}", pathParameters),
266 autorest.WithQueryParameters(queryParameters))
267 return preparer.Prepare((&http.Request{}).WithContext(ctx))
268 }
269
270
271
272 func (client DataCollectionRuleAssociationsClient) GetSender(req *http.Request) (*http.Response, error) {
273 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
274 }
275
276
277
278 func (client DataCollectionRuleAssociationsClient) GetResponder(resp *http.Response) (result DataCollectionRuleAssociationProxyOnlyResource, err error) {
279 err = autorest.Respond(
280 resp,
281 azure.WithErrorUnlessStatusCode(http.StatusOK),
282 autorest.ByUnmarshallingJSON(&result),
283 autorest.ByClosing())
284 result.Response = autorest.Response{Response: resp}
285 return
286 }
287
288
289
290
291
292 func (client DataCollectionRuleAssociationsClient) ListByDataCollectionEndpoint(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string) (result DataCollectionRuleAssociationProxyOnlyResourceListResultPage, err error) {
293 if tracing.IsEnabled() {
294 ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRuleAssociationsClient.ListByDataCollectionEndpoint")
295 defer func() {
296 sc := -1
297 if result.dcraporlr.Response.Response != nil {
298 sc = result.dcraporlr.Response.Response.StatusCode
299 }
300 tracing.EndSpan(ctx, sc, err)
301 }()
302 }
303 if err := validation.Validate([]validation.Validation{
304 {TargetValue: client.SubscriptionID,
305 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
306 {TargetValue: resourceGroupName,
307 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
308 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
309 return result, validation.NewError("insights.DataCollectionRuleAssociationsClient", "ListByDataCollectionEndpoint", err.Error())
310 }
311
312 result.fn = client.listByDataCollectionEndpointNextResults
313 req, err := client.ListByDataCollectionEndpointPreparer(ctx, resourceGroupName, dataCollectionEndpointName)
314 if err != nil {
315 err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "ListByDataCollectionEndpoint", nil, "Failure preparing request")
316 return
317 }
318
319 resp, err := client.ListByDataCollectionEndpointSender(req)
320 if err != nil {
321 result.dcraporlr.Response = autorest.Response{Response: resp}
322 err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "ListByDataCollectionEndpoint", resp, "Failure sending request")
323 return
324 }
325
326 result.dcraporlr, err = client.ListByDataCollectionEndpointResponder(resp)
327 if err != nil {
328 err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "ListByDataCollectionEndpoint", resp, "Failure responding to request")
329 return
330 }
331 if result.dcraporlr.hasNextLink() && result.dcraporlr.IsEmpty() {
332 err = result.NextWithContext(ctx)
333 return
334 }
335
336 return
337 }
338
339
340 func (client DataCollectionRuleAssociationsClient) ListByDataCollectionEndpointPreparer(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string) (*http.Request, error) {
341 pathParameters := map[string]interface{}{
342 "dataCollectionEndpointName": autorest.Encode("path", dataCollectionEndpointName),
343 "resourceGroupName": autorest.Encode("path", resourceGroupName),
344 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
345 }
346
347 const APIVersion = "2021-09-01-preview"
348 queryParameters := map[string]interface{}{
349 "api-version": APIVersion,
350 }
351
352 preparer := autorest.CreatePreparer(
353 autorest.AsGet(),
354 autorest.WithBaseURL(client.BaseURI),
355 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}/associations", pathParameters),
356 autorest.WithQueryParameters(queryParameters))
357 return preparer.Prepare((&http.Request{}).WithContext(ctx))
358 }
359
360
361
362 func (client DataCollectionRuleAssociationsClient) ListByDataCollectionEndpointSender(req *http.Request) (*http.Response, error) {
363 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
364 }
365
366
367
368 func (client DataCollectionRuleAssociationsClient) ListByDataCollectionEndpointResponder(resp *http.Response) (result DataCollectionRuleAssociationProxyOnlyResourceListResult, err error) {
369 err = autorest.Respond(
370 resp,
371 azure.WithErrorUnlessStatusCode(http.StatusOK),
372 autorest.ByUnmarshallingJSON(&result),
373 autorest.ByClosing())
374 result.Response = autorest.Response{Response: resp}
375 return
376 }
377
378
379 func (client DataCollectionRuleAssociationsClient) listByDataCollectionEndpointNextResults(ctx context.Context, lastResults DataCollectionRuleAssociationProxyOnlyResourceListResult) (result DataCollectionRuleAssociationProxyOnlyResourceListResult, err error) {
380 req, err := lastResults.dataCollectionRuleAssociationProxyOnlyResourceListResultPreparer(ctx)
381 if err != nil {
382 return result, autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "listByDataCollectionEndpointNextResults", nil, "Failure preparing next results request")
383 }
384 if req == nil {
385 return
386 }
387 resp, err := client.ListByDataCollectionEndpointSender(req)
388 if err != nil {
389 result.Response = autorest.Response{Response: resp}
390 return result, autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "listByDataCollectionEndpointNextResults", resp, "Failure sending next results request")
391 }
392 result, err = client.ListByDataCollectionEndpointResponder(resp)
393 if err != nil {
394 err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "listByDataCollectionEndpointNextResults", resp, "Failure responding to next results request")
395 }
396 return
397 }
398
399
400 func (client DataCollectionRuleAssociationsClient) ListByDataCollectionEndpointComplete(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string) (result DataCollectionRuleAssociationProxyOnlyResourceListResultIterator, err error) {
401 if tracing.IsEnabled() {
402 ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRuleAssociationsClient.ListByDataCollectionEndpoint")
403 defer func() {
404 sc := -1
405 if result.Response().Response.Response != nil {
406 sc = result.page.Response().Response.Response.StatusCode
407 }
408 tracing.EndSpan(ctx, sc, err)
409 }()
410 }
411 result.page, err = client.ListByDataCollectionEndpoint(ctx, resourceGroupName, dataCollectionEndpointName)
412 return
413 }
414
415
416
417
418 func (client DataCollectionRuleAssociationsClient) ListByResource(ctx context.Context, resourceURI string) (result DataCollectionRuleAssociationProxyOnlyResourceListResultPage, err error) {
419 if tracing.IsEnabled() {
420 ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRuleAssociationsClient.ListByResource")
421 defer func() {
422 sc := -1
423 if result.dcraporlr.Response.Response != nil {
424 sc = result.dcraporlr.Response.Response.StatusCode
425 }
426 tracing.EndSpan(ctx, sc, err)
427 }()
428 }
429 if err := validation.Validate([]validation.Validation{
430 {TargetValue: resourceURI,
431 Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
432 return result, validation.NewError("insights.DataCollectionRuleAssociationsClient", "ListByResource", err.Error())
433 }
434
435 result.fn = client.listByResourceNextResults
436 req, err := client.ListByResourcePreparer(ctx, resourceURI)
437 if err != nil {
438 err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "ListByResource", nil, "Failure preparing request")
439 return
440 }
441
442 resp, err := client.ListByResourceSender(req)
443 if err != nil {
444 result.dcraporlr.Response = autorest.Response{Response: resp}
445 err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "ListByResource", resp, "Failure sending request")
446 return
447 }
448
449 result.dcraporlr, err = client.ListByResourceResponder(resp)
450 if err != nil {
451 err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "ListByResource", resp, "Failure responding to request")
452 return
453 }
454 if result.dcraporlr.hasNextLink() && result.dcraporlr.IsEmpty() {
455 err = result.NextWithContext(ctx)
456 return
457 }
458
459 return
460 }
461
462
463 func (client DataCollectionRuleAssociationsClient) ListByResourcePreparer(ctx context.Context, resourceURI string) (*http.Request, error) {
464 pathParameters := map[string]interface{}{
465 "resourceUri": resourceURI,
466 }
467
468 const APIVersion = "2021-09-01-preview"
469 queryParameters := map[string]interface{}{
470 "api-version": APIVersion,
471 }
472
473 preparer := autorest.CreatePreparer(
474 autorest.AsGet(),
475 autorest.WithBaseURL(client.BaseURI),
476 autorest.WithPathParameters("/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations", pathParameters),
477 autorest.WithQueryParameters(queryParameters))
478 return preparer.Prepare((&http.Request{}).WithContext(ctx))
479 }
480
481
482
483 func (client DataCollectionRuleAssociationsClient) ListByResourceSender(req *http.Request) (*http.Response, error) {
484 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
485 }
486
487
488
489 func (client DataCollectionRuleAssociationsClient) ListByResourceResponder(resp *http.Response) (result DataCollectionRuleAssociationProxyOnlyResourceListResult, err error) {
490 err = autorest.Respond(
491 resp,
492 azure.WithErrorUnlessStatusCode(http.StatusOK),
493 autorest.ByUnmarshallingJSON(&result),
494 autorest.ByClosing())
495 result.Response = autorest.Response{Response: resp}
496 return
497 }
498
499
500 func (client DataCollectionRuleAssociationsClient) listByResourceNextResults(ctx context.Context, lastResults DataCollectionRuleAssociationProxyOnlyResourceListResult) (result DataCollectionRuleAssociationProxyOnlyResourceListResult, err error) {
501 req, err := lastResults.dataCollectionRuleAssociationProxyOnlyResourceListResultPreparer(ctx)
502 if err != nil {
503 return result, autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "listByResourceNextResults", nil, "Failure preparing next results request")
504 }
505 if req == nil {
506 return
507 }
508 resp, err := client.ListByResourceSender(req)
509 if err != nil {
510 result.Response = autorest.Response{Response: resp}
511 return result, autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "listByResourceNextResults", resp, "Failure sending next results request")
512 }
513 result, err = client.ListByResourceResponder(resp)
514 if err != nil {
515 err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "listByResourceNextResults", resp, "Failure responding to next results request")
516 }
517 return
518 }
519
520
521 func (client DataCollectionRuleAssociationsClient) ListByResourceComplete(ctx context.Context, resourceURI string) (result DataCollectionRuleAssociationProxyOnlyResourceListResultIterator, err error) {
522 if tracing.IsEnabled() {
523 ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRuleAssociationsClient.ListByResource")
524 defer func() {
525 sc := -1
526 if result.Response().Response.Response != nil {
527 sc = result.page.Response().Response.Response.StatusCode
528 }
529 tracing.EndSpan(ctx, sc, err)
530 }()
531 }
532 result.page, err = client.ListByResource(ctx, resourceURI)
533 return
534 }
535
536
537
538
539
540 func (client DataCollectionRuleAssociationsClient) ListByRule(ctx context.Context, resourceGroupName string, dataCollectionRuleName string) (result DataCollectionRuleAssociationProxyOnlyResourceListResultPage, err error) {
541 if tracing.IsEnabled() {
542 ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRuleAssociationsClient.ListByRule")
543 defer func() {
544 sc := -1
545 if result.dcraporlr.Response.Response != nil {
546 sc = result.dcraporlr.Response.Response.StatusCode
547 }
548 tracing.EndSpan(ctx, sc, err)
549 }()
550 }
551 if err := validation.Validate([]validation.Validation{
552 {TargetValue: client.SubscriptionID,
553 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
554 {TargetValue: resourceGroupName,
555 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
556 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
557 return result, validation.NewError("insights.DataCollectionRuleAssociationsClient", "ListByRule", err.Error())
558 }
559
560 result.fn = client.listByRuleNextResults
561 req, err := client.ListByRulePreparer(ctx, resourceGroupName, dataCollectionRuleName)
562 if err != nil {
563 err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "ListByRule", nil, "Failure preparing request")
564 return
565 }
566
567 resp, err := client.ListByRuleSender(req)
568 if err != nil {
569 result.dcraporlr.Response = autorest.Response{Response: resp}
570 err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "ListByRule", resp, "Failure sending request")
571 return
572 }
573
574 result.dcraporlr, err = client.ListByRuleResponder(resp)
575 if err != nil {
576 err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "ListByRule", resp, "Failure responding to request")
577 return
578 }
579 if result.dcraporlr.hasNextLink() && result.dcraporlr.IsEmpty() {
580 err = result.NextWithContext(ctx)
581 return
582 }
583
584 return
585 }
586
587
588 func (client DataCollectionRuleAssociationsClient) ListByRulePreparer(ctx context.Context, resourceGroupName string, dataCollectionRuleName string) (*http.Request, error) {
589 pathParameters := map[string]interface{}{
590 "dataCollectionRuleName": autorest.Encode("path", dataCollectionRuleName),
591 "resourceGroupName": autorest.Encode("path", resourceGroupName),
592 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
593 }
594
595 const APIVersion = "2021-09-01-preview"
596 queryParameters := map[string]interface{}{
597 "api-version": APIVersion,
598 }
599
600 preparer := autorest.CreatePreparer(
601 autorest.AsGet(),
602 autorest.WithBaseURL(client.BaseURI),
603 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations", pathParameters),
604 autorest.WithQueryParameters(queryParameters))
605 return preparer.Prepare((&http.Request{}).WithContext(ctx))
606 }
607
608
609
610 func (client DataCollectionRuleAssociationsClient) ListByRuleSender(req *http.Request) (*http.Response, error) {
611 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
612 }
613
614
615
616 func (client DataCollectionRuleAssociationsClient) ListByRuleResponder(resp *http.Response) (result DataCollectionRuleAssociationProxyOnlyResourceListResult, err error) {
617 err = autorest.Respond(
618 resp,
619 azure.WithErrorUnlessStatusCode(http.StatusOK),
620 autorest.ByUnmarshallingJSON(&result),
621 autorest.ByClosing())
622 result.Response = autorest.Response{Response: resp}
623 return
624 }
625
626
627 func (client DataCollectionRuleAssociationsClient) listByRuleNextResults(ctx context.Context, lastResults DataCollectionRuleAssociationProxyOnlyResourceListResult) (result DataCollectionRuleAssociationProxyOnlyResourceListResult, err error) {
628 req, err := lastResults.dataCollectionRuleAssociationProxyOnlyResourceListResultPreparer(ctx)
629 if err != nil {
630 return result, autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "listByRuleNextResults", nil, "Failure preparing next results request")
631 }
632 if req == nil {
633 return
634 }
635 resp, err := client.ListByRuleSender(req)
636 if err != nil {
637 result.Response = autorest.Response{Response: resp}
638 return result, autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "listByRuleNextResults", resp, "Failure sending next results request")
639 }
640 result, err = client.ListByRuleResponder(resp)
641 if err != nil {
642 err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "listByRuleNextResults", resp, "Failure responding to next results request")
643 }
644 return
645 }
646
647
648 func (client DataCollectionRuleAssociationsClient) ListByRuleComplete(ctx context.Context, resourceGroupName string, dataCollectionRuleName string) (result DataCollectionRuleAssociationProxyOnlyResourceListResultIterator, err error) {
649 if tracing.IsEnabled() {
650 ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRuleAssociationsClient.ListByRule")
651 defer func() {
652 sc := -1
653 if result.Response().Response.Response != nil {
654 sc = result.page.Response().Response.Response.StatusCode
655 }
656 tracing.EndSpan(ctx, sc, err)
657 }()
658 }
659 result.page, err = client.ListByRule(ctx, resourceGroupName, dataCollectionRuleName)
660 return
661 }
662
View as plain text