Creates or updates a Cloud Scheduler job.

cr_schedule(
  name,
  schedule = NULL,
  httpTarget = NULL,
  description = NULL,
  overwrite = FALSE,
  timeZone = Sys.timezone(),
  region = cr_region_get(),
  projectId = cr_project_get()
)

Arguments

name

Optionally caller-specified in CreateJob, after

schedule

A cron schedule e.g. "15 5 * * *"

httpTarget

A HTTP target object HttpTarget

description

Optionally caller-specified in CreateJob or

overwrite

If TRUE and an existing job with the same name exists, will overwrite it with the new parameters

timeZone

Specifies the time zone to be used in interpreting schedule. If set to NULL will be "UTC". Note that some time zones include a provision for daylight savings time.

region

The region usually set with cr_region_set

projectId

The GCP project to run within usually set with cr_project_set

Value

A gar_scheduleJob class object

See also

Examples

if (FALSE) { cr_project_set("my-project") cr_region_set("europe-west1") cr_schedule("test", "* * * * *", httpTarget = HttpTarget(uri="https://code.markedmondson.me")) # schedule a cloud build (no source) build1 <- cr_build_make("cloudbuild.yaml") cr_schedule("cloud-build-test", "15 5 * * *", httpTarget = cr_build_schedule_http(build1)) # schedule a cloud build with code source from GCS bucket my_gcs_source <- cr_build_upload_gcs("my_folder", bucket = cr_get_bucket()) build <- cr_build_make("cloudbuild.yaml", source = my_gcs_source) cr_schedule("cloud-build-test2", "15 5 * * *", httpTarget = cr_build_schedule_http(build)) # update a schedule with the same name - only supply what you want to change cr_schedule("cloud-build-test2", "12 6 * * *", overwrite=TRUE) # By default will use the timezone as specified by Sys.timezone() - change # this by supplying it directly cr_schedule("timzone-utc", "12 2 * * *", timeZone = "UTC") # schedule private Cloud Run app # for authenticated Cloud Run apps - create with allowUnauthenticated=FALSE cr_deploy_run("my-app", allowUnauthenticated = TRUE) # deploying via R will help create a service email called my-app-invoker cr_run_email("my-app") #> "my-app-invoker@your-project.iam.gserviceaccount.com" # schedule the endpoint my_app <- cr_run_get("my-app") endpoint <- paste0(my_app$status$url, "/fetch_stuff") app_sched <- cr_run_schedule_http(endpoint, http_method = "GET", email = cr_run_email("my-app")) cr_schedule("my-app-scheduled-1", schedule = "16 4 * * *", httpTarget = app_sched) }