MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / createJob

Function createJob

scheduler/createJob.js:35–58  ·  view source on GitHub ↗

* Create a job with an App Engine target via the Cloud Scheduler API

(projectId, locationId, serviceId)

Source from the content-addressed store, hash-verified

33 * Create a job with an App Engine target via the Cloud Scheduler API
34 */
35async 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}`);
58}
59createJob(projectId, locationId, serviceId).catch(err => {
60 console.error(err.message);
61 process.exitCode = 1;

Callers 1

createJob.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected