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 ExportConfigurationsClient struct {
20 BaseClient
21 }
22
23
24 func NewExportConfigurationsClient(subscriptionID string) ExportConfigurationsClient {
25 return NewExportConfigurationsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30
31 func NewExportConfigurationsClientWithBaseURI(baseURI string, subscriptionID string) ExportConfigurationsClient {
32 return ExportConfigurationsClient{NewWithBaseURI(baseURI, subscriptionID)}
33 }
34
35
36
37
38
39
40
41 func (client ExportConfigurationsClient) Create(ctx context.Context, resourceGroupName string, resourceName string, exportProperties ApplicationInsightsComponentExportRequest) (result ListApplicationInsightsComponentExportConfiguration, err error) {
42 if tracing.IsEnabled() {
43 ctx = tracing.StartSpan(ctx, fqdn+"/ExportConfigurationsClient.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.ExportConfigurationsClient", "Create", err.Error())
59 }
60
61 req, err := client.CreatePreparer(ctx, resourceGroupName, resourceName, exportProperties)
62 if err != nil {
63 err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "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.ExportConfigurationsClient", "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.ExportConfigurationsClient", "Create", resp, "Failure responding to request")
77 return
78 }
79
80 return
81 }
82
83
84 func (client ExportConfigurationsClient) CreatePreparer(ctx context.Context, resourceGroupName string, resourceName string, exportProperties ApplicationInsightsComponentExportRequest) (*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}/exportconfiguration", pathParameters),
101 autorest.WithJSON(exportProperties),
102 autorest.WithQueryParameters(queryParameters))
103 return preparer.Prepare((&http.Request{}).WithContext(ctx))
104 }
105
106
107
108 func (client ExportConfigurationsClient) CreateSender(req *http.Request) (*http.Response, error) {
109 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
110 }
111
112
113
114 func (client ExportConfigurationsClient) CreateResponder(resp *http.Response) (result ListApplicationInsightsComponentExportConfiguration, err error) {
115 err = autorest.Respond(
116 resp,
117 azure.WithErrorUnlessStatusCode(http.StatusOK),
118 autorest.ByUnmarshallingJSON(&result.Value),
119 autorest.ByClosing())
120 result.Response = autorest.Response{Response: resp}
121 return
122 }
123
124
125
126
127
128
129 func (client ExportConfigurationsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, exportID string) (result ApplicationInsightsComponentExportConfiguration, err error) {
130 if tracing.IsEnabled() {
131 ctx = tracing.StartSpan(ctx, fqdn+"/ExportConfigurationsClient.Delete")
132 defer func() {
133 sc := -1
134 if result.Response.Response != nil {
135 sc = result.Response.Response.StatusCode
136 }
137 tracing.EndSpan(ctx, sc, err)
138 }()
139 }
140 if err := validation.Validate([]validation.Validation{
141 {TargetValue: resourceGroupName,
142 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
143 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
144 {TargetValue: client.SubscriptionID,
145 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
146 return result, validation.NewError("insights.ExportConfigurationsClient", "Delete", err.Error())
147 }
148
149 req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName, exportID)
150 if err != nil {
151 err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Delete", nil, "Failure preparing request")
152 return
153 }
154
155 resp, err := client.DeleteSender(req)
156 if err != nil {
157 result.Response = autorest.Response{Response: resp}
158 err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Delete", resp, "Failure sending request")
159 return
160 }
161
162 result, err = client.DeleteResponder(resp)
163 if err != nil {
164 err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Delete", resp, "Failure responding to request")
165 return
166 }
167
168 return
169 }
170
171
172 func (client ExportConfigurationsClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string, exportID string) (*http.Request, error) {
173 pathParameters := map[string]interface{}{
174 "exportId": autorest.Encode("path", exportID),
175 "resourceGroupName": autorest.Encode("path", resourceGroupName),
176 "resourceName": autorest.Encode("path", resourceName),
177 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
178 }
179
180 const APIVersion = "2015-05-01"
181 queryParameters := map[string]interface{}{
182 "api-version": APIVersion,
183 }
184
185 preparer := autorest.CreatePreparer(
186 autorest.AsDelete(),
187 autorest.WithBaseURL(client.BaseURI),
188 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration/{exportId}", pathParameters),
189 autorest.WithQueryParameters(queryParameters))
190 return preparer.Prepare((&http.Request{}).WithContext(ctx))
191 }
192
193
194
195 func (client ExportConfigurationsClient) DeleteSender(req *http.Request) (*http.Response, error) {
196 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
197 }
198
199
200
201 func (client ExportConfigurationsClient) DeleteResponder(resp *http.Response) (result ApplicationInsightsComponentExportConfiguration, err error) {
202 err = autorest.Respond(
203 resp,
204 azure.WithErrorUnlessStatusCode(http.StatusOK),
205 autorest.ByUnmarshallingJSON(&result),
206 autorest.ByClosing())
207 result.Response = autorest.Response{Response: resp}
208 return
209 }
210
211
212
213
214
215
216 func (client ExportConfigurationsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, exportID string) (result ApplicationInsightsComponentExportConfiguration, err error) {
217 if tracing.IsEnabled() {
218 ctx = tracing.StartSpan(ctx, fqdn+"/ExportConfigurationsClient.Get")
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.ExportConfigurationsClient", "Get", err.Error())
234 }
235
236 req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, exportID)
237 if err != nil {
238 err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Get", nil, "Failure preparing request")
239 return
240 }
241
242 resp, err := client.GetSender(req)
243 if err != nil {
244 result.Response = autorest.Response{Response: resp}
245 err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Get", resp, "Failure sending request")
246 return
247 }
248
249 result, err = client.GetResponder(resp)
250 if err != nil {
251 err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Get", resp, "Failure responding to request")
252 return
253 }
254
255 return
256 }
257
258
259 func (client ExportConfigurationsClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, exportID string) (*http.Request, error) {
260 pathParameters := map[string]interface{}{
261 "exportId": autorest.Encode("path", exportID),
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.AsGet(),
274 autorest.WithBaseURL(client.BaseURI),
275 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration/{exportId}", pathParameters),
276 autorest.WithQueryParameters(queryParameters))
277 return preparer.Prepare((&http.Request{}).WithContext(ctx))
278 }
279
280
281
282 func (client ExportConfigurationsClient) GetSender(req *http.Request) (*http.Response, error) {
283 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
284 }
285
286
287
288 func (client ExportConfigurationsClient) GetResponder(resp *http.Response) (result ApplicationInsightsComponentExportConfiguration, err error) {
289 err = autorest.Respond(
290 resp,
291 azure.WithErrorUnlessStatusCode(http.StatusOK),
292 autorest.ByUnmarshallingJSON(&result),
293 autorest.ByClosing())
294 result.Response = autorest.Response{Response: resp}
295 return
296 }
297
298
299
300
301
302 func (client ExportConfigurationsClient) List(ctx context.Context, resourceGroupName string, resourceName string) (result ListApplicationInsightsComponentExportConfiguration, err error) {
303 if tracing.IsEnabled() {
304 ctx = tracing.StartSpan(ctx, fqdn+"/ExportConfigurationsClient.List")
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.ExportConfigurationsClient", "List", err.Error())
320 }
321
322 req, err := client.ListPreparer(ctx, resourceGroupName, resourceName)
323 if err != nil {
324 err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "List", nil, "Failure preparing request")
325 return
326 }
327
328 resp, err := client.ListSender(req)
329 if err != nil {
330 result.Response = autorest.Response{Response: resp}
331 err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "List", resp, "Failure sending request")
332 return
333 }
334
335 result, err = client.ListResponder(resp)
336 if err != nil {
337 err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "List", resp, "Failure responding to request")
338 return
339 }
340
341 return
342 }
343
344
345 func (client ExportConfigurationsClient) ListPreparer(ctx context.Context, resourceGroupName string, resourceName 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 }
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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration", pathParameters),
361 autorest.WithQueryParameters(queryParameters))
362 return preparer.Prepare((&http.Request{}).WithContext(ctx))
363 }
364
365
366
367 func (client ExportConfigurationsClient) ListSender(req *http.Request) (*http.Response, error) {
368 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
369 }
370
371
372
373 func (client ExportConfigurationsClient) ListResponder(resp *http.Response) (result ListApplicationInsightsComponentExportConfiguration, err error) {
374 err = autorest.Respond(
375 resp,
376 azure.WithErrorUnlessStatusCode(http.StatusOK),
377 autorest.ByUnmarshallingJSON(&result.Value),
378 autorest.ByClosing())
379 result.Response = autorest.Response{Response: resp}
380 return
381 }
382
383
384
385
386
387
388
389 func (client ExportConfigurationsClient) Update(ctx context.Context, resourceGroupName string, resourceName string, exportID string, exportProperties ApplicationInsightsComponentExportRequest) (result ApplicationInsightsComponentExportConfiguration, err error) {
390 if tracing.IsEnabled() {
391 ctx = tracing.StartSpan(ctx, fqdn+"/ExportConfigurationsClient.Update")
392 defer func() {
393 sc := -1
394 if result.Response.Response != nil {
395 sc = result.Response.Response.StatusCode
396 }
397 tracing.EndSpan(ctx, sc, err)
398 }()
399 }
400 if err := validation.Validate([]validation.Validation{
401 {TargetValue: resourceGroupName,
402 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
403 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
404 {TargetValue: client.SubscriptionID,
405 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
406 return result, validation.NewError("insights.ExportConfigurationsClient", "Update", err.Error())
407 }
408
409 req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, exportID, exportProperties)
410 if err != nil {
411 err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Update", nil, "Failure preparing request")
412 return
413 }
414
415 resp, err := client.UpdateSender(req)
416 if err != nil {
417 result.Response = autorest.Response{Response: resp}
418 err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Update", resp, "Failure sending request")
419 return
420 }
421
422 result, err = client.UpdateResponder(resp)
423 if err != nil {
424 err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Update", resp, "Failure responding to request")
425 return
426 }
427
428 return
429 }
430
431
432 func (client ExportConfigurationsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, exportID string, exportProperties ApplicationInsightsComponentExportRequest) (*http.Request, error) {
433 pathParameters := map[string]interface{}{
434 "exportId": autorest.Encode("path", exportID),
435 "resourceGroupName": autorest.Encode("path", resourceGroupName),
436 "resourceName": autorest.Encode("path", resourceName),
437 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
438 }
439
440 const APIVersion = "2015-05-01"
441 queryParameters := map[string]interface{}{
442 "api-version": APIVersion,
443 }
444
445 preparer := autorest.CreatePreparer(
446 autorest.AsContentType("application/json; charset=utf-8"),
447 autorest.AsPut(),
448 autorest.WithBaseURL(client.BaseURI),
449 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration/{exportId}", pathParameters),
450 autorest.WithJSON(exportProperties),
451 autorest.WithQueryParameters(queryParameters))
452 return preparer.Prepare((&http.Request{}).WithContext(ctx))
453 }
454
455
456
457 func (client ExportConfigurationsClient) UpdateSender(req *http.Request) (*http.Response, error) {
458 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
459 }
460
461
462
463 func (client ExportConfigurationsClient) UpdateResponder(resp *http.Response) (result ApplicationInsightsComponentExportConfiguration, err error) {
464 err = autorest.Respond(
465 resp,
466 azure.WithErrorUnlessStatusCode(http.StatusOK),
467 autorest.ByUnmarshallingJSON(&result),
468 autorest.ByClosing())
469 result.Response = autorest.Response{Response: resp}
470 return
471 }
472
View as plain text