@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
381 lines • 13.8 kB
JavaScript
"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! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.Schedule = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* 'Colab Enterprise Notebook Execution Schedules.'
*
* To get more information about Schedule, see:
*
* * [API documentation](https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.schedules)
* * How-to Guides
* * [Schedule a notebook run](https://cloud.google.com/colab/docs/schedule-notebook-run)
*
* ## Example Usage
*
* ### Colab Schedule Basic
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const myRuntimeTemplate = new gcp.colab.RuntimeTemplate("my_runtime_template", {
* name: "runtime-template",
* displayName: "Runtime template",
* location: "us-central1",
* machineSpec: {
* machineType: "e2-standard-4",
* },
* networkSpec: {
* enableInternetAccess: true,
* },
* });
* const outputBucket = new gcp.storage.Bucket("output_bucket", {
* name: "my_bucket",
* location: "US",
* forceDestroy: true,
* uniformBucketLevelAccess: true,
* });
* const notebook = new gcp.storage.BucketObject("notebook", {
* name: "hello_world.ipynb",
* bucket: outputBucket.name,
* content: ` {
* "cells": [
* {
* "cell_type": "code",
* "execution_count": null,
* "metadata": {},
* "outputs": [],
* "source": [
* "print(\\"Hello, World!\\")"
* ]
* }
* ],
* "metadata": {
* "kernelspec": {
* "display_name": "Python 3",
* "language": "python",
* "name": "python3"
* },
* "language_info": {
* "codemirror_mode": {
* "name": "ipython",
* "version": 3
* },
* "file_extension": ".py",
* "mimetype": "text/x-python",
* "name": "python",
* "nbconvert_exporter": "python",
* "pygments_lexer": "ipython3",
* "version": "3.8.5"
* }
* },
* "nbformat": 4,
* "nbformat_minor": 4
* }
* `,
* });
* const schedule = new gcp.colab.Schedule("schedule", {
* displayName: "basic-schedule",
* location: "us-west1",
* maxConcurrentRunCount: "2",
* cron: "TZ=America/Los_Angeles * * * * *",
* createNotebookExecutionJobRequest: {
* notebookExecutionJob: {
* displayName: "Notebook execution",
* gcsNotebookSource: {
* uri: pulumi.interpolate`gs://${notebook.bucket}/${notebook.name}`,
* generation: notebook.generation,
* },
* notebookRuntimeTemplateResourceName: pulumi.interpolate`projects/${myRuntimeTemplate.project}/locations/${myRuntimeTemplate.location}/notebookRuntimeTemplates/${myRuntimeTemplate.name}`,
* gcsOutputUri: pulumi.interpolate`gs://${outputBucket.name}`,
* serviceAccount: "my@service-account.com",
* },
* },
* }, {
* dependsOn: [
* myRuntimeTemplate,
* outputBucket,
* ],
* });
* ```
* ### Colab Schedule Paused
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const myRuntimeTemplate = new gcp.colab.RuntimeTemplate("my_runtime_template", {
* name: "runtime-template",
* displayName: "Runtime template",
* location: "us-central1",
* machineSpec: {
* machineType: "e2-standard-4",
* },
* networkSpec: {
* enableInternetAccess: true,
* },
* });
* const outputBucket = new gcp.storage.Bucket("output_bucket", {
* name: "my_bucket",
* location: "US",
* forceDestroy: true,
* uniformBucketLevelAccess: true,
* });
* const notebook = new gcp.storage.BucketObject("notebook", {
* name: "hello_world.ipynb",
* bucket: outputBucket.name,
* content: ` {
* "cells": [
* {
* "cell_type": "code",
* "execution_count": null,
* "metadata": {},
* "outputs": [],
* "source": [
* "print(\\"Hello, World!\\")"
* ]
* }
* ],
* "metadata": {
* "kernelspec": {
* "display_name": "Python 3",
* "language": "python",
* "name": "python3"
* },
* "language_info": {
* "codemirror_mode": {
* "name": "ipython",
* "version": 3
* },
* "file_extension": ".py",
* "mimetype": "text/x-python",
* "name": "python",
* "nbconvert_exporter": "python",
* "pygments_lexer": "ipython3",
* "version": "3.8.5"
* }
* },
* "nbformat": 4,
* "nbformat_minor": 4
* }
* `,
* });
* const schedule = new gcp.colab.Schedule("schedule", {
* displayName: "paused-schedule",
* location: "us-west1",
* maxConcurrentRunCount: "2",
* cron: "TZ=America/Los_Angeles * * * * *",
* desiredState: "PAUSED",
* createNotebookExecutionJobRequest: {
* notebookExecutionJob: {
* displayName: "Notebook execution",
* gcsNotebookSource: {
* uri: pulumi.interpolate`gs://${notebook.bucket}/${notebook.name}`,
* generation: notebook.generation,
* },
* notebookRuntimeTemplateResourceName: pulumi.interpolate`projects/${myRuntimeTemplate.project}/locations/${myRuntimeTemplate.location}/notebookRuntimeTemplates/${myRuntimeTemplate.name}`,
* gcsOutputUri: pulumi.interpolate`gs://${outputBucket.name}`,
* serviceAccount: "my@service-account.com",
* },
* },
* }, {
* dependsOn: [
* myRuntimeTemplate,
* outputBucket,
* ],
* });
* ```
* ### Colab Schedule Full
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const myRuntimeTemplate = new gcp.colab.RuntimeTemplate("my_runtime_template", {
* name: "runtime-template",
* displayName: "Runtime template",
* location: "us-central1",
* machineSpec: {
* machineType: "e2-standard-4",
* },
* networkSpec: {
* enableInternetAccess: true,
* },
* });
* const outputBucket = new gcp.storage.Bucket("output_bucket", {
* name: "my_bucket",
* location: "US",
* forceDestroy: true,
* uniformBucketLevelAccess: true,
* });
* const secret = new gcp.secretmanager.Secret("secret", {
* secretId: "secret",
* replication: {
* auto: {},
* },
* });
* const secretVersion = new gcp.secretmanager.SecretVersion("secret_version", {
* secret: secret.id,
* secretData: "secret-data",
* });
* const dataformRepository = new gcp.dataform.Repository("dataform_repository", {
* name: "dataform-repository",
* displayName: "dataform_repository",
* npmrcEnvironmentVariablesSecretVersion: secretVersion.id,
* kmsKeyName: "my-key",
* labels: {
* label_foo1: "label-bar1",
* },
* gitRemoteSettings: {
* url: "https://github.com/OWNER/REPOSITORY.git",
* defaultBranch: "main",
* authenticationTokenSecretVersion: secretVersion.id,
* },
* workspaceCompilationOverrides: {
* defaultDatabase: "database",
* schemaSuffix: "_suffix",
* tablePrefix: "prefix_",
* },
* });
* const schedule = new gcp.colab.Schedule("schedule", {
* displayName: "full-schedule",
* location: "us-west1",
* allowQueueing: true,
* maxConcurrentRunCount: "2",
* cron: "TZ=America/Los_Angeles * * * * *",
* maxRunCount: "5",
* startTime: "2014-10-02T15:01:23Z",
* endTime: "2014-10-10T15:01:23Z",
* desiredState: "ACTIVE",
* createNotebookExecutionJobRequest: {
* notebookExecutionJob: {
* displayName: "Notebook execution",
* executionTimeout: "86400s",
* dataformRepositorySource: {
* commitSha: "randomsha123",
* dataformRepositoryResourceName: pulumi.interpolate`projects/my-project-name/locations/us-west1/repositories/${dataformRepository.name}`,
* },
* notebookRuntimeTemplateResourceName: pulumi.interpolate`projects/${myRuntimeTemplate.project}/locations/${myRuntimeTemplate.location}/notebookRuntimeTemplates/${myRuntimeTemplate.name}`,
* gcsOutputUri: pulumi.interpolate`gs://${outputBucket.name}`,
* serviceAccount: "my@service-account.com",
* },
* },
* }, {
* dependsOn: [
* myRuntimeTemplate,
* outputBucket,
* secretVersion,
* dataformRepository,
* ],
* });
* ```
*
* ## Import
*
* Schedule can be imported using any of these accepted formats:
*
* * `projects/{{project}}/locations/{{location}}/schedules/{{name}}`
*
* * `{{project}}/{{location}}/{{name}}`
*
* * `{{location}}/{{name}}`
*
* When using the `pulumi import` command, Schedule can be imported using one of the formats above. For example:
*
* ```sh
* $ pulumi import gcp:colab/schedule:Schedule default projects/{{project}}/locations/{{location}}/schedules/{{name}}
* ```
*
* ```sh
* $ pulumi import gcp:colab/schedule:Schedule default {{project}}/{{location}}/{{name}}
* ```
*
* ```sh
* $ pulumi import gcp:colab/schedule:Schedule default {{location}}/{{name}}
* ```
*/
class Schedule extends pulumi.CustomResource {
/**
* Get an existing Schedule 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 Schedule(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of Schedule. 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'] === Schedule.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["allowQueueing"] = state?.allowQueueing;
resourceInputs["createNotebookExecutionJobRequest"] = state?.createNotebookExecutionJobRequest;
resourceInputs["cron"] = state?.cron;
resourceInputs["desiredState"] = state?.desiredState;
resourceInputs["displayName"] = state?.displayName;
resourceInputs["endTime"] = state?.endTime;
resourceInputs["location"] = state?.location;
resourceInputs["maxConcurrentRunCount"] = state?.maxConcurrentRunCount;
resourceInputs["maxRunCount"] = state?.maxRunCount;
resourceInputs["name"] = state?.name;
resourceInputs["project"] = state?.project;
resourceInputs["startTime"] = state?.startTime;
resourceInputs["state"] = state?.state;
}
else {
const args = argsOrState;
if (args?.createNotebookExecutionJobRequest === undefined && !opts.urn) {
throw new Error("Missing required property 'createNotebookExecutionJobRequest'");
}
if (args?.cron === undefined && !opts.urn) {
throw new Error("Missing required property 'cron'");
}
if (args?.displayName === undefined && !opts.urn) {
throw new Error("Missing required property 'displayName'");
}
if (args?.location === undefined && !opts.urn) {
throw new Error("Missing required property 'location'");
}
if (args?.maxConcurrentRunCount === undefined && !opts.urn) {
throw new Error("Missing required property 'maxConcurrentRunCount'");
}
resourceInputs["allowQueueing"] = args?.allowQueueing;
resourceInputs["createNotebookExecutionJobRequest"] = args?.createNotebookExecutionJobRequest;
resourceInputs["cron"] = args?.cron;
resourceInputs["desiredState"] = args?.desiredState;
resourceInputs["displayName"] = args?.displayName;
resourceInputs["endTime"] = args?.endTime;
resourceInputs["location"] = args?.location;
resourceInputs["maxConcurrentRunCount"] = args?.maxConcurrentRunCount;
resourceInputs["maxRunCount"] = args?.maxRunCount;
resourceInputs["project"] = args?.project;
resourceInputs["startTime"] = args?.startTime;
resourceInputs["name"] = undefined /*out*/;
resourceInputs["state"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(Schedule.__pulumiType, name, resourceInputs, opts);
}
}
exports.Schedule = Schedule;
/** @internal */
Schedule.__pulumiType = 'gcp:colab/schedule:Schedule';
//# sourceMappingURL=schedule.js.map