1package managedapplications
2
3// Copyright (c) Microsoft and contributors.  All rights reserved.
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13//
14// See the License for the specific language governing permissions and
15// limitations under the License.
16//
17// Code generated by Microsoft (R) AutoRest Code Generator.
18// Changes may cause incorrect behavior and will be lost if the code is regenerated.
19
20import (
21	"context"
22	"encoding/json"
23	"github.com/Azure/go-autorest/autorest"
24	"github.com/Azure/go-autorest/autorest/azure"
25	"github.com/Azure/go-autorest/autorest/to"
26	"github.com/Azure/go-autorest/tracing"
27	"net/http"
28)
29
30// The package's fully qualified name.
31const fqdn = "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-09-01/managedapplications"
32
33// ApplicationArtifactType enumerates the values for application artifact type.
34type ApplicationArtifactType string
35
36const (
37	// Custom ...
38	Custom ApplicationArtifactType = "Custom"
39	// Template ...
40	Template ApplicationArtifactType = "Template"
41)
42
43// PossibleApplicationArtifactTypeValues returns an array of possible values for the ApplicationArtifactType const type.
44func PossibleApplicationArtifactTypeValues() []ApplicationArtifactType {
45	return []ApplicationArtifactType{Custom, Template}
46}
47
48// ApplicationLockLevel enumerates the values for application lock level.
49type ApplicationLockLevel string
50
51const (
52	// CanNotDelete ...
53	CanNotDelete ApplicationLockLevel = "CanNotDelete"
54	// None ...
55	None ApplicationLockLevel = "None"
56	// ReadOnly ...
57	ReadOnly ApplicationLockLevel = "ReadOnly"
58)
59
60// PossibleApplicationLockLevelValues returns an array of possible values for the ApplicationLockLevel const type.
61func PossibleApplicationLockLevelValues() []ApplicationLockLevel {
62	return []ApplicationLockLevel{CanNotDelete, None, ReadOnly}
63}
64
65// ProvisioningState enumerates the values for provisioning state.
66type ProvisioningState string
67
68const (
69	// Accepted ...
70	Accepted ProvisioningState = "Accepted"
71	// Canceled ...
72	Canceled ProvisioningState = "Canceled"
73	// Created ...
74	Created ProvisioningState = "Created"
75	// Creating ...
76	Creating ProvisioningState = "Creating"
77	// Deleted ...
78	Deleted ProvisioningState = "Deleted"
79	// Deleting ...
80	Deleting ProvisioningState = "Deleting"
81	// Failed ...
82	Failed ProvisioningState = "Failed"
83	// Ready ...
84	Ready ProvisioningState = "Ready"
85	// Running ...
86	Running ProvisioningState = "Running"
87	// Succeeded ...
88	Succeeded ProvisioningState = "Succeeded"
89	// Updating ...
90	Updating ProvisioningState = "Updating"
91)
92
93// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type.
94func PossibleProvisioningStateValues() []ProvisioningState {
95	return []ProvisioningState{Accepted, Canceled, Created, Creating, Deleted, Deleting, Failed, Ready, Running, Succeeded, Updating}
96}
97
98// ResourceIdentityType enumerates the values for resource identity type.
99type ResourceIdentityType string
100
101const (
102	// SystemAssigned ...
103	SystemAssigned ResourceIdentityType = "SystemAssigned"
104)
105
106// PossibleResourceIdentityTypeValues returns an array of possible values for the ResourceIdentityType const type.
107func PossibleResourceIdentityTypeValues() []ResourceIdentityType {
108	return []ResourceIdentityType{SystemAssigned}
109}
110
111// Application information about managed application.
112type Application struct {
113	autorest.Response `json:"-"`
114	// ApplicationProperties - The managed application properties.
115	*ApplicationProperties `json:"properties,omitempty"`
116	// Plan - The plan information.
117	Plan *Plan `json:"plan,omitempty"`
118	// Kind - The kind of the managed application. Allowed values are MarketPlace and ServiceCatalog.
119	Kind *string `json:"kind,omitempty"`
120	// ManagedBy - ID of the resource that manages this resource.
121	ManagedBy *string `json:"managedBy,omitempty"`
122	// Sku - The SKU of the resource.
123	Sku *Sku `json:"sku,omitempty"`
124	// Identity - The identity of the resource.
125	Identity *Identity `json:"identity,omitempty"`
126	// ID - READ-ONLY; Resource ID
127	ID *string `json:"id,omitempty"`
128	// Name - READ-ONLY; Resource name
129	Name *string `json:"name,omitempty"`
130	// Type - READ-ONLY; Resource type
131	Type *string `json:"type,omitempty"`
132	// Location - Resource location
133	Location *string `json:"location,omitempty"`
134	// Tags - Resource tags
135	Tags map[string]*string `json:"tags"`
136}
137
138// MarshalJSON is the custom marshaler for Application.
139func (a Application) MarshalJSON() ([]byte, error) {
140	objectMap := make(map[string]interface{})
141	if a.ApplicationProperties != nil {
142		objectMap["properties"] = a.ApplicationProperties
143	}
144	if a.Plan != nil {
145		objectMap["plan"] = a.Plan
146	}
147	if a.Kind != nil {
148		objectMap["kind"] = a.Kind
149	}
150	if a.ManagedBy != nil {
151		objectMap["managedBy"] = a.ManagedBy
152	}
153	if a.Sku != nil {
154		objectMap["sku"] = a.Sku
155	}
156	if a.Identity != nil {
157		objectMap["identity"] = a.Identity
158	}
159	if a.Location != nil {
160		objectMap["location"] = a.Location
161	}
162	if a.Tags != nil {
163		objectMap["tags"] = a.Tags
164	}
165	return json.Marshal(objectMap)
166}
167
168// UnmarshalJSON is the custom unmarshaler for Application struct.
169func (a *Application) UnmarshalJSON(body []byte) error {
170	var m map[string]*json.RawMessage
171	err := json.Unmarshal(body, &m)
172	if err != nil {
173		return err
174	}
175	for k, v := range m {
176		switch k {
177		case "properties":
178			if v != nil {
179				var applicationProperties ApplicationProperties
180				err = json.Unmarshal(*v, &applicationProperties)
181				if err != nil {
182					return err
183				}
184				a.ApplicationProperties = &applicationProperties
185			}
186		case "plan":
187			if v != nil {
188				var plan Plan
189				err = json.Unmarshal(*v, &plan)
190				if err != nil {
191					return err
192				}
193				a.Plan = &plan
194			}
195		case "kind":
196			if v != nil {
197				var kind string
198				err = json.Unmarshal(*v, &kind)
199				if err != nil {
200					return err
201				}
202				a.Kind = &kind
203			}
204		case "managedBy":
205			if v != nil {
206				var managedBy string
207				err = json.Unmarshal(*v, &managedBy)
208				if err != nil {
209					return err
210				}
211				a.ManagedBy = &managedBy
212			}
213		case "sku":
214			if v != nil {
215				var sku Sku
216				err = json.Unmarshal(*v, &sku)
217				if err != nil {
218					return err
219				}
220				a.Sku = &sku
221			}
222		case "identity":
223			if v != nil {
224				var identity Identity
225				err = json.Unmarshal(*v, &identity)
226				if err != nil {
227					return err
228				}
229				a.Identity = &identity
230			}
231		case "id":
232			if v != nil {
233				var ID string
234				err = json.Unmarshal(*v, &ID)
235				if err != nil {
236					return err
237				}
238				a.ID = &ID
239			}
240		case "name":
241			if v != nil {
242				var name string
243				err = json.Unmarshal(*v, &name)
244				if err != nil {
245					return err
246				}
247				a.Name = &name
248			}
249		case "type":
250			if v != nil {
251				var typeVar string
252				err = json.Unmarshal(*v, &typeVar)
253				if err != nil {
254					return err
255				}
256				a.Type = &typeVar
257			}
258		case "location":
259			if v != nil {
260				var location string
261				err = json.Unmarshal(*v, &location)
262				if err != nil {
263					return err
264				}
265				a.Location = &location
266			}
267		case "tags":
268			if v != nil {
269				var tags map[string]*string
270				err = json.Unmarshal(*v, &tags)
271				if err != nil {
272					return err
273				}
274				a.Tags = tags
275			}
276		}
277	}
278
279	return nil
280}
281
282// ApplicationArtifact managed application artifact.
283type ApplicationArtifact struct {
284	// Name - The managed application artifact name.
285	Name *string `json:"name,omitempty"`
286	// URI - The managed application artifact blob uri.
287	URI *string `json:"uri,omitempty"`
288	// Type - The managed application artifact type. Possible values include: 'Template', 'Custom'
289	Type ApplicationArtifactType `json:"type,omitempty"`
290}
291
292// ApplicationDefinition information about managed application definition.
293type ApplicationDefinition struct {
294	autorest.Response `json:"-"`
295	// ApplicationDefinitionProperties - The managed application definition properties.
296	*ApplicationDefinitionProperties `json:"properties,omitempty"`
297	// ManagedBy - ID of the resource that manages this resource.
298	ManagedBy *string `json:"managedBy,omitempty"`
299	// Sku - The SKU of the resource.
300	Sku *Sku `json:"sku,omitempty"`
301	// Identity - The identity of the resource.
302	Identity *Identity `json:"identity,omitempty"`
303	// ID - READ-ONLY; Resource ID
304	ID *string `json:"id,omitempty"`
305	// Name - READ-ONLY; Resource name
306	Name *string `json:"name,omitempty"`
307	// Type - READ-ONLY; Resource type
308	Type *string `json:"type,omitempty"`
309	// Location - Resource location
310	Location *string `json:"location,omitempty"`
311	// Tags - Resource tags
312	Tags map[string]*string `json:"tags"`
313}
314
315// MarshalJSON is the custom marshaler for ApplicationDefinition.
316func (ad ApplicationDefinition) MarshalJSON() ([]byte, error) {
317	objectMap := make(map[string]interface{})
318	if ad.ApplicationDefinitionProperties != nil {
319		objectMap["properties"] = ad.ApplicationDefinitionProperties
320	}
321	if ad.ManagedBy != nil {
322		objectMap["managedBy"] = ad.ManagedBy
323	}
324	if ad.Sku != nil {
325		objectMap["sku"] = ad.Sku
326	}
327	if ad.Identity != nil {
328		objectMap["identity"] = ad.Identity
329	}
330	if ad.Location != nil {
331		objectMap["location"] = ad.Location
332	}
333	if ad.Tags != nil {
334		objectMap["tags"] = ad.Tags
335	}
336	return json.Marshal(objectMap)
337}
338
339// UnmarshalJSON is the custom unmarshaler for ApplicationDefinition struct.
340func (ad *ApplicationDefinition) UnmarshalJSON(body []byte) error {
341	var m map[string]*json.RawMessage
342	err := json.Unmarshal(body, &m)
343	if err != nil {
344		return err
345	}
346	for k, v := range m {
347		switch k {
348		case "properties":
349			if v != nil {
350				var applicationDefinitionProperties ApplicationDefinitionProperties
351				err = json.Unmarshal(*v, &applicationDefinitionProperties)
352				if err != nil {
353					return err
354				}
355				ad.ApplicationDefinitionProperties = &applicationDefinitionProperties
356			}
357		case "managedBy":
358			if v != nil {
359				var managedBy string
360				err = json.Unmarshal(*v, &managedBy)
361				if err != nil {
362					return err
363				}
364				ad.ManagedBy = &managedBy
365			}
366		case "sku":
367			if v != nil {
368				var sku Sku
369				err = json.Unmarshal(*v, &sku)
370				if err != nil {
371					return err
372				}
373				ad.Sku = &sku
374			}
375		case "identity":
376			if v != nil {
377				var identity Identity
378				err = json.Unmarshal(*v, &identity)
379				if err != nil {
380					return err
381				}
382				ad.Identity = &identity
383			}
384		case "id":
385			if v != nil {
386				var ID string
387				err = json.Unmarshal(*v, &ID)
388				if err != nil {
389					return err
390				}
391				ad.ID = &ID
392			}
393		case "name":
394			if v != nil {
395				var name string
396				err = json.Unmarshal(*v, &name)
397				if err != nil {
398					return err
399				}
400				ad.Name = &name
401			}
402		case "type":
403			if v != nil {
404				var typeVar string
405				err = json.Unmarshal(*v, &typeVar)
406				if err != nil {
407					return err
408				}
409				ad.Type = &typeVar
410			}
411		case "location":
412			if v != nil {
413				var location string
414				err = json.Unmarshal(*v, &location)
415				if err != nil {
416					return err
417				}
418				ad.Location = &location
419			}
420		case "tags":
421			if v != nil {
422				var tags map[string]*string
423				err = json.Unmarshal(*v, &tags)
424				if err != nil {
425					return err
426				}
427				ad.Tags = tags
428			}
429		}
430	}
431
432	return nil
433}
434
435// ApplicationDefinitionListResult list of managed application definitions.
436type ApplicationDefinitionListResult struct {
437	autorest.Response `json:"-"`
438	// Value - The array of managed application definitions.
439	Value *[]ApplicationDefinition `json:"value,omitempty"`
440	// NextLink - The URL to use for getting the next set of results.
441	NextLink *string `json:"nextLink,omitempty"`
442}
443
444// ApplicationDefinitionListResultIterator provides access to a complete listing of ApplicationDefinition
445// values.
446type ApplicationDefinitionListResultIterator struct {
447	i    int
448	page ApplicationDefinitionListResultPage
449}
450
451// NextWithContext advances to the next value.  If there was an error making
452// the request the iterator does not advance and the error is returned.
453func (iter *ApplicationDefinitionListResultIterator) NextWithContext(ctx context.Context) (err error) {
454	if tracing.IsEnabled() {
455		ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationDefinitionListResultIterator.NextWithContext")
456		defer func() {
457			sc := -1
458			if iter.Response().Response.Response != nil {
459				sc = iter.Response().Response.Response.StatusCode
460			}
461			tracing.EndSpan(ctx, sc, err)
462		}()
463	}
464	iter.i++
465	if iter.i < len(iter.page.Values()) {
466		return nil
467	}
468	err = iter.page.NextWithContext(ctx)
469	if err != nil {
470		iter.i--
471		return err
472	}
473	iter.i = 0
474	return nil
475}
476
477// Next advances to the next value.  If there was an error making
478// the request the iterator does not advance and the error is returned.
479// Deprecated: Use NextWithContext() instead.
480func (iter *ApplicationDefinitionListResultIterator) Next() error {
481	return iter.NextWithContext(context.Background())
482}
483
484// NotDone returns true if the enumeration should be started or is not yet complete.
485func (iter ApplicationDefinitionListResultIterator) NotDone() bool {
486	return iter.page.NotDone() && iter.i < len(iter.page.Values())
487}
488
489// Response returns the raw server response from the last page request.
490func (iter ApplicationDefinitionListResultIterator) Response() ApplicationDefinitionListResult {
491	return iter.page.Response()
492}
493
494// Value returns the current value or a zero-initialized value if the
495// iterator has advanced beyond the end of the collection.
496func (iter ApplicationDefinitionListResultIterator) Value() ApplicationDefinition {
497	if !iter.page.NotDone() {
498		return ApplicationDefinition{}
499	}
500	return iter.page.Values()[iter.i]
501}
502
503// Creates a new instance of the ApplicationDefinitionListResultIterator type.
504func NewApplicationDefinitionListResultIterator(page ApplicationDefinitionListResultPage) ApplicationDefinitionListResultIterator {
505	return ApplicationDefinitionListResultIterator{page: page}
506}
507
508// IsEmpty returns true if the ListResult contains no values.
509func (adlr ApplicationDefinitionListResult) IsEmpty() bool {
510	return adlr.Value == nil || len(*adlr.Value) == 0
511}
512
513// applicationDefinitionListResultPreparer prepares a request to retrieve the next set of results.
514// It returns nil if no more results exist.
515func (adlr ApplicationDefinitionListResult) applicationDefinitionListResultPreparer(ctx context.Context) (*http.Request, error) {
516	if adlr.NextLink == nil || len(to.String(adlr.NextLink)) < 1 {
517		return nil, nil
518	}
519	return autorest.Prepare((&http.Request{}).WithContext(ctx),
520		autorest.AsJSON(),
521		autorest.AsGet(),
522		autorest.WithBaseURL(to.String(adlr.NextLink)))
523}
524
525// ApplicationDefinitionListResultPage contains a page of ApplicationDefinition values.
526type ApplicationDefinitionListResultPage struct {
527	fn   func(context.Context, ApplicationDefinitionListResult) (ApplicationDefinitionListResult, error)
528	adlr ApplicationDefinitionListResult
529}
530
531// NextWithContext advances to the next page of values.  If there was an error making
532// the request the page does not advance and the error is returned.
533func (page *ApplicationDefinitionListResultPage) NextWithContext(ctx context.Context) (err error) {
534	if tracing.IsEnabled() {
535		ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationDefinitionListResultPage.NextWithContext")
536		defer func() {
537			sc := -1
538			if page.Response().Response.Response != nil {
539				sc = page.Response().Response.Response.StatusCode
540			}
541			tracing.EndSpan(ctx, sc, err)
542		}()
543	}
544	next, err := page.fn(ctx, page.adlr)
545	if err != nil {
546		return err
547	}
548	page.adlr = next
549	return nil
550}
551
552// Next advances to the next page of values.  If there was an error making
553// the request the page does not advance and the error is returned.
554// Deprecated: Use NextWithContext() instead.
555func (page *ApplicationDefinitionListResultPage) Next() error {
556	return page.NextWithContext(context.Background())
557}
558
559// NotDone returns true if the page enumeration should be started or is not yet complete.
560func (page ApplicationDefinitionListResultPage) NotDone() bool {
561	return !page.adlr.IsEmpty()
562}
563
564// Response returns the raw server response from the last page request.
565func (page ApplicationDefinitionListResultPage) Response() ApplicationDefinitionListResult {
566	return page.adlr
567}
568
569// Values returns the slice of values for the current page or nil if there are no values.
570func (page ApplicationDefinitionListResultPage) Values() []ApplicationDefinition {
571	if page.adlr.IsEmpty() {
572		return nil
573	}
574	return *page.adlr.Value
575}
576
577// Creates a new instance of the ApplicationDefinitionListResultPage type.
578func NewApplicationDefinitionListResultPage(getNextPage func(context.Context, ApplicationDefinitionListResult) (ApplicationDefinitionListResult, error)) ApplicationDefinitionListResultPage {
579	return ApplicationDefinitionListResultPage{fn: getNextPage}
580}
581
582// ApplicationDefinitionProperties the managed application definition properties.
583type ApplicationDefinitionProperties struct {
584	// LockLevel - The managed application lock level. Possible values include: 'CanNotDelete', 'ReadOnly', 'None'
585	LockLevel ApplicationLockLevel `json:"lockLevel,omitempty"`
586	// DisplayName - The managed application definition display name.
587	DisplayName *string `json:"displayName,omitempty"`
588	// IsEnabled - A value indicating whether the package is enabled or not.
589	IsEnabled *string `json:"isEnabled,omitempty"`
590	// Authorizations - The managed application provider authorizations.
591	Authorizations *[]ApplicationProviderAuthorization `json:"authorizations,omitempty"`
592	// Artifacts - The collection of managed application artifacts. The portal will use the files specified as artifacts to construct the user experience of creating a managed application from a managed application definition.
593	Artifacts *[]ApplicationArtifact `json:"artifacts,omitempty"`
594	// Description - The managed application definition description.
595	Description *string `json:"description,omitempty"`
596	// PackageFileURI - The managed application definition package file Uri. Use this element
597	PackageFileURI *string `json:"packageFileUri,omitempty"`
598	// MainTemplate - The inline main template json which has resources to be provisioned. It can be a JObject or well-formed JSON string.
599	MainTemplate interface{} `json:"mainTemplate,omitempty"`
600	// CreateUIDefinition - The createUiDefinition json for the backing template with Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string.
601	CreateUIDefinition interface{} `json:"createUiDefinition,omitempty"`
602}
603
604// ApplicationDefinitionsCreateOrUpdateByIDFuture an abstraction for monitoring and retrieving the results
605// of a long-running operation.
606type ApplicationDefinitionsCreateOrUpdateByIDFuture struct {
607	azure.Future
608}
609
610// Result returns the result of the asynchronous operation.
611// If the operation has not completed it will return an error.
612func (future *ApplicationDefinitionsCreateOrUpdateByIDFuture) Result(client ApplicationDefinitionsClient) (ad ApplicationDefinition, err error) {
613	var done bool
614	done, err = future.DoneWithContext(context.Background(), client)
615	if err != nil {
616		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsCreateOrUpdateByIDFuture", "Result", future.Response(), "Polling failure")
617		return
618	}
619	if !done {
620		err = azure.NewAsyncOpIncompleteError("managedapplications.ApplicationDefinitionsCreateOrUpdateByIDFuture")
621		return
622	}
623	sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
624	if ad.Response.Response, err = future.GetResult(sender); err == nil && ad.Response.Response.StatusCode != http.StatusNoContent {
625		ad, err = client.CreateOrUpdateByIDResponder(ad.Response.Response)
626		if err != nil {
627			err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsCreateOrUpdateByIDFuture", "Result", ad.Response.Response, "Failure responding to request")
628		}
629	}
630	return
631}
632
633// ApplicationDefinitionsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a
634// long-running operation.
635type ApplicationDefinitionsCreateOrUpdateFuture struct {
636	azure.Future
637}
638
639// Result returns the result of the asynchronous operation.
640// If the operation has not completed it will return an error.
641func (future *ApplicationDefinitionsCreateOrUpdateFuture) Result(client ApplicationDefinitionsClient) (ad ApplicationDefinition, err error) {
642	var done bool
643	done, err = future.DoneWithContext(context.Background(), client)
644	if err != nil {
645		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure")
646		return
647	}
648	if !done {
649		err = azure.NewAsyncOpIncompleteError("managedapplications.ApplicationDefinitionsCreateOrUpdateFuture")
650		return
651	}
652	sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
653	if ad.Response.Response, err = future.GetResult(sender); err == nil && ad.Response.Response.StatusCode != http.StatusNoContent {
654		ad, err = client.CreateOrUpdateResponder(ad.Response.Response)
655		if err != nil {
656			err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsCreateOrUpdateFuture", "Result", ad.Response.Response, "Failure responding to request")
657		}
658	}
659	return
660}
661
662// ApplicationDefinitionsDeleteByIDFuture an abstraction for monitoring and retrieving the results of a
663// long-running operation.
664type ApplicationDefinitionsDeleteByIDFuture struct {
665	azure.Future
666}
667
668// Result returns the result of the asynchronous operation.
669// If the operation has not completed it will return an error.
670func (future *ApplicationDefinitionsDeleteByIDFuture) Result(client ApplicationDefinitionsClient) (ar autorest.Response, err error) {
671	var done bool
672	done, err = future.DoneWithContext(context.Background(), client)
673	if err != nil {
674		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsDeleteByIDFuture", "Result", future.Response(), "Polling failure")
675		return
676	}
677	if !done {
678		err = azure.NewAsyncOpIncompleteError("managedapplications.ApplicationDefinitionsDeleteByIDFuture")
679		return
680	}
681	ar.Response = future.Response()
682	return
683}
684
685// ApplicationDefinitionsDeleteFuture an abstraction for monitoring and retrieving the results of a
686// long-running operation.
687type ApplicationDefinitionsDeleteFuture struct {
688	azure.Future
689}
690
691// Result returns the result of the asynchronous operation.
692// If the operation has not completed it will return an error.
693func (future *ApplicationDefinitionsDeleteFuture) Result(client ApplicationDefinitionsClient) (ar autorest.Response, err error) {
694	var done bool
695	done, err = future.DoneWithContext(context.Background(), client)
696	if err != nil {
697		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsDeleteFuture", "Result", future.Response(), "Polling failure")
698		return
699	}
700	if !done {
701		err = azure.NewAsyncOpIncompleteError("managedapplications.ApplicationDefinitionsDeleteFuture")
702		return
703	}
704	ar.Response = future.Response()
705	return
706}
707
708// ApplicationListResult list of managed applications.
709type ApplicationListResult struct {
710	autorest.Response `json:"-"`
711	// Value - The array of managed applications.
712	Value *[]Application `json:"value,omitempty"`
713	// NextLink - The URL to use for getting the next set of results.
714	NextLink *string `json:"nextLink,omitempty"`
715}
716
717// ApplicationListResultIterator provides access to a complete listing of Application values.
718type ApplicationListResultIterator struct {
719	i    int
720	page ApplicationListResultPage
721}
722
723// NextWithContext advances to the next value.  If there was an error making
724// the request the iterator does not advance and the error is returned.
725func (iter *ApplicationListResultIterator) NextWithContext(ctx context.Context) (err error) {
726	if tracing.IsEnabled() {
727		ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationListResultIterator.NextWithContext")
728		defer func() {
729			sc := -1
730			if iter.Response().Response.Response != nil {
731				sc = iter.Response().Response.Response.StatusCode
732			}
733			tracing.EndSpan(ctx, sc, err)
734		}()
735	}
736	iter.i++
737	if iter.i < len(iter.page.Values()) {
738		return nil
739	}
740	err = iter.page.NextWithContext(ctx)
741	if err != nil {
742		iter.i--
743		return err
744	}
745	iter.i = 0
746	return nil
747}
748
749// Next advances to the next value.  If there was an error making
750// the request the iterator does not advance and the error is returned.
751// Deprecated: Use NextWithContext() instead.
752func (iter *ApplicationListResultIterator) Next() error {
753	return iter.NextWithContext(context.Background())
754}
755
756// NotDone returns true if the enumeration should be started or is not yet complete.
757func (iter ApplicationListResultIterator) NotDone() bool {
758	return iter.page.NotDone() && iter.i < len(iter.page.Values())
759}
760
761// Response returns the raw server response from the last page request.
762func (iter ApplicationListResultIterator) Response() ApplicationListResult {
763	return iter.page.Response()
764}
765
766// Value returns the current value or a zero-initialized value if the
767// iterator has advanced beyond the end of the collection.
768func (iter ApplicationListResultIterator) Value() Application {
769	if !iter.page.NotDone() {
770		return Application{}
771	}
772	return iter.page.Values()[iter.i]
773}
774
775// Creates a new instance of the ApplicationListResultIterator type.
776func NewApplicationListResultIterator(page ApplicationListResultPage) ApplicationListResultIterator {
777	return ApplicationListResultIterator{page: page}
778}
779
780// IsEmpty returns true if the ListResult contains no values.
781func (alr ApplicationListResult) IsEmpty() bool {
782	return alr.Value == nil || len(*alr.Value) == 0
783}
784
785// applicationListResultPreparer prepares a request to retrieve the next set of results.
786// It returns nil if no more results exist.
787func (alr ApplicationListResult) applicationListResultPreparer(ctx context.Context) (*http.Request, error) {
788	if alr.NextLink == nil || len(to.String(alr.NextLink)) < 1 {
789		return nil, nil
790	}
791	return autorest.Prepare((&http.Request{}).WithContext(ctx),
792		autorest.AsJSON(),
793		autorest.AsGet(),
794		autorest.WithBaseURL(to.String(alr.NextLink)))
795}
796
797// ApplicationListResultPage contains a page of Application values.
798type ApplicationListResultPage struct {
799	fn  func(context.Context, ApplicationListResult) (ApplicationListResult, error)
800	alr ApplicationListResult
801}
802
803// NextWithContext advances to the next page of values.  If there was an error making
804// the request the page does not advance and the error is returned.
805func (page *ApplicationListResultPage) NextWithContext(ctx context.Context) (err error) {
806	if tracing.IsEnabled() {
807		ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationListResultPage.NextWithContext")
808		defer func() {
809			sc := -1
810			if page.Response().Response.Response != nil {
811				sc = page.Response().Response.Response.StatusCode
812			}
813			tracing.EndSpan(ctx, sc, err)
814		}()
815	}
816	next, err := page.fn(ctx, page.alr)
817	if err != nil {
818		return err
819	}
820	page.alr = next
821	return nil
822}
823
824// Next advances to the next page of values.  If there was an error making
825// the request the page does not advance and the error is returned.
826// Deprecated: Use NextWithContext() instead.
827func (page *ApplicationListResultPage) Next() error {
828	return page.NextWithContext(context.Background())
829}
830
831// NotDone returns true if the page enumeration should be started or is not yet complete.
832func (page ApplicationListResultPage) NotDone() bool {
833	return !page.alr.IsEmpty()
834}
835
836// Response returns the raw server response from the last page request.
837func (page ApplicationListResultPage) Response() ApplicationListResult {
838	return page.alr
839}
840
841// Values returns the slice of values for the current page or nil if there are no values.
842func (page ApplicationListResultPage) Values() []Application {
843	if page.alr.IsEmpty() {
844		return nil
845	}
846	return *page.alr.Value
847}
848
849// Creates a new instance of the ApplicationListResultPage type.
850func NewApplicationListResultPage(getNextPage func(context.Context, ApplicationListResult) (ApplicationListResult, error)) ApplicationListResultPage {
851	return ApplicationListResultPage{fn: getNextPage}
852}
853
854// ApplicationPatchable information about managed application.
855type ApplicationPatchable struct {
856	// ApplicationPropertiesPatchable - The managed application properties.
857	*ApplicationPropertiesPatchable `json:"properties,omitempty"`
858	// Plan - The plan information.
859	Plan *PlanPatchable `json:"plan,omitempty"`
860	// Kind - The kind of the managed application. Allowed values are MarketPlace and ServiceCatalog.
861	Kind *string `json:"kind,omitempty"`
862	// ManagedBy - ID of the resource that manages this resource.
863	ManagedBy *string `json:"managedBy,omitempty"`
864	// Sku - The SKU of the resource.
865	Sku *Sku `json:"sku,omitempty"`
866	// Identity - The identity of the resource.
867	Identity *Identity `json:"identity,omitempty"`
868	// ID - READ-ONLY; Resource ID
869	ID *string `json:"id,omitempty"`
870	// Name - READ-ONLY; Resource name
871	Name *string `json:"name,omitempty"`
872	// Type - READ-ONLY; Resource type
873	Type *string `json:"type,omitempty"`
874	// Location - Resource location
875	Location *string `json:"location,omitempty"`
876	// Tags - Resource tags
877	Tags map[string]*string `json:"tags"`
878}
879
880// MarshalJSON is the custom marshaler for ApplicationPatchable.
881func (ap ApplicationPatchable) MarshalJSON() ([]byte, error) {
882	objectMap := make(map[string]interface{})
883	if ap.ApplicationPropertiesPatchable != nil {
884		objectMap["properties"] = ap.ApplicationPropertiesPatchable
885	}
886	if ap.Plan != nil {
887		objectMap["plan"] = ap.Plan
888	}
889	if ap.Kind != nil {
890		objectMap["kind"] = ap.Kind
891	}
892	if ap.ManagedBy != nil {
893		objectMap["managedBy"] = ap.ManagedBy
894	}
895	if ap.Sku != nil {
896		objectMap["sku"] = ap.Sku
897	}
898	if ap.Identity != nil {
899		objectMap["identity"] = ap.Identity
900	}
901	if ap.Location != nil {
902		objectMap["location"] = ap.Location
903	}
904	if ap.Tags != nil {
905		objectMap["tags"] = ap.Tags
906	}
907	return json.Marshal(objectMap)
908}
909
910// UnmarshalJSON is the custom unmarshaler for ApplicationPatchable struct.
911func (ap *ApplicationPatchable) UnmarshalJSON(body []byte) error {
912	var m map[string]*json.RawMessage
913	err := json.Unmarshal(body, &m)
914	if err != nil {
915		return err
916	}
917	for k, v := range m {
918		switch k {
919		case "properties":
920			if v != nil {
921				var applicationPropertiesPatchable ApplicationPropertiesPatchable
922				err = json.Unmarshal(*v, &applicationPropertiesPatchable)
923				if err != nil {
924					return err
925				}
926				ap.ApplicationPropertiesPatchable = &applicationPropertiesPatchable
927			}
928		case "plan":
929			if v != nil {
930				var plan PlanPatchable
931				err = json.Unmarshal(*v, &plan)
932				if err != nil {
933					return err
934				}
935				ap.Plan = &plan
936			}
937		case "kind":
938			if v != nil {
939				var kind string
940				err = json.Unmarshal(*v, &kind)
941				if err != nil {
942					return err
943				}
944				ap.Kind = &kind
945			}
946		case "managedBy":
947			if v != nil {
948				var managedBy string
949				err = json.Unmarshal(*v, &managedBy)
950				if err != nil {
951					return err
952				}
953				ap.ManagedBy = &managedBy
954			}
955		case "sku":
956			if v != nil {
957				var sku Sku
958				err = json.Unmarshal(*v, &sku)
959				if err != nil {
960					return err
961				}
962				ap.Sku = &sku
963			}
964		case "identity":
965			if v != nil {
966				var identity Identity
967				err = json.Unmarshal(*v, &identity)
968				if err != nil {
969					return err
970				}
971				ap.Identity = &identity
972			}
973		case "id":
974			if v != nil {
975				var ID string
976				err = json.Unmarshal(*v, &ID)
977				if err != nil {
978					return err
979				}
980				ap.ID = &ID
981			}
982		case "name":
983			if v != nil {
984				var name string
985				err = json.Unmarshal(*v, &name)
986				if err != nil {
987					return err
988				}
989				ap.Name = &name
990			}
991		case "type":
992			if v != nil {
993				var typeVar string
994				err = json.Unmarshal(*v, &typeVar)
995				if err != nil {
996					return err
997				}
998				ap.Type = &typeVar
999			}
1000		case "location":
1001			if v != nil {
1002				var location string
1003				err = json.Unmarshal(*v, &location)
1004				if err != nil {
1005					return err
1006				}
1007				ap.Location = &location
1008			}
1009		case "tags":
1010			if v != nil {
1011				var tags map[string]*string
1012				err = json.Unmarshal(*v, &tags)
1013				if err != nil {
1014					return err
1015				}
1016				ap.Tags = tags
1017			}
1018		}
1019	}
1020
1021	return nil
1022}
1023
1024// ApplicationProperties the managed application properties.
1025type ApplicationProperties struct {
1026	// ManagedResourceGroupID - The managed resource group Id.
1027	ManagedResourceGroupID *string `json:"managedResourceGroupId,omitempty"`
1028	// ApplicationDefinitionID - The fully qualified path of managed application definition Id.
1029	ApplicationDefinitionID *string `json:"applicationDefinitionId,omitempty"`
1030	// Parameters - Name and value pairs that define the managed application parameters. It can be a JObject or a well formed JSON string.
1031	Parameters interface{} `json:"parameters,omitempty"`
1032	// Outputs - READ-ONLY; Name and value pairs that define the managed application outputs.
1033	Outputs interface{} `json:"outputs,omitempty"`
1034	// ProvisioningState - READ-ONLY; The managed application provisioning state. Possible values include: 'Accepted', 'Running', 'Ready', 'Creating', 'Created', 'Deleting', 'Deleted', 'Canceled', 'Failed', 'Succeeded', 'Updating'
1035	ProvisioningState ProvisioningState `json:"provisioningState,omitempty"`
1036	// UIDefinitionURI - The blob URI where the UI definition file is located.
1037	UIDefinitionURI *string `json:"uiDefinitionUri,omitempty"`
1038}
1039
1040// ApplicationPropertiesPatchable the managed application properties.
1041type ApplicationPropertiesPatchable struct {
1042	// ManagedResourceGroupID - The managed resource group Id.
1043	ManagedResourceGroupID *string `json:"managedResourceGroupId,omitempty"`
1044	// ApplicationDefinitionID - The fully qualified path of managed application definition Id.
1045	ApplicationDefinitionID *string `json:"applicationDefinitionId,omitempty"`
1046	// Parameters - Name and value pairs that define the managed application parameters. It can be a JObject or a well formed JSON string.
1047	Parameters interface{} `json:"parameters,omitempty"`
1048	// Outputs - READ-ONLY; Name and value pairs that define the managed application outputs.
1049	Outputs interface{} `json:"outputs,omitempty"`
1050	// ProvisioningState - READ-ONLY; The managed application provisioning state. Possible values include: 'Accepted', 'Running', 'Ready', 'Creating', 'Created', 'Deleting', 'Deleted', 'Canceled', 'Failed', 'Succeeded', 'Updating'
1051	ProvisioningState ProvisioningState `json:"provisioningState,omitempty"`
1052	// UIDefinitionURI - The blob URI where the UI definition file is located.
1053	UIDefinitionURI *string `json:"uiDefinitionUri,omitempty"`
1054}
1055
1056// ApplicationProviderAuthorization the managed application provider authorization.
1057type ApplicationProviderAuthorization struct {
1058	// PrincipalID - The provider's principal identifier. This is the identity that the provider will use to call ARM to manage the managed application resources.
1059	PrincipalID *string `json:"principalId,omitempty"`
1060	// RoleDefinitionID - The provider's role definition identifier. This role will define all the permissions that the provider must have on the managed application's container resource group. This role definition cannot have permission to delete the resource group.
1061	RoleDefinitionID *string `json:"roleDefinitionId,omitempty"`
1062}
1063
1064// ApplicationsCreateOrUpdateByIDFuture an abstraction for monitoring and retrieving the results of a
1065// long-running operation.
1066type ApplicationsCreateOrUpdateByIDFuture struct {
1067	azure.Future
1068}
1069
1070// Result returns the result of the asynchronous operation.
1071// If the operation has not completed it will return an error.
1072func (future *ApplicationsCreateOrUpdateByIDFuture) Result(client ApplicationsClient) (a Application, err error) {
1073	var done bool
1074	done, err = future.DoneWithContext(context.Background(), client)
1075	if err != nil {
1076		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsCreateOrUpdateByIDFuture", "Result", future.Response(), "Polling failure")
1077		return
1078	}
1079	if !done {
1080		err = azure.NewAsyncOpIncompleteError("managedapplications.ApplicationsCreateOrUpdateByIDFuture")
1081		return
1082	}
1083	sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1084	if a.Response.Response, err = future.GetResult(sender); err == nil && a.Response.Response.StatusCode != http.StatusNoContent {
1085		a, err = client.CreateOrUpdateByIDResponder(a.Response.Response)
1086		if err != nil {
1087			err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsCreateOrUpdateByIDFuture", "Result", a.Response.Response, "Failure responding to request")
1088		}
1089	}
1090	return
1091}
1092
1093// ApplicationsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a
1094// long-running operation.
1095type ApplicationsCreateOrUpdateFuture struct {
1096	azure.Future
1097}
1098
1099// Result returns the result of the asynchronous operation.
1100// If the operation has not completed it will return an error.
1101func (future *ApplicationsCreateOrUpdateFuture) Result(client ApplicationsClient) (a Application, err error) {
1102	var done bool
1103	done, err = future.DoneWithContext(context.Background(), client)
1104	if err != nil {
1105		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure")
1106		return
1107	}
1108	if !done {
1109		err = azure.NewAsyncOpIncompleteError("managedapplications.ApplicationsCreateOrUpdateFuture")
1110		return
1111	}
1112	sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1113	if a.Response.Response, err = future.GetResult(sender); err == nil && a.Response.Response.StatusCode != http.StatusNoContent {
1114		a, err = client.CreateOrUpdateResponder(a.Response.Response)
1115		if err != nil {
1116			err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsCreateOrUpdateFuture", "Result", a.Response.Response, "Failure responding to request")
1117		}
1118	}
1119	return
1120}
1121
1122// ApplicationsDeleteByIDFuture an abstraction for monitoring and retrieving the results of a long-running
1123// operation.
1124type ApplicationsDeleteByIDFuture struct {
1125	azure.Future
1126}
1127
1128// Result returns the result of the asynchronous operation.
1129// If the operation has not completed it will return an error.
1130func (future *ApplicationsDeleteByIDFuture) Result(client ApplicationsClient) (ar autorest.Response, err error) {
1131	var done bool
1132	done, err = future.DoneWithContext(context.Background(), client)
1133	if err != nil {
1134		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsDeleteByIDFuture", "Result", future.Response(), "Polling failure")
1135		return
1136	}
1137	if !done {
1138		err = azure.NewAsyncOpIncompleteError("managedapplications.ApplicationsDeleteByIDFuture")
1139		return
1140	}
1141	ar.Response = future.Response()
1142	return
1143}
1144
1145// ApplicationsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running
1146// operation.
1147type ApplicationsDeleteFuture struct {
1148	azure.Future
1149}
1150
1151// Result returns the result of the asynchronous operation.
1152// If the operation has not completed it will return an error.
1153func (future *ApplicationsDeleteFuture) Result(client ApplicationsClient) (ar autorest.Response, err error) {
1154	var done bool
1155	done, err = future.DoneWithContext(context.Background(), client)
1156	if err != nil {
1157		err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsDeleteFuture", "Result", future.Response(), "Polling failure")
1158		return
1159	}
1160	if !done {
1161		err = azure.NewAsyncOpIncompleteError("managedapplications.ApplicationsDeleteFuture")
1162		return
1163	}
1164	ar.Response = future.Response()
1165	return
1166}
1167
1168// ErrorResponse error response indicates managed application is not able to process the incoming request.
1169// The reason is provided in the error message.
1170type ErrorResponse struct {
1171	// HTTPStatus - Http status code.
1172	HTTPStatus *string `json:"httpStatus,omitempty"`
1173	// ErrorCode - Error code.
1174	ErrorCode *string `json:"errorCode,omitempty"`
1175	// ErrorMessage - Error message indicating why the operation failed.
1176	ErrorMessage *string `json:"errorMessage,omitempty"`
1177}
1178
1179// GenericResource resource information.
1180type GenericResource struct {
1181	// ManagedBy - ID of the resource that manages this resource.
1182	ManagedBy *string `json:"managedBy,omitempty"`
1183	// Sku - The SKU of the resource.
1184	Sku *Sku `json:"sku,omitempty"`
1185	// Identity - The identity of the resource.
1186	Identity *Identity `json:"identity,omitempty"`
1187	// ID - READ-ONLY; Resource ID
1188	ID *string `json:"id,omitempty"`
1189	// Name - READ-ONLY; Resource name
1190	Name *string `json:"name,omitempty"`
1191	// Type - READ-ONLY; Resource type
1192	Type *string `json:"type,omitempty"`
1193	// Location - Resource location
1194	Location *string `json:"location,omitempty"`
1195	// Tags - Resource tags
1196	Tags map[string]*string `json:"tags"`
1197}
1198
1199// MarshalJSON is the custom marshaler for GenericResource.
1200func (gr GenericResource) MarshalJSON() ([]byte, error) {
1201	objectMap := make(map[string]interface{})
1202	if gr.ManagedBy != nil {
1203		objectMap["managedBy"] = gr.ManagedBy
1204	}
1205	if gr.Sku != nil {
1206		objectMap["sku"] = gr.Sku
1207	}
1208	if gr.Identity != nil {
1209		objectMap["identity"] = gr.Identity
1210	}
1211	if gr.Location != nil {
1212		objectMap["location"] = gr.Location
1213	}
1214	if gr.Tags != nil {
1215		objectMap["tags"] = gr.Tags
1216	}
1217	return json.Marshal(objectMap)
1218}
1219
1220// Identity identity for the resource.
1221type Identity struct {
1222	// PrincipalID - READ-ONLY; The principal ID of resource identity.
1223	PrincipalID *string `json:"principalId,omitempty"`
1224	// TenantID - READ-ONLY; The tenant ID of resource.
1225	TenantID *string `json:"tenantId,omitempty"`
1226	// Type - The identity type. Possible values include: 'SystemAssigned'
1227	Type ResourceIdentityType `json:"type,omitempty"`
1228}
1229
1230// Plan plan for the managed application.
1231type Plan struct {
1232	// Name - The plan name.
1233	Name *string `json:"name,omitempty"`
1234	// Publisher - The publisher ID.
1235	Publisher *string `json:"publisher,omitempty"`
1236	// Product - The product code.
1237	Product *string `json:"product,omitempty"`
1238	// PromotionCode - The promotion code.
1239	PromotionCode *string `json:"promotionCode,omitempty"`
1240	// Version - The plan's version.
1241	Version *string `json:"version,omitempty"`
1242}
1243
1244// PlanPatchable plan for the managed application.
1245type PlanPatchable struct {
1246	// Name - The plan name.
1247	Name *string `json:"name,omitempty"`
1248	// Publisher - The publisher ID.
1249	Publisher *string `json:"publisher,omitempty"`
1250	// Product - The product code.
1251	Product *string `json:"product,omitempty"`
1252	// PromotionCode - The promotion code.
1253	PromotionCode *string `json:"promotionCode,omitempty"`
1254	// Version - The plan's version.
1255	Version *string `json:"version,omitempty"`
1256}
1257
1258// Resource resource information.
1259type Resource struct {
1260	// ID - READ-ONLY; Resource ID
1261	ID *string `json:"id,omitempty"`
1262	// Name - READ-ONLY; Resource name
1263	Name *string `json:"name,omitempty"`
1264	// Type - READ-ONLY; Resource type
1265	Type *string `json:"type,omitempty"`
1266	// Location - Resource location
1267	Location *string `json:"location,omitempty"`
1268	// Tags - Resource tags
1269	Tags map[string]*string `json:"tags"`
1270}
1271
1272// MarshalJSON is the custom marshaler for Resource.
1273func (r Resource) MarshalJSON() ([]byte, error) {
1274	objectMap := make(map[string]interface{})
1275	if r.Location != nil {
1276		objectMap["location"] = r.Location
1277	}
1278	if r.Tags != nil {
1279		objectMap["tags"] = r.Tags
1280	}
1281	return json.Marshal(objectMap)
1282}
1283
1284// Sku SKU for the resource.
1285type Sku struct {
1286	// Name - The SKU name.
1287	Name *string `json:"name,omitempty"`
1288	// Tier - The SKU tier.
1289	Tier *string `json:"tier,omitempty"`
1290	// Size - The SKU size.
1291	Size *string `json:"size,omitempty"`
1292	// Family - The SKU family.
1293	Family *string `json:"family,omitempty"`
1294	// Model - The SKU model.
1295	Model *string `json:"model,omitempty"`
1296	// Capacity - The SKU capacity.
1297	Capacity *int32 `json:"capacity,omitempty"`
1298}
1299