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

com.pulumi.gcp.workflows.kotlin.Workflow.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.12.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.gcp.workflows.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.Map

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

    public var args: WorkflowArgs = WorkflowArgs()

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

/**
 * Workflow program to be executed by Workflows.
 * To get more information about Workflow, see:
 * * [API documentation](https://cloud.google.com/workflows/docs/reference/rest/v1/projects.locations.workflows)
 * * How-to Guides
 *     * [Managing Workflows](https://cloud.google.com/workflows/docs/creating-updating-workflow)
 * ## Example Usage
 * ### Workflow Basic
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const testAccount = new gcp.serviceaccount.Account("test_account", {
 *     accountId: "my-account",
 *     displayName: "Test Service Account",
 * });
 * const example = new gcp.workflows.Workflow("example", {
 *     name: "workflow",
 *     region: "us-central1",
 *     description: "Magic",
 *     serviceAccount: testAccount.id,
 *     callLogLevel: "LOG_ERRORS_ONLY",
 *     labels: {
 *         env: "test",
 *     },
 *     userEnvVars: {
 *         url: "https://timeapi.io/api/Time/current/zone?timeZone=Europe/Amsterdam",
 *     },
 *     sourceContents: `# This is a sample workflow. You can replace it with your source code.
 * # This workflow does the following:
 * # - reads current time and date information from an external API and stores
 * #   the response in currentTime variable
 * # - retrieves a list of Wikipedia articles related to the day of the week
 * #   from currentTime
 * # - returns the list of articles as an output of the workflow
 * # Note: In Terraform you need to escape the  or it will cause errors.
 * - getCurrentTime:
 *     call: http.get
 *     args:
 *         url: \${sys.get_env("url")}
 *     result: currentTime
 * - readWikipedia:
 *     call: http.get
 *     args:
 *         url: https://en.wikipedia.org/w/api.php
 *         query:
 *             action: opensearch
 *             search: \${currentTime.body.dayOfWeek}
 *     result: wikiResult
 * - returnOutput:
 *     return: \${wikiResult.body[1]}
 * `,
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * test_account = gcp.serviceaccount.Account("test_account",
 *     account_id="my-account",
 *     display_name="Test Service Account")
 * example = gcp.workflows.Workflow("example",
 *     name="workflow",
 *     region="us-central1",
 *     description="Magic",
 *     service_account=test_account.id,
 *     call_log_level="LOG_ERRORS_ONLY",
 *     labels={
 *         "env": "test",
 *     },
 *     user_env_vars={
 *         "url": "https://timeapi.io/api/Time/current/zone?timeZone=Europe/Amsterdam",
 *     },
 *     source_contents="""# This is a sample workflow. You can replace it with your source code.
 * # This workflow does the following:
 * # - reads current time and date information from an external API and stores
 * #   the response in currentTime variable
 * # - retrieves a list of Wikipedia articles related to the day of the week
 * #   from currentTime
 * # - returns the list of articles as an output of the workflow
 * # Note: In Terraform you need to escape the $$ or it will cause errors.
 * - getCurrentTime:
 *     call: http.get
 *     args:
 *         url: ${sys.get_env("url")}
 *     result: currentTime
 * - readWikipedia:
 *     call: http.get
 *     args:
 *         url: https://en.wikipedia.org/w/api.php
 *         query:
 *             action: opensearch
 *             search: ${currentTime.body.dayOfWeek}
 *     result: wikiResult
 * - returnOutput:
 *     return: ${wikiResult.body[1]}
 * """)
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var testAccount = new Gcp.ServiceAccount.Account("test_account", new()
 *     {
 *         AccountId = "my-account",
 *         DisplayName = "Test Service Account",
 *     });
 *     var example = new Gcp.Workflows.Workflow("example", new()
 *     {
 *         Name = "workflow",
 *         Region = "us-central1",
 *         Description = "Magic",
 *         ServiceAccount = testAccount.Id,
 *         CallLogLevel = "LOG_ERRORS_ONLY",
 *         Labels =
 *         {
 *             { "env", "test" },
 *         },
 *         UserEnvVars =
 *         {
 *             { "url", "https://timeapi.io/api/Time/current/zone?timeZone=Europe/Amsterdam" },
 *         },
 *         SourceContents = @"# This is a sample workflow. You can replace it with your source code.
 * # This workflow does the following:
 * # - reads current time and date information from an external API and stores
 * #   the response in currentTime variable
 * # - retrieves a list of Wikipedia articles related to the day of the week
 * #   from currentTime
 * # - returns the list of articles as an output of the workflow
 * # Note: In Terraform you need to escape the $$ or it will cause errors.
 * - getCurrentTime:
 *     call: http.get
 *     args:
 *         url: ${sys.get_env(""url"")}
 *     result: currentTime
 * - readWikipedia:
 *     call: http.get
 *     args:
 *         url: https://en.wikipedia.org/w/api.php
 *         query:
 *             action: opensearch
 *             search: ${currentTime.body.dayOfWeek}
 *     result: wikiResult
 * - returnOutput:
 *     return: ${wikiResult.body[1]}
 * ",
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/serviceaccount"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/workflows"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		testAccount, err := serviceaccount.NewAccount(ctx, "test_account", &serviceaccount.AccountArgs{
 * 			AccountId:   pulumi.String("my-account"),
 * 			DisplayName: pulumi.String("Test Service Account"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = workflows.NewWorkflow(ctx, "example", &workflows.WorkflowArgs{
 * 			Name:           pulumi.String("workflow"),
 * 			Region:         pulumi.String("us-central1"),
 * 			Description:    pulumi.String("Magic"),
 * 			ServiceAccount: testAccount.ID(),
 * 			CallLogLevel:   pulumi.String("LOG_ERRORS_ONLY"),
 * 			Labels: pulumi.StringMap{
 * 				"env": pulumi.String("test"),
 * 			},
 * 			UserEnvVars: pulumi.StringMap{
 * 				"url": pulumi.String("https://timeapi.io/api/Time/current/zone?timeZone=Europe/Amsterdam"),
 * 			},
 * 			SourceContents: pulumi.String(`# This is a sample workflow. You can replace it with your source code.
 * # This workflow does the following:
 * # - reads current time and date information from an external API and stores
 * #   the response in currentTime variable
 * # - retrieves a list of Wikipedia articles related to the day of the week
 * #   from currentTime
 * # - returns the list of articles as an output of the workflow
 * # Note: In Terraform you need to escape the $$ or it will cause errors.
 * - getCurrentTime:
 *     call: http.get
 *     args:
 *         url: ${sys.get_env("url")}
 *     result: currentTime
 * - readWikipedia:
 *     call: http.get
 *     args:
 *         url: https://en.wikipedia.org/w/api.php
 *         query:
 *             action: opensearch
 *             search: ${currentTime.body.dayOfWeek}
 *     result: wikiResult
 * - returnOutput:
 *     return: ${wikiResult.body[1]}
 * `),
 * 		})
 * 		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.serviceaccount.Account;
 * import com.pulumi.gcp.serviceaccount.AccountArgs;
 * import com.pulumi.gcp.workflows.Workflow;
 * import com.pulumi.gcp.workflows.WorkflowArgs;
 * 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 testAccount = new Account("testAccount", AccountArgs.builder()
 *             .accountId("my-account")
 *             .displayName("Test Service Account")
 *             .build());
 *         var example = new Workflow("example", WorkflowArgs.builder()
 *             .name("workflow")
 *             .region("us-central1")
 *             .description("Magic")
 *             .serviceAccount(testAccount.id())
 *             .callLogLevel("LOG_ERRORS_ONLY")
 *             .labels(Map.of("env", "test"))
 *             .userEnvVars(Map.of("url", "https://timeapi.io/api/Time/current/zone?timeZone=Europe/Amsterdam"))
 *             .sourceContents("""
 * # This is a sample workflow. You can replace it with your source code.
 * # This workflow does the following:
 * # - reads current time and date information from an external API and stores
 * #   the response in currentTime variable
 * # - retrieves a list of Wikipedia articles related to the day of the week
 * #   from currentTime
 * # - returns the list of articles as an output of the workflow
 * # Note: In Terraform you need to escape the $$ or it will cause errors.
 * - getCurrentTime:
 *     call: http.get
 *     args:
 *         url: ${sys.get_env("url")}
 *     result: currentTime
 * - readWikipedia:
 *     call: http.get
 *     args:
 *         url: https://en.wikipedia.org/w/api.php
 *         query:
 *             action: opensearch
 *             search: ${currentTime.body.dayOfWeek}
 *     result: wikiResult
 * - returnOutput:
 *     return: ${wikiResult.body[1]}
 *             """)
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   testAccount:
 *     type: gcp:serviceaccount:Account
 *     name: test_account
 *     properties:
 *       accountId: my-account
 *       displayName: Test Service Account
 *   example:
 *     type: gcp:workflows:Workflow
 *     properties:
 *       name: workflow
 *       region: us-central1
 *       description: Magic
 *       serviceAccount: ${testAccount.id}
 *       callLogLevel: LOG_ERRORS_ONLY
 *       labels:
 *         env: test
 *       userEnvVars:
 *         url: https://timeapi.io/api/Time/current/zone?timeZone=Europe/Amsterdam
 *       sourceContents: |
 *         # This is a sample workflow. You can replace it with your source code.
 *         # This workflow does the following:
 *         # - reads current time and date information from an external API and stores
 *         #   the response in currentTime variable
 *         # - retrieves a list of Wikipedia articles related to the day of the week
 *         #   from currentTime
 *         # - returns the list of articles as an output of the workflow
 *         # Note: In Terraform you need to escape the $$ or it will cause errors.
 *         - getCurrentTime:
 *             call: http.get
 *             args:
 *                 url: ${sys.get_env("url")}
 *             result: currentTime
 *         - readWikipedia:
 *             call: http.get
 *             args:
 *                 url: https://en.wikipedia.org/w/api.php
 *                 query:
 *                     action: opensearch
 *                     search: ${currentTime.body.dayOfWeek}
 *             result: wikiResult
 *         - returnOutput:
 *             return: ${wikiResult.body[1]}
 * ```
 * 
 * ## Import
 * This resource does not support import.
 */
public class Workflow internal constructor(
    override val javaResource: com.pulumi.gcp.workflows.Workflow,
) : KotlinCustomResource(javaResource, WorkflowMapper) {
    /**
     * Describes the level of platform logging to apply to calls and call responses during
     * executions of this workflow. If both the workflow and the execution specify a logging level,
     * the execution level takes precedence.
     * Possible values are: `CALL_LOG_LEVEL_UNSPECIFIED`, `LOG_ALL_CALLS`, `LOG_ERRORS_ONLY`, `LOG_NONE`.
     */
    public val callLogLevel: Output?
        get() = javaResource.callLogLevel().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The timestamp of when the workflow was created in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits.
     */
    public val createTime: Output
        get() = javaResource.createTime().applyValue({ args0 -> args0 })

    /**
     * The KMS key used to encrypt workflow and execution data.
     * Format: projects/{project}/locations/{location}/keyRings/{keyRing}/cryptoKeys/{cryptoKey}
     */
    public val cryptoKeyName: Output?
        get() = javaResource.cryptoKeyName().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Description of the workflow provided by the user. Must be at most 1000 unicode characters long.
     */
    public val description: Output
        get() = javaResource.description().applyValue({ args0 -> args0 })

    /**
     * All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
     */
    public val effectiveLabels: Output>
        get() = javaResource.effectiveLabels().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.key.to(args0.value)
            }).toMap()
        })

    /**
     * A set of key/value label pairs to assign to this Workflow.
     * **Note**: This field is non-authoritative, and will only manage the labels present in your configuration.
     * Please refer to the field `effective_labels` for all of the labels present on the resource.
     */
    public val labels: Output>?
        get() = javaResource.labels().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

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

    /**
     * Creates a unique name beginning with the
     * specified prefix. If this and name are unspecified, a random value is chosen for the name.
     */
    public val namePrefix: Output
        get() = javaResource.namePrefix().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 })

    /**
     * The combination of labels configured directly on the resource
     * and default labels configured on the provider.
     */
    public val pulumiLabels: Output>
        get() = javaResource.pulumiLabels().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.key.to(args0.value)
            }).toMap()
        })

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

    /**
     * The revision of the workflow. A new one is generated if the service account or source contents is changed.
     */
    public val revisionId: Output
        get() = javaResource.revisionId().applyValue({ args0 -> args0 })

    /**
     * Name of the service account associated with the latest workflow version. This service
     * account represents the identity of the workflow and determines what permissions the workflow has.
     * Format: projects/{project}/serviceAccounts/{account} or {account}.
     * Using - as a wildcard for the {project} or not providing one at all will infer the project from the account.
     * The {account} value can be the email address or the unique_id of the service account.
     * If not provided, workflow will use the project's default service account.
     * Modifying this field for an existing workflow results in a new workflow revision.
     */
    public val serviceAccount: Output
        get() = javaResource.serviceAccount().applyValue({ args0 -> args0 })

    /**
     * Workflow code to be executed. The size limit is 128KB.
     */
    public val sourceContents: Output?
        get() = javaResource.sourceContents().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * State of the workflow deployment.
     */
    public val state: Output
        get() = javaResource.state().applyValue({ args0 -> args0 })

    /**
     * The timestamp of when the workflow was last updated in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits.
     */
    public val updateTime: Output
        get() = javaResource.updateTime().applyValue({ args0 -> args0 })

    /**
     * User-defined environment variables associated with this workflow revision. This map has a maximum length of 20. Each string can take up to 4KiB. Keys cannot be empty strings and cannot start with “GOOGLE” or “WORKFLOWS".
     */
    public val userEnvVars: Output>?
        get() = javaResource.userEnvVars().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })
}

public object WorkflowMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.workflows.Workflow::class == javaResource::class

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

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy