Inizia a utilizzare le librerie client di Cloud per l'API Workflows
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Mostra come iniziare a utilizzare le librerie client Cloud per Workflows.
Per saperne di più
Per la documentazione dettagliata che include questo esempio di codice, vedi quanto segue:
Esempio di codice
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","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)."]]