Reputation: 91
Reading the docs for the Nodejs Scheduler I did not found how to pass a name for the cron job I want to create.
Does anyone know if this package supports this?
I tried:
> const job = {
> httpTarget: {
> uri: `my_url`,
> httpMethod: 'GET',
> },
> schedule: '0 0,8-17 * * 0-6',
> timeZone: 'my_timezone',
> body: Buffer.from(JSON.stringify({JOB_ID: 'custom_name', name: 'custom_name'})),
> name: 'custom_name'
> };
Upvotes: 1
Views: 299
Reputation: 91
I figured out what was wrong in order to set the name correctly we need to set the name with the project_id and the location_id
httpTarget: {
uri: 'my_url',
httpMethod: 'GET',
},
schedule: '0 0,8-17 * * 0-6',
timeZone: 'my_timezone',
name: 'projects/YOUR_PROJECT_ID/locations/YOUR_LOCATION_ID/jobs/YOUR_CUSTOM_JOB_NAME'
};
Upvotes: 0
Reputation: 1979
From looking at the API spec for the Cloud Scheduler Job resource and at the Nodejs Quickstart I think you need to move the body
attribute within the httpTarget
as the Job resource does not have a body
attribute, it should be associated with the http request.
Based on your code you would end wanting something like this:
const job = {
httpTarget: {
uri: 'my_url',
httpMethod: 'GET',
body: Buffer.from(JSON.stringify({JOB_ID: 'custom_name', name: 'custom_name'})),
},
schedule: '0 0,8-17 * * 0-6',
timeZone: 'my_timezone',
name: 'custom_name'
};
Upvotes: 2