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

com.pulumi.cloudflare.kotlin.WorkersCronTrigger.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.

The newest version!
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.cloudflare.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 [WorkersCronTrigger].
 */
@PulumiTagMarker
public class WorkersCronTriggerResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: WorkersCronTriggerArgs = WorkersCronTriggerArgs()

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

/**
 *  /* /* /* /* /* /*
 * Worker Cron Triggers allow users to map a cron expression to a Worker script
 * using a `ScheduledEvent` listener that enables Workers to be executed on a
 * schedule. Worker Cron Triggers are ideal for running periodic jobs for
 * maintenance or calling third-party APIs to collect up-to-date data.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as cloudflare from "@pulumi/cloudflare";
 * import * as std from "@pulumi/std";
 * const exampleScript = new cloudflare.WorkersScript("example_script", {
 *     accountId: "f037e56e89293a057740de681ac9abbe",
 *     name: "example-script",
 *     content: std.file({
 *         input: "path/to/my.js",
 *     }).then(invoke => invoke.result),
 * });
 * const exampleTrigger = new cloudflare.WorkersCronTrigger("example_trigger", {
 *     accountId: "f037e56e89293a057740de681ac9abbe",
 *     scriptName: exampleScript.name,
 *     schedules: [
 *         "*/5 * * * *",
 *         "10 7 * * mon-fri",
 *     ],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_cloudflare as cloudflare
 * import pulumi_std as std
 * example_script = cloudflare.WorkersScript("example_script",
 *     account_id="f037e56e89293a057740de681ac9abbe",
 *     name="example-script",
 *     content=std.file(input="path/to/my.js").result)
 * example_trigger = cloudflare.WorkersCronTrigger("example_trigger",
 *     account_id="f037e56e89293a057740de681ac9abbe",
 *     script_name=example_script.name,
 *     schedules=[
 *         "*/5 * * * *",
 *         "10 7 * * mon-fri",
 *     ])
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Cloudflare = Pulumi.Cloudflare;
 * using Std = Pulumi.Std;
 * return await Deployment.RunAsync(() =>
 * {
 *     var exampleScript = new Cloudflare.WorkersScript("example_script", new()
 *     {
 *         AccountId = "f037e56e89293a057740de681ac9abbe",
 *         Name = "example-script",
 *         Content = Std.File.Invoke(new()
 *         {
 *             Input = "path/to/my.js",
 *         }).Apply(invoke => invoke.Result),
 *     });
 *     var exampleTrigger = new Cloudflare.WorkersCronTrigger("example_trigger", new()
 *     {
 *         AccountId = "f037e56e89293a057740de681ac9abbe",
 *         ScriptName = exampleScript.Name,
 *         Schedules = new[]
 *         {
 *             "*/5 * * * *",
 *             "10 7 * * mon-fri",
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-cloudflare/sdk/v5/go/cloudflare"
 * 	"github.com/pulumi/pulumi-std/sdk/go/std"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		invokeFile, err := std.File(ctx, &std.FileArgs{
 * 			Input: "path/to/my.js",
 * 		}, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleScript, err := cloudflare.NewWorkersScript(ctx, "example_script", &cloudflare.WorkersScriptArgs{
 * 			AccountId: pulumi.String("f037e56e89293a057740de681ac9abbe"),
 * 			Name:      pulumi.String("example-script"),
 * 			Content:   pulumi.String(invokeFile.Result),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = cloudflare.NewWorkersCronTrigger(ctx, "example_trigger", &cloudflare.WorkersCronTriggerArgs{
 * 			AccountId:  pulumi.String("f037e56e89293a057740de681ac9abbe"),
 * 			ScriptName: exampleScript.Name,
 * 			Schedules: pulumi.StringArray{
 * 				pulumi.String("*/5 * * * *"),
 * 				pulumi.String("10 7 * * mon-fri"),
 * 			},
 * 		})
 * 		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.WorkersScript;
 * import com.pulumi.cloudflare.WorkersScriptArgs;
 * import com.pulumi.cloudflare.WorkersCronTrigger;
 * import com.pulumi.cloudflare.WorkersCronTriggerArgs;
 * 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 exampleScript = new WorkersScript("exampleScript", WorkersScriptArgs.builder()
 *             .accountId("f037e56e89293a057740de681ac9abbe")
 *             .name("example-script")
 *             .content(StdFunctions.file(FileArgs.builder()
 *                 .input("path/to/my.js")
 *                 .build()).result())
 *             .build());
 *         var exampleTrigger = new WorkersCronTrigger("exampleTrigger", WorkersCronTriggerArgs.builder()
 *             .accountId("f037e56e89293a057740de681ac9abbe")
 *             .scriptName(exampleScript.name())
 *             .schedules(
 *                 "*/5 * * * *",
 *                 "10 7 * * mon-fri")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   exampleScript:
 *     type: cloudflare:WorkersScript
 *     name: example_script
 *     properties:
 *       accountId: f037e56e89293a057740de681ac9abbe
 *       name: example-script
 *       content:
 *         fn::invoke:
 *           Function: std:file
 *           Arguments:
 *             input: path/to/my.js
 *           Return: result
 *   exampleTrigger:
 *     type: cloudflare:WorkersCronTrigger
 *     name: example_trigger
 *     properties:
 *       accountId: f037e56e89293a057740de681ac9abbe
 *       scriptName: ${exampleScript.name}
 *       schedules:
 *         - '*/5 * * * *'
 *         - 10 7 * * mon-fri
 * ```
 * 
 * ## Import
 * ```sh
 * $ pulumi import cloudflare:index/workersCronTrigger:WorkersCronTrigger example /
 * ```
 */
public class WorkersCronTrigger internal constructor(
    override val javaResource: com.pulumi.cloudflare.WorkersCronTrigger,
) : KotlinCustomResource(javaResource, WorkersCronTriggerMapper) {
    /**
     * The account identifier to target for the resource.
     */
    public val accountId: Output
        get() = javaResource.accountId().applyValue({ args0 -> args0 })

    /**
     * Cron expressions to execute the Worker script.
     */
    public val schedules: Output>
        get() = javaResource.schedules().applyValue({ args0 -> args0.map({ args0 -> args0 }) })

    /**
     * Worker script to target for the schedules.
     */
    public val scriptName: Output
        get() = javaResource.scriptName().applyValue({ args0 -> args0 })
}

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

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy