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