Create execution

Creates a workflow execution.

Code sample

Node.js

Before trying this sample, follow the Node.js setup instructions in the Workflows quickstart using client libraries . For more information, see the Workflows Node.js API reference documentation .

To authenticate to Workflows, set up Application Default Credentials. For more information, see Set up authentication for a local development environment .

  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

Before trying this sample, follow the Node.js setup instructions in the Workflows quickstart using client libraries . For more information, see the Workflows Node.js API reference documentation .

To authenticate to Workflows, set up Application Default Credentials. For more information, see Set up authentication for a local development environment .

  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 
 ; 
 }); 
 

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser .

Create a Mobile Website
View Site in Mobile | Classic
Share by: