Workflows API 用の Cloud クライアント ライブラリを使ってみる。
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Workflows 用の Cloud クライアント ライブラリの使用を開始する方法を説明します。
もっと見る
このコードサンプルを含む詳細なドキュメントについては、以下をご覧ください。
コードサンプル
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],[],[],[],null,["# Get started with the Cloud Client Libraries for the Workflows API\n\nDemonstrates getting started with the Cloud Client Libraries for Workflows.\n\nExplore further\n---------------\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-----------\n\n### C++\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/location.h\"\n #include \u003ciostream\u003e\n\n int main(int argc, char* argv[]) try {\n if (argc != 3) {\n std::cerr \u003c\u003c \"Usage: \" \u003c\u003c argv[0] \u003c\u003c \" 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) throw std::move(w).status();\n std::cout \u003c\u003c w-\u003eDebugString() \u003c\u003c \"\\n\";\n }\n\n return 0;\n } catch (google::cloud::Status const& status) {\n std::cerr \u003c\u003c \"google::cloud::Status thrown: \" \u003c\u003c status \u003c\u003c \"\\n\";\n return 1;\n }\n\n### Node.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\n### Node.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\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=workflows)."]]