All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pulumi.gcp.dns.kotlin.PolicyArgs.kt Maven / Gradle / Ivy

@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.gcp.dns.kotlin

import com.pulumi.core.Output
import com.pulumi.core.Output.of
import com.pulumi.gcp.dns.PolicyArgs.builder
import com.pulumi.gcp.dns.kotlin.inputs.PolicyAlternativeNameServerConfigArgs
import com.pulumi.gcp.dns.kotlin.inputs.PolicyAlternativeNameServerConfigArgsBuilder
import com.pulumi.gcp.dns.kotlin.inputs.PolicyNetworkArgs
import com.pulumi.gcp.dns.kotlin.inputs.PolicyNetworkArgsBuilder
import com.pulumi.kotlin.ConvertibleToJava
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.applySuspend
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.jvm.JvmName

/**
 * A policy is a collection of DNS rules applied to one or more Virtual
 * Private Cloud resources.
 * To get more information about Policy, see:
 * * [API documentation](https://cloud.google.com/dns/docs/reference/v1beta2/policies)
 * * How-to Guides
 *     * [Using DNS server policies](https://cloud.google.com/dns/zones/#using-dns-server-policies)
 * ## Example Usage
 * ### Dns Policy Basic
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const network_1 = new gcp.compute.Network("network-1", {
 *     name: "network-1",
 *     autoCreateSubnetworks: false,
 * });
 * const network_2 = new gcp.compute.Network("network-2", {
 *     name: "network-2",
 *     autoCreateSubnetworks: false,
 * });
 * const example_policy = new gcp.dns.Policy("example-policy", {
 *     name: "example-policy",
 *     enableInboundForwarding: true,
 *     enableLogging: true,
 *     alternativeNameServerConfig: {
 *         targetNameServers: [
 *             {
 *                 ipv4Address: "172.16.1.10",
 *                 forwardingPath: "private",
 *             },
 *             {
 *                 ipv4Address: "172.16.1.20",
 *             },
 *         ],
 *     },
 *     networks: [
 *         {
 *             networkUrl: network_1.id,
 *         },
 *         {
 *             networkUrl: network_2.id,
 *         },
 *     ],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * network_1 = gcp.compute.Network("network-1",
 *     name="network-1",
 *     auto_create_subnetworks=False)
 * network_2 = gcp.compute.Network("network-2",
 *     name="network-2",
 *     auto_create_subnetworks=False)
 * example_policy = gcp.dns.Policy("example-policy",
 *     name="example-policy",
 *     enable_inbound_forwarding=True,
 *     enable_logging=True,
 *     alternative_name_server_config={
 *         "target_name_servers": [
 *             {
 *                 "ipv4_address": "172.16.1.10",
 *                 "forwarding_path": "private",
 *             },
 *             {
 *                 "ipv4_address": "172.16.1.20",
 *             },
 *         ],
 *     },
 *     networks=[
 *         {
 *             "network_url": network_1.id,
 *         },
 *         {
 *             "network_url": network_2.id,
 *         },
 *     ])
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var network_1 = new Gcp.Compute.Network("network-1", new()
 *     {
 *         Name = "network-1",
 *         AutoCreateSubnetworks = false,
 *     });
 *     var network_2 = new Gcp.Compute.Network("network-2", new()
 *     {
 *         Name = "network-2",
 *         AutoCreateSubnetworks = false,
 *     });
 *     var example_policy = new Gcp.Dns.Policy("example-policy", new()
 *     {
 *         Name = "example-policy",
 *         EnableInboundForwarding = true,
 *         EnableLogging = true,
 *         AlternativeNameServerConfig = new Gcp.Dns.Inputs.PolicyAlternativeNameServerConfigArgs
 *         {
 *             TargetNameServers = new[]
 *             {
 *                 new Gcp.Dns.Inputs.PolicyAlternativeNameServerConfigTargetNameServerArgs
 *                 {
 *                     Ipv4Address = "172.16.1.10",
 *                     ForwardingPath = "private",
 *                 },
 *                 new Gcp.Dns.Inputs.PolicyAlternativeNameServerConfigTargetNameServerArgs
 *                 {
 *                     Ipv4Address = "172.16.1.20",
 *                 },
 *             },
 *         },
 *         Networks = new[]
 *         {
 *             new Gcp.Dns.Inputs.PolicyNetworkArgs
 *             {
 *                 NetworkUrl = network_1.Id,
 *             },
 *             new Gcp.Dns.Inputs.PolicyNetworkArgs
 *             {
 *                 NetworkUrl = network_2.Id,
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/dns"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := compute.NewNetwork(ctx, "network-1", &compute.NetworkArgs{
 * 			Name:                  pulumi.String("network-1"),
 * 			AutoCreateSubnetworks: pulumi.Bool(false),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = compute.NewNetwork(ctx, "network-2", &compute.NetworkArgs{
 * 			Name:                  pulumi.String("network-2"),
 * 			AutoCreateSubnetworks: pulumi.Bool(false),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = dns.NewPolicy(ctx, "example-policy", &dns.PolicyArgs{
 * 			Name:                    pulumi.String("example-policy"),
 * 			EnableInboundForwarding: pulumi.Bool(true),
 * 			EnableLogging:           pulumi.Bool(true),
 * 			AlternativeNameServerConfig: &dns.PolicyAlternativeNameServerConfigArgs{
 * 				TargetNameServers: dns.PolicyAlternativeNameServerConfigTargetNameServerArray{
 * 					&dns.PolicyAlternativeNameServerConfigTargetNameServerArgs{
 * 						Ipv4Address:    pulumi.String("172.16.1.10"),
 * 						ForwardingPath: pulumi.String("private"),
 * 					},
 * 					&dns.PolicyAlternativeNameServerConfigTargetNameServerArgs{
 * 						Ipv4Address: pulumi.String("172.16.1.20"),
 * 					},
 * 				},
 * 			},
 * 			Networks: dns.PolicyNetworkArray{
 * 				&dns.PolicyNetworkArgs{
 * 					NetworkUrl: network_1.ID(),
 * 				},
 * 				&dns.PolicyNetworkArgs{
 * 					NetworkUrl: network_2.ID(),
 * 				},
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		return nil
 * 	})
 * }
 * ```
 * ```java
 * package generated_program;
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.gcp.compute.Network;
 * import com.pulumi.gcp.compute.NetworkArgs;
 * import com.pulumi.gcp.dns.Policy;
 * import com.pulumi.gcp.dns.PolicyArgs;
 * import com.pulumi.gcp.dns.inputs.PolicyAlternativeNameServerConfigArgs;
 * import com.pulumi.gcp.dns.inputs.PolicyNetworkArgs;
 * import java.util.List;
 * import java.util.ArrayList;
 * import java.util.Map;
 * import java.io.File;
 * import java.nio.file.Files;
 * import java.nio.file.Paths;
 * public class App {
 *     public static void main(String[] args) {
 *         Pulumi.run(App::stack);
 *     }
 *     public static void stack(Context ctx) {
 *         var network_1 = new Network("network-1", NetworkArgs.builder()
 *             .name("network-1")
 *             .autoCreateSubnetworks(false)
 *             .build());
 *         var network_2 = new Network("network-2", NetworkArgs.builder()
 *             .name("network-2")
 *             .autoCreateSubnetworks(false)
 *             .build());
 *         var example_policy = new Policy("example-policy", PolicyArgs.builder()
 *             .name("example-policy")
 *             .enableInboundForwarding(true)
 *             .enableLogging(true)
 *             .alternativeNameServerConfig(PolicyAlternativeNameServerConfigArgs.builder()
 *                 .targetNameServers(
 *                     PolicyAlternativeNameServerConfigTargetNameServerArgs.builder()
 *                         .ipv4Address("172.16.1.10")
 *                         .forwardingPath("private")
 *                         .build(),
 *                     PolicyAlternativeNameServerConfigTargetNameServerArgs.builder()
 *                         .ipv4Address("172.16.1.20")
 *                         .build())
 *                 .build())
 *             .networks(
 *                 PolicyNetworkArgs.builder()
 *                     .networkUrl(network_1.id())
 *                     .build(),
 *                 PolicyNetworkArgs.builder()
 *                     .networkUrl(network_2.id())
 *                     .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example-policy:
 *     type: gcp:dns:Policy
 *     properties:
 *       name: example-policy
 *       enableInboundForwarding: true
 *       enableLogging: true
 *       alternativeNameServerConfig:
 *         targetNameServers:
 *           - ipv4Address: 172.16.1.10
 *             forwardingPath: private
 *           - ipv4Address: 172.16.1.20
 *       networks:
 *         - networkUrl: ${["network-1"].id}
 *         - networkUrl: ${["network-2"].id}
 *   network-1:
 *     type: gcp:compute:Network
 *     properties:
 *       name: network-1
 *       autoCreateSubnetworks: false
 *   network-2:
 *     type: gcp:compute:Network
 *     properties:
 *       name: network-2
 *       autoCreateSubnetworks: false
 * ```
 * 
 * ## Import
 * Policy can be imported using any of these accepted formats:
 * * `projects/{{project}}/policies/{{name}}`
 * * `{{project}}/{{name}}`
 * * `{{name}}`
 * When using the `pulumi import` command, Policy can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:dns/policy:Policy default projects/{{project}}/policies/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:dns/policy:Policy default {{project}}/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:dns/policy:Policy default {{name}}
 * ```
 * @property alternativeNameServerConfig Sets an alternative name server for the associated networks.
 * When specified, all DNS queries are forwarded to a name server that you choose.
 * Names such as .internal are not available when an alternative name server is specified.
 * Structure is documented below.
 * @property description A textual description field. Defaults to 'Managed by Pulumi'.
 * @property enableInboundForwarding Allows networks bound to this policy to receive DNS queries sent
 * by VMs or applications over VPN connections. When enabled, a
 * virtual IP address will be allocated from each of the sub-networks
 * that are bound to this policy.
 * @property enableLogging Controls whether logging is enabled for the networks bound to this policy.
 * Defaults to no logging if not set.
 * @property name User assigned name for this policy.
 * - - -
 * @property networks List of network names specifying networks to which this policy is applied.
 * Structure is documented below.
 * @property project The ID of the project in which the resource belongs.
 * If it is not provided, the provider project is used.
 */
public data class PolicyArgs(
    public val alternativeNameServerConfig: Output? = null,
    public val description: Output? = null,
    public val enableInboundForwarding: Output? = null,
    public val enableLogging: Output? = null,
    public val name: Output? = null,
    public val networks: Output>? = null,
    public val project: Output? = null,
) : ConvertibleToJava {
    override fun toJava(): com.pulumi.gcp.dns.PolicyArgs = com.pulumi.gcp.dns.PolicyArgs.builder()
        .alternativeNameServerConfig(
            alternativeNameServerConfig?.applyValue({ args0 ->
                args0.let({ args0 ->
                    args0.toJava()
                })
            }),
        )
        .description(description?.applyValue({ args0 -> args0 }))
        .enableInboundForwarding(enableInboundForwarding?.applyValue({ args0 -> args0 }))
        .enableLogging(enableLogging?.applyValue({ args0 -> args0 }))
        .name(name?.applyValue({ args0 -> args0 }))
        .networks(
            networks?.applyValue({ args0 ->
                args0.map({ args0 ->
                    args0.let({ args0 ->
                        args0.toJava()
                    })
                })
            }),
        )
        .project(project?.applyValue({ args0 -> args0 })).build()
}

/**
 * Builder for [PolicyArgs].
 */
@PulumiTagMarker
public class PolicyArgsBuilder internal constructor() {
    private var alternativeNameServerConfig: Output? = null

    private var description: Output? = null

    private var enableInboundForwarding: Output? = null

    private var enableLogging: Output? = null

    private var name: Output? = null

    private var networks: Output>? = null

    private var project: Output? = null

    /**
     * @param value Sets an alternative name server for the associated networks.
     * When specified, all DNS queries are forwarded to a name server that you choose.
     * Names such as .internal are not available when an alternative name server is specified.
     * Structure is documented below.
     */
    @JvmName("hjbmkyqdnerinygc")
    public suspend fun alternativeNameServerConfig(`value`: Output) {
        this.alternativeNameServerConfig = value
    }

    /**
     * @param value A textual description field. Defaults to 'Managed by Pulumi'.
     */
    @JvmName("ouuunqfvqwsrikyh")
    public suspend fun description(`value`: Output) {
        this.description = value
    }

    /**
     * @param value Allows networks bound to this policy to receive DNS queries sent
     * by VMs or applications over VPN connections. When enabled, a
     * virtual IP address will be allocated from each of the sub-networks
     * that are bound to this policy.
     */
    @JvmName("gtdgprjmkgssnogn")
    public suspend fun enableInboundForwarding(`value`: Output) {
        this.enableInboundForwarding = value
    }

    /**
     * @param value Controls whether logging is enabled for the networks bound to this policy.
     * Defaults to no logging if not set.
     */
    @JvmName("fguhivijvhvbqwrw")
    public suspend fun enableLogging(`value`: Output) {
        this.enableLogging = value
    }

    /**
     * @param value User assigned name for this policy.
     * - - -
     */
    @JvmName("uqnkadwoypfplxwv")
    public suspend fun name(`value`: Output) {
        this.name = value
    }

    /**
     * @param value List of network names specifying networks to which this policy is applied.
     * Structure is documented below.
     */
    @JvmName("nulfvaixbiorpjta")
    public suspend fun networks(`value`: Output>) {
        this.networks = value
    }

    @JvmName("osgfuxnckhtfqict")
    public suspend fun networks(vararg values: Output) {
        this.networks = Output.all(values.asList())
    }

    /**
     * @param values List of network names specifying networks to which this policy is applied.
     * Structure is documented below.
     */
    @JvmName("vkwkgmdqxacufglw")
    public suspend fun networks(values: List>) {
        this.networks = Output.all(values)
    }

    /**
     * @param value The ID of the project in which the resource belongs.
     * If it is not provided, the provider project is used.
     */
    @JvmName("yjciayyujqtcqgvo")
    public suspend fun project(`value`: Output) {
        this.project = value
    }

    /**
     * @param value Sets an alternative name server for the associated networks.
     * When specified, all DNS queries are forwarded to a name server that you choose.
     * Names such as .internal are not available when an alternative name server is specified.
     * Structure is documented below.
     */
    @JvmName("pvelctcrrwdiyjsv")
    public suspend fun alternativeNameServerConfig(`value`: PolicyAlternativeNameServerConfigArgs?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.alternativeNameServerConfig = mapped
    }

    /**
     * @param argument Sets an alternative name server for the associated networks.
     * When specified, all DNS queries are forwarded to a name server that you choose.
     * Names such as .internal are not available when an alternative name server is specified.
     * Structure is documented below.
     */
    @JvmName("cdaacqwijnpbytwe")
    public suspend fun alternativeNameServerConfig(argument: suspend PolicyAlternativeNameServerConfigArgsBuilder.() -> Unit) {
        val toBeMapped = PolicyAlternativeNameServerConfigArgsBuilder().applySuspend {
            argument()
        }.build()
        val mapped = of(toBeMapped)
        this.alternativeNameServerConfig = mapped
    }

    /**
     * @param value A textual description field. Defaults to 'Managed by Pulumi'.
     */
    @JvmName("lrptbgylbfyetrlx")
    public suspend fun description(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.description = mapped
    }

    /**
     * @param value Allows networks bound to this policy to receive DNS queries sent
     * by VMs or applications over VPN connections. When enabled, a
     * virtual IP address will be allocated from each of the sub-networks
     * that are bound to this policy.
     */
    @JvmName("yrrbhvinulqsbpql")
    public suspend fun enableInboundForwarding(`value`: Boolean?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.enableInboundForwarding = mapped
    }

    /**
     * @param value Controls whether logging is enabled for the networks bound to this policy.
     * Defaults to no logging if not set.
     */
    @JvmName("hxmobfjsmvhoenmw")
    public suspend fun enableLogging(`value`: Boolean?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.enableLogging = mapped
    }

    /**
     * @param value User assigned name for this policy.
     * - - -
     */
    @JvmName("whghjietebejiiel")
    public suspend fun name(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.name = mapped
    }

    /**
     * @param value List of network names specifying networks to which this policy is applied.
     * Structure is documented below.
     */
    @JvmName("bwxsogbhfrnewqnc")
    public suspend fun networks(`value`: List?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.networks = mapped
    }

    /**
     * @param argument List of network names specifying networks to which this policy is applied.
     * Structure is documented below.
     */
    @JvmName("wfuhfiabohegvjql")
    public suspend fun networks(argument: List Unit>) {
        val toBeMapped = argument.toList().map {
            PolicyNetworkArgsBuilder().applySuspend { it() }.build()
        }
        val mapped = of(toBeMapped)
        this.networks = mapped
    }

    /**
     * @param argument List of network names specifying networks to which this policy is applied.
     * Structure is documented below.
     */
    @JvmName("ogwsiolsfrrodeix")
    public suspend fun networks(vararg argument: suspend PolicyNetworkArgsBuilder.() -> Unit) {
        val toBeMapped = argument.toList().map {
            PolicyNetworkArgsBuilder().applySuspend { it() }.build()
        }
        val mapped = of(toBeMapped)
        this.networks = mapped
    }

    /**
     * @param argument List of network names specifying networks to which this policy is applied.
     * Structure is documented below.
     */
    @JvmName("kawmrtxarnaqmrai")
    public suspend fun networks(argument: suspend PolicyNetworkArgsBuilder.() -> Unit) {
        val toBeMapped = listOf(PolicyNetworkArgsBuilder().applySuspend { argument() }.build())
        val mapped = of(toBeMapped)
        this.networks = mapped
    }

    /**
     * @param values List of network names specifying networks to which this policy is applied.
     * Structure is documented below.
     */
    @JvmName("rbirflmlwpikxjxf")
    public suspend fun networks(vararg values: PolicyNetworkArgs) {
        val toBeMapped = values.toList()
        val mapped = toBeMapped.let({ args0 -> of(args0) })
        this.networks = mapped
    }

    /**
     * @param value The ID of the project in which the resource belongs.
     * If it is not provided, the provider project is used.
     */
    @JvmName("egjdpgnfvotyxmtk")
    public suspend fun project(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.project = mapped
    }

    internal fun build(): PolicyArgs = PolicyArgs(
        alternativeNameServerConfig = alternativeNameServerConfig,
        description = description,
        enableInboundForwarding = enableInboundForwarding,
        enableLogging = enableLogging,
        name = name,
        networks = networks,
        project = project,
    )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy