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