0
votes

Using Google Cloud Scheduler, it is possible to create a Cloud Scheduler job with a Pub/Sub target. Is it possible to do the same using Cloud Scheduler API? I didnt find the schedule information in the Cloud Scheduler API documentation.

2

2 Answers

0
votes

It appears that the answer is yes. Cloud Scheduler calls a scheduled piece of work a job. There is a REST API to create a Job that can be found documented here. If we read that page carefully we find that it is a POST request which takes a Job as a payload which contains a JSON description of what we want to describe which includes CRON based schedule and target parameters of what should be fired when the scheduler is reached. If we don't want to work at the REST level, there appears to be client API bindings at higher levels.

0
votes

This is certainly possible!

The following command creates a job that publishes a message with the body 'Hello' to the Pub/Sub topic 'my-topic' every 3 hours:

gcloud scheduler jobs create pubsub my-job \
  --schedule="0 */3 * * *" \
  --topic=my-topic \
  --message-body="Hello"

For additional options and flags I would recommend to read the documentation.