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 WorkItemConfigurationsClient struct {
20 BaseClient
21 }
22
23
24 func NewWorkItemConfigurationsClient(subscriptionID string) WorkItemConfigurationsClient {
25 return NewWorkItemConfigurationsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30
31 func NewWorkItemConfigurationsClientWithBaseURI(baseURI string, subscriptionID string) WorkItemConfigurationsClient {
32 return WorkItemConfigurationsClient{NewWithBaseURI(baseURI, subscriptionID)}
33 }
34
35
36
37
38
39
40
41 func (client WorkItemConfigurationsClient) Create(ctx context.Context, resourceGroupName string, resourceName string, workItemConfigurationProperties WorkItemCreateConfiguration) (result WorkItemConfiguration, err error) {
42 if tracing.IsEnabled() {
43 ctx = tracing.StartSpan(ctx, fqdn+"/WorkItemConfigurationsClient.Create")
44 defer func() {
45 sc := -1
46 if result.Response.Response != nil {
47 sc = result.Response.Response.StatusCode
48 }
49 tracing.EndSpan(ctx, sc, err)
50 }()
51 }
52 if err := validation.Validate([]validation.Validation{
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 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
57 {TargetValue: client.SubscriptionID,
58 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
59 return result, validation.NewError("insights.WorkItemConfigurationsClient", "Create", err.Error())
60 }
61
62 req, err := client.CreatePreparer(ctx, resourceGroupName, resourceName, workItemConfigurationProperties)
63 if err != nil {
64 err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "Create", nil, "Failure preparing request")
65 return
66 }
67
68 resp, err := client.CreateSender(req)
69 if err != nil {
70 result.Response = autorest.Response{Response: resp}
71 err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "Create", resp, "Failure sending request")
72 return
73 }
74
75 result, err = client.CreateResponder(resp)
76 if err != nil {
77 err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "Create", resp, "Failure responding to request")
78 return
79 }
80
81 return
82 }
83
84
85 func (client WorkItemConfigurationsClient) CreatePreparer(ctx context.Context, resourceGroupName string, resourceName string, workItemConfigurationProperties WorkItemCreateConfiguration) (*http.Request, error) {
86 pathParameters := map[string]interface{}{
87 "resourceGroupName": autorest.Encode("path", resourceGroupName),
88 "resourceName": autorest.Encode("path", resourceName),
89 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
90 }
91
92 const APIVersion = "2015-05-01"
93 queryParameters := map[string]interface{}{
94 "api-version": APIVersion,
95 }
96
97 preparer := autorest.CreatePreparer(
98 autorest.AsContentType("application/json; charset=utf-8"),
99 autorest.AsPost(),
100 autorest.WithBaseURL(client.BaseURI),
101 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs", pathParameters),
102 autorest.WithJSON(workItemConfigurationProperties),
103 autorest.WithQueryParameters(queryParameters))
104 return preparer.Prepare((&http.Request{}).WithContext(ctx))
105 }
106
107
108
109 func (client WorkItemConfigurationsClient) CreateSender(req *http.Request) (*http.Response, error) {
110 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
111 }
112
113
114
115 func (client WorkItemConfigurationsClient) CreateResponder(resp *http.Response) (result WorkItemConfiguration, err error) {
116 err = autorest.Respond(
117 resp,
118 azure.WithErrorUnlessStatusCode(http.StatusOK),
119 autorest.ByUnmarshallingJSON(&result),
120 autorest.ByClosing())
121 result.Response = autorest.Response{Response: resp}
122 return
123 }
124
125
126
127
128
129
130
131 func (client WorkItemConfigurationsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, workItemConfigID string) (result autorest.Response, err error) {
132 if tracing.IsEnabled() {
133 ctx = tracing.StartSpan(ctx, fqdn+"/WorkItemConfigurationsClient.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: resourceGroupName,
144 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
145 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
146 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
147 {TargetValue: client.SubscriptionID,
148 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
149 return result, validation.NewError("insights.WorkItemConfigurationsClient", "Delete", err.Error())
150 }
151
152 req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName, workItemConfigID)
153 if err != nil {
154 err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "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.WorkItemConfigurationsClient", "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.WorkItemConfigurationsClient", "Delete", resp, "Failure responding to request")
168 return
169 }
170
171 return
172 }
173
174
175 func (client WorkItemConfigurationsClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string, workItemConfigID 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 "workItemConfigId": autorest.Encode("path", workItemConfigID),
181 }
182
183 const APIVersion = "2015-05-01"
184 queryParameters := map[string]interface{}{
185 "api-version": APIVersion,
186 }
187
188 preparer := autorest.CreatePreparer(
189 autorest.AsDelete(),
190 autorest.WithBaseURL(client.BaseURI),
191 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs/{workItemConfigId}", pathParameters),
192 autorest.WithQueryParameters(queryParameters))
193 return preparer.Prepare((&http.Request{}).WithContext(ctx))
194 }
195
196
197
198 func (client WorkItemConfigurationsClient) DeleteSender(req *http.Request) (*http.Response, error) {
199 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
200 }
201
202
203
204 func (client WorkItemConfigurationsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
205 err = autorest.Respond(
206 resp,
207 azure.WithErrorUnlessStatusCode(http.StatusOK),
208 autorest.ByClosing())
209 result.Response = resp
210 return
211 }
212
213
214
215
216
217 func (client WorkItemConfigurationsClient) GetDefault(ctx context.Context, resourceGroupName string, resourceName string) (result WorkItemConfiguration, err error) {
218 if tracing.IsEnabled() {
219 ctx = tracing.StartSpan(ctx, fqdn+"/WorkItemConfigurationsClient.GetDefault")
220 defer func() {
221 sc := -1
222 if result.Response.Response != nil {
223 sc = result.Response.Response.StatusCode
224 }
225 tracing.EndSpan(ctx, sc, err)
226 }()
227 }
228 if err := validation.Validate([]validation.Validation{
229 {TargetValue: resourceGroupName,
230 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
231 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
232 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
233 {TargetValue: client.SubscriptionID,
234 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
235 return result, validation.NewError("insights.WorkItemConfigurationsClient", "GetDefault", err.Error())
236 }
237
238 req, err := client.GetDefaultPreparer(ctx, resourceGroupName, resourceName)
239 if err != nil {
240 err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "GetDefault", nil, "Failure preparing request")
241 return
242 }
243
244 resp, err := client.GetDefaultSender(req)
245 if err != nil {
246 result.Response = autorest.Response{Response: resp}
247 err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "GetDefault", resp, "Failure sending request")
248 return
249 }
250
251 result, err = client.GetDefaultResponder(resp)
252 if err != nil {
253 err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "GetDefault", resp, "Failure responding to request")
254 return
255 }
256
257 return
258 }
259
260
261 func (client WorkItemConfigurationsClient) GetDefaultPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) {
262 pathParameters := map[string]interface{}{
263 "resourceGroupName": autorest.Encode("path", resourceGroupName),
264 "resourceName": autorest.Encode("path", resourceName),
265 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
266 }
267
268 const APIVersion = "2015-05-01"
269 queryParameters := map[string]interface{}{
270 "api-version": APIVersion,
271 }
272
273 preparer := autorest.CreatePreparer(
274 autorest.AsGet(),
275 autorest.WithBaseURL(client.BaseURI),
276 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/DefaultWorkItemConfig", pathParameters),
277 autorest.WithQueryParameters(queryParameters))
278 return preparer.Prepare((&http.Request{}).WithContext(ctx))
279 }
280
281
282
283 func (client WorkItemConfigurationsClient) GetDefaultSender(req *http.Request) (*http.Response, error) {
284 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
285 }
286
287
288
289 func (client WorkItemConfigurationsClient) GetDefaultResponder(resp *http.Response) (result WorkItemConfiguration, err error) {
290 err = autorest.Respond(
291 resp,
292 azure.WithErrorUnlessStatusCode(http.StatusOK),
293 autorest.ByUnmarshallingJSON(&result),
294 autorest.ByClosing())
295 result.Response = autorest.Response{Response: resp}
296 return
297 }
298
299
300
301
302
303
304
305 func (client WorkItemConfigurationsClient) GetItem(ctx context.Context, resourceGroupName string, resourceName string, workItemConfigID string) (result WorkItemConfiguration, err error) {
306 if tracing.IsEnabled() {
307 ctx = tracing.StartSpan(ctx, fqdn+"/WorkItemConfigurationsClient.GetItem")
308 defer func() {
309 sc := -1
310 if result.Response.Response != nil {
311 sc = result.Response.Response.StatusCode
312 }
313 tracing.EndSpan(ctx, sc, err)
314 }()
315 }
316 if err := validation.Validate([]validation.Validation{
317 {TargetValue: resourceGroupName,
318 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
319 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
320 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
321 {TargetValue: client.SubscriptionID,
322 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
323 return result, validation.NewError("insights.WorkItemConfigurationsClient", "GetItem", err.Error())
324 }
325
326 req, err := client.GetItemPreparer(ctx, resourceGroupName, resourceName, workItemConfigID)
327 if err != nil {
328 err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "GetItem", nil, "Failure preparing request")
329 return
330 }
331
332 resp, err := client.GetItemSender(req)
333 if err != nil {
334 result.Response = autorest.Response{Response: resp}
335 err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "GetItem", resp, "Failure sending request")
336 return
337 }
338
339 result, err = client.GetItemResponder(resp)
340 if err != nil {
341 err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "GetItem", resp, "Failure responding to request")
342 return
343 }
344
345 return
346 }
347
348
349 func (client WorkItemConfigurationsClient) GetItemPreparer(ctx context.Context, resourceGroupName string, resourceName string, workItemConfigID string) (*http.Request, error) {
350 pathParameters := map[string]interface{}{
351 "resourceGroupName": autorest.Encode("path", resourceGroupName),
352 "resourceName": autorest.Encode("path", resourceName),
353 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
354 "workItemConfigId": autorest.Encode("path", workItemConfigID),
355 }
356
357 const APIVersion = "2015-05-01"
358 queryParameters := map[string]interface{}{
359 "api-version": APIVersion,
360 }
361
362 preparer := autorest.CreatePreparer(
363 autorest.AsGet(),
364 autorest.WithBaseURL(client.BaseURI),
365 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs/{workItemConfigId}", pathParameters),
366 autorest.WithQueryParameters(queryParameters))
367 return preparer.Prepare((&http.Request{}).WithContext(ctx))
368 }
369
370
371
372 func (client WorkItemConfigurationsClient) GetItemSender(req *http.Request) (*http.Response, error) {
373 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
374 }
375
376
377
378 func (client WorkItemConfigurationsClient) GetItemResponder(resp *http.Response) (result WorkItemConfiguration, err error) {
379 err = autorest.Respond(
380 resp,
381 azure.WithErrorUnlessStatusCode(http.StatusOK),
382 autorest.ByUnmarshallingJSON(&result),
383 autorest.ByClosing())
384 result.Response = autorest.Response{Response: resp}
385 return
386 }
387
388
389
390
391
392 func (client WorkItemConfigurationsClient) List(ctx context.Context, resourceGroupName string, resourceName string) (result WorkItemConfigurationsListResult, err error) {
393 if tracing.IsEnabled() {
394 ctx = tracing.StartSpan(ctx, fqdn+"/WorkItemConfigurationsClient.List")
395 defer func() {
396 sc := -1
397 if result.Response.Response != nil {
398 sc = result.Response.Response.StatusCode
399 }
400 tracing.EndSpan(ctx, sc, err)
401 }()
402 }
403 if err := validation.Validate([]validation.Validation{
404 {TargetValue: resourceGroupName,
405 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
406 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
407 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
408 {TargetValue: client.SubscriptionID,
409 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
410 return result, validation.NewError("insights.WorkItemConfigurationsClient", "List", err.Error())
411 }
412
413 req, err := client.ListPreparer(ctx, resourceGroupName, resourceName)
414 if err != nil {
415 err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "List", nil, "Failure preparing request")
416 return
417 }
418
419 resp, err := client.ListSender(req)
420 if err != nil {
421 result.Response = autorest.Response{Response: resp}
422 err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "List", resp, "Failure sending request")
423 return
424 }
425
426 result, err = client.ListResponder(resp)
427 if err != nil {
428 err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "List", resp, "Failure responding to request")
429 return
430 }
431
432 return
433 }
434
435
436 func (client WorkItemConfigurationsClient) ListPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) {
437 pathParameters := map[string]interface{}{
438 "resourceGroupName": autorest.Encode("path", resourceGroupName),
439 "resourceName": autorest.Encode("path", resourceName),
440 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
441 }
442
443 const APIVersion = "2015-05-01"
444 queryParameters := map[string]interface{}{
445 "api-version": APIVersion,
446 }
447
448 preparer := autorest.CreatePreparer(
449 autorest.AsGet(),
450 autorest.WithBaseURL(client.BaseURI),
451 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs", pathParameters),
452 autorest.WithQueryParameters(queryParameters))
453 return preparer.Prepare((&http.Request{}).WithContext(ctx))
454 }
455
456
457
458 func (client WorkItemConfigurationsClient) ListSender(req *http.Request) (*http.Response, error) {
459 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
460 }
461
462
463
464 func (client WorkItemConfigurationsClient) ListResponder(resp *http.Response) (result WorkItemConfigurationsListResult, err error) {
465 err = autorest.Respond(
466 resp,
467 azure.WithErrorUnlessStatusCode(http.StatusOK),
468 autorest.ByUnmarshallingJSON(&result),
469 autorest.ByClosing())
470 result.Response = autorest.Response{Response: resp}
471 return
472 }
473
474
475
476
477
478
479
480
481
482 func (client WorkItemConfigurationsClient) UpdateItem(ctx context.Context, resourceGroupName string, resourceName string, workItemConfigID string, workItemConfigurationProperties WorkItemCreateConfiguration) (result WorkItemConfiguration, err error) {
483 if tracing.IsEnabled() {
484 ctx = tracing.StartSpan(ctx, fqdn+"/WorkItemConfigurationsClient.UpdateItem")
485 defer func() {
486 sc := -1
487 if result.Response.Response != nil {
488 sc = result.Response.Response.StatusCode
489 }
490 tracing.EndSpan(ctx, sc, err)
491 }()
492 }
493 if err := validation.Validate([]validation.Validation{
494 {TargetValue: resourceGroupName,
495 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
496 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
497 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
498 {TargetValue: client.SubscriptionID,
499 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
500 return result, validation.NewError("insights.WorkItemConfigurationsClient", "UpdateItem", err.Error())
501 }
502
503 req, err := client.UpdateItemPreparer(ctx, resourceGroupName, resourceName, workItemConfigID, workItemConfigurationProperties)
504 if err != nil {
505 err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "UpdateItem", nil, "Failure preparing request")
506 return
507 }
508
509 resp, err := client.UpdateItemSender(req)
510 if err != nil {
511 result.Response = autorest.Response{Response: resp}
512 err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "UpdateItem", resp, "Failure sending request")
513 return
514 }
515
516 result, err = client.UpdateItemResponder(resp)
517 if err != nil {
518 err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "UpdateItem", resp, "Failure responding to request")
519 return
520 }
521
522 return
523 }
524
525
526 func (client WorkItemConfigurationsClient) UpdateItemPreparer(ctx context.Context, resourceGroupName string, resourceName string, workItemConfigID string, workItemConfigurationProperties WorkItemCreateConfiguration) (*http.Request, error) {
527 pathParameters := map[string]interface{}{
528 "resourceGroupName": autorest.Encode("path", resourceGroupName),
529 "resourceName": autorest.Encode("path", resourceName),
530 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
531 "workItemConfigId": autorest.Encode("path", workItemConfigID),
532 }
533
534 const APIVersion = "2015-05-01"
535 queryParameters := map[string]interface{}{
536 "api-version": APIVersion,
537 }
538
539 preparer := autorest.CreatePreparer(
540 autorest.AsContentType("application/json; charset=utf-8"),
541 autorest.AsPatch(),
542 autorest.WithBaseURL(client.BaseURI),
543 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs/{workItemConfigId}", pathParameters),
544 autorest.WithJSON(workItemConfigurationProperties),
545 autorest.WithQueryParameters(queryParameters))
546 return preparer.Prepare((&http.Request{}).WithContext(ctx))
547 }
548
549
550
551 func (client WorkItemConfigurationsClient) UpdateItemSender(req *http.Request) (*http.Response, error) {
552 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
553 }
554
555
556
557 func (client WorkItemConfigurationsClient) UpdateItemResponder(resp *http.Response) (result WorkItemConfiguration, err error) {
558 err = autorest.Respond(
559 resp,
560 azure.WithErrorUnlessStatusCode(http.StatusOK),
561 autorest.ByUnmarshallingJSON(&result),
562 autorest.ByClosing())
563 result.Response = autorest.Response{Response: resp}
564 return
565 }
566
View as plain text