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