Membuat eksekusi

Membuat eksekusi alur kerja.

Contoh kode

Node.js

Sebelum mencoba contoh ini, ikuti petunjuk penyiapan Node.js di Panduan memulai Workflows menggunakan library klien. Untuk mengetahui informasi selengkapnya, lihat dokumentasi referensi API Node.js Workflows.

Untuk melakukan autentikasi ke Workflows, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, lihat Menyiapkan autentikasi untuk lingkungan pengembangan lokal.

const {ExecutionsClient} = require('@google-cloud/workflows');
const client = new ExecutionsClient();

async function createExecution(projectId, location, name) {
  /**
   * TODO(developer): Uncomment these variables before running the sample.
   */
  // const projectId = 'my-project';
  // const location = 'us-central1';
  // const name = 'my-test-workflow';

  const [resp] = await client.createExecution({
    parent: client.workflowPath(projectId, location, name),
  });
  console.info(`name: ${resp.name}`);
}

createExecution(projectId, location, name).catch(err => {
  console.error(err.message);
  process.exitCode = 1;
});

Node.js

Sebelum mencoba contoh ini, ikuti petunjuk penyiapan Node.js di Panduan memulai Workflows menggunakan library klien. Untuk mengetahui informasi selengkapnya, lihat dokumentasi referensi API Node.js Workflows.

Untuk melakukan autentikasi ke Workflows, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, lihat Menyiapkan autentikasi untuk lingkungan pengembangan lokal.

import {ExecutionsClient} from '@google-cloud/workflows';
const client: ExecutionsClient = new ExecutionsClient();

async function createExecution(
  projectId: string,
  location: string,
  name: string
) {
  /**
   * TODO(developer): Uncomment these variables before running the sample.
   */
  // const projectId = 'my-project';
  // const location = 'us-central1';
  // const name = 'my-test-workflow';

  const [resp] = await client.createExecution({
    parent: client.workflowPath(projectId, location, name),
  });
  console.info(`name: ${resp.name}`);
}

createExecution(projectId, location, name).catch((err: Error) => {
  console.error(err.message);
  process.exitCode = 1;
});

Langkah berikutnya

Untuk menelusuri dan memfilter contoh kode untuk produk Google Cloud lainnya, lihat Google Cloud browser contoh.