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