// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.managedapplications.generated;

import com.azure.resourcemanager.managedapplications.fluent.models.ApplicationDefinitionInner;
import com.azure.resourcemanager.managedapplications.models.ApplicationLockLevel;
import com.azure.resourcemanager.managedapplications.models.ApplicationProviderAuthorization;
import java.util.Arrays;

/** Samples for ApplicationDefinitions CreateOrUpdateById. */
public final class ApplicationDefinitionsCreateOrUpdateByIdSamples {
    /*
     * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/createOrUpdateApplicationDefinition.json
     */
    /**
     * Sample code: Create or update managed application definition.
     *
     * @param manager Entry point to ApplicationManager.
     */
    public static void createOrUpdateManagedApplicationDefinition(
        com.azure.resourcemanager.managedapplications.ApplicationManager manager) {
        manager
            .applicationDefinitions()
            .createOrUpdateById(
                "rg",
                "myManagedApplicationDef",
                new ApplicationDefinitionInner()
                    .withLocation("East US 2")
                    .withLockLevel(ApplicationLockLevel.NONE)
                    .withDisplayName("myManagedApplicationDef")
                    .withAuthorizations(
                        Arrays
                            .asList(
                                new ApplicationProviderAuthorization()
                                    .withPrincipalId("validprincipalguid")
                                    .withRoleDefinitionId("validroleguid")))
                    .withDescription("myManagedApplicationDef description")
                    .withPackageFileUri("https://path/to/packagezipfile"),
                com.azure.core.util.Context.NONE);
    }
}
