UNPKG

@pulumi/gcp

Version:

A Pulumi package for creating and managing Google Cloud Platform resources.

279 lines • 9.98 kB
"use strict"; // *** WARNING: this file was generated by pulumi-language-nodejs. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Job = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("../utilities")); /** * A scheduled job that can publish a PubSub message or an HTTP request * every X interval of time, using a crontab format string. * * To get more information about Job, see: * * * [API documentation](https://cloud.google.com/scheduler/docs/reference/rest/) * * How-to Guides * * [Official Documentation](https://cloud.google.com/scheduler/) * * ## Example Usage * * ### Scheduler Job Pubsub * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * import * as std from "@pulumi/std"; * * const topic = new gcp.pubsub.Topic("topic", {name: "job-topic"}); * const job = new gcp.cloudscheduler.Job("job", { * name: "test-job", * description: "test job", * schedule: "*/2 * * * *", * pubsubTarget: { * topicName: topic.id, * data: std.base64encode({ * input: "test", * }).then(invoke => invoke.result), * }, * }); * ``` * ### Scheduler Job Http * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * import * as std from "@pulumi/std"; * * const job = new gcp.cloudscheduler.Job("job", { * name: "test-job", * description: "test http job", * schedule: "*/8 * * * *", * timeZone: "America/New_York", * attemptDeadline: "320s", * retryConfig: { * retryCount: 1, * }, * httpTarget: { * httpMethod: "POST", * uri: "https://example.com/", * body: std.base64encode({ * input: "{\"foo\":\"bar\"}", * }).then(invoke => invoke.result), * headers: { * "Content-Type": "application/json", * }, * }, * }); * ``` * ### Scheduler Job Paused * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * import * as std from "@pulumi/std"; * * const job = new gcp.cloudscheduler.Job("job", { * paused: true, * name: "test-job", * description: "test http job with updated fields", * schedule: "*/8 * * * *", * timeZone: "America/New_York", * attemptDeadline: "320s", * retryConfig: { * retryCount: 1, * }, * httpTarget: { * httpMethod: "POST", * uri: "https://example.com/ping", * body: std.base64encode({ * input: "{\"foo\":\"bar\"}", * }).then(invoke => invoke.result), * headers: { * "Content-Type": "application/json", * }, * }, * }); * ``` * ### Scheduler Job App Engine * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const job = new gcp.cloudscheduler.Job("job", { * name: "test-job", * schedule: "*/4 * * * *", * description: "test app engine job", * timeZone: "Europe/London", * attemptDeadline: "320s", * retryConfig: { * minBackoffDuration: "1s", * maxRetryDuration: "10s", * maxDoublings: 2, * retryCount: 3, * }, * appEngineHttpTarget: { * httpMethod: "POST", * appEngineRouting: { * service: "web", * version: "prod", * instance: "my-instance-001", * }, * relativeUri: "/ping", * }, * }); * ``` * ### Scheduler Job Oauth * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = gcp.compute.getDefaultServiceAccount({}); * const job = new gcp.cloudscheduler.Job("job", { * name: "test-job", * description: "test http job", * schedule: "*/8 * * * *", * timeZone: "America/New_York", * attemptDeadline: "320s", * httpTarget: { * httpMethod: "GET", * uri: "https://cloudscheduler.googleapis.com/v1/projects/my-project-name/locations/us-west1/jobs", * oauthToken: { * serviceAccountEmail: _default.then(_default => _default.email), * }, * }, * }); * ``` * ### Scheduler Job Oidc * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = gcp.compute.getDefaultServiceAccount({}); * const job = new gcp.cloudscheduler.Job("job", { * name: "test-job", * description: "test http job", * schedule: "*/8 * * * *", * timeZone: "America/New_York", * attemptDeadline: "320s", * httpTarget: { * httpMethod: "GET", * uri: "https://example.com/ping", * oidcToken: { * serviceAccountEmail: _default.then(_default => _default.email), * }, * }, * }); * ``` * * ## Import * * Job can be imported using any of these accepted formats: * * * `projects/{{project}}/locations/{{region}}/jobs/{{name}}` * * `{{project}}/{{region}}/{{name}}` * * `{{region}}/{{name}}` * * `{{name}}` * * When using the `pulumi import` command, Job can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:cloudscheduler/job:Job default projects/{{project}}/locations/{{region}}/jobs/{{name}} * $ pulumi import gcp:cloudscheduler/job:Job default {{project}}/{{region}}/{{name}} * $ pulumi import gcp:cloudscheduler/job:Job default {{region}}/{{name}} * $ pulumi import gcp:cloudscheduler/job:Job default {{name}} * ``` */ class Job extends pulumi.CustomResource { /** * Get an existing Job resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name, id, state, opts) { return new Job(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'gcp:cloudscheduler/job:Job'; /** * Returns true if the given object is an instance of Job. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === Job.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["appEngineHttpTarget"] = state?.appEngineHttpTarget; resourceInputs["attemptDeadline"] = state?.attemptDeadline; resourceInputs["deletionPolicy"] = state?.deletionPolicy; resourceInputs["description"] = state?.description; resourceInputs["httpTarget"] = state?.httpTarget; resourceInputs["name"] = state?.name; resourceInputs["paused"] = state?.paused; resourceInputs["project"] = state?.project; resourceInputs["pubsubTarget"] = state?.pubsubTarget; resourceInputs["region"] = state?.region; resourceInputs["retryConfig"] = state?.retryConfig; resourceInputs["schedule"] = state?.schedule; resourceInputs["state"] = state?.state; resourceInputs["timeZone"] = state?.timeZone; } else { const args = argsOrState; resourceInputs["appEngineHttpTarget"] = args?.appEngineHttpTarget; resourceInputs["attemptDeadline"] = args?.attemptDeadline; resourceInputs["deletionPolicy"] = args?.deletionPolicy; resourceInputs["description"] = args?.description; resourceInputs["httpTarget"] = args?.httpTarget; resourceInputs["name"] = args?.name; resourceInputs["paused"] = args?.paused; resourceInputs["project"] = args?.project; resourceInputs["pubsubTarget"] = args?.pubsubTarget; resourceInputs["region"] = args?.region; resourceInputs["retryConfig"] = args?.retryConfig; resourceInputs["schedule"] = args?.schedule; resourceInputs["timeZone"] = args?.timeZone; resourceInputs["state"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Job.__pulumiType, name, resourceInputs, opts); } } exports.Job = Job; //# sourceMappingURL=job.js.map