1 package managedapplications
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 ApplicationsClient struct {
20 BaseClient
21 }
22
23
24 func NewApplicationsClient(subscriptionID string) ApplicationsClient {
25 return NewApplicationsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30 func NewApplicationsClientWithBaseURI(baseURI string, subscriptionID string) ApplicationsClient {
31 return ApplicationsClient{NewWithBaseURI(baseURI, subscriptionID)}
32 }
33
34
35
36
37
38
39 func (client ApplicationsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, applicationName string, parameters Application) (result ApplicationsCreateOrUpdateFuture, err error) {
40 if tracing.IsEnabled() {
41 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.CreateOrUpdate")
42 defer func() {
43 sc := -1
44 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
45 sc = result.FutureAPI.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: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}},
55 {TargetValue: applicationName,
56 Constraints: []validation.Constraint{{Target: "applicationName", Name: validation.MaxLength, Rule: 64, Chain: nil},
57 {Target: "applicationName", Name: validation.MinLength, Rule: 3, Chain: nil}}},
58 {TargetValue: parameters,
59 Constraints: []validation.Constraint{{Target: "parameters.ApplicationProperties", Name: validation.Null, Rule: true,
60 Chain: []validation.Constraint{{Target: "parameters.ApplicationProperties.ManagedResourceGroupID", Name: validation.Null, Rule: true, Chain: nil}}},
61 {Target: "parameters.Plan", Name: validation.Null, Rule: false,
62 Chain: []validation.Constraint{{Target: "parameters.Plan.Name", Name: validation.Null, Rule: true, Chain: nil},
63 {Target: "parameters.Plan.Publisher", Name: validation.Null, Rule: true, Chain: nil},
64 {Target: "parameters.Plan.Product", Name: validation.Null, Rule: true, Chain: nil},
65 {Target: "parameters.Plan.Version", Name: validation.Null, Rule: true, Chain: nil},
66 }},
67 {Target: "parameters.Kind", Name: validation.Null, Rule: true,
68 Chain: []validation.Constraint{{Target: "parameters.Kind", Name: validation.Pattern, Rule: `^[-\w\._,\(\)]+$`, Chain: nil}}}}}}); err != nil {
69 return result, validation.NewError("managedapplications.ApplicationsClient", "CreateOrUpdate", err.Error())
70 }
71
72 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, applicationName, parameters)
73 if err != nil {
74 err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "CreateOrUpdate", nil, "Failure preparing request")
75 return
76 }
77
78 result, err = client.CreateOrUpdateSender(req)
79 if err != nil {
80 err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "CreateOrUpdate", result.Response(), "Failure sending request")
81 return
82 }
83
84 return
85 }
86
87
88 func (client ApplicationsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, applicationName string, parameters Application) (*http.Request, error) {
89 pathParameters := map[string]interface{}{
90 "applicationName": autorest.Encode("path", applicationName),
91 "resourceGroupName": autorest.Encode("path", resourceGroupName),
92 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
93 }
94
95 const APIVersion = "2018-06-01"
96 queryParameters := map[string]interface{}{
97 "api-version": APIVersion,
98 }
99
100 preparer := autorest.CreatePreparer(
101 autorest.AsContentType("application/json; charset=utf-8"),
102 autorest.AsPut(),
103 autorest.WithBaseURL(client.BaseURI),
104 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}", pathParameters),
105 autorest.WithJSON(parameters),
106 autorest.WithQueryParameters(queryParameters))
107 return preparer.Prepare((&http.Request{}).WithContext(ctx))
108 }
109
110
111
112 func (client ApplicationsClient) CreateOrUpdateSender(req *http.Request) (future ApplicationsCreateOrUpdateFuture, err error) {
113 var resp *http.Response
114 future.FutureAPI = &azure.Future{}
115 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
116 if err != nil {
117 return
118 }
119 var azf azure.Future
120 azf, err = azure.NewFutureFromResponse(resp)
121 future.FutureAPI = &azf
122 future.Result = future.result
123 return
124 }
125
126
127
128 func (client ApplicationsClient) CreateOrUpdateResponder(resp *http.Response) (result Application, err error) {
129 err = autorest.Respond(
130 resp,
131 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
132 autorest.ByUnmarshallingJSON(&result),
133 autorest.ByClosing())
134 result.Response = autorest.Response{Response: resp}
135 return
136 }
137
138
139
140
141
142
143
144 func (client ApplicationsClient) CreateOrUpdateByID(ctx context.Context, applicationID string, parameters Application) (result ApplicationsCreateOrUpdateByIDFuture, err error) {
145 if tracing.IsEnabled() {
146 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.CreateOrUpdateByID")
147 defer func() {
148 sc := -1
149 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
150 sc = result.FutureAPI.Response().StatusCode
151 }
152 tracing.EndSpan(ctx, sc, err)
153 }()
154 }
155 if err := validation.Validate([]validation.Validation{
156 {TargetValue: parameters,
157 Constraints: []validation.Constraint{{Target: "parameters.ApplicationProperties", Name: validation.Null, Rule: true,
158 Chain: []validation.Constraint{{Target: "parameters.ApplicationProperties.ManagedResourceGroupID", Name: validation.Null, Rule: true, Chain: nil}}},
159 {Target: "parameters.Plan", Name: validation.Null, Rule: false,
160 Chain: []validation.Constraint{{Target: "parameters.Plan.Name", Name: validation.Null, Rule: true, Chain: nil},
161 {Target: "parameters.Plan.Publisher", Name: validation.Null, Rule: true, Chain: nil},
162 {Target: "parameters.Plan.Product", Name: validation.Null, Rule: true, Chain: nil},
163 {Target: "parameters.Plan.Version", Name: validation.Null, Rule: true, Chain: nil},
164 }},
165 {Target: "parameters.Kind", Name: validation.Null, Rule: true,
166 Chain: []validation.Constraint{{Target: "parameters.Kind", Name: validation.Pattern, Rule: `^[-\w\._,\(\)]+$`, Chain: nil}}}}}}); err != nil {
167 return result, validation.NewError("managedapplications.ApplicationsClient", "CreateOrUpdateByID", err.Error())
168 }
169
170 req, err := client.CreateOrUpdateByIDPreparer(ctx, applicationID, parameters)
171 if err != nil {
172 err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "CreateOrUpdateByID", nil, "Failure preparing request")
173 return
174 }
175
176 result, err = client.CreateOrUpdateByIDSender(req)
177 if err != nil {
178 err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "CreateOrUpdateByID", result.Response(), "Failure sending request")
179 return
180 }
181
182 return
183 }
184
185
186 func (client ApplicationsClient) CreateOrUpdateByIDPreparer(ctx context.Context, applicationID string, parameters Application) (*http.Request, error) {
187 pathParameters := map[string]interface{}{
188 "applicationId": applicationID,
189 }
190
191 const APIVersion = "2018-06-01"
192 queryParameters := map[string]interface{}{
193 "api-version": APIVersion,
194 }
195
196 preparer := autorest.CreatePreparer(
197 autorest.AsContentType("application/json; charset=utf-8"),
198 autorest.AsPut(),
199 autorest.WithBaseURL(client.BaseURI),
200 autorest.WithPathParameters("/{applicationId}", pathParameters),
201 autorest.WithJSON(parameters),
202 autorest.WithQueryParameters(queryParameters))
203 return preparer.Prepare((&http.Request{}).WithContext(ctx))
204 }
205
206
207
208 func (client ApplicationsClient) CreateOrUpdateByIDSender(req *http.Request) (future ApplicationsCreateOrUpdateByIDFuture, err error) {
209 var resp *http.Response
210 future.FutureAPI = &azure.Future{}
211 resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
212 if err != nil {
213 return
214 }
215 var azf azure.Future
216 azf, err = azure.NewFutureFromResponse(resp)
217 future.FutureAPI = &azf
218 future.Result = future.result
219 return
220 }
221
222
223
224 func (client ApplicationsClient) CreateOrUpdateByIDResponder(resp *http.Response) (result Application, err error) {
225 err = autorest.Respond(
226 resp,
227 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
228 autorest.ByUnmarshallingJSON(&result),
229 autorest.ByClosing())
230 result.Response = autorest.Response{Response: resp}
231 return
232 }
233
234
235
236
237
238 func (client ApplicationsClient) Delete(ctx context.Context, resourceGroupName string, applicationName string) (result ApplicationsDeleteFuture, err error) {
239 if tracing.IsEnabled() {
240 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.Delete")
241 defer func() {
242 sc := -1
243 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
244 sc = result.FutureAPI.Response().StatusCode
245 }
246 tracing.EndSpan(ctx, sc, err)
247 }()
248 }
249 if err := validation.Validate([]validation.Validation{
250 {TargetValue: resourceGroupName,
251 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
252 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
253 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}},
254 {TargetValue: applicationName,
255 Constraints: []validation.Constraint{{Target: "applicationName", Name: validation.MaxLength, Rule: 64, Chain: nil},
256 {Target: "applicationName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil {
257 return result, validation.NewError("managedapplications.ApplicationsClient", "Delete", err.Error())
258 }
259
260 req, err := client.DeletePreparer(ctx, resourceGroupName, applicationName)
261 if err != nil {
262 err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "Delete", nil, "Failure preparing request")
263 return
264 }
265
266 result, err = client.DeleteSender(req)
267 if err != nil {
268 err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "Delete", result.Response(), "Failure sending request")
269 return
270 }
271
272 return
273 }
274
275
276 func (client ApplicationsClient) DeletePreparer(ctx context.Context, resourceGroupName string, applicationName string) (*http.Request, error) {
277 pathParameters := map[string]interface{}{
278 "applicationName": autorest.Encode("path", applicationName),
279 "resourceGroupName": autorest.Encode("path", resourceGroupName),
280 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
281 }
282
283 const APIVersion = "2018-06-01"
284 queryParameters := map[string]interface{}{
285 "api-version": APIVersion,
286 }
287
288 preparer := autorest.CreatePreparer(
289 autorest.AsDelete(),
290 autorest.WithBaseURL(client.BaseURI),
291 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}", pathParameters),
292 autorest.WithQueryParameters(queryParameters))
293 return preparer.Prepare((&http.Request{}).WithContext(ctx))
294 }
295
296
297
298 func (client ApplicationsClient) DeleteSender(req *http.Request) (future ApplicationsDeleteFuture, err error) {
299 var resp *http.Response
300 future.FutureAPI = &azure.Future{}
301 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
302 if err != nil {
303 return
304 }
305 var azf azure.Future
306 azf, err = azure.NewFutureFromResponse(resp)
307 future.FutureAPI = &azf
308 future.Result = future.result
309 return
310 }
311
312
313
314 func (client ApplicationsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
315 err = autorest.Respond(
316 resp,
317 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
318 autorest.ByClosing())
319 result.Response = resp
320 return
321 }
322
323
324
325
326
327
328 func (client ApplicationsClient) DeleteByID(ctx context.Context, applicationID string) (result ApplicationsDeleteByIDFuture, err error) {
329 if tracing.IsEnabled() {
330 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.DeleteByID")
331 defer func() {
332 sc := -1
333 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
334 sc = result.FutureAPI.Response().StatusCode
335 }
336 tracing.EndSpan(ctx, sc, err)
337 }()
338 }
339 req, err := client.DeleteByIDPreparer(ctx, applicationID)
340 if err != nil {
341 err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "DeleteByID", nil, "Failure preparing request")
342 return
343 }
344
345 result, err = client.DeleteByIDSender(req)
346 if err != nil {
347 err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "DeleteByID", result.Response(), "Failure sending request")
348 return
349 }
350
351 return
352 }
353
354
355 func (client ApplicationsClient) DeleteByIDPreparer(ctx context.Context, applicationID string) (*http.Request, error) {
356 pathParameters := map[string]interface{}{
357 "applicationId": applicationID,
358 }
359
360 const APIVersion = "2018-06-01"
361 queryParameters := map[string]interface{}{
362 "api-version": APIVersion,
363 }
364
365 preparer := autorest.CreatePreparer(
366 autorest.AsDelete(),
367 autorest.WithBaseURL(client.BaseURI),
368 autorest.WithPathParameters("/{applicationId}", pathParameters),
369 autorest.WithQueryParameters(queryParameters))
370 return preparer.Prepare((&http.Request{}).WithContext(ctx))
371 }
372
373
374
375 func (client ApplicationsClient) DeleteByIDSender(req *http.Request) (future ApplicationsDeleteByIDFuture, err error) {
376 var resp *http.Response
377 future.FutureAPI = &azure.Future{}
378 resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
379 if err != nil {
380 return
381 }
382 var azf azure.Future
383 azf, err = azure.NewFutureFromResponse(resp)
384 future.FutureAPI = &azf
385 future.Result = future.result
386 return
387 }
388
389
390
391 func (client ApplicationsClient) DeleteByIDResponder(resp *http.Response) (result autorest.Response, err error) {
392 err = autorest.Respond(
393 resp,
394 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
395 autorest.ByClosing())
396 result.Response = resp
397 return
398 }
399
400
401
402
403
404 func (client ApplicationsClient) Get(ctx context.Context, resourceGroupName string, applicationName string) (result Application, err error) {
405 if tracing.IsEnabled() {
406 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.Get")
407 defer func() {
408 sc := -1
409 if result.Response.Response != nil {
410 sc = result.Response.Response.StatusCode
411 }
412 tracing.EndSpan(ctx, sc, err)
413 }()
414 }
415 if err := validation.Validate([]validation.Validation{
416 {TargetValue: resourceGroupName,
417 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
418 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
419 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}},
420 {TargetValue: applicationName,
421 Constraints: []validation.Constraint{{Target: "applicationName", Name: validation.MaxLength, Rule: 64, Chain: nil},
422 {Target: "applicationName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil {
423 return result, validation.NewError("managedapplications.ApplicationsClient", "Get", err.Error())
424 }
425
426 req, err := client.GetPreparer(ctx, resourceGroupName, applicationName)
427 if err != nil {
428 err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "Get", nil, "Failure preparing request")
429 return
430 }
431
432 resp, err := client.GetSender(req)
433 if err != nil {
434 result.Response = autorest.Response{Response: resp}
435 err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "Get", resp, "Failure sending request")
436 return
437 }
438
439 result, err = client.GetResponder(resp)
440 if err != nil {
441 err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "Get", resp, "Failure responding to request")
442 return
443 }
444
445 return
446 }
447
448
449 func (client ApplicationsClient) GetPreparer(ctx context.Context, resourceGroupName string, applicationName string) (*http.Request, error) {
450 pathParameters := map[string]interface{}{
451 "applicationName": autorest.Encode("path", applicationName),
452 "resourceGroupName": autorest.Encode("path", resourceGroupName),
453 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
454 }
455
456 const APIVersion = "2018-06-01"
457 queryParameters := map[string]interface{}{
458 "api-version": APIVersion,
459 }
460
461 preparer := autorest.CreatePreparer(
462 autorest.AsGet(),
463 autorest.WithBaseURL(client.BaseURI),
464 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}", pathParameters),
465 autorest.WithQueryParameters(queryParameters))
466 return preparer.Prepare((&http.Request{}).WithContext(ctx))
467 }
468
469
470
471 func (client ApplicationsClient) GetSender(req *http.Request) (*http.Response, error) {
472 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
473 }
474
475
476
477 func (client ApplicationsClient) GetResponder(resp *http.Response) (result Application, err error) {
478 err = autorest.Respond(
479 resp,
480 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound),
481 autorest.ByUnmarshallingJSON(&result),
482 autorest.ByClosing())
483 result.Response = autorest.Response{Response: resp}
484 return
485 }
486
487
488
489
490
491
492 func (client ApplicationsClient) GetByID(ctx context.Context, applicationID string) (result Application, err error) {
493 if tracing.IsEnabled() {
494 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.GetByID")
495 defer func() {
496 sc := -1
497 if result.Response.Response != nil {
498 sc = result.Response.Response.StatusCode
499 }
500 tracing.EndSpan(ctx, sc, err)
501 }()
502 }
503 req, err := client.GetByIDPreparer(ctx, applicationID)
504 if err != nil {
505 err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "GetByID", nil, "Failure preparing request")
506 return
507 }
508
509 resp, err := client.GetByIDSender(req)
510 if err != nil {
511 result.Response = autorest.Response{Response: resp}
512 err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "GetByID", resp, "Failure sending request")
513 return
514 }
515
516 result, err = client.GetByIDResponder(resp)
517 if err != nil {
518 err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "GetByID", resp, "Failure responding to request")
519 return
520 }
521
522 return
523 }
524
525
526 func (client ApplicationsClient) GetByIDPreparer(ctx context.Context, applicationID string) (*http.Request, error) {
527 pathParameters := map[string]interface{}{
528 "applicationId": applicationID,
529 }
530
531 const APIVersion = "2018-06-01"
532 queryParameters := map[string]interface{}{
533 "api-version": APIVersion,
534 }
535
536 preparer := autorest.CreatePreparer(
537 autorest.AsGet(),
538 autorest.WithBaseURL(client.BaseURI),
539 autorest.WithPathParameters("/{applicationId}", pathParameters),
540 autorest.WithQueryParameters(queryParameters))
541 return preparer.Prepare((&http.Request{}).WithContext(ctx))
542 }
543
544
545
546 func (client ApplicationsClient) GetByIDSender(req *http.Request) (*http.Response, error) {
547 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
548 }
549
550
551
552 func (client ApplicationsClient) GetByIDResponder(resp *http.Response) (result Application, err error) {
553 err = autorest.Respond(
554 resp,
555 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound),
556 autorest.ByUnmarshallingJSON(&result),
557 autorest.ByClosing())
558 result.Response = autorest.Response{Response: resp}
559 return
560 }
561
562
563
564
565 func (client ApplicationsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ApplicationListResultPage, err error) {
566 if tracing.IsEnabled() {
567 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.ListByResourceGroup")
568 defer func() {
569 sc := -1
570 if result.alr.Response.Response != nil {
571 sc = result.alr.Response.Response.StatusCode
572 }
573 tracing.EndSpan(ctx, sc, err)
574 }()
575 }
576 if err := validation.Validate([]validation.Validation{
577 {TargetValue: resourceGroupName,
578 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
579 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
580 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil {
581 return result, validation.NewError("managedapplications.ApplicationsClient", "ListByResourceGroup", err.Error())
582 }
583
584 result.fn = client.listByResourceGroupNextResults
585 req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
586 if err != nil {
587 err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "ListByResourceGroup", nil, "Failure preparing request")
588 return
589 }
590
591 resp, err := client.ListByResourceGroupSender(req)
592 if err != nil {
593 result.alr.Response = autorest.Response{Response: resp}
594 err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "ListByResourceGroup", resp, "Failure sending request")
595 return
596 }
597
598 result.alr, err = client.ListByResourceGroupResponder(resp)
599 if err != nil {
600 err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "ListByResourceGroup", resp, "Failure responding to request")
601 return
602 }
603 if result.alr.hasNextLink() && result.alr.IsEmpty() {
604 err = result.NextWithContext(ctx)
605 return
606 }
607
608 return
609 }
610
611
612 func (client ApplicationsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
613 pathParameters := map[string]interface{}{
614 "resourceGroupName": autorest.Encode("path", resourceGroupName),
615 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
616 }
617
618 const APIVersion = "2018-06-01"
619 queryParameters := map[string]interface{}{
620 "api-version": APIVersion,
621 }
622
623 preparer := autorest.CreatePreparer(
624 autorest.AsGet(),
625 autorest.WithBaseURL(client.BaseURI),
626 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications", pathParameters),
627 autorest.WithQueryParameters(queryParameters))
628 return preparer.Prepare((&http.Request{}).WithContext(ctx))
629 }
630
631
632
633 func (client ApplicationsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
634 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
635 }
636
637
638
639 func (client ApplicationsClient) ListByResourceGroupResponder(resp *http.Response) (result ApplicationListResult, err error) {
640 err = autorest.Respond(
641 resp,
642 azure.WithErrorUnlessStatusCode(http.StatusOK),
643 autorest.ByUnmarshallingJSON(&result),
644 autorest.ByClosing())
645 result.Response = autorest.Response{Response: resp}
646 return
647 }
648
649
650 func (client ApplicationsClient) listByResourceGroupNextResults(ctx context.Context, lastResults ApplicationListResult) (result ApplicationListResult, err error) {
651 req, err := lastResults.applicationListResultPreparer(ctx)
652 if err != nil {
653 return result, autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
654 }
655 if req == nil {
656 return
657 }
658 resp, err := client.ListByResourceGroupSender(req)
659 if err != nil {
660 result.Response = autorest.Response{Response: resp}
661 return result, autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
662 }
663 result, err = client.ListByResourceGroupResponder(resp)
664 if err != nil {
665 err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
666 }
667 return
668 }
669
670
671 func (client ApplicationsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ApplicationListResultIterator, err error) {
672 if tracing.IsEnabled() {
673 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.ListByResourceGroup")
674 defer func() {
675 sc := -1
676 if result.Response().Response.Response != nil {
677 sc = result.page.Response().Response.Response.StatusCode
678 }
679 tracing.EndSpan(ctx, sc, err)
680 }()
681 }
682 result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
683 return
684 }
685
686
687 func (client ApplicationsClient) ListBySubscription(ctx context.Context) (result ApplicationListResultPage, err error) {
688 if tracing.IsEnabled() {
689 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.ListBySubscription")
690 defer func() {
691 sc := -1
692 if result.alr.Response.Response != nil {
693 sc = result.alr.Response.Response.StatusCode
694 }
695 tracing.EndSpan(ctx, sc, err)
696 }()
697 }
698 result.fn = client.listBySubscriptionNextResults
699 req, err := client.ListBySubscriptionPreparer(ctx)
700 if err != nil {
701 err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "ListBySubscription", nil, "Failure preparing request")
702 return
703 }
704
705 resp, err := client.ListBySubscriptionSender(req)
706 if err != nil {
707 result.alr.Response = autorest.Response{Response: resp}
708 err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "ListBySubscription", resp, "Failure sending request")
709 return
710 }
711
712 result.alr, err = client.ListBySubscriptionResponder(resp)
713 if err != nil {
714 err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "ListBySubscription", resp, "Failure responding to request")
715 return
716 }
717 if result.alr.hasNextLink() && result.alr.IsEmpty() {
718 err = result.NextWithContext(ctx)
719 return
720 }
721
722 return
723 }
724
725
726 func (client ApplicationsClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) {
727 pathParameters := map[string]interface{}{
728 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
729 }
730
731 const APIVersion = "2018-06-01"
732 queryParameters := map[string]interface{}{
733 "api-version": APIVersion,
734 }
735
736 preparer := autorest.CreatePreparer(
737 autorest.AsGet(),
738 autorest.WithBaseURL(client.BaseURI),
739 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications", pathParameters),
740 autorest.WithQueryParameters(queryParameters))
741 return preparer.Prepare((&http.Request{}).WithContext(ctx))
742 }
743
744
745
746 func (client ApplicationsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) {
747 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
748 }
749
750
751
752 func (client ApplicationsClient) ListBySubscriptionResponder(resp *http.Response) (result ApplicationListResult, err error) {
753 err = autorest.Respond(
754 resp,
755 azure.WithErrorUnlessStatusCode(http.StatusOK),
756 autorest.ByUnmarshallingJSON(&result),
757 autorest.ByClosing())
758 result.Response = autorest.Response{Response: resp}
759 return
760 }
761
762
763 func (client ApplicationsClient) listBySubscriptionNextResults(ctx context.Context, lastResults ApplicationListResult) (result ApplicationListResult, err error) {
764 req, err := lastResults.applicationListResultPreparer(ctx)
765 if err != nil {
766 return result, autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request")
767 }
768 if req == nil {
769 return
770 }
771 resp, err := client.ListBySubscriptionSender(req)
772 if err != nil {
773 result.Response = autorest.Response{Response: resp}
774 return result, autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "listBySubscriptionNextResults", resp, "Failure sending next results request")
775 }
776 result, err = client.ListBySubscriptionResponder(resp)
777 if err != nil {
778 err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request")
779 }
780 return
781 }
782
783
784 func (client ApplicationsClient) ListBySubscriptionComplete(ctx context.Context) (result ApplicationListResultIterator, err error) {
785 if tracing.IsEnabled() {
786 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.ListBySubscription")
787 defer func() {
788 sc := -1
789 if result.Response().Response.Response != nil {
790 sc = result.page.Response().Response.Response.StatusCode
791 }
792 tracing.EndSpan(ctx, sc, err)
793 }()
794 }
795 result.page, err = client.ListBySubscription(ctx)
796 return
797 }
798
799
800
801
802
803
804 func (client ApplicationsClient) Update(ctx context.Context, resourceGroupName string, applicationName string, parameters *ApplicationPatchable) (result Application, err error) {
805 if tracing.IsEnabled() {
806 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.Update")
807 defer func() {
808 sc := -1
809 if result.Response.Response != nil {
810 sc = result.Response.Response.StatusCode
811 }
812 tracing.EndSpan(ctx, sc, err)
813 }()
814 }
815 if err := validation.Validate([]validation.Validation{
816 {TargetValue: resourceGroupName,
817 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
818 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
819 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}},
820 {TargetValue: applicationName,
821 Constraints: []validation.Constraint{{Target: "applicationName", Name: validation.MaxLength, Rule: 64, Chain: nil},
822 {Target: "applicationName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil {
823 return result, validation.NewError("managedapplications.ApplicationsClient", "Update", err.Error())
824 }
825
826 req, err := client.UpdatePreparer(ctx, resourceGroupName, applicationName, parameters)
827 if err != nil {
828 err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "Update", nil, "Failure preparing request")
829 return
830 }
831
832 resp, err := client.UpdateSender(req)
833 if err != nil {
834 result.Response = autorest.Response{Response: resp}
835 err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "Update", resp, "Failure sending request")
836 return
837 }
838
839 result, err = client.UpdateResponder(resp)
840 if err != nil {
841 err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "Update", resp, "Failure responding to request")
842 return
843 }
844
845 return
846 }
847
848
849 func (client ApplicationsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, applicationName string, parameters *ApplicationPatchable) (*http.Request, error) {
850 pathParameters := map[string]interface{}{
851 "applicationName": autorest.Encode("path", applicationName),
852 "resourceGroupName": autorest.Encode("path", resourceGroupName),
853 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
854 }
855
856 const APIVersion = "2018-06-01"
857 queryParameters := map[string]interface{}{
858 "api-version": APIVersion,
859 }
860
861 preparer := autorest.CreatePreparer(
862 autorest.AsContentType("application/json; charset=utf-8"),
863 autorest.AsPatch(),
864 autorest.WithBaseURL(client.BaseURI),
865 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}", pathParameters),
866 autorest.WithQueryParameters(queryParameters))
867 if parameters != nil {
868 preparer = autorest.DecoratePreparer(preparer,
869 autorest.WithJSON(parameters))
870 }
871 return preparer.Prepare((&http.Request{}).WithContext(ctx))
872 }
873
874
875
876 func (client ApplicationsClient) UpdateSender(req *http.Request) (*http.Response, error) {
877 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
878 }
879
880
881
882 func (client ApplicationsClient) UpdateResponder(resp *http.Response) (result Application, err error) {
883 err = autorest.Respond(
884 resp,
885 azure.WithErrorUnlessStatusCode(http.StatusOK),
886 autorest.ByUnmarshallingJSON(&result),
887 autorest.ByClosing())
888 result.Response = autorest.Response{Response: resp}
889 return
890 }
891
892
893
894
895
896
897
898
899 func (client ApplicationsClient) UpdateByID(ctx context.Context, applicationID string, parameters *Application) (result Application, err error) {
900 if tracing.IsEnabled() {
901 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.UpdateByID")
902 defer func() {
903 sc := -1
904 if result.Response.Response != nil {
905 sc = result.Response.Response.StatusCode
906 }
907 tracing.EndSpan(ctx, sc, err)
908 }()
909 }
910 req, err := client.UpdateByIDPreparer(ctx, applicationID, parameters)
911 if err != nil {
912 err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "UpdateByID", nil, "Failure preparing request")
913 return
914 }
915
916 resp, err := client.UpdateByIDSender(req)
917 if err != nil {
918 result.Response = autorest.Response{Response: resp}
919 err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "UpdateByID", resp, "Failure sending request")
920 return
921 }
922
923 result, err = client.UpdateByIDResponder(resp)
924 if err != nil {
925 err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "UpdateByID", resp, "Failure responding to request")
926 return
927 }
928
929 return
930 }
931
932
933 func (client ApplicationsClient) UpdateByIDPreparer(ctx context.Context, applicationID string, parameters *Application) (*http.Request, error) {
934 pathParameters := map[string]interface{}{
935 "applicationId": applicationID,
936 }
937
938 const APIVersion = "2018-06-01"
939 queryParameters := map[string]interface{}{
940 "api-version": APIVersion,
941 }
942
943 preparer := autorest.CreatePreparer(
944 autorest.AsContentType("application/json; charset=utf-8"),
945 autorest.AsPatch(),
946 autorest.WithBaseURL(client.BaseURI),
947 autorest.WithPathParameters("/{applicationId}", pathParameters),
948 autorest.WithQueryParameters(queryParameters))
949 if parameters != nil {
950 preparer = autorest.DecoratePreparer(preparer,
951 autorest.WithJSON(parameters))
952 }
953 return preparer.Prepare((&http.Request{}).WithContext(ctx))
954 }
955
956
957
958 func (client ApplicationsClient) UpdateByIDSender(req *http.Request) (*http.Response, error) {
959 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
960 }
961
962
963
964 func (client ApplicationsClient) UpdateByIDResponder(resp *http.Response) (result Application, err error) {
965 err = autorest.Respond(
966 resp,
967 azure.WithErrorUnlessStatusCode(http.StatusOK),
968 autorest.ByUnmarshallingJSON(&result),
969 autorest.ByClosing())
970 result.Response = autorest.Response{Response: resp}
971 return
972 }
973
View as plain text