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 ProactiveDetectionConfigurationsClient struct {
20 BaseClient
21 }
22
23
24 func NewProactiveDetectionConfigurationsClient(subscriptionID string) ProactiveDetectionConfigurationsClient {
25 return NewProactiveDetectionConfigurationsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30
31 func NewProactiveDetectionConfigurationsClientWithBaseURI(baseURI string, subscriptionID string) ProactiveDetectionConfigurationsClient {
32 return ProactiveDetectionConfigurationsClient{NewWithBaseURI(baseURI, subscriptionID)}
33 }
34
35
36
37
38
39
40
41 func (client ProactiveDetectionConfigurationsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, configurationID string) (result ApplicationInsightsComponentProactiveDetectionConfiguration, err error) {
42 if tracing.IsEnabled() {
43 ctx = tracing.StartSpan(ctx, fqdn+"/ProactiveDetectionConfigurationsClient.Get")
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.ProactiveDetectionConfigurationsClient", "Get", err.Error())
59 }
60
61 req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, configurationID)
62 if err != nil {
63 err = autorest.NewErrorWithError(err, "insights.ProactiveDetectionConfigurationsClient", "Get", nil, "Failure preparing request")
64 return
65 }
66
67 resp, err := client.GetSender(req)
68 if err != nil {
69 result.Response = autorest.Response{Response: resp}
70 err = autorest.NewErrorWithError(err, "insights.ProactiveDetectionConfigurationsClient", "Get", resp, "Failure sending request")
71 return
72 }
73
74 result, err = client.GetResponder(resp)
75 if err != nil {
76 err = autorest.NewErrorWithError(err, "insights.ProactiveDetectionConfigurationsClient", "Get", resp, "Failure responding to request")
77 return
78 }
79
80 return
81 }
82
83
84 func (client ProactiveDetectionConfigurationsClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, configurationID string) (*http.Request, error) {
85 pathParameters := map[string]interface{}{
86 "ConfigurationId": autorest.Encode("path", configurationID),
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.AsGet(),
99 autorest.WithBaseURL(client.BaseURI),
100 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}", pathParameters),
101 autorest.WithQueryParameters(queryParameters))
102 return preparer.Prepare((&http.Request{}).WithContext(ctx))
103 }
104
105
106
107 func (client ProactiveDetectionConfigurationsClient) GetSender(req *http.Request) (*http.Response, error) {
108 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
109 }
110
111
112
113 func (client ProactiveDetectionConfigurationsClient) GetResponder(resp *http.Response) (result ApplicationInsightsComponentProactiveDetectionConfiguration, err error) {
114 err = autorest.Respond(
115 resp,
116 azure.WithErrorUnlessStatusCode(http.StatusOK),
117 autorest.ByUnmarshallingJSON(&result),
118 autorest.ByClosing())
119 result.Response = autorest.Response{Response: resp}
120 return
121 }
122
123
124
125
126
127 func (client ProactiveDetectionConfigurationsClient) List(ctx context.Context, resourceGroupName string, resourceName string) (result ListApplicationInsightsComponentProactiveDetectionConfiguration, err error) {
128 if tracing.IsEnabled() {
129 ctx = tracing.StartSpan(ctx, fqdn+"/ProactiveDetectionConfigurationsClient.List")
130 defer func() {
131 sc := -1
132 if result.Response.Response != nil {
133 sc = result.Response.Response.StatusCode
134 }
135 tracing.EndSpan(ctx, sc, err)
136 }()
137 }
138 if err := validation.Validate([]validation.Validation{
139 {TargetValue: resourceGroupName,
140 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
141 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
142 {TargetValue: client.SubscriptionID,
143 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
144 return result, validation.NewError("insights.ProactiveDetectionConfigurationsClient", "List", err.Error())
145 }
146
147 req, err := client.ListPreparer(ctx, resourceGroupName, resourceName)
148 if err != nil {
149 err = autorest.NewErrorWithError(err, "insights.ProactiveDetectionConfigurationsClient", "List", nil, "Failure preparing request")
150 return
151 }
152
153 resp, err := client.ListSender(req)
154 if err != nil {
155 result.Response = autorest.Response{Response: resp}
156 err = autorest.NewErrorWithError(err, "insights.ProactiveDetectionConfigurationsClient", "List", resp, "Failure sending request")
157 return
158 }
159
160 result, err = client.ListResponder(resp)
161 if err != nil {
162 err = autorest.NewErrorWithError(err, "insights.ProactiveDetectionConfigurationsClient", "List", resp, "Failure responding to request")
163 return
164 }
165
166 return
167 }
168
169
170 func (client ProactiveDetectionConfigurationsClient) ListPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) {
171 pathParameters := map[string]interface{}{
172 "resourceGroupName": autorest.Encode("path", resourceGroupName),
173 "resourceName": autorest.Encode("path", resourceName),
174 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
175 }
176
177 const APIVersion = "2015-05-01"
178 queryParameters := map[string]interface{}{
179 "api-version": APIVersion,
180 }
181
182 preparer := autorest.CreatePreparer(
183 autorest.AsGet(),
184 autorest.WithBaseURL(client.BaseURI),
185 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs", pathParameters),
186 autorest.WithQueryParameters(queryParameters))
187 return preparer.Prepare((&http.Request{}).WithContext(ctx))
188 }
189
190
191
192 func (client ProactiveDetectionConfigurationsClient) ListSender(req *http.Request) (*http.Response, error) {
193 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
194 }
195
196
197
198 func (client ProactiveDetectionConfigurationsClient) ListResponder(resp *http.Response) (result ListApplicationInsightsComponentProactiveDetectionConfiguration, err error) {
199 err = autorest.Respond(
200 resp,
201 azure.WithErrorUnlessStatusCode(http.StatusOK),
202 autorest.ByUnmarshallingJSON(&result.Value),
203 autorest.ByClosing())
204 result.Response = autorest.Response{Response: resp}
205 return
206 }
207
208
209
210
211
212
213
214
215
216 func (client ProactiveDetectionConfigurationsClient) Update(ctx context.Context, resourceGroupName string, resourceName string, configurationID string, proactiveDetectionProperties ApplicationInsightsComponentProactiveDetectionConfiguration) (result ApplicationInsightsComponentProactiveDetectionConfiguration, err error) {
217 if tracing.IsEnabled() {
218 ctx = tracing.StartSpan(ctx, fqdn+"/ProactiveDetectionConfigurationsClient.Update")
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: resourceGroupName,
229 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
230 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
231 {TargetValue: client.SubscriptionID,
232 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
233 return result, validation.NewError("insights.ProactiveDetectionConfigurationsClient", "Update", err.Error())
234 }
235
236 req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, configurationID, proactiveDetectionProperties)
237 if err != nil {
238 err = autorest.NewErrorWithError(err, "insights.ProactiveDetectionConfigurationsClient", "Update", nil, "Failure preparing request")
239 return
240 }
241
242 resp, err := client.UpdateSender(req)
243 if err != nil {
244 result.Response = autorest.Response{Response: resp}
245 err = autorest.NewErrorWithError(err, "insights.ProactiveDetectionConfigurationsClient", "Update", resp, "Failure sending request")
246 return
247 }
248
249 result, err = client.UpdateResponder(resp)
250 if err != nil {
251 err = autorest.NewErrorWithError(err, "insights.ProactiveDetectionConfigurationsClient", "Update", resp, "Failure responding to request")
252 return
253 }
254
255 return
256 }
257
258
259 func (client ProactiveDetectionConfigurationsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, configurationID string, proactiveDetectionProperties ApplicationInsightsComponentProactiveDetectionConfiguration) (*http.Request, error) {
260 pathParameters := map[string]interface{}{
261 "ConfigurationId": autorest.Encode("path", configurationID),
262 "resourceGroupName": autorest.Encode("path", resourceGroupName),
263 "resourceName": autorest.Encode("path", resourceName),
264 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
265 }
266
267 const APIVersion = "2015-05-01"
268 queryParameters := map[string]interface{}{
269 "api-version": APIVersion,
270 }
271
272 preparer := autorest.CreatePreparer(
273 autorest.AsContentType("application/json; charset=utf-8"),
274 autorest.AsPut(),
275 autorest.WithBaseURL(client.BaseURI),
276 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}", pathParameters),
277 autorest.WithJSON(proactiveDetectionProperties),
278 autorest.WithQueryParameters(queryParameters))
279 return preparer.Prepare((&http.Request{}).WithContext(ctx))
280 }
281
282
283
284 func (client ProactiveDetectionConfigurationsClient) UpdateSender(req *http.Request) (*http.Response, error) {
285 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
286 }
287
288
289
290 func (client ProactiveDetectionConfigurationsClient) UpdateResponder(resp *http.Response) (result ApplicationInsightsComponentProactiveDetectionConfiguration, err error) {
291 err = autorest.Respond(
292 resp,
293 azure.WithErrorUnlessStatusCode(http.StatusOK),
294 autorest.ByUnmarshallingJSON(&result),
295 autorest.ByClosing())
296 result.Response = autorest.Response{Response: resp}
297 return
298 }
299
View as plain text