Skip to content

Commit

Permalink
add support for max log lines query string param
Browse files Browse the repository at this point in the history
  • Loading branch information
toph-allen committed Dec 31, 2024
1 parent 5655e57 commit 911b076
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
14 changes: 11 additions & 3 deletions R/content.R
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,10 @@ terminate_jobs <- function(content, keys = NULL) {
#' Get the log output for a job. Requires Connect 2022.10.0 or newer.
#'
#' @param content A Content object, as returned by `content_item()`
#' @param key A job key, which you can find using `get_jobs()`.
#' @param key A job key, which you can find using `get_jobs()`
#' @param max_log_lines Optional. An integer indicating the maximum number of
#' log lines to return. If `NULL` (default), Connect returns a maximum of 5000
#' lines.
#'
#' @return A data frame with the requested log. Each row represents an entry.
#'
Expand All @@ -787,12 +790,17 @@ terminate_jobs <- function(content, keys = NULL) {
#' @family job functions
#' @family content functions
#' @export
get_job_log <- function(content, key) {
get_job_log <- function(content, key, max_log_lines = NULL) {
validate_R6_class(content, "Content")

error_if_less_than(content$connect$version, "2022.10.0")

res <- content$connect$GET(v1_url("content", content$content$guid, "jobs", key, "log"))
query <- list(maxLogLines = max_log_lines)
print(query)
res <- content$connect$GET(
v1_url("content", content$content$guid, "jobs", key, "log"),
query = query
)
parse_connectapi_typed(res$entries, connectapi_ptypes$job_log)
}

Expand Down
7 changes: 5 additions & 2 deletions man/get_job_log.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions tests/testthat/test-content.R
Original file line number Diff line number Diff line change
Expand Up @@ -346,5 +346,10 @@ test_that("get_job_log() gets job logs", {
)
)
)

expect_GET(
get_job_log(item, "uJhnmtV11bLS66kk", max_log_lines = 10),
"http://connect.example/__api__/v1/content/8f37d6e0/jobs/uJhnmtV11bLS66kk/log?maxLogLines=10"
)
})
})

0 comments on commit 911b076

Please sign in to comment.