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

com.pulumi.azurenative.azurestackhci.kotlin.SecurityRule.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: 2.82.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.azurenative.azurestackhci.kotlin

import com.pulumi.azurenative.azurestackhci.kotlin.outputs.ExtendedLocationResponse
import com.pulumi.azurenative.azurestackhci.kotlin.outputs.SystemDataResponse
import com.pulumi.core.Output
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.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import com.pulumi.azurenative.azurestackhci.kotlin.outputs.ExtendedLocationResponse.Companion.toKotlin as extendedLocationResponseToKotlin
import com.pulumi.azurenative.azurestackhci.kotlin.outputs.SystemDataResponse.Companion.toKotlin as systemDataResponseToKotlin

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

    public var args: SecurityRuleArgs = SecurityRuleArgs()

    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 SecurityRuleArgsBuilder.() -> Unit) {
        val builder = SecurityRuleArgsBuilder()
        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(): SecurityRule {
        val builtJavaResource =
            com.pulumi.azurenative.azurestackhci.SecurityRule(
                this.name,
                this.args.toJava(),
                this.opts.toJava(),
            )
        return SecurityRule(builtJavaResource)
    }
}

/**
 * Security Rule resource.
 * Azure REST API version: 2024-02-01-preview.
 * Other available API versions: 2024-05-01-preview.
 * ## Example Usage
 * ### SecurityRulesCreateOrUpdate
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using AzureNative = Pulumi.AzureNative;
 * return await Deployment.RunAsync(() =>
 * {
 *     var securityRule = new AzureNative.AzureStackHCI.SecurityRule("securityRule", new()
 *     {
 *         Access = AzureNative.AzureStackHCI.SecurityRuleAccess.Allow,
 *         DestinationAddressPrefixes = new[]
 *         {
 *             "*",
 *         },
 *         DestinationPortRanges = new[]
 *         {
 *             "80",
 *         },
 *         Direction = AzureNative.AzureStackHCI.SecurityRuleDirection.Inbound,
 *         ExtendedLocation = new AzureNative.AzureStackHCI.Inputs.ExtendedLocationArgs
 *         {
 *             Name = "/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ExtendedLocation/customLocations/dogfood-location",
 *             Type = AzureNative.AzureStackHCI.ExtendedLocationTypes.CustomLocation,
 *         },
 *         NetworkSecurityGroupName = "testnsg",
 *         Priority = 130,
 *         Protocol = AzureNative.AzureStackHCI.SecurityRuleProtocol.Asterisk,
 *         ResourceGroupName = "testrg",
 *         SecurityRuleName = "rule1",
 *         SourceAddressPrefixes = new[]
 *         {
 *             "*",
 *         },
 *         SourcePortRanges = new[]
 *         {
 *             "*",
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	azurestackhci "github.com/pulumi/pulumi-azure-native-sdk/azurestackhci/v2"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := azurestackhci.NewSecurityRule(ctx, "securityRule", &azurestackhci.SecurityRuleArgs{
 * 			Access: pulumi.String(azurestackhci.SecurityRuleAccessAllow),
 * 			DestinationAddressPrefixes: pulumi.StringArray{
 * 				pulumi.String("*"),
 * 			},
 * 			DestinationPortRanges: pulumi.StringArray{
 * 				pulumi.String("80"),
 * 			},
 * 			Direction: pulumi.String(azurestackhci.SecurityRuleDirectionInbound),
 * 			ExtendedLocation: &azurestackhci.ExtendedLocationArgs{
 * 				Name: pulumi.String("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ExtendedLocation/customLocations/dogfood-location"),
 * 				Type: pulumi.String(azurestackhci.ExtendedLocationTypesCustomLocation),
 * 			},
 * 			NetworkSecurityGroupName: pulumi.String("testnsg"),
 * 			Priority:                 pulumi.Int(130),
 * 			Protocol:                 pulumi.String(azurestackhci.SecurityRuleProtocolAsterisk),
 * 			ResourceGroupName:        pulumi.String("testrg"),
 * 			SecurityRuleName:         pulumi.String("rule1"),
 * 			SourceAddressPrefixes: pulumi.StringArray{
 * 				pulumi.String("*"),
 * 			},
 * 			SourcePortRanges: pulumi.StringArray{
 * 				pulumi.String("*"),
 * 			},
 * 		})
 * 		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.azurenative.azurestackhci.SecurityRule;
 * import com.pulumi.azurenative.azurestackhci.SecurityRuleArgs;
 * import com.pulumi.azurenative.azurestackhci.inputs.ExtendedLocationArgs;
 * 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 securityRule = new SecurityRule("securityRule", SecurityRuleArgs.builder()
 *             .access("Allow")
 *             .destinationAddressPrefixes("*")
 *             .destinationPortRanges("80")
 *             .direction("Inbound")
 *             .extendedLocation(ExtendedLocationArgs.builder()
 *                 .name("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ExtendedLocation/customLocations/dogfood-location")
 *                 .type("CustomLocation")
 *                 .build())
 *             .networkSecurityGroupName("testnsg")
 *             .priority(130)
 *             .protocol("*")
 *             .resourceGroupName("testrg")
 *             .securityRuleName("rule1")
 *             .sourceAddressPrefixes("*")
 *             .sourcePortRanges("*")
 *             .build());
 *     }
 * }
 * ```
 * ## Import
 * An existing resource can be imported using its type token, name, and identifier, e.g.
 * ```sh
 * $ pulumi import azure-native:azurestackhci:SecurityRule rule1 /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkSecurityGroups/{networkSecurityGroupName}/securityRules/{securityRuleName}
 * ```
 */
public class SecurityRule internal constructor(
    override val javaResource: com.pulumi.azurenative.azurestackhci.SecurityRule,
) : KotlinCustomResource(javaResource, SecurityRuleMapper) {
    /**
     * The network traffic is allowed or denied.
     */
    public val access: Output
        get() = javaResource.access().applyValue({ args0 -> args0 })

    /**
     * A description for this rule. Restricted to 140 chars.
     */
    public val description: Output?
        get() = javaResource.description().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The destination address prefixes. CIDR or destination IP ranges.
     */
    public val destinationAddressPrefixes: Output>?
        get() = javaResource.destinationAddressPrefixes().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 -> args0 })
            }).orElse(null)
        })

    /**
     * The destination port ranges. Integer or range between 0 and 65535. Asterisk '*' can also be used to match all ports.
     */
    public val destinationPortRanges: Output>?
        get() = javaResource.destinationPortRanges().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 -> args0 })
            }).orElse(null)
        })

    /**
     * The direction of the rule. The direction specifies if rule will be evaluated on incoming or outgoing traffic.
     */
    public val direction: Output
        get() = javaResource.direction().applyValue({ args0 -> args0 })

    /**
     * The extendedLocation of the resource.
     */
    public val extendedLocation: Output?
        get() = javaResource.extendedLocation().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> extendedLocationResponseToKotlin(args0) })
            }).orElse(null)
        })

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

    /**
     * The priority of the rule. The value can be between 100 and 4096. The priority number must be unique for each rule in the collection. The lower the priority number, the higher the priority of the rule.
     */
    public val priority: Output
        get() = javaResource.priority().applyValue({ args0 -> args0 })

    /**
     * Network protocol this rule applies to.
     */
    public val protocol: Output
        get() = javaResource.protocol().applyValue({ args0 -> args0 })

    /**
     * Provisioning state of the SR
     */
    public val provisioningState: Output
        get() = javaResource.provisioningState().applyValue({ args0 -> args0 })

    /**
     * The CIDR or source IP ranges.
     */
    public val sourceAddressPrefixes: Output>?
        get() = javaResource.sourceAddressPrefixes().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 -> args0 })
            }).orElse(null)
        })

    /**
     * The source port ranges. Integer or range between 0 and 65535. Asterisk '*' can also be used to match all ports.
     */
    public val sourcePortRanges: Output>?
        get() = javaResource.sourcePortRanges().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 -> args0 })
            }).orElse(null)
        })

    /**
     * Azure Resource Manager metadata containing createdBy and modifiedBy information.
     */
    public val systemData: Output
        get() = javaResource.systemData().applyValue({ args0 ->
            args0.let({ args0 ->
                systemDataResponseToKotlin(args0)
            })
        })

    /**
     * The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
     */
    public val type: Output
        get() = javaResource.type().applyValue({ args0 -> args0 })
}

public object SecurityRuleMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azurenative.azurestackhci.SecurityRule::class == javaResource::class

    override fun map(javaResource: Resource): SecurityRule = SecurityRule(
        javaResource as
            com.pulumi.azurenative.azurestackhci.SecurityRule,
    )
}

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy