2222const args = process . argv . slice ( 2 ) ;
2323const [ projectId , locationId , serviceId ] = args ;
2424// [START cloudscheduler_create_job]
25- import { CloudSchedulerClient } from '@google-cloud/scheduler' ;
25+ import { CloudSchedulerClient } from '@google-cloud/scheduler' ;
2626// TODO(developer): Uncomment and set the following variables
2727// const projectId = "PROJECT_ID"
2828// const locationId = "LOCATION_ID"
@@ -33,31 +33,31 @@ const client = new CloudSchedulerClient();
3333 * Create a job with an App Engine target via the Cloud Scheduler API
3434 */
3535async function createJob ( projectId , locationId , serviceId ) {
36- // Construct the fully qualified location path.
37- const parent = client . locationPath ( projectId , locationId ) ;
38- // Construct the request body.
39- const job = {
40- appEngineHttpTarget : {
41- appEngineRouting : {
42- service : serviceId ,
43- } ,
44- relativeUri : '/log_payload' ,
45- httpMethod : 'POST' ,
46- body : Buffer . from ( 'Hello World' ) ,
47- } ,
48- schedule : '* * * * *' ,
49- timeZone : 'America/Los_Angeles' ,
50- } ;
51- const request = {
52- parent : parent ,
53- job : job ,
54- } ;
55- // Use the client to send the job creation request.
56- const [ response ] = await client . createJob ( request ) ;
57- console . log ( `Created job: ${ response . name } ` ) ;
36+ // Construct the fully qualified location path.
37+ const parent = client . locationPath ( projectId , locationId ) ;
38+ // Construct the request body.
39+ const job = {
40+ appEngineHttpTarget : {
41+ appEngineRouting : {
42+ service : serviceId ,
43+ } ,
44+ relativeUri : '/log_payload' ,
45+ httpMethod : 'POST' ,
46+ body : Buffer . from ( 'Hello World' ) ,
47+ } ,
48+ schedule : '* * * * *' ,
49+ timeZone : 'America/Los_Angeles' ,
50+ } ;
51+ const request = {
52+ parent : parent ,
53+ job : job ,
54+ } ;
55+ // Use the client to send the job creation request.
56+ const [ response ] = await client . createJob ( request ) ;
57+ console . log ( `Created job: ${ response . name } ` ) ;
5858}
5959createJob ( projectId , locationId , serviceId ) . catch ( err => {
60- console . error ( err . message ) ;
61- process . exitCode = 1 ;
60+ console . error ( err . message ) ;
61+ process . exitCode = 1 ;
6262} ) ;
6363// [END cloudscheduler_create_job]
0 commit comments