Skip to content

Instantly share code, notes, and snippets.

@kellobri
Created April 11, 2025 19:23
Show Gist options
  • Save kellobri/4ab0cb4aa9a445f423d1d51e8c90a1d5 to your computer and use it in GitHub Desktop.
Save kellobri/4ab0cb4aa9a445f423d1d51e8c90a1d5 to your computer and use it in GitHub Desktop.
Basic R script to check and update min processes on a piece of interactive Connect content
#' ---
#' title: "Scheduled Min Process Management"
#' ---
# Every time this script runs, it should check the minimum process setting value for a given piece of content
# If it finds that min processes are set to something other than 0 or NULL, it will set them back to O
# If it finds that min processes are set to 0 or NULL, it will set them to 1
library(connectapi)
# Assumes CONNECT_SERVER and CONNECT_API_KEY are set in the environment
client <- connect()
# Use the /v1/content endpoint to GET content details (requires a content GUID)
result <- client$GET("/v1/content/GUID")
min_proc <- result$min_processes
# Use the /v1/content endpoint to update (PATCH) the min process settings for this piece of content
if (is.null(min_proc) || min_proc == 0) {
cat("The min processes for IMPORTANT APP are currently set to 0\n")
data <- '{"min_processes": 1}'
set_min_proc <- client$PATCH("/v1/content/GUID", body = data, encode = "raw")
if (set_min_proc$min_processes == 1) {
cat("The min processes for IMPORTANT APP have now been turned on!\n")
} else {
cat("Something unexpected happened here...\n")
}
} else {
cat("The min processes for IMPORTANT APP are currently set to a value that is not 0\n")
data <- '{"min_processes": 0}'
set_min_proc <- client$PATCH("/v1/content/GUID", body = data, encode = "raw")
if (set_min_proc$min_processes == 0) {
cat("The min processes for IMPORTANT APP have now been turned off!\n")
} else {
cat("Something unexpected happened here...\n")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment