Created
April 11, 2025 19:23
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' --- | |
#' 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