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

package com.azure.resourcemanager.trafficmanager.generated;

import com.azure.resourcemanager.trafficmanager.fluent.models.EndpointInner;
import com.azure.resourcemanager.trafficmanager.fluent.models.ProfileInner;
import com.azure.resourcemanager.trafficmanager.models.AllowedEndpointRecordType;
import com.azure.resourcemanager.trafficmanager.models.DnsConfig;
import com.azure.resourcemanager.trafficmanager.models.EndpointPropertiesCustomHeadersItem;
import com.azure.resourcemanager.trafficmanager.models.EndpointStatus;
import com.azure.resourcemanager.trafficmanager.models.MonitorConfig;
import com.azure.resourcemanager.trafficmanager.models.MonitorConfigCustomHeadersItem;
import com.azure.resourcemanager.trafficmanager.models.MonitorConfigExpectedStatusCodeRangesItem;
import com.azure.resourcemanager.trafficmanager.models.MonitorProtocol;
import com.azure.resourcemanager.trafficmanager.models.ProfileStatus;
import com.azure.resourcemanager.trafficmanager.models.TrafficRoutingMethod;
import com.azure.resourcemanager.trafficmanager.models.TrafficViewEnrollmentStatus;
import java.util.Arrays;

/** Samples for Profiles CreateOrUpdate. */
public final class ProfilesCreateOrUpdateSamples {
    /*
     * x-ms-original-file: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-PUT-MultiValue.json
     */
    /**
     * Sample code: Profile-PUT-MultiValue.
     *
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void profilePUTMultiValue(com.azure.resourcemanager.AzureResourceManager azure) {
        azure
            .trafficManagerProfiles()
            .manager()
            .serviceClient()
            .getProfiles()
            .createOrUpdateWithResponse(
                "azuresdkfornetautoresttrafficmanager1421",
                "azsmnet6386",
                new ProfileInner()
                    .withLocation("global")
                    .withProfileStatus(ProfileStatus.ENABLED)
                    .withTrafficRoutingMethod(TrafficRoutingMethod.MULTI_VALUE)
                    .withDnsConfig(new DnsConfig().withRelativeName("azsmnet6386").withTtl(35L))
                    .withMonitorConfig(
                        new MonitorConfig().withProtocol(MonitorProtocol.HTTP).withPort(80L).withPath("/testpath.aspx"))
                    .withTrafficViewEnrollmentStatus(TrafficViewEnrollmentStatus.DISABLED)
                    .withMaxReturn(2L),
                com.azure.core.util.Context.NONE);
    }

    /*
     * x-ms-original-file: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-PUT-WithCustomHeaders.json
     */
    /**
     * Sample code: Profile-PUT-WithCustomHeaders.
     *
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void profilePUTWithCustomHeaders(com.azure.resourcemanager.AzureResourceManager azure) {
        azure
            .trafficManagerProfiles()
            .manager()
            .serviceClient()
            .getProfiles()
            .createOrUpdateWithResponse(
                "azuresdkfornetautoresttrafficmanager2583",
                "azuresdkfornetautoresttrafficmanager6192",
                new ProfileInner()
                    .withLocation("global")
                    .withProfileStatus(ProfileStatus.ENABLED)
                    .withTrafficRoutingMethod(TrafficRoutingMethod.PERFORMANCE)
                    .withDnsConfig(
                        new DnsConfig().withRelativeName("azuresdkfornetautoresttrafficmanager6192").withTtl(35L))
                    .withMonitorConfig(
                        new MonitorConfig()
                            .withProtocol(MonitorProtocol.HTTP)
                            .withPort(80L)
                            .withPath("/testpath.aspx")
                            .withIntervalInSeconds(10L)
                            .withTimeoutInSeconds(5L)
                            .withToleratedNumberOfFailures(2L)
                            .withCustomHeaders(
                                Arrays
                                    .asList(
                                        new MonitorConfigCustomHeadersItem().withName("header-1").withValue("value-1"),
                                        new MonitorConfigCustomHeadersItem().withName("header-2").withValue("value-2")))
                            .withExpectedStatusCodeRanges(
                                Arrays
                                    .asList(
                                        new MonitorConfigExpectedStatusCodeRangesItem().withMin(200).withMax(205),
                                        new MonitorConfigExpectedStatusCodeRangesItem().withMin(400).withMax(410))))
                    .withEndpoints(
                        Arrays
                            .asList(
                                new EndpointInner()
                                    .withName("My external endpoint")
                                    .withType("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints")
                                    .withTarget("foobar.contoso.com")
                                    .withEndpointStatus(EndpointStatus.ENABLED)
                                    .withEndpointLocation("North Europe")
                                    .withCustomHeaders(
                                        Arrays
                                            .asList(
                                                new EndpointPropertiesCustomHeadersItem()
                                                    .withName("header-2")
                                                    .withValue("value-2-overridden")))))
                    .withTrafficViewEnrollmentStatus(TrafficViewEnrollmentStatus.DISABLED),
                com.azure.core.util.Context.NONE);
    }

    /*
     * x-ms-original-file: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-PUT-NoEndpoints.json
     */
    /**
     * Sample code: Profile-PUT-NoEndpoints.
     *
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void profilePUTNoEndpoints(com.azure.resourcemanager.AzureResourceManager azure) {
        azure
            .trafficManagerProfiles()
            .manager()
            .serviceClient()
            .getProfiles()
            .createOrUpdateWithResponse(
                "azuresdkfornetautoresttrafficmanager1421",
                "azsmnet6386",
                new ProfileInner()
                    .withLocation("global")
                    .withProfileStatus(ProfileStatus.ENABLED)
                    .withTrafficRoutingMethod(TrafficRoutingMethod.PERFORMANCE)
                    .withDnsConfig(new DnsConfig().withRelativeName("azsmnet6386").withTtl(35L))
                    .withMonitorConfig(
                        new MonitorConfig()
                            .withProtocol(MonitorProtocol.HTTP)
                            .withPort(80L)
                            .withPath("/testpath.aspx")),
                com.azure.core.util.Context.NONE);
    }

    /*
     * x-ms-original-file: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-PUT-WithAliasing.json
     */
    /**
     * Sample code: Profile-PUT-WithAliasing.
     *
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void profilePUTWithAliasing(com.azure.resourcemanager.AzureResourceManager azure) {
        azure
            .trafficManagerProfiles()
            .manager()
            .serviceClient()
            .getProfiles()
            .createOrUpdateWithResponse(
                "azuresdkfornetautoresttrafficmanager2583",
                "azuresdkfornetautoresttrafficmanager6192",
                new ProfileInner()
                    .withLocation("global")
                    .withProfileStatus(ProfileStatus.ENABLED)
                    .withTrafficRoutingMethod(TrafficRoutingMethod.PERFORMANCE)
                    .withDnsConfig(
                        new DnsConfig().withRelativeName("azuresdkfornetautoresttrafficmanager6192").withTtl(35L))
                    .withMonitorConfig(
                        new MonitorConfig()
                            .withProtocol(MonitorProtocol.HTTP)
                            .withPort(80L)
                            .withPath("/testpath.aspx")
                            .withIntervalInSeconds(10L)
                            .withTimeoutInSeconds(5L)
                            .withToleratedNumberOfFailures(2L))
                    .withEndpoints(
                        Arrays
                            .asList(
                                new EndpointInner()
                                    .withName("My external endpoint")
                                    .withType("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints")
                                    .withTarget("foobar.contoso.com")
                                    .withEndpointStatus(EndpointStatus.ENABLED)
                                    .withEndpointLocation("North Europe")))
                    .withAllowedEndpointRecordTypes(Arrays.asList(AllowedEndpointRecordType.DOMAIN_NAME)),
                com.azure.core.util.Context.NONE);
    }

    /*
     * x-ms-original-file: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-PUT-WithEndpoints.json
     */
    /**
     * Sample code: Profile-PUT-WithEndpoints.
     *
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void profilePUTWithEndpoints(com.azure.resourcemanager.AzureResourceManager azure) {
        azure
            .trafficManagerProfiles()
            .manager()
            .serviceClient()
            .getProfiles()
            .createOrUpdateWithResponse(
                "azuresdkfornetautoresttrafficmanager2583",
                "azuresdkfornetautoresttrafficmanager6192",
                new ProfileInner()
                    .withLocation("global")
                    .withProfileStatus(ProfileStatus.ENABLED)
                    .withTrafficRoutingMethod(TrafficRoutingMethod.PERFORMANCE)
                    .withDnsConfig(
                        new DnsConfig().withRelativeName("azuresdkfornetautoresttrafficmanager6192").withTtl(35L))
                    .withMonitorConfig(
                        new MonitorConfig()
                            .withProtocol(MonitorProtocol.HTTP)
                            .withPort(80L)
                            .withPath("/testpath.aspx")
                            .withIntervalInSeconds(10L)
                            .withTimeoutInSeconds(5L)
                            .withToleratedNumberOfFailures(2L))
                    .withEndpoints(
                        Arrays
                            .asList(
                                new EndpointInner()
                                    .withName("My external endpoint")
                                    .withType("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints")
                                    .withTarget("foobar.contoso.com")
                                    .withEndpointStatus(EndpointStatus.ENABLED)
                                    .withEndpointLocation("North Europe"))),
                com.azure.core.util.Context.NONE);
    }

    /*
     * x-ms-original-file: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-PUT-WithNestedEndpoints.json
     */
    /**
     * Sample code: Profile-PUT-WithNestedEndpoints.
     *
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void profilePUTWithNestedEndpoints(com.azure.resourcemanager.AzureResourceManager azure) {
        azure
            .trafficManagerProfiles()
            .manager()
            .serviceClient()
            .getProfiles()
            .createOrUpdateWithResponse(
                "myresourcegroup",
                "parentprofile",
                new ProfileInner()
                    .withLocation("global")
                    .withProfileStatus(ProfileStatus.ENABLED)
                    .withTrafficRoutingMethod(TrafficRoutingMethod.PRIORITY)
                    .withDnsConfig(new DnsConfig().withRelativeName("parentprofile").withTtl(35L))
                    .withMonitorConfig(
                        new MonitorConfig()
                            .withProtocol(MonitorProtocol.HTTP)
                            .withPort(80L)
                            .withPath("/testpath.aspx")
                            .withIntervalInSeconds(10L)
                            .withTimeoutInSeconds(5L)
                            .withToleratedNumberOfFailures(2L))
                    .withEndpoints(
                        Arrays
                            .asList(
                                new EndpointInner()
                                    .withName("MyFirstNestedEndpoint")
                                    .withType("Microsoft.Network/trafficManagerProfiles/nestedEndpoints")
                                    .withTarget("firstnestedprofile.tmpreview.watmtest.azure-test.net")
                                    .withEndpointStatus(EndpointStatus.ENABLED)
                                    .withWeight(1L)
                                    .withPriority(1L)
                                    .withMinChildEndpoints(2L)
                                    .withMinChildEndpointsIPv4(1L)
                                    .withMinChildEndpointsIPv6(2L),
                                new EndpointInner()
                                    .withName("MySecondNestedEndpoint")
                                    .withType("Microsoft.Network/trafficManagerProfiles/nestedEndpoints")
                                    .withTarget("secondnestedprofile.tmpreview.watmtest.azure-test.net")
                                    .withEndpointStatus(EndpointStatus.ENABLED)
                                    .withWeight(1L)
                                    .withPriority(2L)
                                    .withMinChildEndpoints(2L)
                                    .withMinChildEndpointsIPv4(2L)
                                    .withMinChildEndpointsIPv6(1L))),
                com.azure.core.util.Context.NONE);
    }
}
