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

com.pulumi.gcp.vmwareengine.kotlin.NetworkPolicy.kt Maven / Gradle / Ivy

Go to download

Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.

There is a newer version: 8.10.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.gcp.vmwareengine.kotlin

import com.pulumi.core.Output
import com.pulumi.gcp.vmwareengine.kotlin.outputs.NetworkPolicyExternalIp
import com.pulumi.gcp.vmwareengine.kotlin.outputs.NetworkPolicyInternetAccess
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import com.pulumi.gcp.vmwareengine.kotlin.outputs.NetworkPolicyExternalIp.Companion.toKotlin as networkPolicyExternalIpToKotlin
import com.pulumi.gcp.vmwareengine.kotlin.outputs.NetworkPolicyInternetAccess.Companion.toKotlin as networkPolicyInternetAccessToKotlin

/**
 * Builder for [NetworkPolicy].
 */
@PulumiTagMarker
public class NetworkPolicyResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: NetworkPolicyArgs = NetworkPolicyArgs()

    public var opts: CustomResourceOptions = CustomResourceOptions()

    /**
     * @param name The _unique_ name of the resulting resource.
     */
    public fun name(`value`: String) {
        this.name = value
    }

    /**
     * @param block The arguments to use to populate this resource's properties.
     */
    public suspend fun args(block: suspend NetworkPolicyArgsBuilder.() -> Unit) {
        val builder = NetworkPolicyArgsBuilder()
        block(builder)
        this.args = builder.build()
    }

    /**
     * @param block A bag of options that control this resource's behavior.
     */
    public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
        this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
    }

    internal fun build(): NetworkPolicy {
        val builtJavaResource = com.pulumi.gcp.vmwareengine.NetworkPolicy(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return NetworkPolicy(builtJavaResource)
    }
}

/**
 * Represents a network policy resource. Network policies are regional resources.
 * To get more information about NetworkPolicy, see:
 * * [API documentation](https://cloud.google.com/vmware-engine/docs/reference/rest/v1/projects.locations.networkPolicies)
 * ## Example Usage
 * ### Vmware Engine Network Policy Basic
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const network_policy_nw = new gcp.vmwareengine.Network("network-policy-nw", {
 *     name: "standard-nw",
 *     location: "global",
 *     type: "STANDARD",
 *     description: "VMwareEngine standard network sample",
 * });
 * const vmw_engine_network_policy = new gcp.vmwareengine.NetworkPolicy("vmw-engine-network-policy", {
 *     location: "us-west1",
 *     name: "sample-network-policy",
 *     edgeServicesCidr: "192.168.30.0/26",
 *     vmwareEngineNetwork: network_policy_nw.id,
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * network_policy_nw = gcp.vmwareengine.Network("network-policy-nw",
 *     name="standard-nw",
 *     location="global",
 *     type="STANDARD",
 *     description="VMwareEngine standard network sample")
 * vmw_engine_network_policy = gcp.vmwareengine.NetworkPolicy("vmw-engine-network-policy",
 *     location="us-west1",
 *     name="sample-network-policy",
 *     edge_services_cidr="192.168.30.0/26",
 *     vmware_engine_network=network_policy_nw.id)
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var network_policy_nw = new Gcp.VMwareEngine.Network("network-policy-nw", new()
 *     {
 *         Name = "standard-nw",
 *         Location = "global",
 *         Type = "STANDARD",
 *         Description = "VMwareEngine standard network sample",
 *     });
 *     var vmw_engine_network_policy = new Gcp.VMwareEngine.NetworkPolicy("vmw-engine-network-policy", new()
 *     {
 *         Location = "us-west1",
 *         Name = "sample-network-policy",
 *         EdgeServicesCidr = "192.168.30.0/26",
 *         VmwareEngineNetwork = network_policy_nw.Id,
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/vmwareengine"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := vmwareengine.NewNetwork(ctx, "network-policy-nw", &vmwareengine.NetworkArgs{
 * 			Name:        pulumi.String("standard-nw"),
 * 			Location:    pulumi.String("global"),
 * 			Type:        pulumi.String("STANDARD"),
 * 			Description: pulumi.String("VMwareEngine standard network sample"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = vmwareengine.NewNetworkPolicy(ctx, "vmw-engine-network-policy", &vmwareengine.NetworkPolicyArgs{
 * 			Location:            pulumi.String("us-west1"),
 * 			Name:                pulumi.String("sample-network-policy"),
 * 			EdgeServicesCidr:    pulumi.String("192.168.30.0/26"),
 * 			VmwareEngineNetwork: network_policy_nw.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.vmwareengine.Network;
 * import com.pulumi.gcp.vmwareengine.NetworkArgs;
 * import com.pulumi.gcp.vmwareengine.NetworkPolicy;
 * import com.pulumi.gcp.vmwareengine.NetworkPolicyArgs;
 * 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_policy_nw = new Network("network-policy-nw", NetworkArgs.builder()
 *             .name("standard-nw")
 *             .location("global")
 *             .type("STANDARD")
 *             .description("VMwareEngine standard network sample")
 *             .build());
 *         var vmw_engine_network_policy = new NetworkPolicy("vmw-engine-network-policy", NetworkPolicyArgs.builder()
 *             .location("us-west1")
 *             .name("sample-network-policy")
 *             .edgeServicesCidr("192.168.30.0/26")
 *             .vmwareEngineNetwork(network_policy_nw.id())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   network-policy-nw:
 *     type: gcp:vmwareengine:Network
 *     properties:
 *       name: standard-nw
 *       location: global
 *       type: STANDARD
 *       description: VMwareEngine standard network sample
 *   vmw-engine-network-policy:
 *     type: gcp:vmwareengine:NetworkPolicy
 *     properties:
 *       location: us-west1
 *       name: sample-network-policy
 *       edgeServicesCidr: 192.168.30.0/26
 *       vmwareEngineNetwork: ${["network-policy-nw"].id}
 * ```
 * 
 * ### Vmware Engine Network Policy Full
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const network_policy_nw = new gcp.vmwareengine.Network("network-policy-nw", {
 *     name: "standard-full-nw",
 *     location: "global",
 *     type: "STANDARD",
 *     description: "VMwareEngine standard network sample",
 * });
 * const vmw_engine_network_policy = new gcp.vmwareengine.NetworkPolicy("vmw-engine-network-policy", {
 *     location: "us-west1",
 *     name: "sample-network-policy-full",
 *     edgeServicesCidr: "192.168.30.0/26",
 *     vmwareEngineNetwork: network_policy_nw.id,
 *     description: "Sample Network Policy",
 *     internetAccess: {
 *         enabled: true,
 *     },
 *     externalIp: {
 *         enabled: true,
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * network_policy_nw = gcp.vmwareengine.Network("network-policy-nw",
 *     name="standard-full-nw",
 *     location="global",
 *     type="STANDARD",
 *     description="VMwareEngine standard network sample")
 * vmw_engine_network_policy = gcp.vmwareengine.NetworkPolicy("vmw-engine-network-policy",
 *     location="us-west1",
 *     name="sample-network-policy-full",
 *     edge_services_cidr="192.168.30.0/26",
 *     vmware_engine_network=network_policy_nw.id,
 *     description="Sample Network Policy",
 *     internet_access=gcp.vmwareengine.NetworkPolicyInternetAccessArgs(
 *         enabled=True,
 *     ),
 *     external_ip=gcp.vmwareengine.NetworkPolicyExternalIpArgs(
 *         enabled=True,
 *     ))
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var network_policy_nw = new Gcp.VMwareEngine.Network("network-policy-nw", new()
 *     {
 *         Name = "standard-full-nw",
 *         Location = "global",
 *         Type = "STANDARD",
 *         Description = "VMwareEngine standard network sample",
 *     });
 *     var vmw_engine_network_policy = new Gcp.VMwareEngine.NetworkPolicy("vmw-engine-network-policy", new()
 *     {
 *         Location = "us-west1",
 *         Name = "sample-network-policy-full",
 *         EdgeServicesCidr = "192.168.30.0/26",
 *         VmwareEngineNetwork = network_policy_nw.Id,
 *         Description = "Sample Network Policy",
 *         InternetAccess = new Gcp.VMwareEngine.Inputs.NetworkPolicyInternetAccessArgs
 *         {
 *             Enabled = true,
 *         },
 *         ExternalIp = new Gcp.VMwareEngine.Inputs.NetworkPolicyExternalIpArgs
 *         {
 *             Enabled = true,
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/vmwareengine"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := vmwareengine.NewNetwork(ctx, "network-policy-nw", &vmwareengine.NetworkArgs{
 * 			Name:        pulumi.String("standard-full-nw"),
 * 			Location:    pulumi.String("global"),
 * 			Type:        pulumi.String("STANDARD"),
 * 			Description: pulumi.String("VMwareEngine standard network sample"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = vmwareengine.NewNetworkPolicy(ctx, "vmw-engine-network-policy", &vmwareengine.NetworkPolicyArgs{
 * 			Location:            pulumi.String("us-west1"),
 * 			Name:                pulumi.String("sample-network-policy-full"),
 * 			EdgeServicesCidr:    pulumi.String("192.168.30.0/26"),
 * 			VmwareEngineNetwork: network_policy_nw.ID(),
 * 			Description:         pulumi.String("Sample Network Policy"),
 * 			InternetAccess: &vmwareengine.NetworkPolicyInternetAccessArgs{
 * 				Enabled: pulumi.Bool(true),
 * 			},
 * 			ExternalIp: &vmwareengine.NetworkPolicyExternalIpArgs{
 * 				Enabled: pulumi.Bool(true),
 * 			},
 * 		})
 * 		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.vmwareengine.Network;
 * import com.pulumi.gcp.vmwareengine.NetworkArgs;
 * import com.pulumi.gcp.vmwareengine.NetworkPolicy;
 * import com.pulumi.gcp.vmwareengine.NetworkPolicyArgs;
 * import com.pulumi.gcp.vmwareengine.inputs.NetworkPolicyInternetAccessArgs;
 * import com.pulumi.gcp.vmwareengine.inputs.NetworkPolicyExternalIpArgs;
 * 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_policy_nw = new Network("network-policy-nw", NetworkArgs.builder()
 *             .name("standard-full-nw")
 *             .location("global")
 *             .type("STANDARD")
 *             .description("VMwareEngine standard network sample")
 *             .build());
 *         var vmw_engine_network_policy = new NetworkPolicy("vmw-engine-network-policy", NetworkPolicyArgs.builder()
 *             .location("us-west1")
 *             .name("sample-network-policy-full")
 *             .edgeServicesCidr("192.168.30.0/26")
 *             .vmwareEngineNetwork(network_policy_nw.id())
 *             .description("Sample Network Policy")
 *             .internetAccess(NetworkPolicyInternetAccessArgs.builder()
 *                 .enabled(true)
 *                 .build())
 *             .externalIp(NetworkPolicyExternalIpArgs.builder()
 *                 .enabled(true)
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   network-policy-nw:
 *     type: gcp:vmwareengine:Network
 *     properties:
 *       name: standard-full-nw
 *       location: global
 *       type: STANDARD
 *       description: VMwareEngine standard network sample
 *   vmw-engine-network-policy:
 *     type: gcp:vmwareengine:NetworkPolicy
 *     properties:
 *       location: us-west1
 *       name: sample-network-policy-full
 *       edgeServicesCidr: 192.168.30.0/26
 *       vmwareEngineNetwork: ${["network-policy-nw"].id}
 *       description: Sample Network Policy
 *       internetAccess:
 *         enabled: true
 *       externalIp:
 *         enabled: true
 * ```
 * 
 * ## Import
 * NetworkPolicy can be imported using any of these accepted formats:
 * * `projects/{{project}}/locations/{{location}}/networkPolicies/{{name}}`
 * * `{{project}}/{{location}}/{{name}}`
 * * `{{location}}/{{name}}`
 * When using the `pulumi import` command, NetworkPolicy can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:vmwareengine/networkPolicy:NetworkPolicy default projects/{{project}}/locations/{{location}}/networkPolicies/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:vmwareengine/networkPolicy:NetworkPolicy default {{project}}/{{location}}/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:vmwareengine/networkPolicy:NetworkPolicy default {{location}}/{{name}}
 * ```
 */
public class NetworkPolicy internal constructor(
    override val javaResource: com.pulumi.gcp.vmwareengine.NetworkPolicy,
) : KotlinCustomResource(javaResource, NetworkPolicyMapper) {
    /**
     * Creation time of this resource.
     * A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and
     * up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".
     */
    public val createTime: Output
        get() = javaResource.createTime().applyValue({ args0 -> args0 })

    /**
     * User-provided description for this network policy.
     */
    public val description: Output?
        get() = javaResource.description().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * IP address range in CIDR notation used to create internet access and external IP access.
     * An RFC 1918 CIDR block, with a "/26" prefix, is required. The range cannot overlap with any
     * prefixes either in the consumer VPC network or in use by the private clouds attached to that VPC network.
     */
    public val edgeServicesCidr: Output
        get() = javaResource.edgeServicesCidr().applyValue({ args0 -> args0 })

    /**
     * Network service that allows External IP addresses to be assigned to VMware workloads.
     * This service can only be enabled when internetAccess is also enabled.
     * Structure is documented below.
     */
    public val externalIp: Output
        get() = javaResource.externalIp().applyValue({ args0 ->
            args0.let({ args0 ->
                networkPolicyExternalIpToKotlin(args0)
            })
        })

    /**
     * Network service that allows VMware workloads to access the internet.
     * Structure is documented below.
     */
    public val internetAccess: Output
        get() = javaResource.internetAccess().applyValue({ args0 ->
            args0.let({ args0 ->
                networkPolicyInternetAccessToKotlin(args0)
            })
        })

    /**
     * The resource name of the location (region) to create the new network policy in.
     * Resource names are schemeless URIs that follow the conventions in https://cloud.google.com/apis/design/resource_names.
     * For example: projects/my-project/locations/us-central1
     */
    public val location: Output
        get() = javaResource.location().applyValue({ args0 -> args0 })

    /**
     * The ID of the Network Policy.
     * - - -
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * The ID of the project in which the resource belongs.
     * If it is not provided, the provider project is used.
     */
    public val project: Output
        get() = javaResource.project().applyValue({ args0 -> args0 })

    /**
     * System-generated unique identifier for the resource.
     */
    public val uid: Output
        get() = javaResource.uid().applyValue({ args0 -> args0 })

    /**
     * Last updated time of this resource.
     * A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine
     * fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".
     */
    public val updateTime: Output
        get() = javaResource.updateTime().applyValue({ args0 -> args0 })

    /**
     * The relative resource name of the VMware Engine network. Specify the name in the following form:
     * projects/{project}/locations/{location}/vmwareEngineNetworks/{vmwareEngineNetworkId} where {project}
     * can either be a project number or a project ID.
     */
    public val vmwareEngineNetwork: Output
        get() = javaResource.vmwareEngineNetwork().applyValue({ args0 -> args0 })

    /**
     * The canonical name of the VMware Engine network in the form:
     * projects/{project_number}/locations/{location}/vmwareEngineNetworks/{vmwareEngineNetworkId}
     */
    public val vmwareEngineNetworkCanonical: Output
        get() = javaResource.vmwareEngineNetworkCanonical().applyValue({ args0 -> args0 })
}

public object NetworkPolicyMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.vmwareengine.NetworkPolicy::class == javaResource::class

    override fun map(javaResource: Resource): NetworkPolicy = NetworkPolicy(
        javaResource as
            com.pulumi.gcp.vmwareengine.NetworkPolicy,
    )
}

/**
 * @see [NetworkPolicy].
 * @param name The _unique_ name of the resulting resource.
 * @param block Builder for [NetworkPolicy].
 */
public suspend fun networkPolicy(
    name: String,
    block: suspend NetworkPolicyResourceBuilder.() -> Unit,
): NetworkPolicy {
    val builder = NetworkPolicyResourceBuilder()
    builder.name(name)
    block(builder)
    return builder.build()
}

/**
 * @see [NetworkPolicy].
 * @param name The _unique_ name of the resulting resource.
 */
public fun networkPolicy(name: String): NetworkPolicy {
    val builder = NetworkPolicyResourceBuilder()
    builder.name(name)
    return builder.build()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy