Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions R/content.R
Original file line number Diff line number Diff line change
Expand Up @@ -1444,10 +1444,12 @@ get_content_packages <- function(content) {
#' @param include Comma-separated character string of values indicating additional
#' details to include in the response. Values can be `owner` and `vanity_url`;
#' both are included by default.
#' @param ... Extra arguments. Passing in `page_number` and `page_size` will
#' affect the internal pagination for Connect's content search API. Setting
#' `page_number` will change the page at which pagination *starts*, and
#' `page_size` will control the size of pages (max 500).
#' @param page_size The number of items to fetch per page. Maximum is 500.
#' @param limit Maximum number of items to return overall. Defaults to `Inf` (all items).
#' @param ... Additional query parameters passed to the API for future expansion.
#' Note: If you pass `page_number` here, it will affect the *starting* page
#' for pagination, but all subsequent pages will still be fetched. This is
#' usually not what you want.
#'
#' @return
#' A list containing sub-fields:
Expand Down Expand Up @@ -1585,6 +1587,8 @@ search_content <- function(
client,
q = NULL,
include = "owner,vanity_url",
page_size = 500,
limit = Inf,
...
) {
error_if_less_than(client$version, "2024.04.0")
Expand All @@ -1595,28 +1599,29 @@ search_content <- function(
client,
q = q,
include = include,
# page_size and page_number can be passed in via `...`. Since this call is
# still passed to page_offset, page_number affects the *starting* page,
# but pagination still continues.
page_size = page_size,
...
)
),
limit = limit
)
}

.search_content <- function(
client,
q,
include,
page_number = 1,
page_size = 500,
include
...
) {
path <- v1_url("search", "content")

query <- list(
q = q,
page_number = page_number,
page_size = page_size,
include = include
include = include,
...
)

client$GET(path, query = query)
Expand Down
21 changes: 16 additions & 5 deletions man/search_content.Rd

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

17 changes: 12 additions & 5 deletions tests/testthat/test-content.R
Original file line number Diff line number Diff line change
Expand Up @@ -496,17 +496,24 @@ with_mock_dir("2025.09.0", {
)
})

test_that("content search passes all parameters through correctly", {
test_that("content search uses default page_size of 500 and page_number of 1", {
without_internet(
expect_GET(
search_content(client, q = "bream"),
"https://connect.example/__api__/v1/search/content?q=bream&page_number=1&page_size=500&include=owner%2Cvanity_url" #nolint
)
)
})

test_that("content search passes arbitrary parameters through ... to query string", {
without_internet(
expect_GET(
search_content(
client,
q = "bream",
page_number = 2,
page_size = 20,
include = "owner"
future_param = "value"
),
"https://connect.example/__api__/v1/search/content?q=bream&page_number=2&page_size=20&include=owner"
"https://connect.example/__api__/v1/search/content?q=bream&page_number=1&page_size=500&include=owner%2Cvanity_url&future_param=value" #nolint
)
)
})
Expand Down