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

com.pulumi.digitalocean.kotlin.ProjectResources.kt Maven / Gradle / Ivy

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

package com.pulumi.digitalocean.kotlin

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.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List

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

    public var args: ProjectResourcesArgs = ProjectResourcesArgs()

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

/**
 * Assign resources to a DigitalOcean Project. This is useful if you need to assign resources
 * managed via this provider to a DigitalOcean Project managed outside of the provider.
 * The following resource types can be associated with a project:
 * * App Platform Apps
 * * Database Clusters
 * * Domains
 * * Droplets
 * * Floating IPs
 * * Kubernetes Clusters
 * * Load Balancers
 * * Spaces Buckets
 * * Volumes
 * ## Example Usage
 * The following example assigns a droplet to a Project managed outside of the provider:
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as digitalocean from "@pulumi/digitalocean";
 * const playground = digitalocean.getProject({
 *     name: "playground",
 * });
 * const foobar = new digitalocean.Droplet("foobar", {
 *     name: "example",
 *     size: digitalocean.DropletSlug.DropletS1VCPU1GB,
 *     image: "ubuntu-22-04-x64",
 *     region: digitalocean.Region.NYC3,
 * });
 * const barfoo = new digitalocean.ProjectResources("barfoo", {
 *     project: playground.then(playground => playground.id),
 *     resources: [foobar.dropletUrn],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_digitalocean as digitalocean
 * playground = digitalocean.get_project(name="playground")
 * foobar = digitalocean.Droplet("foobar",
 *     name="example",
 *     size=digitalocean.DropletSlug.DROPLET_S1_VCPU1_GB,
 *     image="ubuntu-22-04-x64",
 *     region=digitalocean.Region.NYC3)
 * barfoo = digitalocean.ProjectResources("barfoo",
 *     project=playground.id,
 *     resources=[foobar.droplet_urn])
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using DigitalOcean = Pulumi.DigitalOcean;
 * return await Deployment.RunAsync(() =>
 * {
 *     var playground = DigitalOcean.GetProject.Invoke(new()
 *     {
 *         Name = "playground",
 *     });
 *     var foobar = new DigitalOcean.Droplet("foobar", new()
 *     {
 *         Name = "example",
 *         Size = DigitalOcean.DropletSlug.DropletS1VCPU1GB,
 *         Image = "ubuntu-22-04-x64",
 *         Region = DigitalOcean.Region.NYC3,
 *     });
 *     var barfoo = new DigitalOcean.ProjectResources("barfoo", new()
 *     {
 *         Project = playground.Apply(getProjectResult => getProjectResult.Id),
 *         Resources = new[]
 *         {
 *             foobar.DropletUrn,
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		playground, err := digitalocean.LookupProject(ctx, &digitalocean.LookupProjectArgs{
 * 			Name: pulumi.StringRef("playground"),
 * 		}, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		foobar, err := digitalocean.NewDroplet(ctx, "foobar", &digitalocean.DropletArgs{
 * 			Name:   pulumi.String("example"),
 * 			Size:   pulumi.String(digitalocean.DropletSlugDropletS1VCPU1GB),
 * 			Image:  pulumi.String("ubuntu-22-04-x64"),
 * 			Region: pulumi.String(digitalocean.RegionNYC3),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = digitalocean.NewProjectResources(ctx, "barfoo", &digitalocean.ProjectResourcesArgs{
 * 			Project: pulumi.String(playground.Id),
 * 			Resources: pulumi.StringArray{
 * 				foobar.DropletUrn,
 * 			},
 * 		})
 * 		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.digitalocean.DigitaloceanFunctions;
 * import com.pulumi.digitalocean.inputs.GetProjectArgs;
 * import com.pulumi.digitalocean.Droplet;
 * import com.pulumi.digitalocean.DropletArgs;
 * import com.pulumi.digitalocean.ProjectResources;
 * import com.pulumi.digitalocean.ProjectResourcesArgs;
 * 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) {
 *         final var playground = DigitaloceanFunctions.getProject(GetProjectArgs.builder()
 *             .name("playground")
 *             .build());
 *         var foobar = new Droplet("foobar", DropletArgs.builder()
 *             .name("example")
 *             .size("s-1vcpu-1gb")
 *             .image("ubuntu-22-04-x64")
 *             .region("nyc3")
 *             .build());
 *         var barfoo = new ProjectResources("barfoo", ProjectResourcesArgs.builder()
 *             .project(playground.applyValue(getProjectResult -> getProjectResult.id()))
 *             .resources(foobar.dropletUrn())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   foobar:
 *     type: digitalocean:Droplet
 *     properties:
 *       name: example
 *       size: s-1vcpu-1gb
 *       image: ubuntu-22-04-x64
 *       region: nyc3
 *   barfoo:
 *     type: digitalocean:ProjectResources
 *     properties:
 *       project: ${playground.id}
 *       resources:
 *         - ${foobar.dropletUrn}
 * variables:
 *   playground:
 *     fn::invoke:
 *       Function: digitalocean:getProject
 *       Arguments:
 *         name: playground
 * ```
 * 
 * ## Import
 * Importing this resource is not supported.
 */
public class ProjectResources internal constructor(
    override val javaResource: com.pulumi.digitalocean.ProjectResources,
) : KotlinCustomResource(javaResource, ProjectResourcesMapper) {
    /**
     * the ID of the project
     */
    public val project: Output
        get() = javaResource.project().applyValue({ args0 -> args0 })

    /**
     * a list of uniform resource names (URNs) for the resources associated with the project
     */
    public val resources: Output>
        get() = javaResource.resources().applyValue({ args0 -> args0.map({ args0 -> args0 }) })
}

public object ProjectResourcesMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.digitalocean.ProjectResources::class == javaResource::class

    override fun map(javaResource: Resource): ProjectResources = ProjectResources(
        javaResource as
            com.pulumi.digitalocean.ProjectResources,
    )
}

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy