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

package com.azure.resourcemanager.appcontainers.generated;

import com.azure.resourcemanager.appcontainers.models.AppLogsConfiguration;
import com.azure.resourcemanager.appcontainers.models.CustomDomainConfiguration;
import com.azure.resourcemanager.appcontainers.models.LogAnalyticsConfiguration;
import com.azure.resourcemanager.appcontainers.models.VnetConfiguration;
import com.azure.resourcemanager.appcontainers.models.WorkloadProfile;
import java.util.Arrays;

/** Samples for ManagedEnvironments CreateOrUpdate. */
public final class ManagedEnvironmentsCreateOrUpdateSamples {
    /*
     * x-ms-original-file: specification/app/resource-manager/Microsoft.App/preview/2022-11-01-preview/examples/ManagedEnvironments_CustomInfrastructureResourceGroup_Create.json
     */
    /**
     * Sample code: Create environment with custom infrastructureResourceGroup.
     *
     * @param manager Entry point to ContainerAppsApiManager.
     */
    public static void createEnvironmentWithCustomInfrastructureResourceGroup(
        com.azure.resourcemanager.appcontainers.ContainerAppsApiManager manager) {
        manager
            .managedEnvironments()
            .define("testcontainerenv")
            .withRegion("East US")
            .withExistingResourceGroup("examplerg")
            .withDaprAIConnectionString(
                "InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://northcentralus-0.in.applicationinsights.azure.com/")
            .withVnetConfiguration(
                new VnetConfiguration()
                    .withInfrastructureSubnetId(
                        "/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/RGName/providers/Microsoft.Network/virtualNetworks/VNetName/subnets/subnetName1"))
            .withAppLogsConfiguration(
                new AppLogsConfiguration()
                    .withLogAnalyticsConfiguration(
                        new LogAnalyticsConfiguration().withCustomerId("string").withSharedKey("fakeTokenPlaceholder")))
            .withZoneRedundant(true)
            .withCustomDomainConfiguration(
                new CustomDomainConfiguration()
                    .withDnsSuffix("www.my-name.com")
                    .withCertificateValue("Y2VydA==".getBytes())
                    .withCertificatePassword("fakeTokenPlaceholder"))
            .withWorkloadProfiles(
                Arrays
                    .asList(
                        new WorkloadProfile()
                            .withName("My-GP-01")
                            .withWorkloadProfileType("GeneralPurpose")
                            .withMinimumCount(3)
                            .withMaximumCount(12),
                        new WorkloadProfile()
                            .withName("My-MO-01")
                            .withWorkloadProfileType("MemoryOptimized")
                            .withMinimumCount(3)
                            .withMaximumCount(6),
                        new WorkloadProfile()
                            .withName("My-CO-01")
                            .withWorkloadProfileType("ComputeOptimized")
                            .withMinimumCount(3)
                            .withMaximumCount(6),
                        new WorkloadProfile().withName("My-consumption-01").withWorkloadProfileType("Consumption")))
            .withInfrastructureResourceGroup("myInfrastructureRgName")
            .create();
    }

    /*
     * x-ms-original-file: specification/app/resource-manager/Microsoft.App/preview/2022-11-01-preview/examples/ManagedEnvironments_CreateOrUpdate.json
     */
    /**
     * Sample code: Create environments.
     *
     * @param manager Entry point to ContainerAppsApiManager.
     */
    public static void createEnvironments(com.azure.resourcemanager.appcontainers.ContainerAppsApiManager manager) {
        manager
            .managedEnvironments()
            .define("testcontainerenv")
            .withRegion("East US")
            .withExistingResourceGroup("examplerg")
            .withDaprAIConnectionString(
                "InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://northcentralus-0.in.applicationinsights.azure.com/")
            .withVnetConfiguration(
                new VnetConfiguration()
                    .withInfrastructureSubnetId(
                        "/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/RGName/providers/Microsoft.Network/virtualNetworks/VNetName/subnets/subnetName1"))
            .withAppLogsConfiguration(
                new AppLogsConfiguration()
                    .withLogAnalyticsConfiguration(
                        new LogAnalyticsConfiguration().withCustomerId("string").withSharedKey("fakeTokenPlaceholder")))
            .withZoneRedundant(true)
            .withCustomDomainConfiguration(
                new CustomDomainConfiguration()
                    .withDnsSuffix("www.my-name.com")
                    .withCertificateValue("Y2VydA==".getBytes())
                    .withCertificatePassword("fakeTokenPlaceholder"))
            .withWorkloadProfiles(
                Arrays
                    .asList(
                        new WorkloadProfile()
                            .withName("My-GP-01")
                            .withWorkloadProfileType("GeneralPurpose")
                            .withMinimumCount(3)
                            .withMaximumCount(12),
                        new WorkloadProfile()
                            .withName("My-MO-01")
                            .withWorkloadProfileType("MemoryOptimized")
                            .withMinimumCount(3)
                            .withMaximumCount(6),
                        new WorkloadProfile()
                            .withName("My-CO-01")
                            .withWorkloadProfileType("ComputeOptimized")
                            .withMinimumCount(3)
                            .withMaximumCount(6),
                        new WorkloadProfile().withName("My-consumption-01").withWorkloadProfileType("Consumption")))
            .create();
    }
}
