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

package com.azure.resourcemanager.paloaltonetworks.ngfw.generated;

import com.azure.resourcemanager.paloaltonetworks.ngfw.models.AzureResourceManagerManagedIdentityProperties;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.AzureResourceManagerUserAssignedIdentity;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.BillingCycle;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.BooleanEnum;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.DnsProxy;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.DnsSettings;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.EgressNat;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.EnabledDnsType;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.EndpointConfiguration;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.FirewallResource;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.FirewallResourceUpdateProperties;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.FrontendSetting;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.IpAddress;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.IpAddressSpace;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.ManagedIdentityType;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.MarketplaceDetails;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.MarketplaceSubscriptionStatus;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.NetworkProfile;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.NetworkType;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.PanoramaConfig;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.PlanData;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.ProtocolType;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.RulestackDetails;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.UsageType;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.VnetConfiguration;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.VwanConfiguration;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/** Samples for Firewalls Update. */
public final class FirewallsUpdateSamples {
    /*
     * x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2022-08-29/examples/Firewalls_Update_MinimumSet_Gen.json
     */
    /**
     * Sample code: Firewalls_Update_MinimumSet_Gen.
     *
     * @param manager Entry point to PaloAltoNetworksNgfwManager.
     */
    public static void firewallsUpdateMinimumSetGen(
        com.azure.resourcemanager.paloaltonetworks.ngfw.PaloAltoNetworksNgfwManager manager) {
        FirewallResource resource =
            manager
                .firewalls()
                .getByResourceGroupWithResponse("firewall-rg", "firewall1", com.azure.core.util.Context.NONE)
                .getValue();
        resource.update().apply();
    }

    /*
     * x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2022-08-29/examples/Firewalls_Update_MaximumSet_Gen.json
     */
    /**
     * Sample code: Firewalls_Update_MaximumSet_Gen.
     *
     * @param manager Entry point to PaloAltoNetworksNgfwManager.
     */
    public static void firewallsUpdateMaximumSetGen(
        com.azure.resourcemanager.paloaltonetworks.ngfw.PaloAltoNetworksNgfwManager manager) {
        FirewallResource resource =
            manager
                .firewalls()
                .getByResourceGroupWithResponse("firewall-rg", "firewall1", com.azure.core.util.Context.NONE)
                .getValue();
        resource
            .update()
            .withTags(mapOf("tagName", "value"))
            .withIdentity(
                new AzureResourceManagerManagedIdentityProperties()
                    .withType(ManagedIdentityType.NONE)
                    .withUserAssignedIdentities(
                        mapOf(
                            "key16",
                            new AzureResourceManagerUserAssignedIdentity()
                                .withClientId("aaaa")
                                .withPrincipalId("aaaaaaaaaaaaaaa"))))
            .withProperties(
                new FirewallResourceUpdateProperties()
                    .withPanEtag("2bf4a339-294d-4c25-b0b2-ef649e9f5c12")
                    .withNetworkProfile(
                        new NetworkProfile()
                            .withVnetConfiguration(
                                new VnetConfiguration()
                                    .withVnet(
                                        new IpAddressSpace()
                                            .withResourceId(
                                                "/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet")
                                            .withAddressSpace("10.1.0.0/16"))
                                    .withTrustSubnet(
                                        new IpAddressSpace()
                                            .withResourceId(
                                                "/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-trust-subnet")
                                            .withAddressSpace("10.1.1.0/24"))
                                    .withUnTrustSubnet(
                                        new IpAddressSpace()
                                            .withResourceId(
                                                "/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-untrust-subnet")
                                            .withAddressSpace("10.1.1.0/24"))
                                    .withIpOfTrustSubnetForUdr(
                                        new IpAddress()
                                            .withResourceId(
                                                "/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-untrust-subnet")
                                            .withAddress("10.1.1.0/24")))
                            .withVwanConfiguration(
                                new VwanConfiguration()
                                    .withNetworkVirtualApplianceId("2bf4a339-294d-4c25-b0b2-ef649e9f5c12")
                                    .withVHub(
                                        new IpAddressSpace()
                                            .withResourceId(
                                                "/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-untrust-subnet")
                                            .withAddressSpace("10.1.1.0/24"))
                                    .withTrustSubnet(
                                        new IpAddressSpace()
                                            .withResourceId(
                                                "/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-trust-subnet")
                                            .withAddressSpace("10.1.1.0/24"))
                                    .withUnTrustSubnet(
                                        new IpAddressSpace()
                                            .withResourceId(
                                                "/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-untrust-subnet")
                                            .withAddressSpace("10.1.1.0/24"))
                                    .withIpOfTrustSubnetForUdr(
                                        new IpAddress()
                                            .withResourceId(
                                                "/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-untrust-subnet")
                                            .withAddress("10.1.1.0/24")))
                            .withNetworkType(NetworkType.VNET)
                            .withPublicIps(
                                Arrays
                                    .asList(
                                        new IpAddress()
                                            .withResourceId(
                                                "/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-PublicIp1")
                                            .withAddress("20.22.92.11")))
                            .withEnableEgressNat(EgressNat.ENABLED)
                            .withEgressNatIp(
                                Arrays
                                    .asList(
                                        new IpAddress()
                                            .withResourceId(
                                                "/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-egressNatIp1")
                                            .withAddress("20.22.92.111"))))
                    .withIsPanoramaManaged(BooleanEnum.TRUE)
                    .withPanoramaConfig(new PanoramaConfig().withConfigString("bas64EncodedString"))
                    .withAssociatedRulestack(
                        new RulestackDetails()
                            .withResourceId("aaaaaaaaaa")
                            .withRulestackId("aaaaaaaaaaaaaaaa")
                            .withLocation("eastus"))
                    .withDnsSettings(
                        new DnsSettings()
                            .withEnableDnsProxy(DnsProxy.DISABLED)
                            .withEnabledDnsType(EnabledDnsType.CUSTOM)
                            .withDnsServers(
                                Arrays
                                    .asList(
                                        new IpAddress()
                                            .withResourceId(
                                                "/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-egressNatIp1")
                                            .withAddress("20.22.92.111"))))
                    .withFrontEndSettings(
                        Arrays
                            .asList(
                                new FrontendSetting()
                                    .withName("frontendsetting11")
                                    .withProtocol(ProtocolType.TCP)
                                    .withFrontendConfiguration(
                                        new EndpointConfiguration()
                                            .withPort("80")
                                            .withAddress(
                                                new IpAddress()
                                                    .withResourceId(
                                                        "/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-frontendSettingIp1")
                                                    .withAddress("20.22.91.251")))
                                    .withBackendConfiguration(
                                        new EndpointConfiguration()
                                            .withPort("80")
                                            .withAddress(
                                                new IpAddress()
                                                    .withResourceId(
                                                        "/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-frontendSettingIp2")
                                                    .withAddress("20.22.32.136")))))
                    .withPlanData(
                        new PlanData()
                            .withUsageType(UsageType.PAYG)
                            .withBillingCycle(BillingCycle.WEEKLY)
                            .withPlanId("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"))
                    .withMarketplaceDetails(
                        new MarketplaceDetails()
                            .withOfferId("aaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
                            .withPublisherId("aaaa")
                            .withMarketplaceSubscriptionStatus(
                                MarketplaceSubscriptionStatus.PENDING_FULFILLMENT_START)))
            .apply();
    }

    @SuppressWarnings("unchecked")
    private static <T> Map<String, T> mapOf(Object... inputs) {
        Map<String, T> map = new HashMap<>();
        for (int i = 0; i < inputs.length; i += 2) {
            String key = (String) inputs[i];
            T value = (T) inputs[i + 1];
            map.put(key, value);
        }
        return map;
    }
}
