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 func (client MyWorkbooksClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties MyWorkbook) (result MyWorkbook, err error) {
40 if tracing.IsEnabled() {
41 ctx = tracing.StartSpan(ctx, fqdn+"/MyWorkbooksClient.CreateOrUpdate")
42 defer func() {
43 sc := -1
44 if result.Response.Response != nil {
45 sc = result.Response.Response.StatusCode
46 }
47 tracing.EndSpan(ctx, sc, err)
48 }()
49 }
50 if err := validation.Validate([]validation.Validation{
51 {TargetValue: client.SubscriptionID,
52 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
53 {TargetValue: resourceGroupName,
54 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
55 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
56 {TargetValue: workbookProperties,
57 Constraints: []validation.Constraint{{Target: "workbookProperties.MyWorkbookProperties", Name: validation.Null, Rule: false,
58 Chain: []validation.Constraint{{Target: "workbookProperties.MyWorkbookProperties.DisplayName", Name: validation.Null, Rule: true, Chain: nil},
59 {Target: "workbookProperties.MyWorkbookProperties.SerializedData", Name: validation.Null, Rule: true, Chain: nil},
60 {Target: "workbookProperties.MyWorkbookProperties.Category", Name: validation.Null, Rule: true, Chain: nil},
61 }}}}}); err != nil {
62 return result, validation.NewError("insights.MyWorkbooksClient", "CreateOrUpdate", err.Error())
63 }
64
65 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, workbookProperties)
66 if err != nil {
67 err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "CreateOrUpdate", nil, "Failure preparing request")
68 return
69 }
70
71 resp, err := client.CreateOrUpdateSender(req)
72 if err != nil {
73 result.Response = autorest.Response{Response: resp}
74 err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "CreateOrUpdate", resp, "Failure sending request")
75 return
76 }
77
78 result, err = client.CreateOrUpdateResponder(resp)
79 if err != nil {
80 err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "CreateOrUpdate", resp, "Failure responding to request")
81 return
82 }
83
84 return
85 }
86
87
88 func (client MyWorkbooksClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties MyWorkbook) (*http.Request, error) {
89 pathParameters := map[string]interface{}{
90 "resourceGroupName": autorest.Encode("path", resourceGroupName),
91 "resourceName": autorest.Encode("path", resourceName),
92 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
93 }
94
95 const APIVersion = "2015-05-01"
96 queryParameters := map[string]interface{}{
97 "api-version": APIVersion,
98 }
99
100 preparer := autorest.CreatePreparer(
101 autorest.AsContentType("application/json; charset=utf-8"),
102 autorest.AsPut(),
103 autorest.WithBaseURL(client.BaseURI),
104 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}", pathParameters),
105 autorest.WithJSON(workbookProperties),
106 autorest.WithQueryParameters(queryParameters))
107 return preparer.Prepare((&http.Request{}).WithContext(ctx))
108 }
109
110
111
112 func (client MyWorkbooksClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
113 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
114 }
115
116
117
118 func (client MyWorkbooksClient) CreateOrUpdateResponder(resp *http.Response) (result MyWorkbook, err error) {
119 err = autorest.Respond(
120 resp,
121 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
122 autorest.ByUnmarshallingJSON(&result),
123 autorest.ByClosing())
124 result.Response = autorest.Response{Response: resp}
125 return
126 }
127
128
129
130
131
132 func (client MyWorkbooksClient) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result autorest.Response, err error) {
133 if tracing.IsEnabled() {
134 ctx = tracing.StartSpan(ctx, fqdn+"/MyWorkbooksClient.Delete")
135 defer func() {
136 sc := -1
137 if result.Response != nil {
138 sc = result.Response.StatusCode
139 }
140 tracing.EndSpan(ctx, sc, err)
141 }()
142 }
143 if err := validation.Validate([]validation.Validation{
144 {TargetValue: client.SubscriptionID,
145 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
146 {TargetValue: resourceGroupName,
147 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
148 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
149 return result, validation.NewError("insights.MyWorkbooksClient", "Delete", err.Error())
150 }
151
152 req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName)
153 if err != nil {
154 err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "Delete", nil, "Failure preparing request")
155 return
156 }
157
158 resp, err := client.DeleteSender(req)
159 if err != nil {
160 result.Response = resp
161 err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "Delete", resp, "Failure sending request")
162 return
163 }
164
165 result, err = client.DeleteResponder(resp)
166 if err != nil {
167 err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "Delete", resp, "Failure responding to request")
168 return
169 }
170
171 return
172 }
173
174
175 func (client MyWorkbooksClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) {
176 pathParameters := map[string]interface{}{
177 "resourceGroupName": autorest.Encode("path", resourceGroupName),
178 "resourceName": autorest.Encode("path", resourceName),
179 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
180 }
181
182 const APIVersion = "2015-05-01"
183 queryParameters := map[string]interface{}{
184 "api-version": APIVersion,
185 }
186
187 preparer := autorest.CreatePreparer(
188 autorest.AsDelete(),
189 autorest.WithBaseURL(client.BaseURI),
190 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}", pathParameters),
191 autorest.WithQueryParameters(queryParameters))
192 return preparer.Prepare((&http.Request{}).WithContext(ctx))
193 }
194
195
196
197 func (client MyWorkbooksClient) DeleteSender(req *http.Request) (*http.Response, error) {
198 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
199 }
200
201
202
203 func (client MyWorkbooksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
204 err = autorest.Respond(
205 resp,
206 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusNoContent),
207 autorest.ByClosing())
208 result.Response = resp
209 return
210 }
211
212
213
214
215
216 func (client MyWorkbooksClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result MyWorkbook, err error) {
217 if tracing.IsEnabled() {
218 ctx = tracing.StartSpan(ctx, fqdn+"/MyWorkbooksClient.Get")
219 defer func() {
220 sc := -1
221 if result.Response.Response != nil {
222 sc = result.Response.Response.StatusCode
223 }
224 tracing.EndSpan(ctx, sc, err)
225 }()
226 }
227 if err := validation.Validate([]validation.Validation{
228 {TargetValue: client.SubscriptionID,
229 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
230 {TargetValue: resourceGroupName,
231 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
232 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
233 return result, validation.NewError("insights.MyWorkbooksClient", "Get", err.Error())
234 }
235
236 req, err := client.GetPreparer(ctx, resourceGroupName, resourceName)
237 if err != nil {
238 err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "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.MyWorkbooksClient", "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.MyWorkbooksClient", "Get", resp, "Failure responding to request")
252 return
253 }
254
255 return
256 }
257
258
259 func (client MyWorkbooksClient) 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/myWorkbooks/{resourceName}", pathParameters),
275 autorest.WithQueryParameters(queryParameters))
276 return preparer.Prepare((&http.Request{}).WithContext(ctx))
277 }
278
279
280
281 func (client MyWorkbooksClient) GetSender(req *http.Request) (*http.Response, error) {
282 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
283 }
284
285
286
287 func (client MyWorkbooksClient) GetResponder(resp *http.Response) (result MyWorkbook, 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
303
304 func (client MyWorkbooksClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, category CategoryType, tags []string, canFetchContent *bool) (result MyWorkbooksListResult, err error) {
305 if tracing.IsEnabled() {
306 ctx = tracing.StartSpan(ctx, fqdn+"/MyWorkbooksClient.ListByResourceGroup")
307 defer func() {
308 sc := -1
309 if result.Response.Response != nil {
310 sc = result.Response.Response.StatusCode
311 }
312 tracing.EndSpan(ctx, sc, err)
313 }()
314 }
315 if err := validation.Validate([]validation.Validation{
316 {TargetValue: client.SubscriptionID,
317 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
318 {TargetValue: resourceGroupName,
319 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
320 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
321 return result, validation.NewError("insights.MyWorkbooksClient", "ListByResourceGroup", err.Error())
322 }
323
324 req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, category, tags, canFetchContent)
325 if err != nil {
326 err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "ListByResourceGroup", nil, "Failure preparing request")
327 return
328 }
329
330 resp, err := client.ListByResourceGroupSender(req)
331 if err != nil {
332 result.Response = autorest.Response{Response: resp}
333 err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "ListByResourceGroup", resp, "Failure sending request")
334 return
335 }
336
337 result, err = client.ListByResourceGroupResponder(resp)
338 if err != nil {
339 err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "ListByResourceGroup", resp, "Failure responding to request")
340 return
341 }
342
343 return
344 }
345
346
347 func (client MyWorkbooksClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, category CategoryType, tags []string, canFetchContent *bool) (*http.Request, error) {
348 pathParameters := map[string]interface{}{
349 "resourceGroupName": autorest.Encode("path", resourceGroupName),
350 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
351 }
352
353 const APIVersion = "2015-05-01"
354 queryParameters := map[string]interface{}{
355 "api-version": APIVersion,
356 "category": autorest.Encode("query", category),
357 }
358 if tags != nil && len(tags) > 0 {
359 queryParameters["tags"] = autorest.Encode("query", tags, ",")
360 }
361 if canFetchContent != nil {
362 queryParameters["canFetchContent"] = autorest.Encode("query", *canFetchContent)
363 }
364
365 preparer := autorest.CreatePreparer(
366 autorest.AsGet(),
367 autorest.WithBaseURL(client.BaseURI),
368 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks", pathParameters),
369 autorest.WithQueryParameters(queryParameters))
370 return preparer.Prepare((&http.Request{}).WithContext(ctx))
371 }
372
373
374
375 func (client MyWorkbooksClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
376 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
377 }
378
379
380
381 func (client MyWorkbooksClient) ListByResourceGroupResponder(resp *http.Response) (result MyWorkbooksListResult, 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
393
394
395
396
397 func (client MyWorkbooksClient) ListBySubscription(ctx context.Context, category CategoryType, tags []string, canFetchContent *bool) (result MyWorkbooksListResult, err error) {
398 if tracing.IsEnabled() {
399 ctx = tracing.StartSpan(ctx, fqdn+"/MyWorkbooksClient.ListBySubscription")
400 defer func() {
401 sc := -1
402 if result.Response.Response != nil {
403 sc = result.Response.Response.StatusCode
404 }
405 tracing.EndSpan(ctx, sc, err)
406 }()
407 }
408 if err := validation.Validate([]validation.Validation{
409 {TargetValue: client.SubscriptionID,
410 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
411 return result, validation.NewError("insights.MyWorkbooksClient", "ListBySubscription", err.Error())
412 }
413
414 req, err := client.ListBySubscriptionPreparer(ctx, category, tags, canFetchContent)
415 if err != nil {
416 err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "ListBySubscription", nil, "Failure preparing request")
417 return
418 }
419
420 resp, err := client.ListBySubscriptionSender(req)
421 if err != nil {
422 result.Response = autorest.Response{Response: resp}
423 err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "ListBySubscription", resp, "Failure sending request")
424 return
425 }
426
427 result, err = client.ListBySubscriptionResponder(resp)
428 if err != nil {
429 err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "ListBySubscription", resp, "Failure responding to request")
430 return
431 }
432
433 return
434 }
435
436
437 func (client MyWorkbooksClient) ListBySubscriptionPreparer(ctx context.Context, category CategoryType, tags []string, canFetchContent *bool) (*http.Request, error) {
438 pathParameters := map[string]interface{}{
439 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
440 }
441
442 const APIVersion = "2015-05-01"
443 queryParameters := map[string]interface{}{
444 "api-version": APIVersion,
445 "category": autorest.Encode("query", category),
446 }
447 if tags != nil && len(tags) > 0 {
448 queryParameters["tags"] = autorest.Encode("query", tags, ",")
449 }
450 if canFetchContent != nil {
451 queryParameters["canFetchContent"] = autorest.Encode("query", *canFetchContent)
452 }
453
454 preparer := autorest.CreatePreparer(
455 autorest.AsGet(),
456 autorest.WithBaseURL(client.BaseURI),
457 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Insights/myWorkbooks", pathParameters),
458 autorest.WithQueryParameters(queryParameters))
459 return preparer.Prepare((&http.Request{}).WithContext(ctx))
460 }
461
462
463
464 func (client MyWorkbooksClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) {
465 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
466 }
467
468
469
470 func (client MyWorkbooksClient) ListBySubscriptionResponder(resp *http.Response) (result MyWorkbooksListResult, err error) {
471 err = autorest.Respond(
472 resp,
473 azure.WithErrorUnlessStatusCode(http.StatusOK),
474 autorest.ByUnmarshallingJSON(&result),
475 autorest.ByClosing())
476 result.Response = autorest.Response{Response: resp}
477 return
478 }
479
480
481
482
483
484
485 func (client MyWorkbooksClient) Update(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties MyWorkbook) (result MyWorkbook, err error) {
486 if tracing.IsEnabled() {
487 ctx = tracing.StartSpan(ctx, fqdn+"/MyWorkbooksClient.Update")
488 defer func() {
489 sc := -1
490 if result.Response.Response != nil {
491 sc = result.Response.Response.StatusCode
492 }
493 tracing.EndSpan(ctx, sc, err)
494 }()
495 }
496 if err := validation.Validate([]validation.Validation{
497 {TargetValue: client.SubscriptionID,
498 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
499 {TargetValue: resourceGroupName,
500 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
501 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
502 return result, validation.NewError("insights.MyWorkbooksClient", "Update", err.Error())
503 }
504
505 req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, workbookProperties)
506 if err != nil {
507 err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "Update", nil, "Failure preparing request")
508 return
509 }
510
511 resp, err := client.UpdateSender(req)
512 if err != nil {
513 result.Response = autorest.Response{Response: resp}
514 err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "Update", resp, "Failure sending request")
515 return
516 }
517
518 result, err = client.UpdateResponder(resp)
519 if err != nil {
520 err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "Update", resp, "Failure responding to request")
521 return
522 }
523
524 return
525 }
526
527
528 func (client MyWorkbooksClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties MyWorkbook) (*http.Request, error) {
529 pathParameters := map[string]interface{}{
530 "resourceGroupName": autorest.Encode("path", resourceGroupName),
531 "resourceName": autorest.Encode("path", resourceName),
532 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
533 }
534
535 const APIVersion = "2015-05-01"
536 queryParameters := map[string]interface{}{
537 "api-version": APIVersion,
538 }
539
540 preparer := autorest.CreatePreparer(
541 autorest.AsContentType("application/json; charset=utf-8"),
542 autorest.AsPatch(),
543 autorest.WithBaseURL(client.BaseURI),
544 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}", pathParameters),
545 autorest.WithJSON(workbookProperties),
546 autorest.WithQueryParameters(queryParameters))
547 return preparer.Prepare((&http.Request{}).WithContext(ctx))
548 }
549
550
551
552 func (client MyWorkbooksClient) UpdateSender(req *http.Request) (*http.Response, error) {
553 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
554 }
555
556
557
558 func (client MyWorkbooksClient) UpdateResponder(resp *http.Response) (result MyWorkbook, err error) {
559 err = autorest.Respond(
560 resp,
561 azure.WithErrorUnlessStatusCode(http.StatusOK),
562 autorest.ByUnmarshallingJSON(&result),
563 autorest.ByClosing())
564 result.Response = autorest.Response{Response: resp}
565 return
566 }
567
View as plain text