Mulai menggunakan Library Klien Cloud untuk Workflows API
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Menunjukkan cara memulai Library Klien Cloud untuk Workflows.
Mempelajari lebih lanjut
Untuk dokumentasi mendetail yang menyertakan contoh kode ini, lihat artikel berikut:
Contoh kode
Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan Lisensi Creative Commons Attribution 4.0, sedangkan contoh kode dilisensikan berdasarkan Lisensi Apache 2.0. Untuk mengetahui informasi selengkapnya, lihat Kebijakan Situs Google Developers. Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],[],[],[],null,["Demonstrates getting started with the Cloud Client Libraries for Workflows.\n\nExplore further\n\n\nFor detailed documentation that includes this code sample, see the following:\n\n- [Workflows client libraries](/workflows/docs/reference/libraries)\n\nCode sample \n\nC++\n\n\nBefore trying this sample, follow the C++ setup instructions in the\n[Workflows quickstart using\nclient libraries](/workflows/docs/quickstart-client-libraries).\n\n\nTo authenticate to Workflows, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n #include \"google/cloud/workflows/v1/workflows_client.h\"\n #include \"google/cloud/locati\u003con.h&quo\u003et;\n #include iostream\n\n int main(int argc, char* argv[]) try {\n if (argc !=\u003c\u003c 3) {\n s\u003c\u003ctd::cerr \u003c\u003c \"Usage: \" argv[0] \" project-id location-id\\n\";\n return 1;\n }\n\n auto const location = google::cloud::Location(argv[1], argv[2]);\n\n namespace workflows = ::google::cloud::workflows_v1;\n auto client =\n workflows::WorkflowsClient(workflows::MakeWorkflowsConnection());\n\n for (auto w : client.ListWorkflows(location.FullName())) {\n if (!w) thr\u003c\u003cow \u003estd::move(w).s\u003c\u003ctatus();\n std::cout w-DebugString() \"\\n\";\n }&\n\n return 0;\n } catch (\u003c\u003cgoogle::cloud::Status const status\u003c\u003c) {\n st\u003c\u003cd::cerr \"google::cloud::Status thrown: \" status \"\\n\";\n return 1;\n }\n\nNode.js\n\n\nBefore trying this sample, follow the Node.js setup instructions in the\n[Workflows quickstart using\nclient libraries](/workflows/docs/quickstart-client-libraries).\n\n\nFor more information, see the\n[Workflows Node.js API\nreference documentation](https://googleapis.dev/nodejs/workflows/latest/).\n\n\nTo authenticate to Workflows, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n const {WorkflowsClient} = require('@google-cloud/workflows');\n const client = new WorkflowsClient();\n\n /**\n * TODO(developer): Uncomment these variables before running the sample.\n */\n // const projectId = 'my-project';\n // const location = 'us-central1';\n\n async function listWorkflows(projectId, location) {\n const [workflows] = await client.listWorkflows({\n parent: client.locationPath(projectId, location),\n });\n for (const workflow of workflows) {\n console.info(`name: ${workflow.name}`);\n }\n }\n\n listWorkflows(projectId, location).catch(err =\u003e {\n console.error(err.message);\n process.exitCode = 1;\n });\n\nNode.js\n\n\nBefore trying this sample, follow the Node.js setup instructions in the\n[Workflows quickstart using\nclient libraries](/workflows/docs/quickstart-client-libraries).\n\n\nFor more information, see the\n[Workflows Node.js API\nreference documentation](https://googleapis.dev/nodejs/workflows/latest/).\n\n\nTo authenticate to Workflows, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n import {WorkflowsClient} from '@google-cloud/workflows';\n const client = new WorkflowsClient();\n\n /**\n * TODO(developer): Uncomment these variables before running the sample.\n */\n // const projectId = 'my-project';\n // const location = 'us-central1';\n\n async function listWorkflows(projectId: string, location: string) {\n const [workflows] = await client.listWorkflows({\n parent: client.locationPath(projectId, location),\n });\n for (const workflow of workflows) {\n console.info(`name: ${workflow.name}`);\n }\n }\n\n listWorkflows(projectId, location).catch((err: Error) =\u003e {\n console.error(err.message);\n process.exitCode = 1;\n });\n\nWhat's next\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=workflows)."]]