1 package monitorlegacy
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 LogProfilesClient struct {
20 BaseClient
21 }
22
23
24 func NewLogProfilesClient(subscriptionID string) LogProfilesClient {
25 return NewLogProfilesClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30 func NewLogProfilesClientWithBaseURI(baseURI string, subscriptionID string) LogProfilesClient {
31 return LogProfilesClient{NewWithBaseURI(baseURI, subscriptionID)}
32 }
33
34
35
36
37
38 func (client LogProfilesClient) CreateOrUpdate(ctx context.Context, logProfileName string, parameters LogProfileResource) (result LogProfileResource, err error) {
39 if tracing.IsEnabled() {
40 ctx = tracing.StartSpan(ctx, fqdn+"/LogProfilesClient.CreateOrUpdate")
41 defer func() {
42 sc := -1
43 if result.Response.Response != nil {
44 sc = result.Response.Response.StatusCode
45 }
46 tracing.EndSpan(ctx, sc, err)
47 }()
48 }
49 if err := validation.Validate([]validation.Validation{
50 {TargetValue: parameters,
51 Constraints: []validation.Constraint{{Target: "parameters.LogProfileProperties", Name: validation.Null, Rule: true,
52 Chain: []validation.Constraint{{Target: "parameters.LogProfileProperties.Locations", Name: validation.Null, Rule: true, Chain: nil},
53 {Target: "parameters.LogProfileProperties.Categories", Name: validation.Null, Rule: true, Chain: nil},
54 {Target: "parameters.LogProfileProperties.RetentionPolicy", Name: validation.Null, Rule: true,
55 Chain: []validation.Constraint{{Target: "parameters.LogProfileProperties.RetentionPolicy.Enabled", Name: validation.Null, Rule: true, Chain: nil},
56 {Target: "parameters.LogProfileProperties.RetentionPolicy.Days", Name: validation.Null, Rule: true,
57 Chain: []validation.Constraint{{Target: "parameters.LogProfileProperties.RetentionPolicy.Days", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}},
58 }},
59 }}}},
60 {TargetValue: client.SubscriptionID,
61 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
62 return result, validation.NewError("monitorlegacy.LogProfilesClient", "CreateOrUpdate", err.Error())
63 }
64
65 req, err := client.CreateOrUpdatePreparer(ctx, logProfileName, parameters)
66 if err != nil {
67 err = autorest.NewErrorWithError(err, "monitorlegacy.LogProfilesClient", "CreateOrUpdate", nil, "Failure preparing request")
68 return
69 }
70
71 resp, err := client.CreateOrUpdateSender(req)
72 if err != nil {
73 result.Response = autorest.Response{Response: resp}
74 err = autorest.NewErrorWithError(err, "monitorlegacy.LogProfilesClient", "CreateOrUpdate", resp, "Failure sending request")
75 return
76 }
77
78 result, err = client.CreateOrUpdateResponder(resp)
79 if err != nil {
80 err = autorest.NewErrorWithError(err, "monitorlegacy.LogProfilesClient", "CreateOrUpdate", resp, "Failure responding to request")
81 return
82 }
83
84 return
85 }
86
87
88 func (client LogProfilesClient) CreateOrUpdatePreparer(ctx context.Context, logProfileName string, parameters LogProfileResource) (*http.Request, error) {
89 pathParameters := map[string]interface{}{
90 "logProfileName": autorest.Encode("path", logProfileName),
91 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
92 }
93
94 const APIVersion = "2016-03-01"
95 queryParameters := map[string]interface{}{
96 "api-version": APIVersion,
97 }
98
99 preparer := autorest.CreatePreparer(
100 autorest.AsContentType("application/json; charset=utf-8"),
101 autorest.AsPut(),
102 autorest.WithBaseURL(client.BaseURI),
103 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}", pathParameters),
104 autorest.WithJSON(parameters),
105 autorest.WithQueryParameters(queryParameters))
106 return preparer.Prepare((&http.Request{}).WithContext(ctx))
107 }
108
109
110
111 func (client LogProfilesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
112 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
113 }
114
115
116
117 func (client LogProfilesClient) CreateOrUpdateResponder(resp *http.Response) (result LogProfileResource, err error) {
118 err = autorest.Respond(
119 resp,
120 azure.WithErrorUnlessStatusCode(http.StatusOK),
121 autorest.ByUnmarshallingJSON(&result),
122 autorest.ByClosing())
123 result.Response = autorest.Response{Response: resp}
124 return
125 }
126
127
128
129
130 func (client LogProfilesClient) Delete(ctx context.Context, logProfileName string) (result autorest.Response, err error) {
131 if tracing.IsEnabled() {
132 ctx = tracing.StartSpan(ctx, fqdn+"/LogProfilesClient.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: client.SubscriptionID,
143 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
144 return result, validation.NewError("monitorlegacy.LogProfilesClient", "Delete", err.Error())
145 }
146
147 req, err := client.DeletePreparer(ctx, logProfileName)
148 if err != nil {
149 err = autorest.NewErrorWithError(err, "monitorlegacy.LogProfilesClient", "Delete", nil, "Failure preparing request")
150 return
151 }
152
153 resp, err := client.DeleteSender(req)
154 if err != nil {
155 result.Response = resp
156 err = autorest.NewErrorWithError(err, "monitorlegacy.LogProfilesClient", "Delete", resp, "Failure sending request")
157 return
158 }
159
160 result, err = client.DeleteResponder(resp)
161 if err != nil {
162 err = autorest.NewErrorWithError(err, "monitorlegacy.LogProfilesClient", "Delete", resp, "Failure responding to request")
163 return
164 }
165
166 return
167 }
168
169
170 func (client LogProfilesClient) DeletePreparer(ctx context.Context, logProfileName string) (*http.Request, error) {
171 pathParameters := map[string]interface{}{
172 "logProfileName": autorest.Encode("path", logProfileName),
173 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
174 }
175
176 const APIVersion = "2016-03-01"
177 queryParameters := map[string]interface{}{
178 "api-version": APIVersion,
179 }
180
181 preparer := autorest.CreatePreparer(
182 autorest.AsDelete(),
183 autorest.WithBaseURL(client.BaseURI),
184 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}", pathParameters),
185 autorest.WithQueryParameters(queryParameters))
186 return preparer.Prepare((&http.Request{}).WithContext(ctx))
187 }
188
189
190
191 func (client LogProfilesClient) DeleteSender(req *http.Request) (*http.Response, error) {
192 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
193 }
194
195
196
197 func (client LogProfilesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
198 err = autorest.Respond(
199 resp,
200 azure.WithErrorUnlessStatusCode(http.StatusOK),
201 autorest.ByClosing())
202 result.Response = resp
203 return
204 }
205
206
207
208
209 func (client LogProfilesClient) Get(ctx context.Context, logProfileName string) (result LogProfileResource, err error) {
210 if tracing.IsEnabled() {
211 ctx = tracing.StartSpan(ctx, fqdn+"/LogProfilesClient.Get")
212 defer func() {
213 sc := -1
214 if result.Response.Response != nil {
215 sc = result.Response.Response.StatusCode
216 }
217 tracing.EndSpan(ctx, sc, err)
218 }()
219 }
220 if err := validation.Validate([]validation.Validation{
221 {TargetValue: client.SubscriptionID,
222 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
223 return result, validation.NewError("monitorlegacy.LogProfilesClient", "Get", err.Error())
224 }
225
226 req, err := client.GetPreparer(ctx, logProfileName)
227 if err != nil {
228 err = autorest.NewErrorWithError(err, "monitorlegacy.LogProfilesClient", "Get", nil, "Failure preparing request")
229 return
230 }
231
232 resp, err := client.GetSender(req)
233 if err != nil {
234 result.Response = autorest.Response{Response: resp}
235 err = autorest.NewErrorWithError(err, "monitorlegacy.LogProfilesClient", "Get", resp, "Failure sending request")
236 return
237 }
238
239 result, err = client.GetResponder(resp)
240 if err != nil {
241 err = autorest.NewErrorWithError(err, "monitorlegacy.LogProfilesClient", "Get", resp, "Failure responding to request")
242 return
243 }
244
245 return
246 }
247
248
249 func (client LogProfilesClient) GetPreparer(ctx context.Context, logProfileName string) (*http.Request, error) {
250 pathParameters := map[string]interface{}{
251 "logProfileName": autorest.Encode("path", logProfileName),
252 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
253 }
254
255 const APIVersion = "2016-03-01"
256 queryParameters := map[string]interface{}{
257 "api-version": APIVersion,
258 }
259
260 preparer := autorest.CreatePreparer(
261 autorest.AsGet(),
262 autorest.WithBaseURL(client.BaseURI),
263 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}", pathParameters),
264 autorest.WithQueryParameters(queryParameters))
265 return preparer.Prepare((&http.Request{}).WithContext(ctx))
266 }
267
268
269
270 func (client LogProfilesClient) GetSender(req *http.Request) (*http.Response, error) {
271 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
272 }
273
274
275
276 func (client LogProfilesClient) GetResponder(resp *http.Response) (result LogProfileResource, err error) {
277 err = autorest.Respond(
278 resp,
279 azure.WithErrorUnlessStatusCode(http.StatusOK),
280 autorest.ByUnmarshallingJSON(&result),
281 autorest.ByClosing())
282 result.Response = autorest.Response{Response: resp}
283 return
284 }
285
286
287 func (client LogProfilesClient) List(ctx context.Context) (result LogProfileCollection, err error) {
288 if tracing.IsEnabled() {
289 ctx = tracing.StartSpan(ctx, fqdn+"/LogProfilesClient.List")
290 defer func() {
291 sc := -1
292 if result.Response.Response != nil {
293 sc = result.Response.Response.StatusCode
294 }
295 tracing.EndSpan(ctx, sc, err)
296 }()
297 }
298 if err := validation.Validate([]validation.Validation{
299 {TargetValue: client.SubscriptionID,
300 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
301 return result, validation.NewError("monitorlegacy.LogProfilesClient", "List", err.Error())
302 }
303
304 req, err := client.ListPreparer(ctx)
305 if err != nil {
306 err = autorest.NewErrorWithError(err, "monitorlegacy.LogProfilesClient", "List", nil, "Failure preparing request")
307 return
308 }
309
310 resp, err := client.ListSender(req)
311 if err != nil {
312 result.Response = autorest.Response{Response: resp}
313 err = autorest.NewErrorWithError(err, "monitorlegacy.LogProfilesClient", "List", resp, "Failure sending request")
314 return
315 }
316
317 result, err = client.ListResponder(resp)
318 if err != nil {
319 err = autorest.NewErrorWithError(err, "monitorlegacy.LogProfilesClient", "List", resp, "Failure responding to request")
320 return
321 }
322
323 return
324 }
325
326
327 func (client LogProfilesClient) ListPreparer(ctx context.Context) (*http.Request, error) {
328 pathParameters := map[string]interface{}{
329 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
330 }
331
332 const APIVersion = "2016-03-01"
333 queryParameters := map[string]interface{}{
334 "api-version": APIVersion,
335 }
336
337 preparer := autorest.CreatePreparer(
338 autorest.AsGet(),
339 autorest.WithBaseURL(client.BaseURI),
340 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles", pathParameters),
341 autorest.WithQueryParameters(queryParameters))
342 return preparer.Prepare((&http.Request{}).WithContext(ctx))
343 }
344
345
346
347 func (client LogProfilesClient) ListSender(req *http.Request) (*http.Response, error) {
348 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
349 }
350
351
352
353 func (client LogProfilesClient) ListResponder(resp *http.Response) (result LogProfileCollection, err error) {
354 err = autorest.Respond(
355 resp,
356 azure.WithErrorUnlessStatusCode(http.StatusOK),
357 autorest.ByUnmarshallingJSON(&result),
358 autorest.ByClosing())
359 result.Response = autorest.Response{Response: resp}
360 return
361 }
362
363
364
365
366
367 func (client LogProfilesClient) Update(ctx context.Context, logProfileName string, logProfilesResource LogProfileResourcePatch) (result LogProfileResource, err error) {
368 if tracing.IsEnabled() {
369 ctx = tracing.StartSpan(ctx, fqdn+"/LogProfilesClient.Update")
370 defer func() {
371 sc := -1
372 if result.Response.Response != nil {
373 sc = result.Response.Response.StatusCode
374 }
375 tracing.EndSpan(ctx, sc, err)
376 }()
377 }
378 if err := validation.Validate([]validation.Validation{
379 {TargetValue: client.SubscriptionID,
380 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
381 return result, validation.NewError("monitorlegacy.LogProfilesClient", "Update", err.Error())
382 }
383
384 req, err := client.UpdatePreparer(ctx, logProfileName, logProfilesResource)
385 if err != nil {
386 err = autorest.NewErrorWithError(err, "monitorlegacy.LogProfilesClient", "Update", nil, "Failure preparing request")
387 return
388 }
389
390 resp, err := client.UpdateSender(req)
391 if err != nil {
392 result.Response = autorest.Response{Response: resp}
393 err = autorest.NewErrorWithError(err, "monitorlegacy.LogProfilesClient", "Update", resp, "Failure sending request")
394 return
395 }
396
397 result, err = client.UpdateResponder(resp)
398 if err != nil {
399 err = autorest.NewErrorWithError(err, "monitorlegacy.LogProfilesClient", "Update", resp, "Failure responding to request")
400 return
401 }
402
403 return
404 }
405
406
407 func (client LogProfilesClient) UpdatePreparer(ctx context.Context, logProfileName string, logProfilesResource LogProfileResourcePatch) (*http.Request, error) {
408 pathParameters := map[string]interface{}{
409 "logProfileName": autorest.Encode("path", logProfileName),
410 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
411 }
412
413 const APIVersion = "2016-03-01"
414 queryParameters := map[string]interface{}{
415 "api-version": APIVersion,
416 }
417
418 preparer := autorest.CreatePreparer(
419 autorest.AsContentType("application/json; charset=utf-8"),
420 autorest.AsPatch(),
421 autorest.WithBaseURL(client.BaseURI),
422 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}", pathParameters),
423 autorest.WithJSON(logProfilesResource),
424 autorest.WithQueryParameters(queryParameters))
425 return preparer.Prepare((&http.Request{}).WithContext(ctx))
426 }
427
428
429
430 func (client LogProfilesClient) UpdateSender(req *http.Request) (*http.Response, error) {
431 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
432 }
433
434
435
436 func (client LogProfilesClient) UpdateResponder(resp *http.Response) (result LogProfileResource, err error) {
437 err = autorest.Respond(
438 resp,
439 azure.WithErrorUnlessStatusCode(http.StatusOK),
440 autorest.ByUnmarshallingJSON(&result),
441 autorest.ByClosing())
442 result.Response = autorest.Response{Response: resp}
443 return
444 }
445
View as plain text