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

com.pulumi.cloudflare.kotlin.ListItem.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: 5.40.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.cloudflare.kotlin

import com.pulumi.cloudflare.kotlin.outputs.ListItemHostname
import com.pulumi.cloudflare.kotlin.outputs.ListItemRedirect
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 com.pulumi.cloudflare.kotlin.outputs.ListItemHostname.Companion.toKotlin as listItemHostnameToKotlin
import com.pulumi.cloudflare.kotlin.outputs.ListItemRedirect.Companion.toKotlin as listItemRedirectToKotlin

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

    public var args: ListItemArgs = ListItemArgs()

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

/**
 * Provides individual list items (IPs, Redirects, ASNs, Hostnames) to be used in Edge Rules Engine
 * across all zones within the same account.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as cloudflare from "@pulumi/cloudflare";
 * // IP List
 * const exampleIpList = new cloudflare.List("example_ip_list", {
 *     accountId: "f037e56e89293a057740de681ac9abbe",
 *     name: "example_list",
 *     description: "example IPs for a list",
 *     kind: "ip",
 * });
 * // IP List Item
 * const exampleIpItem = new cloudflare.ListItem("example_ip_item", {
 *     accountId: "f037e56e89293a057740de681ac9abbe",
 *     listId: exampleIpList.id,
 *     comment: "List Item Comment",
 *     ip: "192.0.2.0",
 * });
 * // Redirect List
 * const exampleRedirectList = new cloudflare.List("example_redirect_list", {
 *     accountId: "f037e56e89293a057740de681ac9abbe",
 *     name: "example_list",
 *     description: "example Redirects for a list",
 *     kind: "redirect",
 * });
 * // Redirect List Item
 * const exampleRedirectItem = new cloudflare.ListItem("example_redirect_item", {
 *     accountId: "f037e56e89293a057740de681ac9abbe",
 *     listId: exampleIpList.id,
 *     redirect: {
 *         sourceUrl: "https://source.tld/",
 *         targetUrl: "https://target.tld",
 *         statusCode: 302,
 *         subpathMatching: true,
 *     },
 * });
 * // ASN List
 * const exampleAsnList = new cloudflare.List("example_asn_list", {
 *     accountId: "f037e56e89293a057740de681ac9abbe",
 *     name: "example_asn_list",
 *     description: "example ASNs for a list",
 *     kind: "asn",
 * });
 * // ASN List Item
 * const exampleAsnItem = new cloudflare.ListItem("example_asn_item", {
 *     accountId: "f037e56e89293a057740de681ac9abbe",
 *     listId: exampleAsnList.id,
 *     comment: "List Item Comment",
 *     asn: 6789,
 * });
 * // Hostname List
 * const exampleHostnameList = new cloudflare.List("example_hostname_list", {
 *     accountId: "f037e56e89293a057740de681ac9abbe",
 *     name: "example_hostname_list",
 *     description: "example Hostnames for a list",
 *     kind: "hostname",
 * });
 * // Hostname List Item
 * const exampleHostnameItem = new cloudflare.ListItem("example_hostname_item", {
 *     accountId: "f037e56e89293a057740de681ac9abbe",
 *     listId: exampleHostnameList.id,
 *     comment: "List Item Comment",
 *     hostname: {
 *         urlHostname: "example.com",
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_cloudflare as cloudflare
 * # IP List
 * example_ip_list = cloudflare.List("example_ip_list",
 *     account_id="f037e56e89293a057740de681ac9abbe",
 *     name="example_list",
 *     description="example IPs for a list",
 *     kind="ip")
 * # IP List Item
 * example_ip_item = cloudflare.ListItem("example_ip_item",
 *     account_id="f037e56e89293a057740de681ac9abbe",
 *     list_id=example_ip_list.id,
 *     comment="List Item Comment",
 *     ip="192.0.2.0")
 * # Redirect List
 * example_redirect_list = cloudflare.List("example_redirect_list",
 *     account_id="f037e56e89293a057740de681ac9abbe",
 *     name="example_list",
 *     description="example Redirects for a list",
 *     kind="redirect")
 * # Redirect List Item
 * example_redirect_item = cloudflare.ListItem("example_redirect_item",
 *     account_id="f037e56e89293a057740de681ac9abbe",
 *     list_id=example_ip_list.id,
 *     redirect={
 *         "source_url": "https://source.tld/",
 *         "target_url": "https://target.tld",
 *         "status_code": 302,
 *         "subpath_matching": True,
 *     })
 * # ASN List
 * example_asn_list = cloudflare.List("example_asn_list",
 *     account_id="f037e56e89293a057740de681ac9abbe",
 *     name="example_asn_list",
 *     description="example ASNs for a list",
 *     kind="asn")
 * # ASN List Item
 * example_asn_item = cloudflare.ListItem("example_asn_item",
 *     account_id="f037e56e89293a057740de681ac9abbe",
 *     list_id=example_asn_list.id,
 *     comment="List Item Comment",
 *     asn=6789)
 * # Hostname List
 * example_hostname_list = cloudflare.List("example_hostname_list",
 *     account_id="f037e56e89293a057740de681ac9abbe",
 *     name="example_hostname_list",
 *     description="example Hostnames for a list",
 *     kind="hostname")
 * # Hostname List Item
 * example_hostname_item = cloudflare.ListItem("example_hostname_item",
 *     account_id="f037e56e89293a057740de681ac9abbe",
 *     list_id=example_hostname_list.id,
 *     comment="List Item Comment",
 *     hostname={
 *         "url_hostname": "example.com",
 *     })
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Cloudflare = Pulumi.Cloudflare;
 * return await Deployment.RunAsync(() =>
 * {
 *     // IP List
 *     var exampleIpList = new Cloudflare.List("example_ip_list", new()
 *     {
 *         AccountId = "f037e56e89293a057740de681ac9abbe",
 *         Name = "example_list",
 *         Description = "example IPs for a list",
 *         Kind = "ip",
 *     });
 *     // IP List Item
 *     var exampleIpItem = new Cloudflare.ListItem("example_ip_item", new()
 *     {
 *         AccountId = "f037e56e89293a057740de681ac9abbe",
 *         ListId = exampleIpList.Id,
 *         Comment = "List Item Comment",
 *         Ip = "192.0.2.0",
 *     });
 *     // Redirect List
 *     var exampleRedirectList = new Cloudflare.List("example_redirect_list", new()
 *     {
 *         AccountId = "f037e56e89293a057740de681ac9abbe",
 *         Name = "example_list",
 *         Description = "example Redirects for a list",
 *         Kind = "redirect",
 *     });
 *     // Redirect List Item
 *     var exampleRedirectItem = new Cloudflare.ListItem("example_redirect_item", new()
 *     {
 *         AccountId = "f037e56e89293a057740de681ac9abbe",
 *         ListId = exampleIpList.Id,
 *         Redirect = new Cloudflare.Inputs.ListItemRedirectArgs
 *         {
 *             SourceUrl = "https://source.tld/",
 *             TargetUrl = "https://target.tld",
 *             StatusCode = 302,
 *             SubpathMatching = true,
 *         },
 *     });
 *     // ASN List
 *     var exampleAsnList = new Cloudflare.List("example_asn_list", new()
 *     {
 *         AccountId = "f037e56e89293a057740de681ac9abbe",
 *         Name = "example_asn_list",
 *         Description = "example ASNs for a list",
 *         Kind = "asn",
 *     });
 *     // ASN List Item
 *     var exampleAsnItem = new Cloudflare.ListItem("example_asn_item", new()
 *     {
 *         AccountId = "f037e56e89293a057740de681ac9abbe",
 *         ListId = exampleAsnList.Id,
 *         Comment = "List Item Comment",
 *         Asn = 6789,
 *     });
 *     // Hostname List
 *     var exampleHostnameList = new Cloudflare.List("example_hostname_list", new()
 *     {
 *         AccountId = "f037e56e89293a057740de681ac9abbe",
 *         Name = "example_hostname_list",
 *         Description = "example Hostnames for a list",
 *         Kind = "hostname",
 *     });
 *     // Hostname List Item
 *     var exampleHostnameItem = new Cloudflare.ListItem("example_hostname_item", new()
 *     {
 *         AccountId = "f037e56e89293a057740de681ac9abbe",
 *         ListId = exampleHostnameList.Id,
 *         Comment = "List Item Comment",
 *         Hostname = new Cloudflare.Inputs.ListItemHostnameArgs
 *         {
 *             UrlHostname = "example.com",
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-cloudflare/sdk/v5/go/cloudflare"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		// IP List
 * 		exampleIpList, err := cloudflare.NewList(ctx, "example_ip_list", &cloudflare.ListArgs{
 * 			AccountId:   pulumi.String("f037e56e89293a057740de681ac9abbe"),
 * 			Name:        pulumi.String("example_list"),
 * 			Description: pulumi.String("example IPs for a list"),
 * 			Kind:        pulumi.String("ip"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		// IP List Item
 * 		_, err = cloudflare.NewListItem(ctx, "example_ip_item", &cloudflare.ListItemArgs{
 * 			AccountId: pulumi.String("f037e56e89293a057740de681ac9abbe"),
 * 			ListId:    exampleIpList.ID(),
 * 			Comment:   pulumi.String("List Item Comment"),
 * 			Ip:        pulumi.String("192.0.2.0"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		// Redirect List
 * 		_, err = cloudflare.NewList(ctx, "example_redirect_list", &cloudflare.ListArgs{
 * 			AccountId:   pulumi.String("f037e56e89293a057740de681ac9abbe"),
 * 			Name:        pulumi.String("example_list"),
 * 			Description: pulumi.String("example Redirects for a list"),
 * 			Kind:        pulumi.String("redirect"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		// Redirect List Item
 * 		_, err = cloudflare.NewListItem(ctx, "example_redirect_item", &cloudflare.ListItemArgs{
 * 			AccountId: pulumi.String("f037e56e89293a057740de681ac9abbe"),
 * 			ListId:    exampleIpList.ID(),
 * 			Redirect: &cloudflare.ListItemRedirectArgs{
 * 				SourceUrl:       pulumi.String("https://source.tld/"),
 * 				TargetUrl:       pulumi.String("https://target.tld"),
 * 				StatusCode:      pulumi.Int(302),
 * 				SubpathMatching: pulumi.Bool(true),
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		// ASN List
 * 		exampleAsnList, err := cloudflare.NewList(ctx, "example_asn_list", &cloudflare.ListArgs{
 * 			AccountId:   pulumi.String("f037e56e89293a057740de681ac9abbe"),
 * 			Name:        pulumi.String("example_asn_list"),
 * 			Description: pulumi.String("example ASNs for a list"),
 * 			Kind:        pulumi.String("asn"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		// ASN List Item
 * 		_, err = cloudflare.NewListItem(ctx, "example_asn_item", &cloudflare.ListItemArgs{
 * 			AccountId: pulumi.String("f037e56e89293a057740de681ac9abbe"),
 * 			ListId:    exampleAsnList.ID(),
 * 			Comment:   pulumi.String("List Item Comment"),
 * 			Asn:       pulumi.Int(6789),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		// Hostname List
 * 		exampleHostnameList, err := cloudflare.NewList(ctx, "example_hostname_list", &cloudflare.ListArgs{
 * 			AccountId:   pulumi.String("f037e56e89293a057740de681ac9abbe"),
 * 			Name:        pulumi.String("example_hostname_list"),
 * 			Description: pulumi.String("example Hostnames for a list"),
 * 			Kind:        pulumi.String("hostname"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		// Hostname List Item
 * 		_, err = cloudflare.NewListItem(ctx, "example_hostname_item", &cloudflare.ListItemArgs{
 * 			AccountId: pulumi.String("f037e56e89293a057740de681ac9abbe"),
 * 			ListId:    exampleHostnameList.ID(),
 * 			Comment:   pulumi.String("List Item Comment"),
 * 			Hostname: &cloudflare.ListItemHostnameArgs{
 * 				UrlHostname: pulumi.String("example.com"),
 * 			},
 * 		})
 * 		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.cloudflare.List;
 * import com.pulumi.cloudflare.ListArgs;
 * import com.pulumi.cloudflare.ListItem;
 * import com.pulumi.cloudflare.ListItemArgs;
 * import com.pulumi.cloudflare.inputs.ListItemRedirectArgs;
 * import com.pulumi.cloudflare.inputs.ListItemHostnameArgs;
 * 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) {
 *         // IP List
 *         var exampleIpList = new List("exampleIpList", ListArgs.builder()
 *             .accountId("f037e56e89293a057740de681ac9abbe")
 *             .name("example_list")
 *             .description("example IPs for a list")
 *             .kind("ip")
 *             .build());
 *         // IP List Item
 *         var exampleIpItem = new ListItem("exampleIpItem", ListItemArgs.builder()
 *             .accountId("f037e56e89293a057740de681ac9abbe")
 *             .listId(exampleIpList.id())
 *             .comment("List Item Comment")
 *             .ip("192.0.2.0")
 *             .build());
 *         // Redirect List
 *         var exampleRedirectList = new List("exampleRedirectList", ListArgs.builder()
 *             .accountId("f037e56e89293a057740de681ac9abbe")
 *             .name("example_list")
 *             .description("example Redirects for a list")
 *             .kind("redirect")
 *             .build());
 *         // Redirect List Item
 *         var exampleRedirectItem = new ListItem("exampleRedirectItem", ListItemArgs.builder()
 *             .accountId("f037e56e89293a057740de681ac9abbe")
 *             .listId(exampleIpList.id())
 *             .redirect(ListItemRedirectArgs.builder()
 *                 .sourceUrl("https://source.tld/")
 *                 .targetUrl("https://target.tld")
 *                 .statusCode(302)
 *                 .subpathMatching(true)
 *                 .build())
 *             .build());
 *         // ASN List
 *         var exampleAsnList = new List("exampleAsnList", ListArgs.builder()
 *             .accountId("f037e56e89293a057740de681ac9abbe")
 *             .name("example_asn_list")
 *             .description("example ASNs for a list")
 *             .kind("asn")
 *             .build());
 *         // ASN List Item
 *         var exampleAsnItem = new ListItem("exampleAsnItem", ListItemArgs.builder()
 *             .accountId("f037e56e89293a057740de681ac9abbe")
 *             .listId(exampleAsnList.id())
 *             .comment("List Item Comment")
 *             .asn(6789)
 *             .build());
 *         // Hostname List
 *         var exampleHostnameList = new List("exampleHostnameList", ListArgs.builder()
 *             .accountId("f037e56e89293a057740de681ac9abbe")
 *             .name("example_hostname_list")
 *             .description("example Hostnames for a list")
 *             .kind("hostname")
 *             .build());
 *         // Hostname List Item
 *         var exampleHostnameItem = new ListItem("exampleHostnameItem", ListItemArgs.builder()
 *             .accountId("f037e56e89293a057740de681ac9abbe")
 *             .listId(exampleHostnameList.id())
 *             .comment("List Item Comment")
 *             .hostname(ListItemHostnameArgs.builder()
 *                 .urlHostname("example.com")
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   # IP List
 *   exampleIpList:
 *     type: cloudflare:List
 *     name: example_ip_list
 *     properties:
 *       accountId: f037e56e89293a057740de681ac9abbe
 *       name: example_list
 *       description: example IPs for a list
 *       kind: ip
 *   # IP List Item
 *   exampleIpItem:
 *     type: cloudflare:ListItem
 *     name: example_ip_item
 *     properties:
 *       accountId: f037e56e89293a057740de681ac9abbe
 *       listId: ${exampleIpList.id}
 *       comment: List Item Comment
 *       ip: 192.0.2.0
 *   # Redirect List
 *   exampleRedirectList:
 *     type: cloudflare:List
 *     name: example_redirect_list
 *     properties:
 *       accountId: f037e56e89293a057740de681ac9abbe
 *       name: example_list
 *       description: example Redirects for a list
 *       kind: redirect
 *   # Redirect List Item
 *   exampleRedirectItem:
 *     type: cloudflare:ListItem
 *     name: example_redirect_item
 *     properties:
 *       accountId: f037e56e89293a057740de681ac9abbe
 *       listId: ${exampleIpList.id}
 *       redirect:
 *         sourceUrl: https://source.tld/
 *         targetUrl: https://target.tld
 *         statusCode: 302
 *         subpathMatching: true
 *   # ASN List
 *   exampleAsnList:
 *     type: cloudflare:List
 *     name: example_asn_list
 *     properties:
 *       accountId: f037e56e89293a057740de681ac9abbe
 *       name: example_asn_list
 *       description: example ASNs for a list
 *       kind: asn
 *   # ASN List Item
 *   exampleAsnItem:
 *     type: cloudflare:ListItem
 *     name: example_asn_item
 *     properties:
 *       accountId: f037e56e89293a057740de681ac9abbe
 *       listId: ${exampleAsnList.id}
 *       comment: List Item Comment
 *       asn: 6789
 *   # Hostname List
 *   exampleHostnameList:
 *     type: cloudflare:List
 *     name: example_hostname_list
 *     properties:
 *       accountId: f037e56e89293a057740de681ac9abbe
 *       name: example_hostname_list
 *       description: example Hostnames for a list
 *       kind: hostname
 *   # Hostname List Item
 *   exampleHostnameItem:
 *     type: cloudflare:ListItem
 *     name: example_hostname_item
 *     properties:
 *       accountId: f037e56e89293a057740de681ac9abbe
 *       listId: ${exampleHostnameList.id}
 *       comment: List Item Comment
 *       hostname:
 *         urlHostname: example.com
 * ```
 * 
 * ## Import
 * ```sh
 * $ pulumi import cloudflare:index/listItem:ListItem example //
 * ```
 */
public class ListItem internal constructor(
    override val javaResource: com.pulumi.cloudflare.ListItem,
) : KotlinCustomResource(javaResource, ListItemMapper) {
    /**
     * The account identifier to target for the resource.
     */
    public val accountId: Output
        get() = javaResource.accountId().applyValue({ args0 -> args0 })

    /**
     * Autonomous system number to include in the list. Must provide only one of: `ip`, `asn`, `redirect`, `hostname`.
     */
    public val asn: Output?
        get() = javaResource.asn().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * An optional comment for the item.
     */
    public val comment: Output?
        get() = javaResource.comment().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * Hostname to store in the list. Must provide only one of: `ip`, `asn`, `redirect`, `hostname`.
     */
    public val hostname: Output?
        get() = javaResource.hostname().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    listItemHostnameToKotlin(args0)
                })
            }).orElse(null)
        })

    /**
     * IP address to include in the list. Must provide only one of: `ip`, `asn`, `redirect`, `hostname`.
     */
    public val ip: Output?
        get() = javaResource.ip().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * The list identifier to target for the resource.
     */
    public val listId: Output
        get() = javaResource.listId().applyValue({ args0 -> args0 })

    /**
     * Redirect configuration to store in the list. Must provide only one of: `ip`, `asn`, `redirect`, `hostname`.
     */
    public val redirect: Output?
        get() = javaResource.redirect().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    listItemRedirectToKotlin(args0)
                })
            }).orElse(null)
        })
}

public object ListItemMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.cloudflare.ListItem::class == javaResource::class

    override fun map(javaResource: Resource): ListItem = ListItem(
        javaResource as
            com.pulumi.cloudflare.ListItem,
    )
}

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy