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 WebTestLocationsClient struct {
20 BaseClient
21 }
22
23
24 func NewWebTestLocationsClient(subscriptionID string) WebTestLocationsClient {
25 return NewWebTestLocationsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30
31 func NewWebTestLocationsClientWithBaseURI(baseURI string, subscriptionID string) WebTestLocationsClient {
32 return WebTestLocationsClient{NewWithBaseURI(baseURI, subscriptionID)}
33 }
34
35
36
37
38
39 func (client WebTestLocationsClient) List(ctx context.Context, resourceGroupName string, resourceName string) (result ApplicationInsightsWebTestLocationsListResult, err error) {
40 if tracing.IsEnabled() {
41 ctx = tracing.StartSpan(ctx, fqdn+"/WebTestLocationsClient.List")
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: resourceGroupName,
52 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
53 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
54 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
55 {TargetValue: client.SubscriptionID,
56 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
57 return result, validation.NewError("insights.WebTestLocationsClient", "List", err.Error())
58 }
59
60 req, err := client.ListPreparer(ctx, resourceGroupName, resourceName)
61 if err != nil {
62 err = autorest.NewErrorWithError(err, "insights.WebTestLocationsClient", "List", nil, "Failure preparing request")
63 return
64 }
65
66 resp, err := client.ListSender(req)
67 if err != nil {
68 result.Response = autorest.Response{Response: resp}
69 err = autorest.NewErrorWithError(err, "insights.WebTestLocationsClient", "List", resp, "Failure sending request")
70 return
71 }
72
73 result, err = client.ListResponder(resp)
74 if err != nil {
75 err = autorest.NewErrorWithError(err, "insights.WebTestLocationsClient", "List", resp, "Failure responding to request")
76 return
77 }
78
79 return
80 }
81
82
83 func (client WebTestLocationsClient) ListPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) {
84 pathParameters := map[string]interface{}{
85 "resourceGroupName": autorest.Encode("path", resourceGroupName),
86 "resourceName": autorest.Encode("path", resourceName),
87 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
88 }
89
90 const APIVersion = "2015-05-01"
91 queryParameters := map[string]interface{}{
92 "api-version": APIVersion,
93 }
94
95 preparer := autorest.CreatePreparer(
96 autorest.AsGet(),
97 autorest.WithBaseURL(client.BaseURI),
98 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/syntheticmonitorlocations", pathParameters),
99 autorest.WithQueryParameters(queryParameters))
100 return preparer.Prepare((&http.Request{}).WithContext(ctx))
101 }
102
103
104
105 func (client WebTestLocationsClient) ListSender(req *http.Request) (*http.Response, error) {
106 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
107 }
108
109
110
111 func (client WebTestLocationsClient) ListResponder(resp *http.Response) (result ApplicationInsightsWebTestLocationsListResult, err error) {
112 err = autorest.Respond(
113 resp,
114 azure.WithErrorUnlessStatusCode(http.StatusOK),
115 autorest.ByUnmarshallingJSON(&result),
116 autorest.ByClosing())
117 result.Response = autorest.Response{Response: resp}
118 return
119 }
120
View as plain text