diff --git a/azurerm/internal/clients/client.go b/azurerm/internal/clients/client.go index 035ba1388f4d..1a749c6487b2 100644 --- a/azurerm/internal/clients/client.go +++ b/azurerm/internal/clients/client.go @@ -38,6 +38,7 @@ import ( kusto "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/kusto/client" loganalytics "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/loganalytics/client" logic "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/logic/client" + managedapplication "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/managedapplication/client" managementgroup "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/managementgroup/client" maps "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/maps/client" mariadb "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/mariadb/client" @@ -79,70 +80,71 @@ type Client struct { Account *ResourceManagerAccount Features features.UserFeatures - AnalysisServices *analysisServices.Client - ApiManagement *apiManagement.Client - AppConfiguration *appConfiguration.Client - AppInsights *applicationInsights.Client - Authorization *authorization.Client - Automation *automation.Client - Batch *batch.Client - Bot *bot.Client - Cdn *cdn.Client - Cognitive *cognitiveServices.Client - Compute *compute.Client - Containers *containerServices.Client - Cosmos *cosmosdb.Client - CostManagement *costmanagement.Client - DatabaseMigration *datamigration.Client - DataBricks *databricks.Client - DataFactory *datafactory.Client - Datalake *datalake.Client - DevSpace *devspace.Client - DevTestLabs *devtestlabs.Client - Dns *dns.Client - EventGrid *eventgrid.Client - Eventhub *eventhub.Client - Frontdoor *frontdoor.Client - HDInsight *hdinsight.Client - HealthCare *healthcare.Client - IoTHub *iothub.Client - IoTCentral *iotcentral.Client - KeyVault *keyvault.Client - Kusto *kusto.Client - LogAnalytics *loganalytics.Client - Logic *logic.Client - ManagementGroups *managementgroup.Client - Maps *maps.Client - MariaDB *mariadb.Client - Media *media.Client - MixedReality *mixedreality.Client - Monitor *monitor.Client - MSI *msi.Client - MSSQL *mssql.Client - MySQL *mysql.Client - NetApp *netapp.Client - Network *network.Client - NotificationHubs *notificationhub.Client - Policy *policy.Client - Portal *portal.Client - Postgres *postgres.Client - PowerBI *powerBI.Client - PrivateDns *privatedns.Client - RecoveryServices *recoveryServices.Client - Redis *redis.Client - Relay *relay.Client - Resource *resource.Client - Search *search.Client - SecurityCenter *securityCenter.Client - ServiceBus *serviceBus.Client - ServiceFabric *serviceFabric.Client - SignalR *signalr.Client - Storage *storage.Client - StreamAnalytics *streamAnalytics.Client - Subscription *subscription.Client - Sql *sql.Client - TrafficManager *trafficManager.Client - Web *web.Client + AnalysisServices *analysisServices.Client + ApiManagement *apiManagement.Client + AppConfiguration *appConfiguration.Client + AppInsights *applicationInsights.Client + Authorization *authorization.Client + Automation *automation.Client + Batch *batch.Client + Bot *bot.Client + Cdn *cdn.Client + Cognitive *cognitiveServices.Client + Compute *compute.Client + Containers *containerServices.Client + Cosmos *cosmosdb.Client + CostManagement *costmanagement.Client + DatabaseMigration *datamigration.Client + DataBricks *databricks.Client + DataFactory *datafactory.Client + Datalake *datalake.Client + DevSpace *devspace.Client + DevTestLabs *devtestlabs.Client + Dns *dns.Client + EventGrid *eventgrid.Client + Eventhub *eventhub.Client + Frontdoor *frontdoor.Client + HDInsight *hdinsight.Client + HealthCare *healthcare.Client + IoTHub *iothub.Client + IoTCentral *iotcentral.Client + KeyVault *keyvault.Client + Kusto *kusto.Client + LogAnalytics *loganalytics.Client + Logic *logic.Client + ManagedApplication *managedapplication.Client + ManagementGroups *managementgroup.Client + Maps *maps.Client + MariaDB *mariadb.Client + Media *media.Client + MixedReality *mixedreality.Client + Monitor *monitor.Client + MSI *msi.Client + MSSQL *mssql.Client + MySQL *mysql.Client + NetApp *netapp.Client + Network *network.Client + NotificationHubs *notificationhub.Client + Policy *policy.Client + Portal *portal.Client + Postgres *postgres.Client + PowerBI *powerBI.Client + PrivateDns *privatedns.Client + RecoveryServices *recoveryServices.Client + Redis *redis.Client + Relay *relay.Client + Resource *resource.Client + Search *search.Client + SecurityCenter *securityCenter.Client + ServiceBus *serviceBus.Client + ServiceFabric *serviceFabric.Client + SignalR *signalr.Client + Storage *storage.Client + StreamAnalytics *streamAnalytics.Client + Subscription *subscription.Client + Sql *sql.Client + TrafficManager *trafficManager.Client + Web *web.Client } // NOTE: it should be possible for this method to become Private once the top level Client's removed @@ -185,6 +187,7 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error client.Kusto = kusto.NewClient(o) client.LogAnalytics = loganalytics.NewClient(o) client.Logic = logic.NewClient(o) + client.ManagedApplication = managedapplication.NewClient(o) client.ManagementGroups = managementgroup.NewClient(o) client.Maps = maps.NewClient(o) client.MariaDB = mariadb.NewClient(o) diff --git a/azurerm/internal/provider/services.go b/azurerm/internal/provider/services.go index cf855e88dc2c..a70fada17342 100644 --- a/azurerm/internal/provider/services.go +++ b/azurerm/internal/provider/services.go @@ -34,6 +34,7 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/kusto" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/loganalytics" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/logic" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/managedapplication" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/managementgroup" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/maps" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/mariadb" @@ -104,6 +105,7 @@ func SupportedServices() []common.ServiceRegistration { kusto.Registration{}, loganalytics.Registration{}, logic.Registration{}, + managedapplication.Registration{}, managementgroup.Registration{}, maps.Registration{}, mariadb.Registration{}, diff --git a/azurerm/internal/services/managedapplication/client/client.go b/azurerm/internal/services/managedapplication/client/client.go new file mode 100644 index 000000000000..2fac84201466 --- /dev/null +++ b/azurerm/internal/services/managedapplication/client/client.go @@ -0,0 +1,19 @@ +package client + +import ( + "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-07-01/managedapplications" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/common" +) + +type Client struct { + ApplicationDefinitionClient *managedapplications.ApplicationDefinitionsClient +} + +func NewClient(o *common.ClientOptions) *Client { + applicationDefinitionClient := managedapplications.NewApplicationDefinitionsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + o.ConfigureClient(&applicationDefinitionClient.Client, o.ResourceManagerAuthorizer) + + return &Client{ + ApplicationDefinitionClient: &applicationDefinitionClient, + } +} diff --git a/azurerm/internal/services/managedapplication/data_source_managed_application_definition.go b/azurerm/internal/services/managedapplication/data_source_managed_application_definition.go new file mode 100644 index 000000000000..9fdbcaf26c75 --- /dev/null +++ b/azurerm/internal/services/managedapplication/data_source_managed_application_definition.go @@ -0,0 +1,138 @@ +package managedapplication + +import ( + "fmt" + "time" + + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/managedapplication/validate" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func dataSourceArmManagedApplicationDefinition() *schema.Resource { + return &schema.Resource{ + Read: dataSourceArmManagedApplicationDefinitionRead, + + Timeouts: &schema.ResourceTimeout{ + Read: schema.DefaultTimeout(5 * time.Minute), + }, + + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.ManagedApplicationDefinitionName, + }, + + "location": azure.SchemaLocationForDataSource(), + + "resource_group_name": azure.SchemaResourceGroupNameForDataSource(), + + "authorization": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "role_definition_id": { + Type: schema.TypeString, + Computed: true, + }, + "service_principal_id": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + + "create_ui_definition": { + Type: schema.TypeString, + Computed: true, + }, + + "description": { + Type: schema.TypeString, + Computed: true, + }, + + "display_name": { + Type: schema.TypeString, + Computed: true, + }, + + "package_enabled": { + Type: schema.TypeBool, + Computed: true, + }, + + "lock_level": { + Type: schema.TypeString, + Computed: true, + }, + + "main_template": { + Type: schema.TypeString, + Computed: true, + }, + + "package_file_uri": { + Type: schema.TypeString, + Computed: true, + }, + + "tags": tags.SchemaDataSource(), + }, + } +} + +func dataSourceArmManagedApplicationDefinitionRead(d *schema.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).ManagedApplication.ApplicationDefinitionClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) + defer cancel() + + name := d.Get("name").(string) + resourceGroup := d.Get("resource_group_name").(string) + + resp, err := client.Get(ctx, resourceGroup, name) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + return fmt.Errorf("Failed: Managed Application Definition (Managed Application Definition Name %q / Resource Group %q) was not found", name, resourceGroup) + } + return fmt.Errorf("Failure reading Managed Application Definition (Managed Application Definition Name %q / Resource Group %q): %+v", name, resourceGroup, err) + } + + d.Set("name", name) + d.Set("resource_group_name", resourceGroup) + if location := resp.Location; location != nil { + d.Set("location", azure.NormalizeLocation(*location)) + } + if props := resp.ApplicationDefinitionProperties; props != nil { + if err := d.Set("authorization", flattenArmManagedApplicationDefinitionAuthorization(props.Authorizations)); err != nil { + return fmt.Errorf("Failure setting `authorization`: %+v", err) + } + d.Set("description", props.Description) + d.Set("display_name", props.DisplayName) + d.Set("package_enabled", props.IsEnabled) + d.Set("lock_level", string(props.LockLevel)) + } + if v, ok := d.GetOk("create_ui_definition"); ok { + d.Set("create_ui_definition", v.(string)) + } + if v, ok := d.GetOk("main_template"); ok { + d.Set("main_template", v.(string)) + } + if v, ok := d.GetOk("package_file_uri"); ok { + d.Set("package_file_uri", v.(string)) + } + + if resp.ID == nil || *resp.ID == "" { + return fmt.Errorf("API returns a nil/empty id on Managed Application Definition %q (Resource Group %q): %+v", name, resourceGroup, err) + } + d.SetId(*resp.ID) + + return tags.FlattenAndSet(d, resp.Tags) +} diff --git a/azurerm/internal/services/managedapplication/parse/managed_application_definition.go b/azurerm/internal/services/managedapplication/parse/managed_application_definition.go new file mode 100644 index 000000000000..4266abef7a8a --- /dev/null +++ b/azurerm/internal/services/managedapplication/parse/managed_application_definition.go @@ -0,0 +1,31 @@ +package parse + +import ( + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" +) + +type ManagedApplicationDefinitionId struct { + Name string + ResourceGroup string +} + +func ManagedApplicationDefinitionID(input string) (*ManagedApplicationDefinitionId, error) { + id, err := azure.ParseAzureResourceID(input) + if err != nil { + return nil, err + } + + account := ManagedApplicationDefinitionId{ + ResourceGroup: id.ResourceGroup, + } + + if account.Name, err = id.PopSegment("applicationDefinitions"); err != nil { + return nil, err + } + + if err := id.ValidateNoEmptySegments(input); err != nil { + return nil, err + } + + return &account, nil +} diff --git a/azurerm/internal/services/managedapplication/parse/managed_application_definition_test.go b/azurerm/internal/services/managedapplication/parse/managed_application_definition_test.go new file mode 100644 index 000000000000..fd62c8929f7e --- /dev/null +++ b/azurerm/internal/services/managedapplication/parse/managed_application_definition_test.go @@ -0,0 +1,81 @@ +package parse + +import ( + "testing" +) + +func TestManagedApplicationDefinitionID(t *testing.T) { + testData := []struct { + input string + expected *ManagedApplicationDefinitionId + }{ + { + input: "", + expected: nil, + }, + { + input: "/subscriptions/00000000-0000-0000-0000-000000000000", + expected: nil, + }, + { + input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups", + expected: nil, + }, + { + input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/hello", + expected: nil, + }, + { + input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/hello/providers", + expected: nil, + }, + { + input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/hello/providers/Microsoft.Solutions", + expected: nil, + }, + { + input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/hello/providers/Microsoft.Solutions/applicationDefinitions", + expected: nil, + }, + { + input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/hello/providers/Microsoft.Solutions/applicationDefinitions/appDef1", + expected: &ManagedApplicationDefinitionId{ + Name: "appDef1", + ResourceGroup: "hello", + }, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q..", v.input) + actual, err := ManagedApplicationDefinitionID(v.input) + + // if we get something there shouldn't be an error + if v.expected != nil && err == nil { + continue + } + + // if nothing's expected we should get an error + if v.expected == nil && err != nil { + continue + } + + if v.expected == nil && actual == nil { + continue + } + + if v.expected == nil && actual != nil { + t.Fatalf("Expected nothing but got %+v", actual) + } + if v.expected != nil && actual == nil { + t.Fatalf("Expected %+v but got nil", actual) + } + + if v.expected.ResourceGroup != actual.ResourceGroup { + t.Fatalf("Expected ResourceGroup to be %q but got %q", v.expected.ResourceGroup, actual.ResourceGroup) + } + if v.expected.Name != actual.Name { + t.Fatalf("Expected Name to be %q but got %q", v.expected.Name, actual.Name) + } + } +} diff --git a/azurerm/internal/services/managedapplication/registration.go b/azurerm/internal/services/managedapplication/registration.go new file mode 100644 index 000000000000..73c8012166e6 --- /dev/null +++ b/azurerm/internal/services/managedapplication/registration.go @@ -0,0 +1,33 @@ +package managedapplication + +import ( + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" +) + +type Registration struct{} + +// Name is the name of this Service +func (r Registration) Name() string { + return "ManagedApplication" +} + +// WebsiteCategories returns a list of categories which can be used for the sidebar +func (r Registration) WebsiteCategories() []string { + return []string{ + "ManagedApplication", + } +} + +// SupportedDataSources returns the supported Data Sources supported by this Service +func (r Registration) SupportedDataSources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "azurerm_managed_application_definition": dataSourceArmManagedApplicationDefinition(), + } +} + +// SupportedResources returns the supported Resources supported by this Service +func (r Registration) SupportedResources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "azurerm_managed_application_definition": resourceArmManagedApplicationDefinition(), + } +} diff --git a/azurerm/internal/services/managedapplication/resource_arm_managed_application_definition.go b/azurerm/internal/services/managedapplication/resource_arm_managed_application_definition.go new file mode 100644 index 000000000000..31f8802b191d --- /dev/null +++ b/azurerm/internal/services/managedapplication/resource_arm_managed_application_definition.go @@ -0,0 +1,309 @@ +package managedapplication + +import ( + "fmt" + "log" + "time" + + "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-07-01/managedapplications" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/managedapplication/parse" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/managedapplication/validate" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags" + azSchema "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/schema" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func resourceArmManagedApplicationDefinition() *schema.Resource { + return &schema.Resource{ + Create: resourceArmManagedApplicationDefinitionCreateUpdate, + Read: resourceArmManagedApplicationDefinitionRead, + Update: resourceArmManagedApplicationDefinitionCreateUpdate, + Delete: resourceArmManagedApplicationDefinitionDelete, + + Importer: azSchema.ValidateResourceIDPriorToImport(func(id string) error { + _, err := parse.ManagedApplicationDefinitionID(id) + return err + }), + + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(30 * time.Minute), + Read: schema.DefaultTimeout(5 * time.Minute), + Update: schema.DefaultTimeout(30 * time.Minute), + Delete: schema.DefaultTimeout(30 * time.Minute), + }, + + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.ManagedApplicationDefinitionName, + }, + + "location": azure.SchemaLocation(), + + "resource_group_name": azure.SchemaResourceGroupName(), + + "authorization": { + Type: schema.TypeSet, + Required: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "role_definition_id": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.IsUUID, + }, + "service_principal_id": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.IsUUID, + }, + }, + }, + }, + + "create_ui_definition": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringIsJSON, + ConflictsWith: []string{"package_file_uri"}, + }, + + "description": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validate.ManagedApplicationDefinitionDescription, + }, + + "display_name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.ManagedApplicationDefinitionDisplayName, + }, + + "package_enabled": { + Type: schema.TypeBool, + Optional: true, + Default: true, + }, + + "lock_level": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{ + string(managedapplications.CanNotDelete), + string(managedapplications.None), + string(managedapplications.ReadOnly), + }, false), + }, + + "main_template": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringIsJSON, + ConflictsWith: []string{"package_file_uri"}, + }, + + "package_file_uri": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.IsURLWithHTTPorHTTPS, + }, + + "tags": tags.Schema(), + }, + } +} + +func resourceArmManagedApplicationDefinitionCreateUpdate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).ManagedApplication.ApplicationDefinitionClient + ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) + defer cancel() + + name := d.Get("name").(string) + resourceGroupName := d.Get("resource_group_name").(string) + + if d.IsNewResource() { + existing, err := client.Get(ctx, resourceGroupName, name) + if err != nil { + if !utils.ResponseWasNotFound(existing.Response) { + return fmt.Errorf("failure checking for present of existing Managed Application Definition Name %q (Resource Group %q): %+v", name, resourceGroupName, err) + } + } + if existing.ID != nil && *existing.ID != "" { + return tf.ImportAsExistsError("azurerm_managed_application_definition", *existing.ID) + } + } + + location := azure.NormalizeLocation(d.Get("location").(string)) + authorizations := d.Get("authorization").(*schema.Set).List() + displayName := d.Get("display_name").(string) + description := d.Get("description").(string) + packageEnabled := d.Get("package_enabled").(bool) + lockLevel := d.Get("lock_level").(string) + t := d.Get("tags").(map[string]interface{}) + + parameters := managedapplications.ApplicationDefinition{ + Location: utils.String(location), + ApplicationDefinitionProperties: &managedapplications.ApplicationDefinitionProperties{ + Authorizations: expandArmManagedApplicationDefinitionAuthorization(authorizations), + Description: utils.String(description), + DisplayName: utils.String(displayName), + IsEnabled: utils.Bool(packageEnabled), + LockLevel: managedapplications.ApplicationLockLevel(lockLevel), + }, + Tags: tags.Expand(t), + } + + if v, ok := d.GetOk("create_ui_definition"); ok { + parameters.CreateUIDefinition = utils.String(v.(string)) + } + + if v, ok := d.GetOk("main_template"); ok { + parameters.MainTemplate = utils.String(v.(string)) + } + + if (parameters.CreateUIDefinition != nil && parameters.MainTemplate == nil) || (parameters.CreateUIDefinition == nil && parameters.MainTemplate != nil) { + return fmt.Errorf("`create_ui_definition` and `main_template` should be set or not set together") + } + + if v, ok := d.GetOk("package_file_uri"); ok { + parameters.PackageFileURI = utils.String(v.(string)) + } + + future, err := client.CreateOrUpdate(ctx, resourceGroupName, name, parameters) + if err != nil { + return fmt.Errorf("failure creating Managed Application Definition %q (Resource Group %q): %+v", name, resourceGroupName, err) + } + if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { + return fmt.Errorf("failure waiting for creation of Managed Application Definition %q (Resource Group %q): %+v", name, resourceGroupName, err) + } + + resp, err := client.Get(ctx, resourceGroupName, name) + if err != nil { + return fmt.Errorf("failure retrieving Managed Application Definition %q (Resource Group %q): %+v", name, resourceGroupName, err) + } + if resp.ID == nil || *resp.ID == "" { + return fmt.Errorf("cannot read Managed Application Definition %q (Resource Group %q) ID", name, resourceGroupName) + } + d.SetId(*resp.ID) + + return resourceArmManagedApplicationDefinitionRead(d, meta) +} + +func resourceArmManagedApplicationDefinitionRead(d *schema.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).ManagedApplication.ApplicationDefinitionClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := parse.ManagedApplicationDefinitionID(d.Id()) + if err != nil { + return err + } + + resp, err := client.Get(ctx, id.ResourceGroup, id.Name) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + log.Printf("[INFO] Managed Application Definition %q does not exist - removing from state", d.Id()) + d.SetId("") + return nil + } + return fmt.Errorf("failure reading Managed Application Definition %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + } + + d.Set("name", id.Name) + d.Set("resource_group_name", id.ResourceGroup) + if location := resp.Location; location != nil { + d.Set("location", azure.NormalizeLocation(*location)) + } + if props := resp.ApplicationDefinitionProperties; props != nil { + if err := d.Set("authorization", flattenArmManagedApplicationDefinitionAuthorization(props.Authorizations)); err != nil { + return fmt.Errorf("failure setting `authorization`: %+v", err) + } + d.Set("description", props.Description) + d.Set("display_name", props.DisplayName) + d.Set("package_enabled", props.IsEnabled) + d.Set("lock_level", string(props.LockLevel)) + } + if v, ok := d.GetOk("create_ui_definition"); ok { + d.Set("create_ui_definition", v.(string)) + } + if v, ok := d.GetOk("main_template"); ok { + d.Set("main_template", v.(string)) + } + if v, ok := d.GetOk("package_file_uri"); ok { + d.Set("package_file_uri", v.(string)) + } + + return tags.FlattenAndSet(d, resp.Tags) +} + +func resourceArmManagedApplicationDefinitionDelete(d *schema.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).ManagedApplication.ApplicationDefinitionClient + ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := parse.ManagedApplicationDefinitionID(d.Id()) + if err != nil { + return err + } + + future, err := client.Delete(ctx, id.ResourceGroup, id.Name) + if err != nil { + return fmt.Errorf("failure deleting Managed Application Definition %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + } + + if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { + return fmt.Errorf("failure waiting for deleting Managed Application Definition (Managed Application Definition Name %q / Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + } + + return nil +} + +func expandArmManagedApplicationDefinitionAuthorization(input []interface{}) *[]managedapplications.ApplicationAuthorization { + results := make([]managedapplications.ApplicationAuthorization, 0) + for _, item := range input { + v := item.(map[string]interface{}) + result := managedapplications.ApplicationAuthorization{ + RoleDefinitionID: utils.String(v["role_definition_id"].(string)), + PrincipalID: utils.String(v["service_principal_id"].(string)), + } + + results = append(results, result) + } + return &results +} + +func flattenArmManagedApplicationDefinitionAuthorization(input *[]managedapplications.ApplicationAuthorization) []interface{} { + results := make([]interface{}, 0) + if input == nil { + return results + } + + for _, item := range *input { + servicePrincipalId := "" + if item.PrincipalID != nil { + servicePrincipalId = *item.PrincipalID + } + + roleDefinitionId := "" + if item.RoleDefinitionID != nil { + roleDefinitionId = *item.RoleDefinitionID + } + + results = append(results, map[string]interface{}{ + "role_definition_id": roleDefinitionId, + "service_principal_id": servicePrincipalId, + }) + } + + return results +} diff --git a/azurerm/internal/services/managedapplication/tests/data_source_managed_application_definition_test.go b/azurerm/internal/services/managedapplication/tests/data_source_managed_application_definition_test.go new file mode 100644 index 000000000000..22faf45daaf7 --- /dev/null +++ b/azurerm/internal/services/managedapplication/tests/data_source_managed_application_definition_test.go @@ -0,0 +1,39 @@ +package tests + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance" +) + +func TestAccDataSourceAzureRMManagedApplicationDefinition_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "data.azurerm_managed_application_definition", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMManagedApplicationDefinitionDestroy, + Steps: []resource.TestStep{ + { + Config: testAccDataSourceManagedApplicationDefinition_basic(data), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet(data.ResourceName, "name"), + ), + }, + }, + }) +} + +func testAccDataSourceManagedApplicationDefinition_basic(data acceptance.TestData) string { + config := testAccAzureRMManagedApplicationDefinition_basic(data) + return fmt.Sprintf(` +%s + +data "azurerm_managed_application_definition" "test" { + name = azurerm_managed_application_definition.test.name + resource_group_name = azurerm_managed_application_definition.test.resource_group_name +} +`, config) +} diff --git a/azurerm/internal/services/managedapplication/tests/resource_arm_managed_application_definition_test.go b/azurerm/internal/services/managedapplication/tests/resource_arm_managed_application_definition_test.go new file mode 100644 index 000000000000..a1fd57f8b3ae --- /dev/null +++ b/azurerm/internal/services/managedapplication/tests/resource_arm_managed_application_definition_test.go @@ -0,0 +1,326 @@ +package tests + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/managedapplication/parse" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func TestAccAzureRMManagedApplicationDefinition_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_managed_application_definition", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMManagedApplicationDefinitionDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMManagedApplicationDefinition_basic(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMManagedApplicationDefinitionExists(data.ResourceName), + ), + }, + data.ImportStep("package_file_uri"), + }, + }) +} + +func TestAccAzureRMManagedApplicationDefinition_requiresImport(t *testing.T) { + if !features.ShouldResourcesBeImported() { + t.Skip("Skipping since resources aren't required to be imported") + return + } + + data := acceptance.BuildTestData(t, "azurerm_managed_application_definition", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMManagedApplicationDefinitionDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMManagedApplicationDefinition_basic(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMManagedApplicationDefinitionExists(data.ResourceName), + ), + }, + data.RequiresImportErrorStep(testAccAzureRMManagedApplicationDefinition_requiresImport), + }, + }) +} + +func TestAccAzureRMManagedApplicationDefinition_complete(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_managed_application_definition", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMManagedApplicationDefinitionDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMManagedApplicationDefinition_complete(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMManagedApplicationDefinitionExists(data.ResourceName), + ), + }, + data.ImportStep("create_ui_definition", "main_template"), + }, + }) +} + +func TestAccAzureRMManagedApplicationDefinition_update(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_managed_application_definition", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMManagedApplicationDefinitionDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMManagedApplicationDefinition_basic(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMManagedApplicationDefinitionExists(data.ResourceName), + resource.TestCheckResourceAttr(data.ResourceName, "display_name", "TestManagedApplicationDefinition"), + resource.TestCheckResourceAttr(data.ResourceName, "description", "Test Managed Application Definition"), + resource.TestCheckResourceAttr(data.ResourceName, "package_enabled", "false"), + resource.TestCheckResourceAttr(data.ResourceName, "tags.%", "0"), + ), + }, + data.ImportStep("package_file_uri"), + { + Config: testAccAzureRMManagedApplicationDefinition_complete(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMManagedApplicationDefinitionExists(data.ResourceName), + resource.TestCheckResourceAttr(data.ResourceName, "display_name", "UpdatedTestManagedApplicationDefinition"), + resource.TestCheckResourceAttr(data.ResourceName, "description", "Updated Test Managed Application Definition"), + resource.TestCheckResourceAttr(data.ResourceName, "package_enabled", "true"), + resource.TestCheckResourceAttr(data.ResourceName, "tags.%", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "tags.ENV", "Test"), + ), + }, + data.ImportStep("create_ui_definition", "main_template", "package_file_uri"), + }, + }) +} + +func testCheckAzureRMManagedApplicationDefinitionExists(resourceName string) resource.TestCheckFunc { + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[resourceName] + if !ok { + return fmt.Errorf("Managed Application Definition not found: %s", resourceName) + } + + id, err := parse.ManagedApplicationDefinitionID(rs.Primary.ID) + if err != nil { + return err + } + + client := acceptance.AzureProvider.Meta().(*clients.Client).ManagedApplication.ApplicationDefinitionClient + ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext + + if resp, err := client.Get(ctx, id.ResourceGroup, id.Name); err != nil { + if utils.ResponseWasNotFound(resp.Response) { + return fmt.Errorf("Bad: Managed Application Definition %q (Resource Group %q) does not exist", id.Name, id.ResourceGroup) + } + return fmt.Errorf("Bad: Get on ManagedApplication.ApplicationDefinitionClient: %+v", err) + } + + return nil + } +} + +func testCheckAzureRMManagedApplicationDefinitionDestroy(s *terraform.State) error { + client := acceptance.AzureProvider.Meta().(*clients.Client).ManagedApplication.ApplicationDefinitionClient + ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext + + for _, rs := range s.RootModule().Resources { + if rs.Type != "azurerm_managed_application_definition" { + continue + } + + id, err := parse.ManagedApplicationDefinitionID(rs.Primary.ID) + if err != nil { + return err + } + + if resp, err := client.Get(ctx, id.ResourceGroup, id.Name); err != nil { + if !utils.ResponseWasNotFound(resp.Response) { + return fmt.Errorf("Bad: Get on ManagedApplication.ApplicationDefinitionClient: %+v", err) + } + } + + return nil + } + + return nil +} + +func testAccAzureRMManagedApplicationDefinition_basic(data acceptance.TestData) string { + template := testAccAzureRMManagedApplicationDefinition_template(data) + return fmt.Sprintf(` +%s + +resource "azurerm_managed_application_definition" "test" { + name = "acctestAppDef%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + lock_level = "ReadOnly" + package_file_uri = "https://github.com/Azure/azure-managedapp-samples/raw/master/Managed Application Sample Packages/201-managed-storage-account/managedstorage.zip" + display_name = "TestManagedApplicationDefinition" + description = "Test Managed Application Definition" + package_enabled = false + + authorization { + service_principal_id = data.azurerm_client_config.current.object_id + role_definition_id = "b24988ac-6180-42a0-ab88-20f7382dd24c" + } +} +`, template, data.RandomInteger) +} + +func testAccAzureRMManagedApplicationDefinition_requiresImport(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_managed_application_definition" "import" { + name = azurerm_managed_application_definition.test.name + location = azurerm_managed_application_definition.test.location + resource_group_name = azurerm_resource_group.test.name +} +`, testAccAzureRMManagedApplicationDefinition_basic(data)) +} + +func testAccAzureRMManagedApplicationDefinition_complete(data acceptance.TestData) string { + template := testAccAzureRMManagedApplicationDefinition_template(data) + return fmt.Sprintf(` +%s + +resource "azurerm_managed_application_definition" "test" { + name = "acctestAppDef%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + lock_level = "ReadOnly" + display_name = "UpdatedTestManagedApplicationDefinition" + description = "Updated Test Managed Application Definition" + package_enabled = true + + create_ui_definition = < 60 { + errors = append(errors, fmt.Errorf("%q must be between 4 and 60 characters in length.", k)) + } + + return warnings, errors +} + +func ManagedApplicationDefinitionDescription(v interface{}, k string) (warnings []string, errors []error) { + value := v.(string) + + if len(value) > 200 { + errors = append(errors, fmt.Errorf("%q should not exceed 200 characters in length.", k)) + } + + return warnings, errors +} diff --git a/azurerm/internal/services/managedapplication/validate/managed_application_definition_test.go b/azurerm/internal/services/managedapplication/validate/managed_application_definition_test.go new file mode 100644 index 000000000000..0e066d750c49 --- /dev/null +++ b/azurerm/internal/services/managedapplication/validate/managed_application_definition_test.go @@ -0,0 +1,209 @@ +package validate + +import ( + "testing" +) + +func TestManagedApplicationDefinitionName(t *testing.T) { + testData := []struct { + input string + expected bool + }{ + { + // empty + input: "", + expected: false, + }, + { + // basic example + input: "hello", + expected: true, + }, + { + // can't start with an underscore + input: "_hello", + expected: false, + }, + { + // can't end with a dash + input: "hello-", + expected: false, + }, + { + // can't contain an exclamation mark + input: "hello!", + expected: false, + }, + { + // dash in the middle + input: "malcolm-in-the-middle", + expected: false, + }, + { + // can't end with a period + input: "hello.", + expected: false, + }, + { + // 63 chars + input: "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk", + expected: true, + }, + { + // 64 chars + input: "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkj", + expected: true, + }, + { + // 65 chars + input: "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkja", + expected: false, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q..", v.input) + + _, errors := ManagedApplicationDefinitionName(v.input, "name") + actual := len(errors) == 0 + if v.expected != actual { + t.Fatalf("Expected %t but got %t", v.expected, actual) + } + } +} + +func TestManagedApplicationDefinitionDisplayName(t *testing.T) { + testData := []struct { + input string + expected bool + }{ + { + // empty + input: "", + expected: false, + }, + { + // basic example + input: "hello", + expected: true, + }, + { + // can't start with an underscore + input: "_hello", + expected: true, + }, + { + // can't end with a dash + input: "hello-", + expected: true, + }, + { + // can't contain an exclamation mark + input: "hello!", + expected: true, + }, + { + // dash in the middle + input: "malcolm-in-the-middle", + expected: true, + }, + { + // can't end with a period + input: "hello.", + expected: true, + }, + { + // 59 chars + input: "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefg", + expected: true, + }, + { + // 60 chars + input: "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefga", + expected: true, + }, + { + // 61 chars + input: "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefgaa", + expected: false, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q..", v.input) + + _, errors := ManagedApplicationDefinitionDisplayName(v.input, "display_name") + actual := len(errors) == 0 + if v.expected != actual { + t.Fatalf("Expected %t but got %t", v.expected, actual) + } + } +} + +func TestManagedApplicationDefinitionDescription(t *testing.T) { + testData := []struct { + input string + expected bool + }{ + { + // empty + input: "", + expected: true, + }, + { + // basic example + input: "hello", + expected: true, + }, + { + // can't start with an underscore + input: "_hello", + expected: true, + }, + { + // can't end with a dash + input: "hello-", + expected: true, + }, + { + // can't contain an exclamation mark + input: "hello!", + expected: true, + }, + { + // dash in the middle + input: "malcolm-in-the-middle", + expected: true, + }, + { + // can't end with a period + input: "hello.", + expected: true, + }, + { + // 199 chars + input: "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvw", + expected: true, + }, + { + // 200 chars + input: "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwd", + expected: true, + }, + { + // 201 chars + input: "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwds", + expected: false, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q..", v.input) + + _, errors := ManagedApplicationDefinitionDescription(v.input, "description") + actual := len(errors) == 0 + if v.expected != actual { + t.Fatalf("Expected %t but got %t", v.expected, actual) + } + } +} diff --git a/examples/managed-application/application-definition/main.tf b/examples/managed-application/application-definition/main.tf new file mode 100644 index 000000000000..1d00c8702877 --- /dev/null +++ b/examples/managed-application/application-definition/main.tf @@ -0,0 +1,25 @@ +provider "azurerm" { + features {} +} + +data "azurerm_client_config" "current" {} + +resource "azurerm_resource_group" "example" { + name = "${var.prefix}-resources" + location = var.location +} + +resource "azurerm_managed_application_definition" "example" { + name = "${var.prefix}managedappdef" + location = azurerm_resource_group.example.location + resource_group_name = azurerm_resource_group.example.name + lock_level = "ReadOnly" + package_file_uri = "https://github.com/Azure/azure-managedapp-samples/raw/master/Managed Application Sample Packages/201-managed-storage-account/managedstorage.zip" + display_name = "TestManagedApplicationDefinition" + description = "Test Managed Application Definition" + + authorization { + service_principal_id = data.azurerm_client_config.current.object_id + role_definition_id = "b24988ac-6180-42a0-ab88-20f7382dd24c" + } +} diff --git a/examples/managed-application/application-definition/variables.tf b/examples/managed-application/application-definition/variables.tf new file mode 100644 index 000000000000..4b1cc6bcfc8d --- /dev/null +++ b/examples/managed-application/application-definition/variables.tf @@ -0,0 +1,7 @@ +variable "location" { + description = "The Azure location where all resources in this example should be created." +} + +variable "prefix" { + description = "The prefix used for all resources used by this Managed Application Definition" +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-07-01/managedapplications/applicationdefinitions.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-07-01/managedapplications/applicationdefinitions.go new file mode 100644 index 000000000000..a338cec7fd3f --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-07-01/managedapplications/applicationdefinitions.go @@ -0,0 +1,668 @@ +package managedapplications + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ApplicationDefinitionsClient is the ARM applications +type ApplicationDefinitionsClient struct { + BaseClient +} + +// NewApplicationDefinitionsClient creates an instance of the ApplicationDefinitionsClient client. +func NewApplicationDefinitionsClient(subscriptionID string) ApplicationDefinitionsClient { + return NewApplicationDefinitionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewApplicationDefinitionsClientWithBaseURI creates an instance of the ApplicationDefinitionsClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewApplicationDefinitionsClientWithBaseURI(baseURI string, subscriptionID string) ApplicationDefinitionsClient { + return ApplicationDefinitionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new managed application definition. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// applicationDefinitionName - the name of the managed application definition. +// parameters - parameters supplied to the create or update an managed application definition. +func (client ApplicationDefinitionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, applicationDefinitionName string, parameters ApplicationDefinition) (result ApplicationDefinitionsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationDefinitionsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}, + {TargetValue: applicationDefinitionName, + Constraints: []validation.Constraint{{Target: "applicationDefinitionName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "applicationDefinitionName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ApplicationDefinitionProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ApplicationDefinitionProperties.NotificationPolicy", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ApplicationDefinitionProperties.NotificationPolicy.NotificationEndpoints", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("managedapplications.ApplicationDefinitionsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, applicationDefinitionName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ApplicationDefinitionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, applicationDefinitionName string, parameters ApplicationDefinition) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationDefinitionName": autorest.Encode("path", applicationDefinitionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-07-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationDefinitionsClient) CreateOrUpdateSender(req *http.Request) (future ApplicationDefinitionsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ApplicationDefinitionsClient) CreateOrUpdateResponder(resp *http.Response) (result ApplicationDefinition, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdateByID creates a new managed application definition. +// Parameters: +// applicationDefinitionID - the fully qualified ID of the managed application definition, including the +// managed application name and the managed application definition resource type. Use the format, +// /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applicationDefinitions/{applicationDefinition-name} +// parameters - parameters supplied to the create or update a managed application definition. +func (client ApplicationDefinitionsClient) CreateOrUpdateByID(ctx context.Context, applicationDefinitionID string, parameters ApplicationDefinition) (result ApplicationDefinitionsCreateOrUpdateByIDFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationDefinitionsClient.CreateOrUpdateByID") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ApplicationDefinitionProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ApplicationDefinitionProperties.NotificationPolicy", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ApplicationDefinitionProperties.NotificationPolicy.NotificationEndpoints", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("managedapplications.ApplicationDefinitionsClient", "CreateOrUpdateByID", err.Error()) + } + + req, err := client.CreateOrUpdateByIDPreparer(ctx, applicationDefinitionID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "CreateOrUpdateByID", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateByIDSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "CreateOrUpdateByID", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdateByIDPreparer prepares the CreateOrUpdateByID request. +func (client ApplicationDefinitionsClient) CreateOrUpdateByIDPreparer(ctx context.Context, applicationDefinitionID string, parameters ApplicationDefinition) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationDefinitionId": applicationDefinitionID, + } + + const APIVersion = "2019-07-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{applicationDefinitionId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateByIDSender sends the CreateOrUpdateByID request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationDefinitionsClient) CreateOrUpdateByIDSender(req *http.Request) (future ApplicationDefinitionsCreateOrUpdateByIDFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateByIDResponder handles the response to the CreateOrUpdateByID request. The method always +// closes the http.Response Body. +func (client ApplicationDefinitionsClient) CreateOrUpdateByIDResponder(resp *http.Response) (result ApplicationDefinition, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the managed application definition. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// applicationDefinitionName - the name of the managed application definition to delete. +func (client ApplicationDefinitionsClient) Delete(ctx context.Context, resourceGroupName string, applicationDefinitionName string) (result ApplicationDefinitionsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationDefinitionsClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}, + {TargetValue: applicationDefinitionName, + Constraints: []validation.Constraint{{Target: "applicationDefinitionName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "applicationDefinitionName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("managedapplications.ApplicationDefinitionsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, applicationDefinitionName) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ApplicationDefinitionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, applicationDefinitionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationDefinitionName": autorest.Encode("path", applicationDefinitionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-07-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationDefinitionsClient) DeleteSender(req *http.Request) (future ApplicationDefinitionsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ApplicationDefinitionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteByID deletes the managed application definition. +// Parameters: +// applicationDefinitionID - the fully qualified ID of the managed application definition, including the +// managed application name and the managed application definition resource type. Use the format, +// /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applicationDefinitions/{applicationDefinition-name} +func (client ApplicationDefinitionsClient) DeleteByID(ctx context.Context, applicationDefinitionID string) (result ApplicationDefinitionsDeleteByIDFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationDefinitionsClient.DeleteByID") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeleteByIDPreparer(ctx, applicationDefinitionID) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "DeleteByID", nil, "Failure preparing request") + return + } + + result, err = client.DeleteByIDSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "DeleteByID", result.Response(), "Failure sending request") + return + } + + return +} + +// DeleteByIDPreparer prepares the DeleteByID request. +func (client ApplicationDefinitionsClient) DeleteByIDPreparer(ctx context.Context, applicationDefinitionID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationDefinitionId": applicationDefinitionID, + } + + const APIVersion = "2019-07-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{applicationDefinitionId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteByIDSender sends the DeleteByID request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationDefinitionsClient) DeleteByIDSender(req *http.Request) (future ApplicationDefinitionsDeleteByIDFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteByIDResponder handles the response to the DeleteByID request. The method always +// closes the http.Response Body. +func (client ApplicationDefinitionsClient) DeleteByIDResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the managed application definition. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// applicationDefinitionName - the name of the managed application definition. +func (client ApplicationDefinitionsClient) Get(ctx context.Context, resourceGroupName string, applicationDefinitionName string) (result ApplicationDefinition, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationDefinitionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}, + {TargetValue: applicationDefinitionName, + Constraints: []validation.Constraint{{Target: "applicationDefinitionName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "applicationDefinitionName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("managedapplications.ApplicationDefinitionsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, applicationDefinitionName) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ApplicationDefinitionsClient) GetPreparer(ctx context.Context, resourceGroupName string, applicationDefinitionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationDefinitionName": autorest.Encode("path", applicationDefinitionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-07-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationDefinitionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ApplicationDefinitionsClient) GetResponder(resp *http.Response) (result ApplicationDefinition, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByID gets the managed application definition. +// Parameters: +// applicationDefinitionID - the fully qualified ID of the managed application definition, including the +// managed application name and the managed application definition resource type. Use the format, +// /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applicationDefinitions/{applicationDefinition-name} +func (client ApplicationDefinitionsClient) GetByID(ctx context.Context, applicationDefinitionID string) (result ApplicationDefinition, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationDefinitionsClient.GetByID") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetByIDPreparer(ctx, applicationDefinitionID) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "GetByID", nil, "Failure preparing request") + return + } + + resp, err := client.GetByIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "GetByID", resp, "Failure sending request") + return + } + + result, err = client.GetByIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "GetByID", resp, "Failure responding to request") + } + + return +} + +// GetByIDPreparer prepares the GetByID request. +func (client ApplicationDefinitionsClient) GetByIDPreparer(ctx context.Context, applicationDefinitionID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationDefinitionId": applicationDefinitionID, + } + + const APIVersion = "2019-07-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{applicationDefinitionId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByIDSender sends the GetByID request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationDefinitionsClient) GetByIDSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetByIDResponder handles the response to the GetByID request. The method always +// closes the http.Response Body. +func (client ApplicationDefinitionsClient) GetByIDResponder(resp *http.Response) (result ApplicationDefinition, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup lists the managed application definitions in a resource group. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client ApplicationDefinitionsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ApplicationDefinitionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationDefinitionsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.adlr.Response.Response != nil { + sc = result.adlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("managedapplications.ApplicationDefinitionsClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.adlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.adlr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ApplicationDefinitionsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-07-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationDefinitionsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ApplicationDefinitionsClient) ListByResourceGroupResponder(resp *http.Response) (result ApplicationDefinitionListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client ApplicationDefinitionsClient) listByResourceGroupNextResults(ctx context.Context, lastResults ApplicationDefinitionListResult) (result ApplicationDefinitionListResult, err error) { + req, err := lastResults.applicationDefinitionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client ApplicationDefinitionsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ApplicationDefinitionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationDefinitionsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-07-01/managedapplications/applications.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-07-01/managedapplications/applications.go new file mode 100644 index 000000000000..0e573b5ed49f --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-07-01/managedapplications/applications.go @@ -0,0 +1,1061 @@ +package managedapplications + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ApplicationsClient is the ARM applications +type ApplicationsClient struct { + BaseClient +} + +// NewApplicationsClient creates an instance of the ApplicationsClient client. +func NewApplicationsClient(subscriptionID string) ApplicationsClient { + return NewApplicationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewApplicationsClientWithBaseURI creates an instance of the ApplicationsClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewApplicationsClientWithBaseURI(baseURI string, subscriptionID string) ApplicationsClient { + return ApplicationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new managed application. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// applicationName - the name of the managed application. +// parameters - parameters supplied to the create or update a managed application. +func (client ApplicationsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, applicationName string, parameters Application) (result ApplicationsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}, + {TargetValue: applicationName, + Constraints: []validation.Constraint{{Target: "applicationName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "applicationName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ApplicationProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ApplicationProperties.JitAccessPolicy", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ApplicationProperties.JitAccessPolicy.JitAccessEnabled", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "parameters.ApplicationProperties.CustomerSupport", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ApplicationProperties.CustomerSupport.Email", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ApplicationProperties.CustomerSupport.Phone", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}, + {Target: "parameters.Plan", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Plan.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Plan.Publisher", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Plan.Product", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Plan.Version", Name: validation.Null, Rule: true, Chain: nil}, + }}, + {Target: "parameters.Kind", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.Kind", Name: validation.Pattern, Rule: `^[-\w\._,\(\)]+$`, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("managedapplications.ApplicationsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, applicationName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ApplicationsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, applicationName string, parameters Application) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationName": autorest.Encode("path", applicationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-07-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationsClient) CreateOrUpdateSender(req *http.Request) (future ApplicationsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ApplicationsClient) CreateOrUpdateResponder(resp *http.Response) (result Application, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdateByID creates a new managed application. +// Parameters: +// applicationID - the fully qualified ID of the managed application, including the managed application name +// and the managed application resource type. Use the format, +// /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name} +// parameters - parameters supplied to the create or update a managed application. +func (client ApplicationsClient) CreateOrUpdateByID(ctx context.Context, applicationID string, parameters Application) (result ApplicationsCreateOrUpdateByIDFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.CreateOrUpdateByID") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ApplicationProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ApplicationProperties.JitAccessPolicy", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ApplicationProperties.JitAccessPolicy.JitAccessEnabled", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "parameters.ApplicationProperties.CustomerSupport", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ApplicationProperties.CustomerSupport.Email", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ApplicationProperties.CustomerSupport.Phone", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}, + {Target: "parameters.Plan", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Plan.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Plan.Publisher", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Plan.Product", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Plan.Version", Name: validation.Null, Rule: true, Chain: nil}, + }}, + {Target: "parameters.Kind", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.Kind", Name: validation.Pattern, Rule: `^[-\w\._,\(\)]+$`, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("managedapplications.ApplicationsClient", "CreateOrUpdateByID", err.Error()) + } + + req, err := client.CreateOrUpdateByIDPreparer(ctx, applicationID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "CreateOrUpdateByID", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateByIDSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "CreateOrUpdateByID", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdateByIDPreparer prepares the CreateOrUpdateByID request. +func (client ApplicationsClient) CreateOrUpdateByIDPreparer(ctx context.Context, applicationID string, parameters Application) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationId": applicationID, + } + + const APIVersion = "2019-07-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{applicationId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateByIDSender sends the CreateOrUpdateByID request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationsClient) CreateOrUpdateByIDSender(req *http.Request) (future ApplicationsCreateOrUpdateByIDFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateByIDResponder handles the response to the CreateOrUpdateByID request. The method always +// closes the http.Response Body. +func (client ApplicationsClient) CreateOrUpdateByIDResponder(resp *http.Response) (result Application, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the managed application. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// applicationName - the name of the managed application. +func (client ApplicationsClient) Delete(ctx context.Context, resourceGroupName string, applicationName string) (result ApplicationsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}, + {TargetValue: applicationName, + Constraints: []validation.Constraint{{Target: "applicationName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "applicationName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("managedapplications.ApplicationsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, applicationName) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ApplicationsClient) DeletePreparer(ctx context.Context, resourceGroupName string, applicationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationName": autorest.Encode("path", applicationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-07-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationsClient) DeleteSender(req *http.Request) (future ApplicationsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ApplicationsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteByID deletes the managed application. +// Parameters: +// applicationID - the fully qualified ID of the managed application, including the managed application name +// and the managed application resource type. Use the format, +// /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name} +func (client ApplicationsClient) DeleteByID(ctx context.Context, applicationID string) (result ApplicationsDeleteByIDFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.DeleteByID") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeleteByIDPreparer(ctx, applicationID) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "DeleteByID", nil, "Failure preparing request") + return + } + + result, err = client.DeleteByIDSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "DeleteByID", result.Response(), "Failure sending request") + return + } + + return +} + +// DeleteByIDPreparer prepares the DeleteByID request. +func (client ApplicationsClient) DeleteByIDPreparer(ctx context.Context, applicationID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationId": applicationID, + } + + const APIVersion = "2019-07-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{applicationId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteByIDSender sends the DeleteByID request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationsClient) DeleteByIDSender(req *http.Request) (future ApplicationsDeleteByIDFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteByIDResponder handles the response to the DeleteByID request. The method always +// closes the http.Response Body. +func (client ApplicationsClient) DeleteByIDResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the managed application. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// applicationName - the name of the managed application. +func (client ApplicationsClient) Get(ctx context.Context, resourceGroupName string, applicationName string) (result Application, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}, + {TargetValue: applicationName, + Constraints: []validation.Constraint{{Target: "applicationName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "applicationName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("managedapplications.ApplicationsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, applicationName) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ApplicationsClient) GetPreparer(ctx context.Context, resourceGroupName string, applicationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationName": autorest.Encode("path", applicationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-07-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ApplicationsClient) GetResponder(resp *http.Response) (result Application, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByID gets the managed application. +// Parameters: +// applicationID - the fully qualified ID of the managed application, including the managed application name +// and the managed application resource type. Use the format, +// /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name} +func (client ApplicationsClient) GetByID(ctx context.Context, applicationID string) (result Application, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.GetByID") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetByIDPreparer(ctx, applicationID) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "GetByID", nil, "Failure preparing request") + return + } + + resp, err := client.GetByIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "GetByID", resp, "Failure sending request") + return + } + + result, err = client.GetByIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "GetByID", resp, "Failure responding to request") + } + + return +} + +// GetByIDPreparer prepares the GetByID request. +func (client ApplicationsClient) GetByIDPreparer(ctx context.Context, applicationID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationId": applicationID, + } + + const APIVersion = "2019-07-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{applicationId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByIDSender sends the GetByID request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationsClient) GetByIDSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetByIDResponder handles the response to the GetByID request. The method always +// closes the http.Response Body. +func (client ApplicationsClient) GetByIDResponder(resp *http.Response) (result Application, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup gets all the applications within a resource group. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client ApplicationsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ApplicationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.alr.Response.Response != nil { + sc = result.alr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("managedapplications.ApplicationsClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.alr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.alr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ApplicationsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-07-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ApplicationsClient) ListByResourceGroupResponder(resp *http.Response) (result ApplicationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client ApplicationsClient) listByResourceGroupNextResults(ctx context.Context, lastResults ApplicationListResult) (result ApplicationListResult, err error) { + req, err := lastResults.applicationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client ApplicationsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ApplicationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// ListBySubscription gets all the applications within a subscription. +func (client ApplicationsClient) ListBySubscription(ctx context.Context) (result ApplicationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.ListBySubscription") + defer func() { + sc := -1 + if result.alr.Response.Response != nil { + sc = result.alr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.alr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.alr, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "ListBySubscription", resp, "Failure responding to request") + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client ApplicationsClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-07-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client ApplicationsClient) ListBySubscriptionResponder(resp *http.Response) (result ApplicationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client ApplicationsClient) listBySubscriptionNextResults(ctx context.Context, lastResults ApplicationListResult) (result ApplicationListResult, err error) { + req, err := lastResults.applicationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client ApplicationsClient) ListBySubscriptionComplete(ctx context.Context) (result ApplicationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySubscription(ctx) + return +} + +// RefreshPermissions refresh Permissions for application. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// applicationName - the name of the managed application. +func (client ApplicationsClient) RefreshPermissions(ctx context.Context, resourceGroupName string, applicationName string) (result ApplicationsRefreshPermissionsFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.RefreshPermissions") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}, + {TargetValue: applicationName, + Constraints: []validation.Constraint{{Target: "applicationName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "applicationName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("managedapplications.ApplicationsClient", "RefreshPermissions", err.Error()) + } + + req, err := client.RefreshPermissionsPreparer(ctx, resourceGroupName, applicationName) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "RefreshPermissions", nil, "Failure preparing request") + return + } + + result, err = client.RefreshPermissionsSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "RefreshPermissions", result.Response(), "Failure sending request") + return + } + + return +} + +// RefreshPermissionsPreparer prepares the RefreshPermissions request. +func (client ApplicationsClient) RefreshPermissionsPreparer(ctx context.Context, resourceGroupName string, applicationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationName": autorest.Encode("path", applicationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-07-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RefreshPermissionsSender sends the RefreshPermissions request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationsClient) RefreshPermissionsSender(req *http.Request) (future ApplicationsRefreshPermissionsFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// RefreshPermissionsResponder handles the response to the RefreshPermissions request. The method always +// closes the http.Response Body. +func (client ApplicationsClient) RefreshPermissionsResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update updates an existing managed application. The only value that can be updated via PATCH currently is the tags. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// applicationName - the name of the managed application. +// parameters - parameters supplied to update an existing managed application. +func (client ApplicationsClient) Update(ctx context.Context, resourceGroupName string, applicationName string, parameters *Application) (result Application, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}, + {TargetValue: applicationName, + Constraints: []validation.Constraint{{Target: "applicationName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "applicationName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("managedapplications.ApplicationsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, applicationName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ApplicationsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, applicationName string, parameters *Application) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationName": autorest.Encode("path", applicationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-07-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if parameters != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(parameters)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ApplicationsClient) UpdateResponder(resp *http.Response) (result Application, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateByID updates an existing managed application. The only value that can be updated via PATCH currently is the +// tags. +// Parameters: +// applicationID - the fully qualified ID of the managed application, including the managed application name +// and the managed application resource type. Use the format, +// /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name} +// parameters - parameters supplied to update an existing managed application. +func (client ApplicationsClient) UpdateByID(ctx context.Context, applicationID string, parameters *Application) (result Application, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.UpdateByID") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdateByIDPreparer(ctx, applicationID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "UpdateByID", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateByIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "UpdateByID", resp, "Failure sending request") + return + } + + result, err = client.UpdateByIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsClient", "UpdateByID", resp, "Failure responding to request") + } + + return +} + +// UpdateByIDPreparer prepares the UpdateByID request. +func (client ApplicationsClient) UpdateByIDPreparer(ctx context.Context, applicationID string, parameters *Application) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationId": applicationID, + } + + const APIVersion = "2019-07-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{applicationId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if parameters != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(parameters)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateByIDSender sends the UpdateByID request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationsClient) UpdateByIDSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// UpdateByIDResponder handles the response to the UpdateByID request. The method always +// closes the http.Response Body. +func (client ApplicationsClient) UpdateByIDResponder(resp *http.Response) (result Application, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-07-01/managedapplications/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-07-01/managedapplications/client.go new file mode 100644 index 000000000000..829b9d531a95 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-07-01/managedapplications/client.go @@ -0,0 +1,161 @@ +// Package managedapplications implements the Azure ARM Managedapplications service API version 2019-07-01. +// +// ARM applications +package managedapplications + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +const ( + // DefaultBaseURI is the default URI used for the service Managedapplications + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Managedapplications. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} + +// ListOperations lists all of the available Microsoft.Solutions REST API operations. +func (client BaseClient) ListOperations(ctx context.Context) (result OperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BaseClient.ListOperations") + defer func() { + sc := -1 + if result.olr.Response.Response != nil { + sc = result.olr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listOperationsNextResults + req, err := client.ListOperationsPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.BaseClient", "ListOperations", nil, "Failure preparing request") + return + } + + resp, err := client.ListOperationsSender(req) + if err != nil { + result.olr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managedapplications.BaseClient", "ListOperations", resp, "Failure sending request") + return + } + + result.olr, err = client.ListOperationsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.BaseClient", "ListOperations", resp, "Failure responding to request") + } + + return +} + +// ListOperationsPreparer prepares the ListOperations request. +func (client BaseClient) ListOperationsPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2019-07-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Solutions/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListOperationsSender sends the ListOperations request. The method will close the +// http.Response Body if it receives an error. +func (client BaseClient) ListOperationsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListOperationsResponder handles the response to the ListOperations request. The method always +// closes the http.Response Body. +func (client BaseClient) ListOperationsResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listOperationsNextResults retrieves the next set of results, if any. +func (client BaseClient) listOperationsNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "managedapplications.BaseClient", "listOperationsNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListOperationsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "managedapplications.BaseClient", "listOperationsNextResults", resp, "Failure sending next results request") + } + result, err = client.ListOperationsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.BaseClient", "listOperationsNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListOperationsComplete enumerates all values, automatically crossing page boundaries as required. +func (client BaseClient) ListOperationsComplete(ctx context.Context) (result OperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BaseClient.ListOperations") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListOperations(ctx) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-07-01/managedapplications/jitrequests.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-07-01/managedapplications/jitrequests.go new file mode 100644 index 000000000000..501ade8adad6 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-07-01/managedapplications/jitrequests.go @@ -0,0 +1,546 @@ +package managedapplications + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// JitRequestsClient is the ARM applications +type JitRequestsClient struct { + BaseClient +} + +// NewJitRequestsClient creates an instance of the JitRequestsClient client. +func NewJitRequestsClient(subscriptionID string) JitRequestsClient { + return NewJitRequestsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewJitRequestsClientWithBaseURI creates an instance of the JitRequestsClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewJitRequestsClientWithBaseURI(baseURI string, subscriptionID string) JitRequestsClient { + return JitRequestsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the JIT request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// jitRequestName - the name of the JIT request. +// parameters - parameters supplied to the update JIT request. +func (client JitRequestsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, jitRequestName string, parameters JitRequestDefinition) (result JitRequestsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JitRequestsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.JitRequestProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.JitRequestProperties.ApplicationResourceID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.JitRequestProperties.JitAuthorizationPolicies", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.JitRequestProperties.JitSchedulingPolicy", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.JitRequestProperties.JitSchedulingPolicy.Duration", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.JitRequestProperties.JitSchedulingPolicy.StartTime", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}}}}); err != nil { + return result, validation.NewError("managedapplications.JitRequestsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, jitRequestName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client JitRequestsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, jitRequestName string, parameters JitRequestDefinition) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jitRequestName": autorest.Encode("path", jitRequestName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-07-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client JitRequestsClient) CreateOrUpdateSender(req *http.Request) (future JitRequestsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client JitRequestsClient) CreateOrUpdateResponder(resp *http.Response) (result JitRequestDefinition, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the JIT request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// jitRequestName - the name of the JIT request. +func (client JitRequestsClient) Delete(ctx context.Context, resourceGroupName string, jitRequestName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JitRequestsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("managedapplications.JitRequestsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, jitRequestName) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client JitRequestsClient) DeletePreparer(ctx context.Context, resourceGroupName string, jitRequestName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jitRequestName": autorest.Encode("path", jitRequestName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-07-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client JitRequestsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client JitRequestsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the JIT request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// jitRequestName - the name of the JIT request. +func (client JitRequestsClient) Get(ctx context.Context, resourceGroupName string, jitRequestName string) (result JitRequestDefinition, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JitRequestsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("managedapplications.JitRequestsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, jitRequestName) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client JitRequestsClient) GetPreparer(ctx context.Context, resourceGroupName string, jitRequestName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jitRequestName": autorest.Encode("path", jitRequestName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-07-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client JitRequestsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JitRequestsClient) GetResponder(resp *http.Response) (result JitRequestDefinition, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup retrieves all JIT requests within the resource group. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client JitRequestsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result JitRequestDefinitionListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JitRequestsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("managedapplications.JitRequestsClient", "ListByResourceGroup", err.Error()) + } + + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client JitRequestsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-07-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client JitRequestsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client JitRequestsClient) ListByResourceGroupResponder(resp *http.Response) (result JitRequestDefinitionListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySubscription retrieves all JIT requests within the subscription. +func (client JitRequestsClient) ListBySubscription(ctx context.Context) (result JitRequestDefinitionListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JitRequestsClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "ListBySubscription", resp, "Failure responding to request") + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client JitRequestsClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-07-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/jitRequests", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client JitRequestsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client JitRequestsClient) ListBySubscriptionResponder(resp *http.Response) (result JitRequestDefinitionListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates the JIT request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// jitRequestName - the name of the JIT request. +// parameters - parameters supplied to the update JIT request. +func (client JitRequestsClient) Update(ctx context.Context, resourceGroupName string, jitRequestName string, parameters JitRequestPatchable) (result JitRequestDefinition, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JitRequestsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("managedapplications.JitRequestsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, jitRequestName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client JitRequestsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, jitRequestName string, parameters JitRequestPatchable) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jitRequestName": autorest.Encode("path", jitRequestName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-07-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client JitRequestsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client JitRequestsClient) UpdateResponder(resp *http.Response) (result JitRequestDefinition, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-07-01/managedapplications/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-07-01/managedapplications/models.go new file mode 100644 index 000000000000..7be91c69d52a --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-07-01/managedapplications/models.go @@ -0,0 +1,1944 @@ +package managedapplications + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-07-01/managedapplications" + +// ApplicationArtifactName enumerates the values for application artifact name. +type ApplicationArtifactName string + +const ( + // Authorizations ... + Authorizations ApplicationArtifactName = "Authorizations" + // CustomRoleDefinition ... + CustomRoleDefinition ApplicationArtifactName = "CustomRoleDefinition" + // NotSpecified ... + NotSpecified ApplicationArtifactName = "NotSpecified" + // ViewDefinition ... + ViewDefinition ApplicationArtifactName = "ViewDefinition" +) + +// PossibleApplicationArtifactNameValues returns an array of possible values for the ApplicationArtifactName const type. +func PossibleApplicationArtifactNameValues() []ApplicationArtifactName { + return []ApplicationArtifactName{Authorizations, CustomRoleDefinition, NotSpecified, ViewDefinition} +} + +// ApplicationArtifactType enumerates the values for application artifact type. +type ApplicationArtifactType string + +const ( + // ApplicationArtifactTypeCustom ... + ApplicationArtifactTypeCustom ApplicationArtifactType = "Custom" + // ApplicationArtifactTypeNotSpecified ... + ApplicationArtifactTypeNotSpecified ApplicationArtifactType = "NotSpecified" + // ApplicationArtifactTypeTemplate ... + ApplicationArtifactTypeTemplate ApplicationArtifactType = "Template" +) + +// PossibleApplicationArtifactTypeValues returns an array of possible values for the ApplicationArtifactType const type. +func PossibleApplicationArtifactTypeValues() []ApplicationArtifactType { + return []ApplicationArtifactType{ApplicationArtifactTypeCustom, ApplicationArtifactTypeNotSpecified, ApplicationArtifactTypeTemplate} +} + +// ApplicationDefinitionArtifactName enumerates the values for application definition artifact name. +type ApplicationDefinitionArtifactName string + +const ( + // ApplicationDefinitionArtifactNameApplicationResourceTemplate ... + ApplicationDefinitionArtifactNameApplicationResourceTemplate ApplicationDefinitionArtifactName = "ApplicationResourceTemplate" + // ApplicationDefinitionArtifactNameCreateUIDefinition ... + ApplicationDefinitionArtifactNameCreateUIDefinition ApplicationDefinitionArtifactName = "CreateUiDefinition" + // ApplicationDefinitionArtifactNameMainTemplateParameters ... + ApplicationDefinitionArtifactNameMainTemplateParameters ApplicationDefinitionArtifactName = "MainTemplateParameters" + // ApplicationDefinitionArtifactNameNotSpecified ... + ApplicationDefinitionArtifactNameNotSpecified ApplicationDefinitionArtifactName = "NotSpecified" +) + +// PossibleApplicationDefinitionArtifactNameValues returns an array of possible values for the ApplicationDefinitionArtifactName const type. +func PossibleApplicationDefinitionArtifactNameValues() []ApplicationDefinitionArtifactName { + return []ApplicationDefinitionArtifactName{ApplicationDefinitionArtifactNameApplicationResourceTemplate, ApplicationDefinitionArtifactNameCreateUIDefinition, ApplicationDefinitionArtifactNameMainTemplateParameters, ApplicationDefinitionArtifactNameNotSpecified} +} + +// ApplicationLockLevel enumerates the values for application lock level. +type ApplicationLockLevel string + +const ( + // CanNotDelete ... + CanNotDelete ApplicationLockLevel = "CanNotDelete" + // None ... + None ApplicationLockLevel = "None" + // ReadOnly ... + ReadOnly ApplicationLockLevel = "ReadOnly" +) + +// PossibleApplicationLockLevelValues returns an array of possible values for the ApplicationLockLevel const type. +func PossibleApplicationLockLevelValues() []ApplicationLockLevel { + return []ApplicationLockLevel{CanNotDelete, None, ReadOnly} +} + +// ApplicationManagementMode enumerates the values for application management mode. +type ApplicationManagementMode string + +const ( + // ApplicationManagementModeManaged ... + ApplicationManagementModeManaged ApplicationManagementMode = "Managed" + // ApplicationManagementModeNotSpecified ... + ApplicationManagementModeNotSpecified ApplicationManagementMode = "NotSpecified" + // ApplicationManagementModeUnmanaged ... + ApplicationManagementModeUnmanaged ApplicationManagementMode = "Unmanaged" +) + +// PossibleApplicationManagementModeValues returns an array of possible values for the ApplicationManagementMode const type. +func PossibleApplicationManagementModeValues() []ApplicationManagementMode { + return []ApplicationManagementMode{ApplicationManagementModeManaged, ApplicationManagementModeNotSpecified, ApplicationManagementModeUnmanaged} +} + +// DeploymentMode enumerates the values for deployment mode. +type DeploymentMode string + +const ( + // DeploymentModeComplete ... + DeploymentModeComplete DeploymentMode = "Complete" + // DeploymentModeIncremental ... + DeploymentModeIncremental DeploymentMode = "Incremental" + // DeploymentModeNotSpecified ... + DeploymentModeNotSpecified DeploymentMode = "NotSpecified" +) + +// PossibleDeploymentModeValues returns an array of possible values for the DeploymentMode const type. +func PossibleDeploymentModeValues() []DeploymentMode { + return []DeploymentMode{DeploymentModeComplete, DeploymentModeIncremental, DeploymentModeNotSpecified} +} + +// JitApprovalMode enumerates the values for jit approval mode. +type JitApprovalMode string + +const ( + // JitApprovalModeAutoApprove ... + JitApprovalModeAutoApprove JitApprovalMode = "AutoApprove" + // JitApprovalModeManualApprove ... + JitApprovalModeManualApprove JitApprovalMode = "ManualApprove" + // JitApprovalModeNotSpecified ... + JitApprovalModeNotSpecified JitApprovalMode = "NotSpecified" +) + +// PossibleJitApprovalModeValues returns an array of possible values for the JitApprovalMode const type. +func PossibleJitApprovalModeValues() []JitApprovalMode { + return []JitApprovalMode{JitApprovalModeAutoApprove, JitApprovalModeManualApprove, JitApprovalModeNotSpecified} +} + +// JitApproverType enumerates the values for jit approver type. +type JitApproverType string + +const ( + // Group ... + Group JitApproverType = "group" + // User ... + User JitApproverType = "user" +) + +// PossibleJitApproverTypeValues returns an array of possible values for the JitApproverType const type. +func PossibleJitApproverTypeValues() []JitApproverType { + return []JitApproverType{Group, User} +} + +// JitRequestState enumerates the values for jit request state. +type JitRequestState string + +const ( + // JitRequestStateApproved ... + JitRequestStateApproved JitRequestState = "Approved" + // JitRequestStateCanceled ... + JitRequestStateCanceled JitRequestState = "Canceled" + // JitRequestStateDenied ... + JitRequestStateDenied JitRequestState = "Denied" + // JitRequestStateExpired ... + JitRequestStateExpired JitRequestState = "Expired" + // JitRequestStateFailed ... + JitRequestStateFailed JitRequestState = "Failed" + // JitRequestStateNotSpecified ... + JitRequestStateNotSpecified JitRequestState = "NotSpecified" + // JitRequestStatePending ... + JitRequestStatePending JitRequestState = "Pending" + // JitRequestStateTimeout ... + JitRequestStateTimeout JitRequestState = "Timeout" +) + +// PossibleJitRequestStateValues returns an array of possible values for the JitRequestState const type. +func PossibleJitRequestStateValues() []JitRequestState { + return []JitRequestState{JitRequestStateApproved, JitRequestStateCanceled, JitRequestStateDenied, JitRequestStateExpired, JitRequestStateFailed, JitRequestStateNotSpecified, JitRequestStatePending, JitRequestStateTimeout} +} + +// JitSchedulingType enumerates the values for jit scheduling type. +type JitSchedulingType string + +const ( + // JitSchedulingTypeNotSpecified ... + JitSchedulingTypeNotSpecified JitSchedulingType = "NotSpecified" + // JitSchedulingTypeOnce ... + JitSchedulingTypeOnce JitSchedulingType = "Once" + // JitSchedulingTypeRecurring ... + JitSchedulingTypeRecurring JitSchedulingType = "Recurring" +) + +// PossibleJitSchedulingTypeValues returns an array of possible values for the JitSchedulingType const type. +func PossibleJitSchedulingTypeValues() []JitSchedulingType { + return []JitSchedulingType{JitSchedulingTypeNotSpecified, JitSchedulingTypeOnce, JitSchedulingTypeRecurring} +} + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // ProvisioningStateAccepted ... + ProvisioningStateAccepted ProvisioningState = "Accepted" + // ProvisioningStateCanceled ... + ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateCreated ... + ProvisioningStateCreated ProvisioningState = "Created" + // ProvisioningStateCreating ... + ProvisioningStateCreating ProvisioningState = "Creating" + // ProvisioningStateDeleted ... + ProvisioningStateDeleted ProvisioningState = "Deleted" + // ProvisioningStateDeleting ... + ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateFailed ... + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateNotSpecified ... + ProvisioningStateNotSpecified ProvisioningState = "NotSpecified" + // ProvisioningStateReady ... + ProvisioningStateReady ProvisioningState = "Ready" + // ProvisioningStateRunning ... + ProvisioningStateRunning ProvisioningState = "Running" + // ProvisioningStateSucceeded ... + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + // ProvisioningStateUpdating ... + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ProvisioningStateAccepted, ProvisioningStateCanceled, ProvisioningStateCreated, ProvisioningStateCreating, ProvisioningStateDeleted, ProvisioningStateDeleting, ProvisioningStateFailed, ProvisioningStateNotSpecified, ProvisioningStateReady, ProvisioningStateRunning, ProvisioningStateSucceeded, ProvisioningStateUpdating} +} + +// ResourceIdentityType enumerates the values for resource identity type. +type ResourceIdentityType string + +const ( + // SystemAssigned ... + SystemAssigned ResourceIdentityType = "SystemAssigned" +) + +// PossibleResourceIdentityTypeValues returns an array of possible values for the ResourceIdentityType const type. +func PossibleResourceIdentityTypeValues() []ResourceIdentityType { + return []ResourceIdentityType{SystemAssigned} +} + +// Application information about managed application. +type Application struct { + autorest.Response `json:"-"` + // ApplicationProperties - The managed application properties. + *ApplicationProperties `json:"properties,omitempty"` + // Plan - The plan information. + Plan *Plan `json:"plan,omitempty"` + // Kind - The kind of the managed application. Allowed values are MarketPlace and ServiceCatalog. + Kind *string `json:"kind,omitempty"` + // Identity - The identity of the resource. + Identity *Identity `json:"identity,omitempty"` + // ManagedBy - ID of the resource that manages this resource. + ManagedBy *string `json:"managedBy,omitempty"` + // Sku - The SKU of the resource. + Sku *Sku `json:"sku,omitempty"` + // ID - READ-ONLY; Resource ID + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for Application. +func (a Application) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if a.ApplicationProperties != nil { + objectMap["properties"] = a.ApplicationProperties + } + if a.Plan != nil { + objectMap["plan"] = a.Plan + } + if a.Kind != nil { + objectMap["kind"] = a.Kind + } + if a.Identity != nil { + objectMap["identity"] = a.Identity + } + if a.ManagedBy != nil { + objectMap["managedBy"] = a.ManagedBy + } + if a.Sku != nil { + objectMap["sku"] = a.Sku + } + if a.Location != nil { + objectMap["location"] = a.Location + } + if a.Tags != nil { + objectMap["tags"] = a.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Application struct. +func (a *Application) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var applicationProperties ApplicationProperties + err = json.Unmarshal(*v, &applicationProperties) + if err != nil { + return err + } + a.ApplicationProperties = &applicationProperties + } + case "plan": + if v != nil { + var plan Plan + err = json.Unmarshal(*v, &plan) + if err != nil { + return err + } + a.Plan = &plan + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + a.Kind = &kind + } + case "identity": + if v != nil { + var identity Identity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + a.Identity = &identity + } + case "managedBy": + if v != nil { + var managedBy string + err = json.Unmarshal(*v, &managedBy) + if err != nil { + return err + } + a.ManagedBy = &managedBy + } + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + a.Sku = &sku + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + a.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + a.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + a.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + a.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + a.Tags = tags + } + } + } + + return nil +} + +// ApplicationArtifact managed application artifact. +type ApplicationArtifact struct { + // Name - The managed application artifact name. Possible values include: 'NotSpecified', 'ViewDefinition', 'Authorizations', 'CustomRoleDefinition' + Name ApplicationArtifactName `json:"name,omitempty"` + // URI - The managed application artifact blob uri. + URI *string `json:"uri,omitempty"` + // Type - The managed application artifact type. Possible values include: 'ApplicationArtifactTypeNotSpecified', 'ApplicationArtifactTypeTemplate', 'ApplicationArtifactTypeCustom' + Type ApplicationArtifactType `json:"type,omitempty"` +} + +// ApplicationAuthorization the managed application provider authorization. +type ApplicationAuthorization struct { + // PrincipalID - The provider's principal identifier. This is the identity that the provider will use to call ARM to manage the managed application resources. + PrincipalID *string `json:"principalId,omitempty"` + // 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. + RoleDefinitionID *string `json:"roleDefinitionId,omitempty"` +} + +// ApplicationBillingDetailsDefinition managed application billing details definition. +type ApplicationBillingDetailsDefinition struct { + // ResourceUsageID - The managed application resource usage Id. + ResourceUsageID *string `json:"resourceUsageId,omitempty"` +} + +// ApplicationClientDetails the application client details to track the entity creating/updating the +// managed app resource. +type ApplicationClientDetails struct { + // Oid - The client Oid. + Oid *string `json:"oid,omitempty"` + // Puid - The client Puid + Puid *string `json:"puid,omitempty"` + // ApplicationID - The client application Id. + ApplicationID *string `json:"applicationId,omitempty"` +} + +// ApplicationDefinition information about managed application definition. +type ApplicationDefinition struct { + autorest.Response `json:"-"` + // ApplicationDefinitionProperties - The managed application definition properties. + *ApplicationDefinitionProperties `json:"properties,omitempty"` + // ManagedBy - ID of the resource that manages this resource. + ManagedBy *string `json:"managedBy,omitempty"` + // Sku - The SKU of the resource. + Sku *Sku `json:"sku,omitempty"` + // ID - READ-ONLY; Resource ID + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ApplicationDefinition. +func (ad ApplicationDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ad.ApplicationDefinitionProperties != nil { + objectMap["properties"] = ad.ApplicationDefinitionProperties + } + if ad.ManagedBy != nil { + objectMap["managedBy"] = ad.ManagedBy + } + if ad.Sku != nil { + objectMap["sku"] = ad.Sku + } + if ad.Location != nil { + objectMap["location"] = ad.Location + } + if ad.Tags != nil { + objectMap["tags"] = ad.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ApplicationDefinition struct. +func (ad *ApplicationDefinition) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var applicationDefinitionProperties ApplicationDefinitionProperties + err = json.Unmarshal(*v, &applicationDefinitionProperties) + if err != nil { + return err + } + ad.ApplicationDefinitionProperties = &applicationDefinitionProperties + } + case "managedBy": + if v != nil { + var managedBy string + err = json.Unmarshal(*v, &managedBy) + if err != nil { + return err + } + ad.ManagedBy = &managedBy + } + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + ad.Sku = &sku + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ad.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ad.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ad.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ad.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + ad.Tags = tags + } + } + } + + return nil +} + +// ApplicationDefinitionArtifact application definition artifact. +type ApplicationDefinitionArtifact struct { + // Name - The managed application definition artifact name. Possible values include: 'ApplicationDefinitionArtifactNameNotSpecified', 'ApplicationDefinitionArtifactNameApplicationResourceTemplate', 'ApplicationDefinitionArtifactNameCreateUIDefinition', 'ApplicationDefinitionArtifactNameMainTemplateParameters' + Name ApplicationDefinitionArtifactName `json:"name,omitempty"` + // URI - The managed application definition artifact blob uri. + URI *string `json:"uri,omitempty"` + // Type - The managed application definition artifact type. Possible values include: 'ApplicationArtifactTypeNotSpecified', 'ApplicationArtifactTypeTemplate', 'ApplicationArtifactTypeCustom' + Type ApplicationArtifactType `json:"type,omitempty"` +} + +// ApplicationDefinitionListResult list of managed application definitions. +type ApplicationDefinitionListResult struct { + autorest.Response `json:"-"` + // Value - The array of managed application definitions. + Value *[]ApplicationDefinition `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// ApplicationDefinitionListResultIterator provides access to a complete listing of ApplicationDefinition +// values. +type ApplicationDefinitionListResultIterator struct { + i int + page ApplicationDefinitionListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ApplicationDefinitionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationDefinitionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ApplicationDefinitionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ApplicationDefinitionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ApplicationDefinitionListResultIterator) Response() ApplicationDefinitionListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ApplicationDefinitionListResultIterator) Value() ApplicationDefinition { + if !iter.page.NotDone() { + return ApplicationDefinition{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ApplicationDefinitionListResultIterator type. +func NewApplicationDefinitionListResultIterator(page ApplicationDefinitionListResultPage) ApplicationDefinitionListResultIterator { + return ApplicationDefinitionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (adlr ApplicationDefinitionListResult) IsEmpty() bool { + return adlr.Value == nil || len(*adlr.Value) == 0 +} + +// applicationDefinitionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (adlr ApplicationDefinitionListResult) applicationDefinitionListResultPreparer(ctx context.Context) (*http.Request, error) { + if adlr.NextLink == nil || len(to.String(adlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(adlr.NextLink))) +} + +// ApplicationDefinitionListResultPage contains a page of ApplicationDefinition values. +type ApplicationDefinitionListResultPage struct { + fn func(context.Context, ApplicationDefinitionListResult) (ApplicationDefinitionListResult, error) + adlr ApplicationDefinitionListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ApplicationDefinitionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationDefinitionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.adlr) + if err != nil { + return err + } + page.adlr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ApplicationDefinitionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ApplicationDefinitionListResultPage) NotDone() bool { + return !page.adlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ApplicationDefinitionListResultPage) Response() ApplicationDefinitionListResult { + return page.adlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ApplicationDefinitionListResultPage) Values() []ApplicationDefinition { + if page.adlr.IsEmpty() { + return nil + } + return *page.adlr.Value +} + +// Creates a new instance of the ApplicationDefinitionListResultPage type. +func NewApplicationDefinitionListResultPage(getNextPage func(context.Context, ApplicationDefinitionListResult) (ApplicationDefinitionListResult, error)) ApplicationDefinitionListResultPage { + return ApplicationDefinitionListResultPage{fn: getNextPage} +} + +// ApplicationDefinitionProperties the managed application definition properties. +type ApplicationDefinitionProperties struct { + // LockLevel - The managed application lock level. Possible values include: 'CanNotDelete', 'ReadOnly', 'None' + LockLevel ApplicationLockLevel `json:"lockLevel,omitempty"` + // DisplayName - The managed application definition display name. + DisplayName *string `json:"displayName,omitempty"` + // IsEnabled - A value indicating whether the package is enabled or not. + IsEnabled *bool `json:"isEnabled,omitempty"` + // Authorizations - The managed application provider authorizations. + Authorizations *[]ApplicationAuthorization `json:"authorizations,omitempty"` + // 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. + Artifacts *[]ApplicationDefinitionArtifact `json:"artifacts,omitempty"` + // Description - The managed application definition description. + Description *string `json:"description,omitempty"` + // PackageFileURI - The managed application definition package file Uri. Use this element + PackageFileURI *string `json:"packageFileUri,omitempty"` + // MainTemplate - The inline main template json which has resources to be provisioned. It can be a JObject or well-formed JSON string. + MainTemplate interface{} `json:"mainTemplate,omitempty"` + // CreateUIDefinition - The createUiDefinition json for the backing template with Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string. + CreateUIDefinition interface{} `json:"createUiDefinition,omitempty"` + // NotificationPolicy - The managed application notification policy. + NotificationPolicy *ApplicationNotificationPolicy `json:"notificationPolicy,omitempty"` + // LockingPolicy - The managed application locking policy. + LockingPolicy *ApplicationPackageLockingPolicyDefinition `json:"lockingPolicy,omitempty"` + // DeploymentPolicy - The managed application deployment policy. + DeploymentPolicy *ApplicationDeploymentPolicy `json:"deploymentPolicy,omitempty"` + // ManagementPolicy - The managed application management policy that determines publisher's access to the managed resource group. + ManagementPolicy *ApplicationManagementPolicy `json:"managementPolicy,omitempty"` + // Policies - The managed application provider policies. + Policies *[]ApplicationPolicy `json:"policies,omitempty"` +} + +// ApplicationDefinitionsCreateOrUpdateByIDFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type ApplicationDefinitionsCreateOrUpdateByIDFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ApplicationDefinitionsCreateOrUpdateByIDFuture) Result(client ApplicationDefinitionsClient) (ad ApplicationDefinition, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsCreateOrUpdateByIDFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("managedapplications.ApplicationDefinitionsCreateOrUpdateByIDFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ad.Response.Response, err = future.GetResult(sender); err == nil && ad.Response.Response.StatusCode != http.StatusNoContent { + ad, err = client.CreateOrUpdateByIDResponder(ad.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsCreateOrUpdateByIDFuture", "Result", ad.Response.Response, "Failure responding to request") + } + } + return +} + +// ApplicationDefinitionsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ApplicationDefinitionsCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ApplicationDefinitionsCreateOrUpdateFuture) Result(client ApplicationDefinitionsClient) (ad ApplicationDefinition, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("managedapplications.ApplicationDefinitionsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ad.Response.Response, err = future.GetResult(sender); err == nil && ad.Response.Response.StatusCode != http.StatusNoContent { + ad, err = client.CreateOrUpdateResponder(ad.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsCreateOrUpdateFuture", "Result", ad.Response.Response, "Failure responding to request") + } + } + return +} + +// ApplicationDefinitionsDeleteByIDFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ApplicationDefinitionsDeleteByIDFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ApplicationDefinitionsDeleteByIDFuture) Result(client ApplicationDefinitionsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsDeleteByIDFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("managedapplications.ApplicationDefinitionsDeleteByIDFuture") + return + } + ar.Response = future.Response() + return +} + +// ApplicationDefinitionsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ApplicationDefinitionsDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ApplicationDefinitionsDeleteFuture) Result(client ApplicationDefinitionsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationDefinitionsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("managedapplications.ApplicationDefinitionsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ApplicationDeploymentPolicy managed application deployment policy. +type ApplicationDeploymentPolicy struct { + // DeploymentMode - The managed application deployment mode. Possible values include: 'DeploymentModeNotSpecified', 'DeploymentModeIncremental', 'DeploymentModeComplete' + DeploymentMode DeploymentMode `json:"deploymentMode,omitempty"` +} + +// ApplicationJitAccessPolicy managed application Jit access policy. +type ApplicationJitAccessPolicy struct { + // JitAccessEnabled - Whether the JIT access is enabled. + JitAccessEnabled *bool `json:"jitAccessEnabled,omitempty"` + // JitApprovalMode - JIT approval mode. Possible values include: 'JitApprovalModeNotSpecified', 'JitApprovalModeAutoApprove', 'JitApprovalModeManualApprove' + JitApprovalMode JitApprovalMode `json:"jitApprovalMode,omitempty"` + // JitApprovers - The JIT approvers + JitApprovers *[]JitApproverDefinition `json:"jitApprovers,omitempty"` + // MaximumJitAccessDuration - The maximum duration JIT access is granted. This is an ISO8601 time period value. + MaximumJitAccessDuration *string `json:"maximumJitAccessDuration,omitempty"` +} + +// ApplicationListResult list of managed applications. +type ApplicationListResult struct { + autorest.Response `json:"-"` + // Value - The array of managed applications. + Value *[]Application `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// ApplicationListResultIterator provides access to a complete listing of Application values. +type ApplicationListResultIterator struct { + i int + page ApplicationListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ApplicationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ApplicationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ApplicationListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ApplicationListResultIterator) Response() ApplicationListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ApplicationListResultIterator) Value() Application { + if !iter.page.NotDone() { + return Application{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ApplicationListResultIterator type. +func NewApplicationListResultIterator(page ApplicationListResultPage) ApplicationListResultIterator { + return ApplicationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (alr ApplicationListResult) IsEmpty() bool { + return alr.Value == nil || len(*alr.Value) == 0 +} + +// applicationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (alr ApplicationListResult) applicationListResultPreparer(ctx context.Context) (*http.Request, error) { + if alr.NextLink == nil || len(to.String(alr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(alr.NextLink))) +} + +// ApplicationListResultPage contains a page of Application values. +type ApplicationListResultPage struct { + fn func(context.Context, ApplicationListResult) (ApplicationListResult, error) + alr ApplicationListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ApplicationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.alr) + if err != nil { + return err + } + page.alr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ApplicationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ApplicationListResultPage) NotDone() bool { + return !page.alr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ApplicationListResultPage) Response() ApplicationListResult { + return page.alr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ApplicationListResultPage) Values() []Application { + if page.alr.IsEmpty() { + return nil + } + return *page.alr.Value +} + +// Creates a new instance of the ApplicationListResultPage type. +func NewApplicationListResultPage(getNextPage func(context.Context, ApplicationListResult) (ApplicationListResult, error)) ApplicationListResultPage { + return ApplicationListResultPage{fn: getNextPage} +} + +// ApplicationManagementPolicy managed application management policy. +type ApplicationManagementPolicy struct { + // Mode - The managed application management mode. Possible values include: 'ApplicationManagementModeNotSpecified', 'ApplicationManagementModeUnmanaged', 'ApplicationManagementModeManaged' + Mode ApplicationManagementMode `json:"mode,omitempty"` +} + +// ApplicationNotificationEndpoint managed application notification endpoint. +type ApplicationNotificationEndpoint struct { + // URI - The managed application notification endpoint uri. + URI *string `json:"uri,omitempty"` +} + +// ApplicationNotificationPolicy managed application notification policy. +type ApplicationNotificationPolicy struct { + // NotificationEndpoints - The managed application notification endpoint. + NotificationEndpoints *[]ApplicationNotificationEndpoint `json:"notificationEndpoints,omitempty"` +} + +// ApplicationPackageContact the application package contact information. +type ApplicationPackageContact struct { + // ContactName - The contact name. + ContactName *string `json:"contactName,omitempty"` + // Email - The contact email. + Email *string `json:"email,omitempty"` + // Phone - The contact phone number. + Phone *string `json:"phone,omitempty"` +} + +// ApplicationPackageLockingPolicyDefinition managed application locking policy. +type ApplicationPackageLockingPolicyDefinition struct { + // AllowedActions - The deny assignment excluded actions. + AllowedActions *[]string `json:"allowedActions,omitempty"` +} + +// ApplicationPackageSupportUrls the appliance package support URLs. +type ApplicationPackageSupportUrls struct { + // PublicAzure - The public azure support URL. + PublicAzure *string `json:"publicAzure,omitempty"` + // GovernmentCloud - The government cloud support URL. + GovernmentCloud *string `json:"governmentCloud,omitempty"` +} + +// ApplicationPatchable information about managed application. +type ApplicationPatchable struct { + // ApplicationPropertiesPatchable - The managed application properties. + *ApplicationPropertiesPatchable `json:"properties,omitempty"` + // Plan - The plan information. + Plan *PlanPatchable `json:"plan,omitempty"` + // Kind - The kind of the managed application. Allowed values are MarketPlace and ServiceCatalog. + Kind *string `json:"kind,omitempty"` + // Identity - The identity of the resource. + Identity *Identity `json:"identity,omitempty"` + // ManagedBy - ID of the resource that manages this resource. + ManagedBy *string `json:"managedBy,omitempty"` + // Sku - The SKU of the resource. + Sku *Sku `json:"sku,omitempty"` + // ID - READ-ONLY; Resource ID + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ApplicationPatchable. +func (ap ApplicationPatchable) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ap.ApplicationPropertiesPatchable != nil { + objectMap["properties"] = ap.ApplicationPropertiesPatchable + } + if ap.Plan != nil { + objectMap["plan"] = ap.Plan + } + if ap.Kind != nil { + objectMap["kind"] = ap.Kind + } + if ap.Identity != nil { + objectMap["identity"] = ap.Identity + } + if ap.ManagedBy != nil { + objectMap["managedBy"] = ap.ManagedBy + } + if ap.Sku != nil { + objectMap["sku"] = ap.Sku + } + if ap.Location != nil { + objectMap["location"] = ap.Location + } + if ap.Tags != nil { + objectMap["tags"] = ap.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ApplicationPatchable struct. +func (ap *ApplicationPatchable) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var applicationPropertiesPatchable ApplicationPropertiesPatchable + err = json.Unmarshal(*v, &applicationPropertiesPatchable) + if err != nil { + return err + } + ap.ApplicationPropertiesPatchable = &applicationPropertiesPatchable + } + case "plan": + if v != nil { + var plan PlanPatchable + err = json.Unmarshal(*v, &plan) + if err != nil { + return err + } + ap.Plan = &plan + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + ap.Kind = &kind + } + case "identity": + if v != nil { + var identity Identity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + ap.Identity = &identity + } + case "managedBy": + if v != nil { + var managedBy string + err = json.Unmarshal(*v, &managedBy) + if err != nil { + return err + } + ap.ManagedBy = &managedBy + } + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + ap.Sku = &sku + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ap.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ap.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ap.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ap.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + ap.Tags = tags + } + } + } + + return nil +} + +// ApplicationPolicy managed application policy. +type ApplicationPolicy struct { + // Name - The policy name + Name *string `json:"name,omitempty"` + // PolicyDefinitionID - The policy definition Id. + PolicyDefinitionID *string `json:"policyDefinitionId,omitempty"` + // Parameters - The policy parameters. + Parameters *string `json:"parameters,omitempty"` +} + +// ApplicationProperties the managed application properties. +type ApplicationProperties struct { + // ManagedResourceGroupID - The managed resource group Id. + ManagedResourceGroupID *string `json:"managedResourceGroupId,omitempty"` + // ApplicationDefinitionID - The fully qualified path of managed application definition Id. + ApplicationDefinitionID *string `json:"applicationDefinitionId,omitempty"` + // Parameters - Name and value pairs that define the managed application parameters. It can be a JObject or a well formed JSON string. + Parameters interface{} `json:"parameters,omitempty"` + // Outputs - READ-ONLY; Name and value pairs that define the managed application outputs. + Outputs interface{} `json:"outputs,omitempty"` + // ProvisioningState - READ-ONLY; The managed application provisioning state. Possible values include: 'ProvisioningStateNotSpecified', 'ProvisioningStateAccepted', 'ProvisioningStateRunning', 'ProvisioningStateReady', 'ProvisioningStateCreating', 'ProvisioningStateCreated', 'ProvisioningStateDeleting', 'ProvisioningStateDeleted', 'ProvisioningStateCanceled', 'ProvisioningStateFailed', 'ProvisioningStateSucceeded', 'ProvisioningStateUpdating' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // BillingDetails - READ-ONLY; The managed application billing details. + BillingDetails *ApplicationBillingDetailsDefinition `json:"billingDetails,omitempty"` + // JitAccessPolicy - The managed application Jit access policy. + JitAccessPolicy *ApplicationJitAccessPolicy `json:"jitAccessPolicy,omitempty"` + // PublisherTenantID - READ-ONLY; The publisher tenant Id. + PublisherTenantID *string `json:"publisherTenantId,omitempty"` + // Authorizations - READ-ONLY; The read-only authorizations property that is retrieved from the application package. + Authorizations *[]ApplicationAuthorization `json:"authorizations,omitempty"` + // ManagementMode - READ-ONLY; The managed application management mode. Possible values include: 'ApplicationManagementModeNotSpecified', 'ApplicationManagementModeUnmanaged', 'ApplicationManagementModeManaged' + ManagementMode ApplicationManagementMode `json:"managementMode,omitempty"` + // CustomerSupport - READ-ONLY; The read-only customer support property that is retrieved from the application package. + CustomerSupport *ApplicationPackageContact `json:"customerSupport,omitempty"` + // SupportUrls - READ-ONLY; The read-only support URLs property that is retrieved from the application package. + SupportUrls *ApplicationPackageSupportUrls `json:"supportUrls,omitempty"` + // Artifacts - READ-ONLY; The collection of managed application artifacts. + Artifacts *[]ApplicationArtifact `json:"artifacts,omitempty"` + // CreatedBy - READ-ONLY; The client entity that created the JIT request. + CreatedBy *ApplicationClientDetails `json:"createdBy,omitempty"` + // UpdatedBy - READ-ONLY; The client entity that last updated the JIT request. + UpdatedBy *ApplicationClientDetails `json:"updatedBy,omitempty"` +} + +// ApplicationPropertiesPatchable the managed application properties. +type ApplicationPropertiesPatchable struct { + // ManagedResourceGroupID - The managed resource group Id. + ManagedResourceGroupID *string `json:"managedResourceGroupId,omitempty"` + // ApplicationDefinitionID - The fully qualified path of managed application definition Id. + ApplicationDefinitionID *string `json:"applicationDefinitionId,omitempty"` + // Parameters - Name and value pairs that define the managed application parameters. It can be a JObject or a well formed JSON string. + Parameters interface{} `json:"parameters,omitempty"` + // Outputs - READ-ONLY; Name and value pairs that define the managed application outputs. + Outputs interface{} `json:"outputs,omitempty"` + // ProvisioningState - READ-ONLY; The managed application provisioning state. Possible values include: 'ProvisioningStateNotSpecified', 'ProvisioningStateAccepted', 'ProvisioningStateRunning', 'ProvisioningStateReady', 'ProvisioningStateCreating', 'ProvisioningStateCreated', 'ProvisioningStateDeleting', 'ProvisioningStateDeleted', 'ProvisioningStateCanceled', 'ProvisioningStateFailed', 'ProvisioningStateSucceeded', 'ProvisioningStateUpdating' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` +} + +// ApplicationsCreateOrUpdateByIDFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ApplicationsCreateOrUpdateByIDFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ApplicationsCreateOrUpdateByIDFuture) Result(client ApplicationsClient) (a Application, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsCreateOrUpdateByIDFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("managedapplications.ApplicationsCreateOrUpdateByIDFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if a.Response.Response, err = future.GetResult(sender); err == nil && a.Response.Response.StatusCode != http.StatusNoContent { + a, err = client.CreateOrUpdateByIDResponder(a.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsCreateOrUpdateByIDFuture", "Result", a.Response.Response, "Failure responding to request") + } + } + return +} + +// ApplicationsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ApplicationsCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ApplicationsCreateOrUpdateFuture) Result(client ApplicationsClient) (a Application, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("managedapplications.ApplicationsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if a.Response.Response, err = future.GetResult(sender); err == nil && a.Response.Response.StatusCode != http.StatusNoContent { + a, err = client.CreateOrUpdateResponder(a.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsCreateOrUpdateFuture", "Result", a.Response.Response, "Failure responding to request") + } + } + return +} + +// ApplicationsDeleteByIDFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ApplicationsDeleteByIDFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ApplicationsDeleteByIDFuture) Result(client ApplicationsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsDeleteByIDFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("managedapplications.ApplicationsDeleteByIDFuture") + return + } + ar.Response = future.Response() + return +} + +// ApplicationsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ApplicationsDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ApplicationsDeleteFuture) Result(client ApplicationsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("managedapplications.ApplicationsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ApplicationsRefreshPermissionsFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ApplicationsRefreshPermissionsFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ApplicationsRefreshPermissionsFuture) Result(client ApplicationsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplicationsRefreshPermissionsFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("managedapplications.ApplicationsRefreshPermissionsFuture") + return + } + ar.Response = future.Response() + return +} + +// ErrorResponse error response indicates managed application is not able to process the incoming request. +// The reason is provided in the error message. +type ErrorResponse struct { + // HTTPStatus - Http status code. + HTTPStatus *string `json:"httpStatus,omitempty"` + // ErrorCode - Error code. + ErrorCode *string `json:"errorCode,omitempty"` + // ErrorMessage - Error message indicating why the operation failed. + ErrorMessage *string `json:"errorMessage,omitempty"` +} + +// GenericResource resource information. +type GenericResource struct { + // ManagedBy - ID of the resource that manages this resource. + ManagedBy *string `json:"managedBy,omitempty"` + // Sku - The SKU of the resource. + Sku *Sku `json:"sku,omitempty"` + // ID - READ-ONLY; Resource ID + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for GenericResource. +func (gr GenericResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gr.ManagedBy != nil { + objectMap["managedBy"] = gr.ManagedBy + } + if gr.Sku != nil { + objectMap["sku"] = gr.Sku + } + if gr.Location != nil { + objectMap["location"] = gr.Location + } + if gr.Tags != nil { + objectMap["tags"] = gr.Tags + } + return json.Marshal(objectMap) +} + +// Identity identity for the resource. +type Identity struct { + // PrincipalID - READ-ONLY; The principal ID of resource identity. + PrincipalID *string `json:"principalId,omitempty"` + // TenantID - READ-ONLY; The tenant ID of resource. + TenantID *string `json:"tenantId,omitempty"` + // Type - The identity type. Possible values include: 'SystemAssigned' + Type ResourceIdentityType `json:"type,omitempty"` +} + +// JitApproverDefinition JIT approver definition. +type JitApproverDefinition struct { + // ID - The approver service principal Id. + ID *string `json:"id,omitempty"` + // Type - The approver type. Possible values include: 'User', 'Group' + Type JitApproverType `json:"type,omitempty"` + // DisplayName - The approver display name. + DisplayName *string `json:"displayName,omitempty"` +} + +// JitAuthorizationPolicies the JIT authorization policies. +type JitAuthorizationPolicies struct { + // PrincipalID - The the principal id that will be granted JIT access. + PrincipalID *string `json:"principalId,omitempty"` + // RoleDefinitionID - The role definition id that will be granted to the Principal. + RoleDefinitionID *string `json:"roleDefinitionId,omitempty"` +} + +// JitRequestDefinition information about JIT request definition. +type JitRequestDefinition struct { + autorest.Response `json:"-"` + // JitRequestProperties - The JIT request properties. + *JitRequestProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for JitRequestDefinition. +func (jrd JitRequestDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jrd.JitRequestProperties != nil { + objectMap["properties"] = jrd.JitRequestProperties + } + if jrd.Location != nil { + objectMap["location"] = jrd.Location + } + if jrd.Tags != nil { + objectMap["tags"] = jrd.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for JitRequestDefinition struct. +func (jrd *JitRequestDefinition) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var jitRequestProperties JitRequestProperties + err = json.Unmarshal(*v, &jitRequestProperties) + if err != nil { + return err + } + jrd.JitRequestProperties = &jitRequestProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + jrd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + jrd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + jrd.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + jrd.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + jrd.Tags = tags + } + } + } + + return nil +} + +// JitRequestDefinitionListResult list of JIT requests. +type JitRequestDefinitionListResult struct { + autorest.Response `json:"-"` + // Value - The array of Jit request definition. + Value *[]JitRequestDefinition `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// JitRequestPatchable information about JIT request. +type JitRequestPatchable struct { + // Tags - Jit request tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for JitRequestPatchable. +func (jrp JitRequestPatchable) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jrp.Tags != nil { + objectMap["tags"] = jrp.Tags + } + return json.Marshal(objectMap) +} + +// JitRequestProperties information about JIT request properties +type JitRequestProperties struct { + // ApplicationResourceID - The parent application id. + ApplicationResourceID *string `json:"applicationResourceId,omitempty"` + // PublisherTenantID - READ-ONLY; The publisher tenant id. + PublisherTenantID *string `json:"publisherTenantId,omitempty"` + // JitAuthorizationPolicies - The JIT authorization policies. + JitAuthorizationPolicies *[]JitAuthorizationPolicies `json:"jitAuthorizationPolicies,omitempty"` + // JitSchedulingPolicy - The JIT request properties. + JitSchedulingPolicy *JitSchedulingPolicy `json:"jitSchedulingPolicy,omitempty"` + // ProvisioningState - READ-ONLY; The JIT request provisioning state. Possible values include: 'ProvisioningStateNotSpecified', 'ProvisioningStateAccepted', 'ProvisioningStateRunning', 'ProvisioningStateReady', 'ProvisioningStateCreating', 'ProvisioningStateCreated', 'ProvisioningStateDeleting', 'ProvisioningStateDeleted', 'ProvisioningStateCanceled', 'ProvisioningStateFailed', 'ProvisioningStateSucceeded', 'ProvisioningStateUpdating' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // JitRequestState - READ-ONLY; The JIT request state. Possible values include: 'JitRequestStateNotSpecified', 'JitRequestStatePending', 'JitRequestStateApproved', 'JitRequestStateDenied', 'JitRequestStateFailed', 'JitRequestStateCanceled', 'JitRequestStateExpired', 'JitRequestStateTimeout' + JitRequestState JitRequestState `json:"jitRequestState,omitempty"` + // CreatedBy - READ-ONLY; The client entity that created the JIT request. + CreatedBy *ApplicationClientDetails `json:"createdBy,omitempty"` + // UpdatedBy - READ-ONLY; The client entity that last updated the JIT request. + UpdatedBy *ApplicationClientDetails `json:"updatedBy,omitempty"` +} + +// JitRequestsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type JitRequestsCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *JitRequestsCreateOrUpdateFuture) Result(client JitRequestsClient) (jrd JitRequestDefinition, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("managedapplications.JitRequestsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if jrd.Response.Response, err = future.GetResult(sender); err == nil && jrd.Response.Response.StatusCode != http.StatusNoContent { + jrd, err = client.CreateOrUpdateResponder(jrd.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.JitRequestsCreateOrUpdateFuture", "Result", jrd.Response.Response, "Failure responding to request") + } + } + return +} + +// JitSchedulingPolicy the JIT scheduling policies. +type JitSchedulingPolicy struct { + // Type - The type of JIT schedule. Possible values include: 'JitSchedulingTypeNotSpecified', 'JitSchedulingTypeOnce', 'JitSchedulingTypeRecurring' + Type JitSchedulingType `json:"type,omitempty"` + Duration *string `json:"duration,omitempty"` + // StartTime - The start time of the request. + StartTime *date.Time `json:"startTime,omitempty"` +} + +// Operation microsoft.Solutions operation +type Operation struct { + // Name - Operation name: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` + // Display - The object that represents the operation. + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay the object that represents the operation. +type OperationDisplay struct { + // Provider - Service provider: Microsoft.Solutions + Provider *string `json:"provider,omitempty"` + // Resource - Resource on which the operation is performed: Application, JitRequest, etc. + Resource *string `json:"resource,omitempty"` + // Operation - Operation type: Read, write, delete, etc. + Operation *string `json:"operation,omitempty"` +} + +// OperationListResult result of the request to list Microsoft.Solutions operations. It contains a list of +// operations and a URL link to get the next set of results. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - List of Microsoft.Solutions operations. + Value *[]Operation `json:"value,omitempty"` + // NextLink - URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListResultIterator provides access to a complete listing of Operation values. +type OperationListResultIterator struct { + i int + page OperationListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OperationListResultIterator) Response() OperationListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OperationListResultIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListResultIterator type. +func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { + return OperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OperationListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// operationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { + if olr.NextLink == nil || len(to.String(olr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of Operation values. +type OperationListResultPage struct { + fn func(context.Context, OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListResultPage) NotDone() bool { + return !page.olr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListResultPage) Response() OperationListResult { + return page.olr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListResultPage) Values() []Operation { + if page.olr.IsEmpty() { + return nil + } + return *page.olr.Value +} + +// Creates a new instance of the OperationListResultPage type. +func NewOperationListResultPage(getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{fn: getNextPage} +} + +// Plan plan for the managed application. +type Plan struct { + // Name - The plan name. + Name *string `json:"name,omitempty"` + // Publisher - The publisher ID. + Publisher *string `json:"publisher,omitempty"` + // Product - The product code. + Product *string `json:"product,omitempty"` + // PromotionCode - The promotion code. + PromotionCode *string `json:"promotionCode,omitempty"` + // Version - The plan's version. + Version *string `json:"version,omitempty"` +} + +// PlanPatchable plan for the managed application. +type PlanPatchable struct { + // Name - The plan name. + Name *string `json:"name,omitempty"` + // Publisher - The publisher ID. + Publisher *string `json:"publisher,omitempty"` + // Product - The product code. + Product *string `json:"product,omitempty"` + // PromotionCode - The promotion code. + PromotionCode *string `json:"promotionCode,omitempty"` + // Version - The plan's version. + Version *string `json:"version,omitempty"` +} + +// Resource resource information. +type Resource struct { + // ID - READ-ONLY; Resource ID + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if r.Location != nil { + objectMap["location"] = r.Location + } + if r.Tags != nil { + objectMap["tags"] = r.Tags + } + return json.Marshal(objectMap) +} + +// Sku SKU for the resource. +type Sku struct { + // Name - The SKU name. + Name *string `json:"name,omitempty"` + // Tier - The SKU tier. + Tier *string `json:"tier,omitempty"` + // Size - The SKU size. + Size *string `json:"size,omitempty"` + // Family - The SKU family. + Family *string `json:"family,omitempty"` + // Model - The SKU model. + Model *string `json:"model,omitempty"` + // Capacity - The SKU capacity. + Capacity *int32 `json:"capacity,omitempty"` +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-07-01/managedapplications/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-07-01/managedapplications/version.go new file mode 100644 index 000000000000..82a5e4deb451 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-07-01/managedapplications/version.go @@ -0,0 +1,30 @@ +package managedapplications + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + version.Number + " managedapplications/2019-07-01" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/vendor/modules.txt b/vendor/modules.txt index a7eccb4bf87c..1d635a60997c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -78,6 +78,7 @@ github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/policy github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-06-01/subscriptions +github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-07-01/managedapplications github.com/Azure/azure-sdk-for-go/services/search/mgmt/2015-08-19/search github.com/Azure/azure-sdk-for-go/services/servicebus/mgmt/2017-04-01/servicebus github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric diff --git a/website/allowed-subcategories b/website/allowed-subcategories index 418442e424b7..93f29022e9d2 100644 --- a/website/allowed-subcategories +++ b/website/allowed-subcategories @@ -31,6 +31,7 @@ Key Vault Load Balancer Log Analytics Logic App +ManagedApplication Management Maps Media diff --git a/website/azurerm.erb b/website/azurerm.erb index f27f0b204dd8..b9ebcb5a8fd7 100644 --- a/website/azurerm.erb +++ b/website/azurerm.erb @@ -302,6 +302,10 @@ azurerm_logic_app_workflow +
  • + azurerm_managed_application_definition +
  • +
  • azurerm_managed_disk
  • @@ -973,6 +977,10 @@ azurerm_linux_virtual_machine_scale_set +
  • + azurerm_managed_application_definition +
  • +
  • azurerm_managed_disk
  • diff --git a/website/docs/d/managed_application_definition.html.markdown b/website/docs/d/managed_application_definition.html.markdown new file mode 100644 index 000000000000..872f607428c7 --- /dev/null +++ b/website/docs/d/managed_application_definition.html.markdown @@ -0,0 +1,76 @@ +--- +subcategory: "ManagedApplication" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_managed_application_definition" +description: |- + Gets information about an existing Managed Application Definition +--- + +# Data Source: azurerm_managed_application_definition + +Uses this data source to access information about an existing Managed Application Definition. + +## Example Usage + +```hcl +provider "azurerm" { + features {} +} + +data "azurerm_managed_application_definition" "example" { + name = "example-managedappdef" + resource_group_name = "example-resources" +} + +output "id" { + value = data.azurerm_managed_application_definition.existing.id +} +``` + +## Argument Reference + +The following arguments are supported: + +* `name` - (Required) Specifies the name of the Managed Application Definition. + +* `resource_group_name` - (Required) Specifies the name of the Resource Group where this Managed Application Definition exists. + +## Attributes Reference + +The following attributes are exported: + +* `location` - The Azure location where the resource exists. + +* `authorization` - One or more `authorization` block defined below. + +* `create_ui_definition` - The createUiDefinition json for the backing template with Microsoft.Solutions/applications resource. + +* `description` - The managed application definition description. + +* `display_name` - The managed application definition display name. + +* `package_enabled` - Is enabled on this package? + +* `lock_level` - The managed application lock level. + +* `main_template` - The inline main template json which has resources to be provisioned. + +* `package_file_uri` - The managed application definition package file Uri. + +* `tags` - A mapping of tags to assign to the resource. + +--- + +An `authorization` block supports the following: + +* `role_definition_id` - The provider's role definition identifier. + +* `service_principal_id` - The provider's principal identifier. + +--- + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: + +* `read` - (Defaults to 5 minutes) Used when retrieving the DataBox. diff --git a/website/docs/r/managed_application_definition.html.markdown b/website/docs/r/managed_application_definition.html.markdown new file mode 100644 index 000000000000..047e187bc820 --- /dev/null +++ b/website/docs/r/managed_application_definition.html.markdown @@ -0,0 +1,102 @@ +--- +subcategory: "ManagedApplication" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_managed_application_definition" +description: |- + Manages a Managed Application Definition. +--- + +# azurerm_managed_application_definition + +Manages a Managed Application Definition. + +## Example Usage + +```hcl +provider "azurerm" { + features {} +} + +data "azurerm_client_config" "current" {} + +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "West Europe" +} + +resource "azurerm_managed_application_definition" "example" { + name = "example-managedapplicationdefinition" + location = azurerm_resource_group.example.location + resource_group_name = azurerm_resource_group.example.name + lock_level = "ReadOnly" + package_file_uri = "https://github.com/Azure/azure-managedapp-samples/raw/master/Managed Application Sample Packages/201-managed-storage-account/managedstorage.zip" + display_name = "TestManagedApplicationDefinition" + description = "Test Managed Application Definition" + + authorization { + service_principal_id = data.azurerm_client_config.current.object_id + role_definition_id = "a094b430-dad3-424d-ae58-13f72fd72591" + } +} +``` + +## Argument Reference + +The following arguments are supported: + +* `name` - (Required) Specifies the name of the Managed Application Definition. Changing this forces a new resource to be created. + +* `resource_group_name` - (Required) The name of the Resource Group where the Managed Application Definition should exist. Changing this forces a new resource to be created. + +* `location` - (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created. + +* `authorization` - (Required) One or more `authorization` block defined below. + +* `lock_level` - (Required) Specifies the managed application lock level. Valid values include `CanNotDelete`, `None`, `ReadOnly`. Changing this forces a new resource to be created. + +* `create_ui_definition` - (Optional) Specifies the createUiDefinition json for the backing template with Microsoft.Solutions/applications resource. + +* `display_name` - (Optional) Specifies the managed application definition display name. + +* `description` - (Optional) Specifies the managed application definition description. + +* `package_enabled` - (Optional) Is enabled for this package? Defaults to `true`. + +* `main_template` - (Optional) Specifies the inline main template json which has resources to be provisioned. + +* `package_file_uri` - (Optional) Specifies the managed application definition package file Uri. + +* `tags` - (Optional) A mapping of tags to assign to the resource. + +--- + +An `authorization` block supports the following: + +* `role_definition_id` - (Required) Specifies 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. + +* `service_principal_id` - (Required) Specifies the provider's principal identifier. This is the identity that the provider will use to call ARM to manage the managed application resources. + +--- + +## Attributes Reference + +The following attributes are exported: + +* `id` - The ID of the Managed Application Definition. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: + +* `create` - (Defaults to 30 minutes) Used when creating the Managed Application Definition. +* `update` - (Defaults to 30 minutes) Used when updating the Managed Application Definition. +* `read` - (Defaults to 5 minutes) Used when retrieving the Managed Application Definition. +* `delete` - (Defaults to 30 minutes) Used when deleting the Managed Application Definition. + +## Import + +Managed Application Definition can be imported using the `resource id`, e.g. + +```shell +$ terraform import azurerm_managed_application_definition.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Solutions/applicationDefinitions/appDefinition1 +```